[R] Pairlist of pairlsit assembly howto
Johannes Graumann
johannes_graumann at web.de
Mon Jul 16 17:46:01 CEST 2007
Thanks for the hints ... there was another issue: "minute" was integers
starting with 0, which made R a bit upset on top of the subset/element issue.
Joh
On Sunday 15 July 2007 16:08:12 Duncan Murdoch wrote:
> (This isn't important to your question, but those aren't pairlists.
> Pairlists are rarely used in R code, except implicitly in the way R
> stores parsed code.)
>
> On 15/07/2007 10:00 AM, Johannes Graumann wrote:
> > Hy guys,
> >
> > I'm trying something like this
> >
> > minbins <- list()
> > for (minute in sequence(3)) {
> > minbins[minute] <- list(data="a",variable="b")
> > }
>
> You want to use
>
> minbins[[minute]] <- list(data="a",variable="b")
>
> The difference between [[ ]] and [ ] is that the former works on the
> element, the latter works on a subset. So your version tried to change
> a subset of length 1 into a subset of length 2, which generates the
> warnings. You want to assign a list of length 2 as an element of minbins.
>
> Duncan Murdoch
>
> > And it doesn't work ...
> > Warning messages:
> > 1: number of items to replace is not a multiple of replacement length in:
> > minbins[minute] <- list(data = "a", variable = "b")
> > 2: number of items to replace is not a multiple of replacement length in:
> > minbins[minute] <- list(data = "a", variable = "b")
> > 3: number of items to replace is not a multiple of replacement length in:
> > minbins[minute] <- list(data = "a", variable = "b")
> >
> > What am I doing wrong and how to do this properly?
> >
> > Thanks, Joh
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20070716/3bd205c8/attachment.bin
More information about the R-help
mailing list