Re: [R] dynamically create columns using a function

2017-07-21 Thread DIGHE, NILESH [AG/2362]
dataset = dat, col = col_mean_gg, col_name = col_name_gg) dat2 } # function demo_fn demo_fn<- function (dat, f, blup_datacut) { for (i in blup_datacut) { dat <- f(dat, i) } dat } # get expected results by applying functions demo_fn(dem, f, c("REG1", &

Re: [R] dynamically create columns using a function

2017-07-21 Thread Elie Canonici Merle
Hi, I don't know about the lazyeval package or what you are trying to do but to answer the main question "How to create columns dynamically using a function?" I would do something like that: # dataset dem <- structure(list(id = c("L1", "L2", "L3", "M1", "M2", "M3"), TEST_SET_NAME = c("A", "A", "A"

[R] dynamically create columns using a function

2017-07-20 Thread DIGHE, NILESH [AG/2362]
Hi, I am writing a function to dynamically create column names and fill those columns with some basic calculations. My function "demo_fn" takes argument "blup_datacut" and I like to use the contents of those arguments to dynamically create new columns in my dataset. Please note that I have anot