To divide a table's columns in R, you can use the mutate()
function from the dplyr
package. Here's an example:
main.r226 chars13 lines
In the above code, we create a sample data frame df
with columns a
, b
and c
. We then use mutate()
to create a new column called new_column
which is the result of dividing column a
by column c
. The %>%
operator is used to "pipe" the df
data frame into the mutate()
function. Finally, we display the updated data frame.
gistlibby LogSnag