Re: [R] lapply to list of variables

2011-11-10 Thread Kenn Konstabel
Hi hi, It is much easier to deal with lists than a large number of separate objects. So the first answer to your question > How can I apply a function to a list of variables. .. might be to convert your "list of variables" to a regular list. Instead of ... monday <- 1:3 tuesday <- 4:7 wednesday

Re: [R] lapply to list of variables

2011-11-08 Thread Dennis Murphy
Hi: Here's another way of doing this on the simplified version of your example: L <- vector('list', 3) # initialize a list of three components ## populate it for(i in seq_along(L)) L[[i]] <- rnorm(20, 10, 3) ## name the components names(L) <- c('Monday', 'Tuesday', 'Wednesday') ## replace va

Re: [R] lapply to list of variables

2011-11-08 Thread Uwe Ligges
On 08.11.2011 17:59, Ana wrote: Hi Can someone help me with this? How can I apply a function to a list of variables. something like this listvar=list("Monday","Tuesday","Wednesday") This is a list of length one character vectors rather than a "list of variables". func=function(x){x

[R] lapply to list of variables

2011-11-08 Thread Ana
Hi Can someone help me with this? How can I apply a function to a list of variables. something like this listvar=list("Monday","Tuesday","Wednesday") func=function(x){x[which(x<=10)]=NA} lapply(listvar, func) were Monday=[213,56,345,33,34,678,444] Tuesday=[213,56,345,33,34,678,444] ... in m