Hi Josh, Petr

I checked that testStatistics is a function but it is not defined in the
code anywhere else. But if I am able to remove it and give the input by my
own to the function which calls testStatistics, it might work.

The hurdle here for me is that the input is a set* of values and each value
has 2 attributes. Each variable is generated per iteration and has the
numerator, denominator as its attributes and a value. But when I read it in
a loop,  i face two problems: 1. only the last i value is stored and the
rest are NULL. 2. the one stored does not contain the attribute values.
 Each value looks like this:
>t
[1] 3.897434
attr(,"numerator")
[1] 0.0002134457
attr(,"denominator")
[1] 5.47657e-05

Eg:
for (i in 1:5)
{
t<- test.functional.t(res.em1,res.em2,mint,maxt,se.m=0,points=300) ###
function calling
}

>t
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

[[4]]
NULL

[1] 3.897434

Any suggestions. Thanks for all the help. :)

Regards
Aparna






On Tue, Feb 28, 2012 at 11:01 PM, Petr PIKAL <petr.pikal@precheza.cz> wrote:

> Hi
>
> Difficult to without knowing what objects you are operating your
> functions.
>
> I get
>
> > test.functional.t(1:10,1:10,3,4)
> Error in res.em1$eta : $ operator is invalid for atomic vectors
> > moderated.functional.t(1:10)
> Error in testStatistics["numerator", ] : incorrect number of dimensions
>
> And without suitable objects for those functions to operate it is
> impossible to come with reasonable suggestion.
>
> Anyway there is a function on your system which is called testStatistics
> and you can not subset functions, hence your error. I did not find this
> function in R pacages but I can not say that it is really not there.
>
> You can get rid of this function by
>
> rm(testStatistics)
>
> Regards
> Petr
>
>
> >
> > 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.psych@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.sampath26@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.
>
>

	[[alternative HTML version deleted]]

