Tuesday, September 23, 2014

R Statistical Software Basics - Descriptive Statistics - Input Data & Check Number of Data Observations - Head & Tail Functions

The practice sheet titled StatisticMarks Data.csv downloaded from Link. – Download Sheet


About the Data Sheet - The data in this sheet is related to marks scored by 100 Students in a Statistical Test. 

Based on the data, we will use R Software Statistical functions to analyze the descriptive statistics. 

In the Data Sheet, we have Data from A2:A101, A1 being the header of the Data.



Best Practice in R Software, Set the Working Directory, so that we can directly import & export Data files in R.
I have stored the StatisticMarks.csv file in Working Directory on my Desktop.

setwd("C:/Users/Rajesh Prabhakar/Desktop/R")

For inputting or reading Data from “StatisticMarks.csv” file, R Command would be

StatMarks=read.csv("StatisticMarks.csv")

I have named input variable name as StatMarks so that it will be easy for reading data into the statistical function formulas.

Click Ctrl R or Run or Ctrl plus Enter Tabs

Once You Click u will see the below blue color line R Console
> StatMarks=read.csv("StatisticMarks.csv")


To check all the Data Observations

StatMarks

Type StatMarks in R Console & Click Ctrl R or Run or Ctrl plus Enter Tabs

This function will list all the 100 observations in data set.

Head Function
head( )

This function returns the first six observations in Data

head(StatMarks)

Click Ctrl R or Run or Ctrl plus Enter Tabs


> head(StatMarks)
             StatisticsMarks
1             100
2             100
3              99
4              99
5              97
6              97

The first six observations in Data set are 100,100,99,99,97,97.


Tail Function
tail( )

This function returns the last six observations in Data

tail(StatMarks)

Click Ctrl R or Run or Ctrl plus Enter Tabs


> tail(StatMarks)
                        StatisticsMarks
95               49
96               45
97               44
98               35
99               30
100              25

The Last six observations in Data Set are 49,45,44,35,30,25.  

No comments:

Post a Comment