Code Monkey home page Code Monkey logo

course_project's Introduction

title author date output
README
Vaibhav
Monday, August 25, 2014
html_document
y_test<-read.table("UCI HAR Dataset/test/y_test.txt")
subject_test<-read.table("UCI HAR Dataset/test/subject_test.txt")
subject_train<-read.table("UCI HAR Dataset/train/subject_train.txt")
y_train<-read.table("UCI HAR Dataset/train/y_train.txt")
X_train<-read.table("UCI HAR Dataset/train/X_train.txt")
features<-read.table("UCI HAR Dataset/features.txt")
activity_labels<-read.table("UCI HAR Dataset/activity_labels.txt")

The above code chunk reads all the relevant files from the home directory and assigns them to corresponding objects

Y<-rbind(y_train,y_test)

The training and testng datasets are merged together using the rbind() function

activity<-data.frame(activity$V2)

The activity labels are merged with the activity values

names(X)<-c(feature_name)
names(activity)<-"Activity"
Subject<-rbind(subject_train,subject_test)
names(Subject)<-"Subject"

The column names for Subject, Activity and Features are added here

Dat1<-cbind(X,Subject,activity)

The activity , subject and X,Y datasets are merged together to form a data frame Dat1

Dat2<-cbind(activity,Subject,Dat2)

The columns corresponding to mean() and std() values are extracted and stored in Dat2.

Dat3<-data.frame()
for(i in 1:6)
{
        
        for(j in 1:30)
        {
                Dat3<-Dat2[which(Dat2$Activity==activity_labels[i,2] & Dat2$Subject==j),]
                Final_Dat<-rbind(Final_Dat,colMeans(Dat3[,-1]))
        }
}
a<-rep(c("WALKING","WALKING_UPSTAIRS","WALKING_DOWNSTAIRS","SITTING","STANDING","LAYING"),each=30)
b<-rep(1:30,6)
Final_Dat<-cbind(a,b,Final_Dat)
Final_Dat<-Final_Dat[,-3]
names(Final_Dat)<-names(Dat2)
Final_Dat<-Final_Dat[complete.cases(Final_Dat),]

for loops are used for creating the final data frame that contains the average of each column for each actiivity and each subject value

course_project's People

Contributors

vaibhav6215 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.