KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have a data frame with columns c1, ..., cn, and a function f that takes in the columns of this data frame as arguments. How can I apply f to each row of the data frame to get a new data frame? For example, x = data.frame(letter=c('a','b','c'), number=c(1,2,3)) # x is # letter | number # a | 1 # b | 2 # c | 3 f = function(letter, number) { paste(letter, number, sep='') } # desired output is # a1 # b2 # c3 How do I do this? I'm guessing it's something along the lines of {s,l,t}apply(x, f), but I can't figure it out.
Tags (comma-separated)
Save Edits
Cancel