Neil Shephard
2007-Jul-24 10:12 UTC
[R] problems with character objects and calls to list() [solved]
Thanks to Patrick Burns and Mark Lyman for their suggestions in solving my problem. Patrick suggested creating the list directly (the solution I opted for).... On 7/23/07, Patrick Burns <pburns at pburns.seanet.com> wrote:> Why not make the list directly: > > list.to.convert <- vector('list', n) > for(x in 1:n) list.to.convert[[x]] <- seq((2*x)-1, 2*x) > > S Poetry may be of use to you.Whilst Mark suggested the correct evaluation of the character object....> > > list(1:2, 3:4, 5:6) > > [[1]] > > [1] 1 2 > > > > [[2]] > > [1] 3 4 > > > > [[3]] > > [1] 5 6 > > > > > eval(parse(text=paste("list(",to.convert,")",sep=""))) > [[1]] > [1] 1 2 > > [[2]] > [1] 3 4 > > [[3]] > [1] 5 6 > > [[4]] > [1] 7 8 > > [[5]] > [1] 9 10 > > [[6]] > [1] 11 12-- "In mathematics you don't understand things. You just get used to them." - Johann von Neumann Email - nshephard at gmail.com / n.shephard at sheffield.ac.uk Website - http://slack.ser.man.ac.uk/ Photos - http://www.flickr.com/photos/slackline/