Often you have to create new variables by aggregating across columns or variables. These aggregations can be averages or sums.
You also sometimes have to create a new variable that shows the maximum, minimum, median, or standard deviation of a set of columns (variables) for each individual case (row).
You can also combine string variables together using a concatenate function or look a row ahead or behind using a lag function.
As with everything in R, there are multiple ways to accomplish these tasks. Here are a couple of ways to compute new variables by working in a row (i.e., across columns) to compute a new value for each row in a data frame.
Row functions: R Programming
DataDaft: How to Add Columns to a Data Frame in R (2:10)
Data Science Materials: Compute New Variables in R (1:52)
There are a number of ways to compute new variables in R. This page shows you several of the R operations can be used in R.
Look for "Live Demo" options to see how it works and looks in R Studio.