This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
We will be using our housing_data example to produce this report.
You can embed an R code chunk like this:
url<-"https://data.gov.in/sites/default/files/datafile/housing_price_index_2010-11_100.csv"
download.file(url,destfile = "housing_data.csv",method = "curl")
housing_data <- read.csv("housing_data.csv")
head(housing_data)
## Particulars X06.2011 X09.2011 X12.2011 X03.2012 X06.2012 X09.2012
## 1 All India 116.0 119.4 125.5 134.1 142.6 147.1
## 2 Ahmedabad 121.3 130.4 137.1 141.0 140.8 146.4
## 3 Bangalore 110.7 107.8 138.6 133.3 133.3 136.6
## 4 Chennai 101.2 110.4 110.7 108.2 119.2 117.8
## 5 Delhi 126.8 124.8 136.7 158.2 177.3 183.2
## 6 Kolkata 103.0 105.0 103.2 106.1 135.2 149.1
## X12.2012 X03.2013 X06.2013 X09.2013
## 1 157.0 160.8 162.3 169.2
## 2 150.6 155.0 161.9 171.7
## 3 141.2 141.9 142.3 150.4
## 4 137.6 137.4 138.3 150.0
## 5 200.7 213.1 214.8 215.7
## 6 162.5 169.4 171.8 173.5
We have also learnt to use read.table() function to read data
housing_data_2<-read.table("housing_data.csv", header = TRUE, sep = ",")
Then we manipulated data a little bit
housing_data_2012 <- housing_data[,c(1,5:11)]
col_names<-housing_data_2012$Particulars
row_names<-colnames(housing_data_2012)
housing_data_transpose <- as.data.frame(t(housing_data_2012[,-1]),row.names = F)
colnames(housing_data_transpose) <- col_names
housing_data_transpose$quarter<-row_names[-1]
housing_data_transpose<-housing_data_transpose[,c(8,1:7)]
#Finding number of occurrences with Housing Index more than 150
housing_data_transpose$count_150<-apply(housing_data_transpose,MARGIN=1,FUN=function(x) length(which(x[c(-1,-2)]>150)))
Plots are beautiful and easy to visualize or communicate through data
#Box Plot
boxplot(housing_data_2012[-1])