[R] create a list fails

jim holtman jholtman at gmail.com
Wed Oct 20 17:01:51 CEST 2010


I do not see that it has been "created" yet.  You my have defined it
earlier in the 'list' expression, but as an object it is not available
yet.  You might have to do something like uwing 'within'

> x <- list()
> x <- within(x, {
+ a = 1:10
+ b = 11:20
+ c = a + b
+ d = a * b})
> x
$d
 [1]  11  24  39  56  75  96 119 144 171 200

$c
 [1] 12 14 16 18 20 22 24 26 28 30

$b
 [1] 11 12 13 14 15 16 17 18 19 20

$a
 [1]  1  2  3  4  5  6  7  8  9 10

>




On Wed, Oct 20, 2010 at 10:42 AM, Maas James Dr (MED) <J.Maas at uea.ac.uk> wrote:
> I can not understand why this fails
>
>>
>> faicoutput2 <- list(stuff21 = as.numeric(faicout$coefficients[2]),
> +                      stuff31=as.numeric(faicout$coefficients[3]),
> +                      stuff41=as.numeric(faicout$coefficients[4]),
> +                      stuff32=(stuff21-stuff31),
> +                      stuff42=(stuff21-stuff41),
> +                      stuff43=(stuff32-stuff42)
> +                      )
> Error: object 'stuff21' not found
>>
> Why does it have to be found, exist previously ... it is being created?
>
>
> But this works fine ....
>
> data <- list(Ntrials =numtritot, Ncomparisons=2,
>             treat=c(rep(1 ,N.trials[1,2]), rep(2,N.trials[1,3])),
>             total.patientnums.trt1=dat2[ ,2],
>             total.patientnums.trt23=dat2[ ,2],
>             num.countstrt1=dat2[ ,5],
>             num.countstrt23=dat2[ ,6] )
>
>
>  .... ????
>
>
>
>
>
> ===============================
> Dr. Jim Maas
> University of East Anglia
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list