Re: [R] Access dataframe with variable name in function

2010-02-12 Thread Dennis Murphy
Hi: Hi: Observe that if you quote the name of the variable in your original function, everything is fine; in fact, you can ask for multiple variables. > k <- function(df, col) df[col] > k(testdata, 'var1') var1 1 0.91663902 2 0.60470753 3 0.09599891 > k(testdata, 'censor') censor 1

Re: [R] Access dataframe with variable name in function

2010-02-12 Thread Sharpie
Philipp Rappold wrote: > > Sorry guys, but I have another one: > > > I want to write a function that returns a certain column of a > dataframe. The function accepts two argument: the dataframe and the > name of the column, but the column is not given as a "string" but as > a variable name.

[R] Access dataframe with variable name in function

2010-02-12 Thread Philipp Rappold
Sorry guys, but I have another one: I want to write a function that returns a certain column of a dataframe. The function accepts two argument: the dataframe and the name of the column, but the column is not given as a "string" but as a variable name. EXAMPLE -- > testd