Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread William Dunlap
arn to love lists. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of matteo > Sent: Monday, June 24, 2013 11:32 AM > To: Bert Gunter > Cc: r-help@r-project

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread matteo
First of all, thanks for all the replies!! What you have written helps, but is not entirely the answer to my problem. What I'd have is the creation of new data.frames each of one named with the ID of the original dataframe and with all the columns. For example, in the original dataframe one co

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Bert Gunter
Inline below... On Mon, Jun 24, 2013 at 11:31 AM, matteo wrote: > First of all, thanks for all the replies!! > What you have written helps, but is not entirely the answer to my problem. > > What I'd have is the creation of new data.frames each of one named with the > ID of the original dataframe

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Bert Gunter
Oh yes, that's even better! -- Bert On Mon, Jun 24, 2013 at 10:33 AM, Rui Barradas wrote: > Hello, > > I had forgotten the much simpler solutions. The following should do it. > > split(dataset, dataset$ID) > > > Rui Barradas > > Em 24-06-2013 18:13, Bert Gunter escreveu: >> >> First of all, is y

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread David Winsemius
On Jun 24, 2013, at 10:03 AM, matteo wrote: > Hi, > >> result <- lapply(unique(dataset$ID), function(uid) dataset[dataset$ID == >> uid, ]) > Ok, I have the element result as a list > >> names(result) <- unique(dataset$ID) > Nothing happens. I don't have any submatrix... > > Matteo > > _

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Rui Barradas
Hello, I had forgotten the much simpler solutions. The following should do it. split(dataset, dataset$ID) Rui Barradas Em 24-06-2013 18:13, Bert Gunter escreveu: First of all, is your data structure a matrix or a data frame? They are different! Assuming the latter, a shorter version of Rui'

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread David Winsemius
Sorry for the blank message. The default behavior of the Mac Mail.app spell checker has me confused. On Jun 24, 2013, at 10:03 AM, matteo wrote: > Hi, > >> result <- lapply(unique(dataset$ID), function(uid) dataset[dataset$ID == >> uid, ]) > Ok, I have the element result as a list > >> names(

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Rui Barradas
Hello, You don't have a sub-data.frame, what you have is a list, with each element of that list a df. Try to see, for instance, result[[1]]. This should be a data.frame corresponding to the first ID. Rui Barradas Em 24-06-2013 18:03, matteo escreveu: Hi, result <- lapply(unique(dataset$ID

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Bert Gunter
First of all, is your data structure a matrix or a data frame? They are different! Assuming the latter, a shorter version of Rui's answer that avoids unique() and automatically takes care of names is: result <- by(dataset, dataset$ID,I) See ?by, ?tapply, and ?split -- Bert On Mon, Jun 24, 2013

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread matteo
Hi, result <- lapply(unique(dataset$ID), function(uid) dataset[dataset$ID == uid, ]) Ok, I have the element result as a list names(result) <- unique(dataset$ID) Nothing happens. I don't have any submatrix... Matteo __ R-help@r-project.org mailing

Re: [R] extracting submatrix from a bigger one

2013-06-24 Thread Rui Barradas
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 (459x2

[R] extracting submatrix from a bigger one

2013-06-24 Thread matteo
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