[R] Can the environment of a function be specified when the function is defined?

2011-08-12 Thread Frederic F
Hello, Is there a syntax to set the environment of a function when this function is defined? The best I could come up with so far is using a wrapper function: foo_internals<- function(x) {"Code of the function"} foo<- function(x) { environment(foo_internals)<-as.environment(target_environme

Re: [R] How to quickly convert a data.frame into a structure of lists

2011-08-10 Thread Frederic F
Hello Denis, > To borrow shamelessly from one of the prominent helpers on this list: > "What is the problem you're trying to solve?"    (attribution: Jim Holtman) I'm trying to connect two sets of legacy R tools: the output of the first one can be transformed in a data.frame without loss of inf

Re: [R] How to quickly convert a data.frame into a structure of lists

2011-08-10 Thread Frederic F
Hello Duncan, Here is a small example to illustrate what I am trying to do. # Example data.frame df=data.frame(A=c("a","a","b","b"), B=c("X","X","Y","Z"), C=c(1,2,3,4)) # A B C # 1 a X 1 # 2 a X 2 # 3 b Y 3 # 4 b Z 4 ### First way of getting the list structure (ls1) using imbricated lapply

[R] How to quickly convert a data.frame into a structure of lists

2011-08-09 Thread Frederic F
Hello, This is my first project in R, so I'm trying to work 'the R way', but it still feels awkward sometimes. The problem that I'm facing right now is that I need to convert a data.frame into a structure of lists. The data.frame has columns in the order of tens (I need to focus on only three of