R Markdown

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. You can embed an R code chunk like this:

data<-c(1,2,3,4,5,6)
data
## [1] 1 2 3 4 5 6
VString<-c('a','b','c')
VString
## [1] "a" "b" "c"
headings<-list(NULL,c("a","b","c"))
headings
## [[1]]
## NULL
## 
## [[2]]
## [1] "a" "b" "c"
m <- matrix(data, nrow=2, ncol=3, byrow=TRUE, dimnames=headings)
m
##      a b c
## [1,] 1 2 3
## [2,] 4 5 6
m2<-matrix(data,nrow=3,ncol=2,byrow=TRUE)
m2
##      [,1] [,2]
## [1,]    1    2
## [2,]    3    4
## [3,]    5    6
m3 <- matrix(data, nrow=3, ncol=3, byrow=FALSE, dimnames=headings)
## Warning in matrix(data, nrow = 3, ncol = 3, byrow = FALSE, dimnames =
## headings): data length differs from size of matrix: [6 != 3 x 3]
m3[1,]
## a b c 
## 1 4 1
m3[,2]
## [1] 4 5 6
m3[3,2]
## b 
## 6
a <- list(aa=1, bb=2, cc=3)
a
## $aa
## [1] 1
## 
## $bb
## [1] 2
## 
## $cc
## [1] 3
a$aa
## [1] 1
years <- c(1980,1985,1990)
scores <- c(34,44,83)
df <- data.frame(years,scores)
df[,1]
## [1] 1980 1985 1990
df$years
## [1] 1980 1985 1990
df$scores
## [1] 34 44 83
View(df)

Including Plots

a<-66
if(a>55){print('a is more than 55')}else{print('a is less than or equal to 55')}
## [1] "a is more than 55"
mylist <- c(55, 66, 77, 88, 99)
for (value in mylist) {
print(value)
}
## [1] 55
## [1] 66
## [1] 77
## [1] 88
## [1] 99
a <- 100
while (a < 500) {
a <- a + 100
print(a)
}
## [1] 200
## [1] 300
## [1] 400
## [1] 500
a
## [1] 500

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.