Hi friends, I need to generate a list, that should contain the quantile value of one column in a data frame. while I am compiling this one i am facing one bug,, Really I cannot find out that where the problem has occurred? Could any one help me to come out from this bug?? Here is the code, data <- lapply(comb.data$zFE, function(x) aggregate(x, by=list(comb.data[["sequence"]]), quantile, probs=c(0.5,0.8,0.9), na.rm=T)) And I am facing bug like this, "Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length" Thanks, Suresh -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714.html Sent from the R help mailing list archive at Nabble.com.
data? We really should see some sample data. See ?dput for a way to supply some. John Kane Kingston ON Canada> -----Original Message----- > From: sureshmallikaraj at gmail.com > Sent: Thu, 28 Jun 2012 01:58:30 -0700 (PDT) > To: r-help at r-project.org > Subject: [R] How can I make a list using aggregate function? > > Hi friends, > > I need to generate a list, that should contain the quantile value of > one > column in a data frame. while I am compiling this one i am facing one > bug,, > Really I cannot find out that where the problem has occurred? Could any > one > help me to come out from this bug?? > > Here is the code, > data <- lapply(comb.data$zFE, function(x) aggregate(x, > by=list(comb.data[["sequence"]]), quantile, probs=c(0.5,0.8,0.9), > na.rm=T)) > > And I am facing bug like this, > "Error in aggregate.data.frame(as.data.frame(x), ...) : > arguments must have same length" > > Thanks, > Suresh > > -- > View this message in context: > http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more!
Hi freind, My data seems to be like , and data frame name is comb.data sequence weight rsat. zFEl 1 CTTTTCTTGTT 4.6 0.00058 -7.452 3.237 2 ACTTTGAGGTG 4.1 0.00077 -7.169 3.114 3 GTCTTGAACTC 4.8 0.00055 -7.506 3.260 4 GCTTTGAAGAA 6.6 0.00019 -8.568 3.721 5 GCTTTCAACAT 7.0 0.00014 -8.874 3.854 6 TCCTTGTTCAT 3.5 0.00099 -6.918 3.004 So I need to use aggregate function based on sequence column(by=list(comb.data$sequence) for zFE column and I should need to store those results in lists..so result would be like [[1]] CTTTTCTTGTT 2.3758 3.237 [[2]] ACTTTGAGGTG 1.78977 -5.11768684 [[3]] GTCTTGAACTC 1.987455 1.260 [[1]] GCTTTGAAGAA 1.019 0.72541 [[4]] GCTTTCAACAT 0.0423 3.865754 ...so I made a code like this,,but i am facing some bugs as i mentioned before,,could you please help to solve this one??I hope now you understand my query... the code is "data <- lapply(comb.data$zFE, function(x) aggregate(x,by=list(comb.data[["sequence"]]), quantile, probs=c(0.5,0.8,0.9), na.rm=T)) " Thanks,, -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714p4634764.html Sent from the R help mailing list archive at Nabble.com.
Hello, Your data is a mess, with more columns than column names. Use # 20 to 100 dput(head(comb.data, 30)) # paste the output of this in a post. Anyway, it seems that what you want is (untested) aggregate(zFEl~sequence, data=comb.data, quantile, probs=c(0.5,0.8,0.9), na.rm=T) Hope this helps, Rui Barradas Em 28-06-2012 15:10, sureshraj escreveu:> Hi freind, > My data seems to be like , and data frame name is comb.data > sequence weight rsat. zFEl > 1 CTTTTCTTGTT 4.6 0.00058 -7.452 3.237 > 2 ACTTTGAGGTG 4.1 0.00077 -7.169 3.114 > 3 GTCTTGAACTC 4.8 0.00055 -7.506 3.260 > 4 GCTTTGAAGAA 6.6 0.00019 -8.568 3.721 > 5 GCTTTCAACAT 7.0 0.00014 -8.874 3.854 > 6 TCCTTGTTCAT 3.5 0.00099 -6.918 3.004 > > So I need to use aggregate function based on sequence > column(by=list(comb.data$sequence) for zFE column and I should need to store > those results in lists..so result would be like > [[1]] > CTTTTCTTGTT 2.3758 3.237 > [[2]] > ACTTTGAGGTG 1.78977 -5.11768684 > [[3]] > GTCTTGAACTC 1.987455 1.260 > [[1]] > GCTTTGAAGAA 1.019 0.72541 > [[4]] > GCTTTCAACAT 0.0423 3.865754 > ...so I made a code like this,,but i am facing some bugs as i mentioned > before,,could you please help to solve this one??I hope now you understand > my query... > > the code is > "data <- lapply(comb.data$zFE, function(x) > aggregate(x,by=list(comb.data[["sequence"]]), quantile, > probs=c(0.5,0.8,0.9), na.rm=T)) " > > > Thanks,, > > > > -- > View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714p4634764.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
Hi, The data is indeed very confusing.? It has four column names and five columns.? Assuming that zFEI is for fifth column, the fourth column is "Unknown1". dat2<-read.table(text=" sequence????????????? weight rsat. Unknown1? zFEl ?1??? CTTTTCTTGTT??? 4.6? 0.00058? -7.452 3.237 ?2??? ACTTTGAGGTG??? 4.1? 0.00077? -7.169 3.114 ?3??? GTCTTGAACTC??? 4.8? 0.00055? -7.506 3.260 ?4? GCTTTGAAGAA??? 6.6? 0.00019? -8.568 3.721 ?5??? GCTTTCAACAT??? 7.0? 0.00014? -8.874 3.854 ?6? TCCTTGTTCAT??? 3.5? 0.00099? -6.918 3.004 ",sep="",header=TRUE) dat3<-aggregate(dat2$zFEl,by=list(dat2$sequence),quantile,probs=c(0.5,0.8,0.9)) dat4<-as.matrix(data.frame(dat3[,1],unlist(dat3[,2]))) colnames(dat4)<-NULL dat5<-lapply(seq_len(nrow(dat4)),function(i) dat4[i,])> dat5[[1]] [1] "ACTTTGAGGTG" "3.114"?????? "3.114"?????? "3.114"????? [[2]] [1] "CTTTTCTTGTT" "3.237"?????? "3.237"?????? "3.237"????? [[3]] [1] "GCTTTCAACAT" "3.854"?????? "3.854"?????? "3.854"????? [[4]] [1] "GCTTTGAAGAA" "3.721"?????? "3.721"?????? "3.721"????? [[5]] [1] "GTCTTGAACTC" "3.260"?????? "3.260"?????? "3.260"????? [[6]] [1] "TCCTTGTTCAT" "3.004"?????? "3.004"?????? "3.004"? The results I guess is fairly closer to the form you want to store as a list. A.K.? ?? ----- Original Message ----- From: Rui Barradas <ruipbarradas at sapo.pt> To: sureshraj <sureshmallikaraj at gmail.com> Cc: r-help at r-project.org Sent: Thursday, June 28, 2012 12:09 PM Subject: Re: [R] How can I make a list using aggregate function? Hello, Your data is a mess, with more columns than column names. Use # 20 to 100 dput(head(comb.data, 30)) # paste the output of this in a post. Anyway, it seems that what you want is (untested) aggregate(zFEl~sequence, data=comb.data, quantile, probs=c(0.5,0.8,0.9), na.rm=T) Hope this helps, Rui Barradas Em 28-06-2012 15:10, sureshraj escreveu:> Hi freind, >? My data seems to be like , and data frame name is comb.data > sequence? ? ? ? ? ? ? weight rsat.? ? ? ? ? zFEl > 1? ? CTTTTCTTGTT? ? 4.6? 0.00058? -7.452 3.237 > 2? ? ACTTTGAGGTG? ? 4.1? 0.00077? -7.169 3.114 > 3? ? GTCTTGAACTC? ? 4.8? 0.00055? -7.506 3.260 > 4? GCTTTGAAGAA? ? 6.6? 0.00019? -8.568 3.721 > 5? ? GCTTTCAACAT? ? 7.0? 0.00014? -8.874 3.854 > 6? TCCTTGTTCAT? ? 3.5? 0.00099? -6.918 3.004 > > So I need to use aggregate function based on sequence > column(by=list(comb.data$sequence) for zFE column and I should need to store > those results in lists..so result would be like >? [[1]] > CTTTTCTTGTT? ? 2.3758? 3.237 > [[2]] > ACTTTGAGGTG? 1.78977? -5.11768684 > [[3]] >? GTCTTGAACTC? ? 1.987455? 1.260 > [[1]] >? GCTTTGAAGAA? 1.019? 0.72541 > [[4]] >? GCTTTCAACAT? ? 0.0423? 3.865754 > ...so I made a code like this,,but i am facing some bugs as i mentioned > before,,could you please help to solve this one??I hope now you understand > my query... > > the code is > "data <- lapply(comb.data$zFE, function(x) > aggregate(x,by=list(comb.data[["sequence"]]), quantile, > probs=c(0.5,0.8,0.9), na.rm=T)) " > > > Thanks,, > > > > -- > View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714p4634764.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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 at 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.
On 06/28/2012 06:58 PM, sureshraj wrote:> Hi friends, > > I need to generate a list, that should contain the quantile value of one > column in a data frame. while I am compiling this one i am facing one bug,, > Really I cannot find out that where the problem has occurred? Could any one > help me to come out from this bug?? > > Here is the code, > data<- lapply(comb.data$zFE, function(x) aggregate(x, > by=list(comb.data[["sequence"]]), quantile, probs=c(0.5,0.8,0.9), na.rm=T)) > > And I am facing bug like this, > "Error in aggregate.data.frame(as.data.frame(x), ...) : > arguments must have same length" >Hi Suresh, If your code is accurate, you have an element of the data frame comb.data named zFEl and you are asking for an element named zFE, which isn't there, and thus has length zero. Is your error simply one of misspelling? Jim
Ooops!!! Thanks you friends for your valuable comments, Finally I found the solution for that,, Neways thanks.... -- View this message in context: http://r.789695.n4.nabble.com/How-can-I-make-a-list-using-aggregate-function-tp4634714p4634871.html Sent from the R help mailing list archive at Nabble.com.