1. Learn
  2. /
  3. Courses
  4. /
  5. Helsinki Open Data Science

Connected

Exercise

Combining variables

Our data includes many questions that can be thought to measure the same dimension. You can read more about the data and the variables here. Here we'll combine multiple questions into combination variables. Useful functions for summation with data frames in R are

function description
colSums(df) returns a sum of each column in df
rowSums(df) returns a sum of each row in df
colMeans(df) returns the mean of each column in df
rowMeans(df) return the mean of each row in df

We'll combine the use of rowMeans()with the select() function from the dplyr library to average the answers of selected questions. See how it is done from the example codes.

Instructions

100 XP
  • Access the dplyr library
  • Execute the example codes to create the combination variables 'deep' and 'surf' as columns in lrn14
  • Select the columns related to strategic learning from lrn14
  • Create the combination variable 'stra' as a column in lrn14