I know it is a very silly question but I could not sort it out that is why asking…
How can I extract the rows from a large data set by common IDs and take the means of these rows and make a column having these IDs as rownames.
e.g.
IDs Var2
Ae4 2
Ae4 4
Ae4 6
Bc3 3
Bc3 5
Ad2 8
Ad2 7
OutPut
Var(x)
Ae4 4
Bc3 4
Ad2 7.5
This kinds of things can easily be done using the
plyrfunctionddply:If your dataset is big, and/or the number of unique
ID‘s is big, you could usedata.table. See this paper for more detail aboutplyr.