#if (!require(devtools)) install.packages("devtools",quiet=TRUE)
::install_github("tuomaseerola/MusicScienceData",quiet=TRUE) devtools
Ch. 1 – Notebook basics
This first notebook is just a demonstration of running R in notebook calculates the correlation between ratings of energy and tension from an existing dataset.
Preliminaries
To install the MusicScienceData
package that contains several example datasets used in this book, run the following command.
Code 1.1
This is the first R code example, which demonstrates loading package that contains datasets, choosing one dataset, and then calculating correlation between two rated concepts (energy and tension).
# Code 1.1
library(MusicScienceData) # loads library w data
<- MusicScienceData::soundtrack # pick data
data cor.test(data$Energy, # calc. correlation
$Tension) data
Pearson's product-moment correlation
data: data$Energy and data$Tension
t = 7.3396, df = 108, p-value = 4.222e-11
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.4368271 0.6896336
sample estimates:
cor
0.576884