Session Ready
Exercise

Correlations and pairwise p-values by a number of steps? (1)

In R you compute correlations among variables by the cor() function. Between the brackets you insert a vector, a matrix or a dataframe containing the variables between which you would like to compute the correlations.

The cor() function does not calculate p-values to test for significance, but the cor.test() function does.

In the following exercises, the correlations are computed for the variables in the dataset talent. The dataset talent contains values for the skills of 505 individuals. With respect to this dataset, it might be interesting to consider the relations among a number of variables and hence, the correlations and their p-values are computed.

The dataframe talent is loaded in the workspace.

Instructions
100 XP
  • First apply the names() function on talent to see the names of the variables.
  • Before computing the actual correlations, a subset is taken from the original dataframe using the subset() function. Assign the name talent_selected to the subset containing reading, english and creativity.
  • Compute the correlations among three variables: english, reading and creativity. Apply the cor() function on the subset talent_selected.
  • Test the significance of the correlations among all pairs of variables using the cor.test() function. Fill in the two variables of which the significance of the correlation is tested in the first two arguments. Refer to the dataset talent_selected, not talent. Do not forget to fill in the third argument: use.