Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(i in 1:nrow(df)){
- df$new_column[i] <- df$column1[i] * df$column2[i]
- }
- new_df <- ddply(df, .(column1,column2), transform, new_column = column1 * column2)
- # but this is taking forever
- df$new_column <- df$column1 * df$column2
- df <- transform(df, new = column1 * column2)
- df <- within(df, new <- column1 * column2)
- library(data.table)
- DT <- data.table(df)
- DT[ , new := column1 * column2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement