Pages

Tuesday, October 1, 2013

Basics of R

The two packages in R required for descriptive Statistics :
First we need to install  the following packages and then load them in R
install.packages("psych")
install.packages("sm")

Reading a text file in R:
Text <- read.table("file.txt",header = T)
Make sure you read the data with the argument: header=TRUE .R does not read the 1st line and continues reading from the second line

Command to find no of rows in  a data file :
nrow(data) OR dim(data)

Output :-

> dim(Text)
[1] 96  4

> nrow(Text)

[1] 96

Subsetting a dataset :

Command :-
New <- subset(impact,impact[ ,3]== "updated")

Here we are subsetting on the variables of the 3rd column  into New dataset  . we are only selecting the variables og the 3rd column which has an  value "post"


To obtain a descriptive statistic of a dataset :

Suppose we have a dataset named "impact". The describe function gives us the  all possible statistic of all variable of that dataset



what is the utility of  describeBy function in R ?
DescribeBy function gives you the summary statistic by categorical variable of a defined column

No comments:

Post a Comment