Skip to content

Problem with cbind() and arguments

4 messages · parlor9, Jeff Newmiller

#
Hello,
I am using Rscript and arguments, and I have to create a object, here is a
small example:
-I have P:
a   b
1   2
1   2
1   2

-And I want this result:
a   b   c
1   2   3
1   2   3
1   2   3

So I pass 'c' as an Rscript argument and use this command:
-But then it will return me this:
a   b   args[1]
1   2   3
1   2   3
1   2   3

I couldn't transform args[1] value 'c' into 'r code', instead of just a
string..
Could anyone give me a hand here? Thanks in advance!



--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-cbind-and-arguments-tp4650808.html
Sent from the R help mailing list archive at Nabble.com.
#
This is not reproducible. Nor can I figure out why you expected assigning 
"5" to "args[1]" was going to end up with c(3,3,3).

FWIW, I highly recommend that you re-read the Introduction to R,
particularly the sections discussing indexing.

Then you might try

P[[ args[1] ]] <- 3
On Sun, 25 Nov 2012, parlor9 wrote:

            
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
#
Yeah, I meant 3 instead of 5.
This was just an example, it's not what Im really doing.
I am using a 'arules' package for data mining, and I have to pass and
'arg[]' element and use it as the new column name of a data.frame. 

It's a bit complicated, so I used this example, and I would like to use
'args[1]' as 'c', in a new column name using cbind..



--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-cbind-and-arguments-tp4650808p4650912.html
Sent from the R help mailing list archive at Nabble.com.