Noob here to R. Trying to figure something out. I need to build a function that adds a new column to the beginning of a dataset. This new column is a concatenation of the va
This should do the trick
addPrimaryKey <-function(df, cols){ q<-apply(df[,cols], 1, function(x) paste(x, collapse="")) df<-cbind(q, df) return(df) }
Just add in some conditional logic for your nulls