Thanks to visit codestin.com
Credit goes to github.com

Skip to content

raksha28/CleanData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Code-book run_analysis.R

Reading the files

The files are expected to be in the working directory, in the same directories as in the zip file. So the features.txt in the working directory, all other files or in the test or in the train folders

The script reads the features file. This will be to assign column names when reading the data files

What it does for both the training and test data:

  1. Read the subject file and assign the column name "subject"
  2. Read the activity file and assign the column name "activity"
  3. Read the data file and assign the column names coming from the features file

Combining the files

Now, for both the training and test files, it will bind the columns of all 3 files."subject" will be column 1, "activity" column 2 and then the data"

To get to the final big file, both training and test file will be combined

Modify the column names

Currently, the column names still contain several symbols

The column names are transformed to lower cases and the brackets and hyphens removed

Get mean and stdev columns

From all columns, only those containing "mean" and "std" are maintained for further analysis

Calculate the mean for each group

To allow for easier grouping and summarizing the data, the dataset is transformed into a data.table

Now, the data is grouped for each activity for each subject and the mean of these values is calculated

Final words

To improve readability, the tidy dataset is ordered by subject and activity

The final set consists of 180 rows and 88 columns (2 for subject and activity, 86 containing the averages).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages