Skip to content

Commit

Permalink
Update run_analysis.R
Browse files Browse the repository at this point in the history
  • Loading branch information
semenoffalex committed Apr 27, 2014
1 parent ef126fb commit d3bed03
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions run_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ names(Y) <- "activity"

# 4. Combining all the variables into one dataset
dataset <- cbind(subj, Y, X)
write.csv(dataset, "dataset.csv")
write.table(dataset, "dataset.txt")

# 5. Creating a 2nd tidy data set with the average of each variable for each activity and each subject.
library(reshape)
ids = c("SubjID", "ActID", "ActName")
melted <- melt(dataset, id.vars = c("subject", "activity"))
avg_dataset <- cast(subject + variable ~ activity, data = melted, fun=mean)
write.csv(avg_dataset, "avg_data.csv")
write.table(avg_dataset, "avg_data.txt")

0 comments on commit d3bed03

Please sign in to comment.