Re: [R] subset of data frame

2014-02-09 Thread arun
Hi, Try: x[x$Species%in%names(sp)[1:2],] A.K. On Saturday, February 8, 2014 10:21 PM, Yuanzhi Li wrote: Hi, everyone I met a small problem when I want take a subset from a data frame. The data frame(x) looks like the followings(10 species with 3 measured traits): Species    trait1    tra

Re: [R] subset of data frame

2014-02-09 Thread Rui Barradas
Hello, First of all use ?dput to post a data example. dput(head(x, 20)) # paste the output of this in a post Now, without a reproducible example it's difficult to say but maybe ?%in% x[x$Species %in% names(sp)[1:2],] Hope this helps, Rui Barradas Em 09-02-2014 00:03, Yuanzhi Li escreveu:

[R] subset of data frame

2014-02-08 Thread Yuanzhi Li
Hi, everyone I met a small problem when I want take a subset from a data frame. The data frame(x) looks like the followings(10 species with 3 measured traits): Species trait1trait2 trait3 sp1 sp1 ... sp2 sp2 ... sp10 sp10 ... It would be easy if we want trait values for most abu

[R] subset of data frame

2014-02-08 Thread Yuanzhi Li
Hi, everyone I met a small problem when I want take a subset from a data frame. The data frame(x) looks like the followings(10 species with 3 measured traits): Species trait1trait2 trait3 sp1 sp1 ... sp2 sp2 ... sp10 sp10 ... It would be easy if we want trait values for most abu

[R] Subset of Data

2012-12-12 Thread farnoosh sheikhi
Hi Arun, I have a question about choosing a subset of data. I have a matrix of 5000 in 3500. I want to choose specific variables such as proc1 to proc1000 and Lab1 to Lab1600 and put it into a new matrix to run some correlation analysis. Since I have 3500 variables, I don't know from what column

Re: [R] Subset of Data

2012-12-12 Thread farnoosh sheikhi
Thank you so much. It worked very well:)   Best,Farnoosh Sheikhi Cc: R help Sent: Wednesday, December 12, 2012 12:59 PM Subject: Re: Subset of Data Hi Farnoosh, Try this: set.seed(151) mat1<-matrix(sample(1:400,100,replace=TRUE),ncol=20) set.seed(15) colnam

Re: [R] Subset of Data

2012-12-12 Thread arun
Hi Farnoosh, Try this: set.seed(151) mat1<-matrix(sample(1:400,100,replace=TRUE),ncol=20) set.seed(15) colnames(mat1)<-paste(sample(c("proc","Lab","other"),20,replace=TRUE),sample(1:45,20,replace=FALSE),sep="") mat1[,grepl("proc|Lab",colnames(mat1))] # Lab37 proc35 Lab3 Lab24 proc6 proc36 Lab

Re: [R] Subset of Data Frame using the date

2011-02-01 Thread Henrique Dallazuanna
Try this: DF <- data.frame( "Date" = c("2009-09-01","2009-09-02","2009-09-03","2009-09-04", "2009-09-05"), "Data" = c( 10:14 ) ) subset(DF, as.Date(Date) >= '2009-09-02' & as.Date(Date) <= '2009-09-04') On Tue, Feb 1, 2011 at 11:09 AM, Usuario R wrote: > Hello, > > I have a data frame with one

[R] Subset of Data Frame using the date

2011-02-01 Thread Usuario R
Hello, I have a data frame with one column set as the date with function as.Date. In example: data.frame( "Date" = c("2009-09-01","2009-09-02","2009-09-03","2009-09-04", "2009-09-05"), "Data" = c( 10:14 ) ) Date Data 2009-09-01 10 2009-09-02 11 2009-09-03 12 2009-09-04 13 Is there