変数名を使用してデータフレーム列に割り当てます。
getModified <- function(dframe, destination_string, foo, bar) {
# complex calculations on foo and bar getting mynewcol here
# ...
# I want to add mynewcolumn with name in destination_string
# if "blah" was the destination_string, the result would be as:
#dframe$blah <- mynewcol
#return(dframe)
# what is the syntax for using the variable?
# no luck here:
dframe[, destination_string] <- mynewcolumn
return(dframe)
}
電話できるように
dframe <- getModified(dframe, "nameofmynewcolum", foo, bar)
dframe$nameofmynewcolumn