Re: [R] assigment operator question

2012-04-08 Thread Thomas Lumley
On Sun, Apr 8, 2012 at 11:57 AM, Duncan Murdoch wrote: > On 12-04-07 4:51 PM, Henrik Bengtsson wrote: >> >> On Sat, Apr 7, 2012 at 1:30 PM, Mark Heckmann >>  wrote: >>> >>> Hello, >>> >>> using the<<- assignment operator I do not understand why the following >>> does not work. >>> >>> l<<- list()

Re: [R] assigment operator question

2012-04-07 Thread Duncan Murdoch
On 12-04-07 4:51 PM, Henrik Bengtsson wrote: On Sat, Apr 7, 2012 at 1:30 PM, Mark Heckmann wrote: Hello, using the<<- assignment operator I do not understand why the following does not work. l<<- list() l list() l$arg1<<- "test" error in l$arg1<<- "test" : Objekt 'l' not found ?"<<-" says:

Re: [R] assigment operator question

2012-04-07 Thread Gabor Grothendieck
On Sat, Apr 7, 2012 at 5:01 PM, Mark Heckmann wrote: > Thanks! I'll try to stick to that advice! > Maybe there is a better way... Here is what I want: > > I want to save some default settings for a package. > The user can change these using a function similar to par(). > I do not want to use optio

Re: [R] assigment operator question

2012-04-07 Thread Henrik Bengtsson
On Sat, Apr 7, 2012 at 2:01 PM, Mark Heckmann wrote: > Thanks! I'll try to stick to that advice! > Maybe there is a better way... Here is what I want: > > I want to save some default settings for a package. > The user can change these using a function similar to par(). > I do not want to use optio

Re: [R] assigment operator question

2012-04-07 Thread Mark Heckmann
Thanks! I'll try to stick to that advice! Maybe there is a better way... Here is what I want: I want to save some default settings for a package. The user can change these using a function similar to par(). I do not want to use options() here as it will be quite a lot of parameters. I was thinking

Re: [R] assigment operator question

2012-04-07 Thread Henrik Bengtsson
On Sat, Apr 7, 2012 at 1:30 PM, Mark Heckmann wrote: > Hello, > > using the <<- assignment operator I do not understand why the following does > not work. > > l <<- list() > l > list() > l$arg1 <<- "test" > error in l$arg1 <<- "test" : Objekt 'l' not found > > ?"<<-" says:  "The operators <<- and

[R] assigment operator question

2012-04-07 Thread Mark Heckmann
Hello, using the <<- assignment operator I do not understand why the following does not work. l <<- list() l list() l$arg1 <<- "test" error in l$arg1 <<- "test" : Objekt 'l' not found ?"<<-" says: "The operators <<- and ->> cause a search to made through the environment for an existing defini

Re: [R] assigment

2010-11-19 Thread Robert Ruser
Joshua, Dennis ans Henrique I'm immensely indebted to you. Thanks to you I resolved my problem - a code works perfectly. I put the code, maybe someone finds it's helpful. f1 <- readLines(file("file1.txt")) f2 <- readLines(file("file2.txt")) for ( i in seq_along(f1)){ assign(f1[i],as.numeric(unli

Re: [R] assigment

2010-11-19 Thread Henrique Dallazuanna
Try this: mapply(assign, x, list(y1, y2, y3), MoreArgs = list(envir = globalenv())) On Fri, Nov 19, 2010 at 8:57 AM, Robert Ruser wrote: > Hello R Users, > I have vectors > x <- c("a2","b7","c8") > y1 <- c(1,2,3,2) > y2 <- c(4,2,7,5,4,3,8) > y3 <- c(1:10) > and I want to assign values form vect

Re: [R] assigment

2010-11-19 Thread Joshua Wiley
On Fri, Nov 19, 2010 at 3:20 AM, Robert Ruser wrote: > a2 a should get the values. Lists are a nice way to allow variable data (e.g., vectors, data frames, matrices, etc. all of different sizes) but still group related things (such as data from a single file) together, kind of like putting all yo

Re: [R] assigment

2010-11-19 Thread Dennis Murphy
Hi: On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser wrote: > Hello R Users, > I have vectors > x <- c("a2","b7","c8") > y1 <- c(1,2,3,2) > y2 <- c(4,2,7,5,4,3,8) > y3 <- c(1:10) > and I want to assign values form vector y1 to a new variable which > name comes from the 1st value of the vector x et

Re: [R] assigment

2010-11-19 Thread Robert Ruser
Thank you, but unfortunately it's not resolve my problem. After writing in R console e.g. a2 a should get the values. Do you know how to read file 2 into R? 2010/11/19 Joshua Wiley : > Hi Robert, > > What about a named list?  This will generalize to your two text files > one with data, the other

Re: [R] assigment

2010-11-19 Thread Joshua Wiley
Hi Robert, What about a named list? This will generalize to your two text files one with data, the other with names. x <- c("a2","b7","c8") y1 <- c(1,2,3,2) y2 <- c(4,2,7,5,4,3,8) y3 <- c(1:10) dat <- list(c(1,2,3,2), c(4,2,7,5,4,3,8), c(1:10)) names(dat) <- c("a2","b7","c8") dat # example dat

[R] assigment

2010-11-19 Thread Robert Ruser
Hello R Users, I have vectors x <- c("a2","b7","c8") y1 <- c(1,2,3,2) y2 <- c(4,2,7,5,4,3,8) y3 <- c(1:10) and I want to assign values form vector y1 to a new variable which name comes from the 1st value of the vector x etc. How to do it using only vector x. As a result I should have: a2 <- y1 b7