I got the below piece of code and it keeps on printing the frequency tables. How do I stop it from doing this.
pl = read.csv("c:/pl.csv")
freqs = function(name){ assign(name, table(pl[,name],pl$bad_outcome), envir = .GlobalEnv);}
lapply(names(pl), freqs);
You have three options:
1) Assign the output, since what you’re seeing as “printing” is actually just a return.
2) Use the l_ply function in plyr.
3) Don’t do the assign inside the lapply, but do it afterwards with
attach: