Hello,

Try the following.


result <- lapply(unique(dataset$ID), function(uid) dataset[dataset$ID == uid, ])
names(result) <- unique(dataset$ID)


Hope this helps,

Rui Barradas

Em 24-06-2013 15:36, matteo escreveu:
Hi guys,
I'm a newby, so sorry for the easy question.

I have a matrix (459x28) in which a large number of observations are
repeated (same placed sampled in different times).
One of the columns is refers to the ID of the place of sampling.
What I would like is to extract subset matrix for every point of sampling.

I can do it manually, e.g. x1<-data.frame(dataset[dataset$ID=="x1",])
but is it possible to write a script and let do it to R?
So i got n submatrix of the n ID found in the original columns.

Cheers

Matteo

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to