Hi Josh Kindly find below the code as it is executed:
test.functional.t <- function(res.em1,res.em2,mint,maxt,se.m=0,points=300) { at <- seq(mint,maxt,length.out=points) by <- at[2] - at[1] mu1 <- spline(x=res.em1$tau,y=res.em1$eta,xout=at,method="natural")$y l2 <- functional.norm(mu1,mu2,by=by) s1 <- mean(sapply(1:res.em1$n, function(i) { v <- spline(x=res.em1$tau,y=res.em1$vi[[i]],xout=at,method="natural")$y functional.norm(v,by=by)^2 })) denominator <- sqrt(s1 / res.em1$n + s2 / res.em2$n) ### formula for se returnValue <- l2 / (denominator + se.m) attr(returnValue,"numerator") <- l2 attr(returnValue,"denominator") <- denominator returnValue } moderated.functional.t <- function(testStatistics,alpha.step=0.05,quantile.step=0.01) { numerators <- unlist(testStatistics["numerator",]) denominators <- unlist(testStatistics["denominator",]) } I get my error in the function above moderated.functional.t. testStatistics is shown to be a function(x) when I type it in R console. But there is no function definition for testStatistics in the code. My R understanding is still elementary. Thanks Aparna On Tue, Feb 28, 2012 at 5:25 PM, Joshua Wiley <jwiley.ps...@gmail.com>wrote: > Hi Aparna, > > Can you please post a reproducible example? It is difficult to > provide much concrete help without having "testStatistics". One thing > you might try is looking at: > > str(testStatistics["numerator",]) > > is it actually a list? If it is not (most likely given the error) and > it is supposed to be, you need to figure out what aspect of the > generation of it is going awry. > > Cheers, > > Josh > > On Tue, Feb 28, 2012 at 12:23 AM, Aparna Sampath > <aparna.sampat...@gmail.com> wrote: > > Hi All > > > > I am trying to use the unlist() in R to a list variable. The following > > statements are within a function. > > { > > denominator <- sqrt(s1 / res.em1$n + s2 / res.em2$n) > > returnValue <- l2 / (denominator + 11) > > attr(returnValue,"numerator") <- l2 > > attr(returnValue,"denominator") <- denominator > > returnValue > > } > > > > And when I try to unlist the variable returnValue > > > > numerators <- unlist(testStatistics["numerator",]) > > denominators <- unlist(testStatistics["denominator",]) > > > > I get the following error: > > > >>Error in testStatistics["numerator", ] : > > object of type 'closure' is not subsettable > > > > I read some threads in R help on this error and they had asked to check > if > > we are using the right datatype to the right function. But in my case it > is > > pretty straightforward since I just list it in one function and try to > > unlist it later. Any suggestions? > > Thanks for the help :) > > > > -- > > View this message in context: > http://r.789695.n4.nabble.com/Error-message-object-of-type-closure-is-not-subsettable-tp3752886p4427399.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > 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. > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > Programmer Analyst II, Statistical Consulting Group > University of California, Los Angeles > https://joshuawiley.com/ > -- Aparna Sampath Master of Science (Bioinformatics) Nanyang Technological University Mob no : +65 91601854 [[alternative HTML version deleted]] ______________________________________________ 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.