Skip to content
Prev 245747 / 398506 Next

Passing a data frame or matrix and working with a column of the data frame or matrix

On Dec 24, 2010, at 4:29 PM, John Sorkin wrote:

            
# Try:

data[column]  # or
data[[column]]

# the column object will have a character value and either "[" or "[["  
will evaluate an unquoted argument.
# and there is no x ... well there is,  but if you passed a vector  
that evaluated to 1:10 to "[" you would be asking for the first 10  
columns, and "[[" would throw an error.

# Try:
learnfn(data, "x")

You seem to be reversing the expected conventions of quoting or not- 
quoting. When you invoke a function you need to send it a specific  
value but when you are writing the function you need to leave values  
open.