This code book covers the key tables, variables and transformations performed during this analysis
combinedX2 - Cleaned up data set with 68 Variables and 10299 observations of all Test and Training Data
combinedX2 - This is the main combined Xtest and Xtraining data. Added to this is the Subjectid and activityid from the different files. All the Mean and Std variables have been 'tidied' by removing '-', '(,')' and converted into lower cases.
'data.frame': 10299 obs. of 68 variables: $ subjectid : int 1 1 1 1 1 1 1 1 1 1 ... $ activityid : int 1 1 1 1 1 1 1 1 1 1 ... $ tbodyaccmean : num 0.282 0.256 0.255 0.343 0.276 ... $ tbodyaccmean : num -0.0377 -0.06455 0.00381 -0.01445 -0.02964 ... $ tbodyaccmean : num -0.1349 -0.0952 -0.1237 -0.1674 -0.1426 ... $ tbodyaccstd : num -0.328 -0.229 -0.275 -0.23 -0.227 ... $ tbodyaccstd : num -0.1372 0.0165 0.0131 0.1739 0.1643 ... $ tbodyaccstd : num -0.189 -0.26 -0.284 -0.213 -0.123 ... $ tgravityaccmean : num 0.945 0.941 0.946 0.952 0.947 ... $ tgravityaccmean : num -0.246 -0.252 -0.264 -0.26 -0.257 ... $ tgravityaccmean : num -0.0322 -0.0329 -0.0256 -0.0261 -0.0284 ... $ tgravityaccstd : num -0.984 -0.984 -0.963 -0.981 -0.977 ... $ tgravityaccstd : num -0.929 -0.917 -0.956 -0.964 -0.989 ... $ tgravityaccstd : num -0.933 -0.949 -0.972 -0.964 -0.96 ... $ tbodyaccjerkmean : num -0.156 -0.208 0.202 0.336 -0.236 ... $ tbodyaccjerkmean : num -0.143 0.358 0.417 -0.464 -0.112 ... $ tbodyaccjerkmean : num -0.11308 -0.4524 0.13908 -0.00503 0.17265 ... $ tbodyaccjerkstd : num -0.184 -0.108 -0.178 -0.12 -0.192 ... $ tbodyaccjerkstd : num -0.1705 -0.0187 -0.0296 0.0287 0.054 ... $ tbodyaccjerkstd : num -0.614 -0.548 -0.58 -0.521 -0.469 ... $ tbodygyromean : num -0.47973 0.09409 0.2112 0.09608 0.00874 ... $ tbodygyromean : num 0.082 -0.3092 -0.2729 -0.1634 0.0117 ... $ tbodygyromean : num 0.25644 0.08644 0.10199 0.02586 0.00417 ... $ tbodygyrostd : num -0.324 -0.399 -0.445 -0.36 -0.378 ... $ tbodygyrostd : num -0.1419 -0.0884 -0.0631 0.0423 0.1337 ... $ tbodygyrostd : num -0.457 -0.402 -0.347 -0.276 -0.308 ... $ tbodygyrojerkmean : num 0.0942 0.1667 -0.1632 -0.0546 -0.0757 ... $ tbodygyrojerkmean : num -0.47621 -0.0338 -0.00556 0.34029 0.17147 ... $ tbodygyrojerkmean : num -0.1421 -0.0893 -0.2316 -0.2697 0.1365 ... $ tbodygyrojerkstd : num -0.346 -0.25 -0.264 -0.102 -0.129 ... $ tbodygyrojerkstd : num -0.487 -0.454 -0.425 -0.243 -0.19 ... $ tbodygyrojerkstd : num -0.422 -0.37 -0.343 -0.312 -0.418 ... $ tbodyaccmagmean : num -0.2246 -0.1265 -0.1601 -0.0735 -0.0495 ... $ tbodyaccmagstd : num -0.238 -0.213 -0.258 -0.195 -0.211 ... $ tgravityaccmagmean : num -0.2246 -0.1265 -0.1601 -0.0735 -0.0495 ... $ tgravityaccmagstd : num -0.238 -0.213 -0.258 -0.195 -0.211 ... $ tbodyaccjerkmagmean : num -0.289 -0.139 -0.194 -0.129 -0.16 ... $ tbodyaccjerkmagstd : num -0.165 -0.199 -0.22 -0.174 -0.15 ... $ tbodygyromagmean : num -0.0344 -0.1409 -0.0946 -0.0493 -0.0214 ... $ tbodygyromagstd : num -0.1682 -0.2161 -0.2908 -0.0901 -0.0446 ... $ tbodygyrojerkmagmean : num -0.466 -0.39 -0.374 -0.236 -0.22 ... $ tbodygyrojerkmagstd : num -0.434 -0.439 -0.418 -0.229 -0.213 ... $ fbodyaccmean : num -0.261 -0.151 -0.23 -0.151 -0.226 ... $ fbodyaccmean : num -0.1226 -0.029 0.0254 0.1953 0.1103 ... $ fbodyaccmean : num -0.331 -0.257 -0.377 -0.321 -0.205 ... $ fbodyaccstd : num -0.357 -0.262 -0.294 -0.263 -0.227 ... $ fbodyaccstd : num -0.1996 -0.0239 -0.0577 0.0879 0.1188 ... $ fbodyaccstd : num -0.178 -0.322 -0.29 -0.217 -0.146 ... $ fbodyaccjerkmean : num -0.21 -0.178 -0.193 -0.183 -0.285 ... $ fbodyaccjerkmean : num -0.2635 -0.1208 -0.1096 -0.026 -0.0111 ... $ fbodyaccjerkmean : num -0.536 -0.499 -0.526 -0.487 -0.426 ... $ fbodyaccjerkstd : num -0.228 -0.114 -0.236 -0.132 -0.169 ... $ fbodyaccjerkstd : num -0.12427 0.02785 -0.00582 0.02037 0.05578 ... $ fbodyaccjerkstd : num -0.698 -0.595 -0.633 -0.553 -0.51 ... $ fbodygyromean : num -0.185 -0.205 -0.317 -0.162 -0.237 ... $ fbodygyromean : num -0.198 -0.2458 -0.2082 0.0266 0.0472 ... $ fbodygyromean : num -0.308 -0.311 -0.186 -0.18 -0.258 ... $ fbodygyrostd : num -0.368 -0.461 -0.486 -0.423 -0.422 ... $ fbodygyrostd : num -0.11505 -0.00984 0.00973 0.04465 0.17602 ... $ fbodygyrostd : num -0.565 -0.49 -0.469 -0.377 -0.389 ... $ fbodyaccmagmean : num -0.1668 -0.0793 -0.1563 -0.1044 -0.1232 ... $ fbodyaccmagstd : num -0.4 -0.423 -0.437 -0.376 -0.388 ... $ fbodybodyaccjerkmagmean : num -0.154 -0.178 -0.149 -0.132 -0.116 ... $ fbodybodyaccjerkmagstd : num -0.185 -0.231 -0.321 -0.233 -0.201 ... $ fbodybodygyromagmean : num -0.22218 -0.26828 -0.30867 -0.06013 -0.00382 ... $ fbodybodygyromagstd : num -0.274 -0.315 -0.401 -0.275 -0.246 ... $ fbodybodygyrojerkmagmean: num -0.432 -0.428 -0.401 -0.218 -0.188 ... $ fbodybodygyrojerkmagstd : num -0.476 -0.493 -0.482 -0.299 -0.3 ...
Variables - 68 variables - 1 for the subjectid, 1 for activityid and 66 of mean() and std() variables amongst the 561 variables found in Xtrain and Xtest data
names(combinedX2)
[1] "subjectid" "activityid" "tbodyaccmean"
[4] "tbodyaccmean" "tbodyaccmean" "tbodyaccstd"
[7] "tbodyaccstd" "tbodyaccstd" "tgravityaccmean"
[10] "tgravityaccmean" "tgravityaccmean" "tgravityaccstd"
[13] "tgravityaccstd" "tgravityaccstd" "tbodyaccjerkmean"
[16] "tbodyaccjerkmean" "tbodyaccjerkmean" "tbodyaccjerkstd"
[19] "tbodyaccjerkstd" "tbodyaccjerkstd" "tbodygyromean"
[22] "tbodygyromean" "tbodygyromean" "tbodygyrostd"
[25] "tbodygyrostd" "tbodygyrostd" "tbodygyrojerkmean"
[28] "tbodygyrojerkmean" "tbodygyrojerkmean" "tbodygyrojerkstd"
[31] "tbodygyrojerkstd" "tbodygyrojerkstd" "tbodyaccmagmean"
[34] "tbodyaccmagstd" "tgravityaccmagmean" "tgravityaccmagstd"
[37] "tbodyaccjerkmagmean" "tbodyaccjerkmagstd" "tbodygyromagmean"
[40] "tbodygyromagstd" "tbodygyrojerkmagmean" "tbodygyrojerkmagstd"
[43] "fbodyaccmean" "fbodyaccmean" "fbodyaccmean"
[46] "fbodyaccstd" "fbodyaccstd" "fbodyaccstd"
[49] "fbodyaccjerkmean" "fbodyaccjerkmean" "fbodyaccjerkmean"
[52] "fbodyaccjerkstd" "fbodyaccjerkstd" "fbodyaccjerkstd"
[55] "fbodygyromean" "fbodygyromean" "fbodygyromean"
[58] "fbodygyrostd" "fbodygyrostd" "fbodygyrostd"
[61] "fbodyaccmagmean" "fbodyaccmagstd" "fbodybodyaccjerkmagmean"
[64] "fbodybodyaccjerkmagstd" "fbodybodygyromagmean" "fbodybodygyromagstd"
[67] "fbodybodygyrojerkmagmean" "fbodybodygyrojerkmagstd"
- Read all of the test data from the test directory xtest, ytest, and stest are the three test data sets
- Read all of the training data from the training directory xtraining, ytraining, and straining are the three training data sets
- Read all of the variable names and activity names from the features and activities data sets features and actities are the two resulting data sets
- Merge the respective test and training data sets mergedXtest and mergedXtrain are the merged data sets with the 563 variables with 2947 test observations and 7352 training observations with variable names for subjectid and activityid
- Combine the test and training dat combinedX data set is obtained my combining the two data sets using arrange. This contains 563 variables and 10299 observations
- Extract the mean() and std() variables and clean up the variable names combinedX2 data set uses grepl to extract only mean and std variables (and not meanFreq() variables. It also cleans up all the other variables by making them lower case and removing all special characters "-", "(,")" etc.
- Create tidy and wide data sets using molten and cast to get averages moltenX uses molten and dcast to compute the averages by subjectid and activity id