Re: [R] Accessing specific data.frame columns within function

2016-02-05 Thread Greg Snow
You are trying to use shortcuts where shortcuts are not appropriate and having to go a lot longer around than if you did not use the shortcut, see fortune(312). You should really reread the help page: help("[[") and section 6.1 of An Introduction to R. Basically you should be able to do something

Re: [R] Accessing specific data.frame columns within function

2016-02-04 Thread Ulrik Stervbo
Hi Clark, In your function you are using the variable 'y' and not 'data'. If this indeed is your intention, there is no need to pass 'data' to your function, otherwise all 'y's in your function should be 'data'. Does this work for you: f <- function(data, oldnames, subset.val = 4){ data <- dat

[R] Accessing specific data.frame columns within function

2016-02-04 Thread Clark Kogan
Hello, I am trying to write a function that adds a few columns to a data.frame. The function uses the columns in a specific way. For instance, it might take a^2 + c to produce a column d. Or it might do more complex manipulations that I don't think I need to discuss here. I want to keep x as a dat