Importing the data from excel:
> library(readxl) # read_excel
> students_responses <- read_excel("Joseph's data.xlsx", na = "-")
Cleaning the data a bit:
> tmp <- students_responses$AvgTime # variable extraction
> tmp <- gsub("½", "0.5", tmp) # replacing "½" by "0.5"
> tmp <- as.numeric(tmp) # converting to numeric
> students_responses$AvgTime <- tmp # overwritting original variable
Splitting the data into 2 data frame, one for the quantitative data and the other one for the qualitative data:
> types_of_variables <- sapply(students_responses, class)
> quantitative <- students_responses[, types_of_variables == "numeric"]
> qualitative <- students_responses[, types_of_variables == "character"]
Calculating the data means of the quantitative variables:
> means <- sapply(quantitative, mean, na.rm = TRUE)
Calculating the kurtosis and the skewness of the quantitative variables (using 2 functions from the e1071
package):
> library(e1071) # skewness, kurtosis
> skewnesses <- sapply(quantitative, skewness, na.rm = TRUE)
> kurtosises <- sapply(quantitative, kurtosis, na.rm = TRUE)
> quantiles <- sapply(quantitative, quantile, na.rm = TRUE)
Putting means
, skewness
and kurtosis
together in a data frame:
> quantitive1 <- data.frame(means, skewnesses, kurtosises, t(quantiles))
> quantitive1
means skewnesses kurtosises X0. X25. X50. X75. X100.
Year 1.681208 0.96978614 -0.33320170 1 1 1 2.00 4
AvgTime 5.690559 3.18842597 10.89608942 0 2 3 6.00 48
I1 4.976744 -0.36164441 -0.17348745 1 4 5 6.00 7
I2 4.847176 -0.28864339 -0.06265987 1 4 5 6.00 7
I3 4.973422 -0.50683602 0.43532858 1 4 5 6.00 7
I4 5.210000 -0.71792710 0.35983470 1 4 5 6.00 7
I5 5.345515 -0.53757636 0.04973338 1 5 5 6.00 7
I6 4.770764 -0.38450172 -0.52098805 1 4 5 6.00 7
I7 5.872483 -1.26227012 1.34462867 1 5 6 7.00 7
I8 5.259136 -0.68224456 0.04371037 1 4 5 6.00 7
I9 4.847176 -0.52634190 -0.07832582 1 4 5 6.00 7
I10 4.846667 -0.60079051 0.48385382 1 4 5 6.00 7
I11 4.726667 -0.49074393 -0.46426718 1 4 5 6.00 7
I12 4.707641 -0.32299619 -0.23977746 1 4 5 6.00 7
I13 4.813333 -0.19751458 -0.09980453 1 4 5 6.00 7
I14 5.176667 -0.57790801 -0.11544186 1 4 5 6.00 7
I15 5.425249 -0.68374131 -0.02024136 2 5 6 6.00 7
I16 5.563333 -0.62839401 0.08537050 2 5 6 6.00 7
I17 5.634228 -0.58269013 0.10740522 2 5 6 6.00 7
I18 5.333333 -0.41210605 0.09429238 1 5 5 6.00 7
I19 5.013333 -0.27125439 -0.09803660 1 4 5 6.00 7
I20 4.763333 -0.32963708 -0.17886051 1 4 5 6.00 7
I21 3.920000 -0.01275629 0.08439781 1 3 4 5.00 7
I22 5.281879 -0.59957311 -0.13553117 1 4 5 6.00 7
I23 5.413333 -0.65109186 -0.08193884 1 4 6 7.00 7
I24 5.404682 -0.75830989 -0.11289154 1 4 6 7.00 7
I25 5.277592 -0.59095496 -0.38900395 1 4 6 6.00 7
I26 5.026667 -0.49210851 -0.01024070 1 4 5 6.00 7
I27 5.120401 -0.57608012 0.42582097 1 4 5 6.00 7
I28 4.833333 -0.26627700 -0.18894783 1 4 5 6.00 7
I29 4.802013 -0.33551854 -0.12786827 1 4 5 6.00 7
I30 5.426174 -0.48167715 -0.40229010 1 4 6 7.00 7
I31 5.244147 -0.64109785 -0.20020897 1 4 5 6.00 7
I32 5.873333 -1.04873782 0.60822308 2 5 6 7.00 7
I33 5.396667 -0.71494051 -0.02705782 1 4 6 7.00 7
I34 3.073333 0.41788843 -0.83920906 1 1 3 4.00 7
I35 3.520000 0.09068249 -1.08569796 1 2 4 5.00 7
I36 4.350000 -0.36886567 0.03802961 1 4 4 5.00 7
I37 3.943522 -0.22992107 -0.42823698 1 3 4 5.00 7
I38 4.573826 -0.48504106 -0.62510470 1 4 5 6.00 7
I39 5.270000 -0.63708001 -0.13584738 1 4 5 6.25 7
I40 5.411960 -0.72719640 0.38905595 1 5 6 6.00 7
I41 5.318937 -0.64183177 0.05268921 1 4 5 6.00 7
I42 4.826667 -0.23092563 -0.13574537 1 4 5 6.00 7
I43 5.106312 -0.47921878 -0.25065674 1 4 5 6.00 7
I44 5.245847 -0.54063337 -0.03021753 1 4 5 6.00 7
I45 5.243333 -0.46622434 -0.16352771 1 4 5 6.00 7
I46 5.026667 -0.39673825 0.04532440 1 4 5 6.00 7
I47 5.316667 -0.81279646 0.52362442 1 5 6 6.00 7
I48 5.183333 -0.73667899 0.57139251 1 4 5 6.00 7
I49 5.468439 -0.59362802 0.02292082 1 5 6 6.00 7
I50 5.421927 -0.58632933 0.42921198 1 5 5 6.00 7
I51 5.780731 -0.79403322 -0.10647142 2 5 6 7.00 7
Cleaning a bit the environment:
> rm(tmp, types_of_variables)
> ls()
[1] "kurtosises" "means" "qualitative"
[4] "quantiles" "quantitative" "quantitive1"
[7] "skewnesses" "students_responses"