search for: demo_fn

Displaying 2 results from an estimated 2 matches for "demo_fn".

Did you mean: demo_f
2017 Jul 20
2
dynamically create columns using a function
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 another function called "calc_gg" within the function "demo_fn". Both functions are pasted below. I have a for...
2017 Jul 21
0
dynamically create columns using a function
...90L), IS_GG = c("NO", "NO", "YES", "NO", "NO", "YES" )), .Names = c("id", "TEST_SET_NAME", "YLD_BE_REG1", "YLD_BE_REG2", "IS_GG"), class = "data.frame", row.names = c(NA, -6L)) demo_fn<- function (data, f, names) { for (i in names) { data <- f(data, i) } data } f <- function(data, name) { col_work <- paste("YLD_BE", name, sep = "_") col_name_result <- paste("GG", name, sep = "_") #do something...