A small sample of the data is shown below. Please consider I have more columns

```
 dat<-read.table (text=" id Tall1    Group1  Tall2   Group2  Tall3   Group3  Tall4   Group4
  1  25  M   24  M   23  N   33  N
  2  34  N   16  M   23  M   43  N
  3  41  N   20  M   44  N   60  N
  4  25  M   24  N   44  N   55  M
   5 26  N   12  N   44  M   90  M
    ", header=TRUE)

```

I want to get the following table

```
NoM MeanM   SDM NoN MeanN   SDN
2   25  0   3   33.66   7.5
3   20  4   2   18  8.45
2   33.5    14.48   3   37  12.12
2   72.5    24.74   3   45.33   13.65

```

I want to get N, mean and SD for each group according to their Talls, i.e., Tall1 with Group1, Tall2 with Group2 and...