Re:Starting data analysis with R: Things I wish I'd been told
by houshuang on Sunday November 23, 2014 @10:53PM
(#8650988)
There are lot's of ways of doing things in R, and I am always learning. I always use vectorized functions when I do something to every row in a data.frame, but when I want to do something to every column, like here, I sometimes use for. How would you use something like plyr here, and would it be as easy to understand?
[ Parent
| on HN ]
Re:Starting data analysis with R: Things I wish I'd been told
by nograpes on Sunday November 23, 2014 @11:25PM
(#8651040)
Like this:
db<-data.frame(replicate(44,1:5))
likertcat <- as.ordered(c("Not at all", "To a small extent", "To some extent",
"To a moderate extent", "To a large extent"))
db[ ,9:44] <- lapply(db[,9:44], function(x) likertcat[x])