jessicacardoso

new_column

Nov 13th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.13 KB | None | 0 0
  1. cube <- function(x){
  2.     x * x * x
  3. }
  4. df <- data.frame(x = c(1,2,3,4,5), y = c(2,4,6,8,10))
  5. df$z <- sapply(df$x, cube)
  6. print(df)
Add Comment
Please, Sign In to add comment