Re: [R] binding vectors or matrix using their names

2004-03-25 Thread Patrick Burns
Not at all -- I can obfuscate much better. [EMAIL PROTECTED] wrote: Goodness Patrick, this must surely qualify for the obfuscated R competition finals. I love it! [snip] A more serious, philosophical word on Patrick's solution. It is rarely necessary (in my limited experience, sure) to

Re: [R] binding vectors or matrix using their names

2004-03-25 Thread Peter Dalgaard
[EMAIL PROTECTED] writes: A more serious, philosophical word on Patrick's solution. It is rarely necessary (in my limited experience, sure) to have to use parse() like this. Where it provides a quick (kludgy?) solution I often find it a useful exercise to consider alternatives. They often

Re: [R] binding vectors or matrix using their names

2004-03-25 Thread Rolf Turner
Well, I ***liked*** Patrick's approach. Why? Because it's basically straightforward. You put together a character string by pasting together the names of the objects you want to do things to, and the things (operations) you want to do to them. Then you get R to ``execute'' this string just as

[R] binding vectors or matrix using their names

2004-03-24 Thread Stephane DRAY
Hello list, I have two vectors x and x2: x=runif(10) x2=runif(10) and one vectors with their names : my.names=c(x,x2) I would like to cbind these two vectors using their names contained in the vector my.names. I can create a string with comma ncomma=paste(my.names,collapse=,) and now, I just

RE: [R] binding vectors or matrix using their names

2004-03-24 Thread Vadim Ogranovich
?get to convert names into objects -Original Message- From: Stephane DRAY [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 24, 2004 11:41 AM To: [EMAIL PROTECTED] Subject: [R] binding vectors or matrix using their names Hello list, I have two vectors x and x2: x=runif(10

Re: [R] binding vectors or matrix using their names

2004-03-24 Thread Tom Blackwell
I believe the syntax is result - do.call(cbind, as.list(my.names)) Haven't checked this on your example, though. - tom blackwell - u michigan medical school - ann arbor - On Wed, 24 Mar 2004, Stephane DRAY wrote: Hello list, I have two vectors x and x2: x=runif(10) x2=runif(10)

Re: [R] binding vectors or matrix using their names

2004-03-24 Thread Stephane DRAY
Hi Tom, Your approach did not work, do.call(cbind, as.list(my.names)) [,1] [,2] [1,] x x2 but it helps me a lot to find the good one: do.call(cbind, as.list(parse(text=my.names))) Thanks, At 14:56 24/03/2004, Tom Blackwell wrote: I believe the syntax is result - do.call(cbind,

RE: [R] binding vectors or matrix using their names

2004-03-24 Thread Liaw, Andy
Perhaps simler: x1 - 1:5 x2 - 2:7 xname - c(x1, x2) sapply(xname, get) x1 x2 [1,] 1 2 [2,] 2 3 [3,] 3 4 [4,] 4 5 [5,] 5 6 HTH, Andy From: Stephane DRAY Hi Tom, Your approach did not work, do.call(cbind, as.list(my.names)) [,1] [,2] [1,] x x2 but it

Re: [R] binding vectors or matrix using their names

2004-03-24 Thread Patrick Burns
I think you are looking for the eval-parse-text idiom: eval(parse(text=paste(cbind(, paste(my.names, collapse=, ), Patrick Burns Burns Statistics [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Stephane DRAY wrote: Hi

RE: [R] binding vectors or matrix using their names

2004-03-24 Thread Liaw, Andy
Gefore anyone jumps on me, I fibbed: From: Liaw, Andy Perhaps simler: x1 - 1:5 x2 - 2:7 That should've been x2 - 2:6. (I mistyped the first time, but cut-and-pasted the wrong line...) xname - c(x1, x2) sapply(xname, get) x1 x2 [1,] 1 2 [2,] 2 3 [3,] 3 4 [4,] 4 5

RE: [R] binding vectors or matrix using their names

2004-03-24 Thread Bill.Venables
in the process. Bill V. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Patrick Burns Sent: Thursday, 25 March 2004 7:02 AM To: Stephane DRAY Cc: [EMAIL PROTECTED]; Stephane DRAY; Tom Blackwell Subject: Re: [R] binding vectors or matrix using their names I