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=2, ncol=3,byrow=FALSE, dimnames=headings)
m2
## a b c
## [1,] 1 3 5
## [2,] 2 4 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
## a b c
## [1,] 1 4 1
## [2,] 2 5 2
## [3,] 3 6 3
years <- (1980)
scores <- c(34, 44,83)
df <- data.frame(years, scores)
df[,1]
## [1] 1980 1980 1980
df$years
## [1] 1980 1980 1980
df$scores
## [1] 34 44 83
View(df)
vec <- c("A", "B", "C")
for (letter in vec) {
print(paste("The letter is", letter))
}
## [1] "The letter is A"
## [1] "The letter is B"
## [1] "The letter is C"
x <- 1
while (x <= 5) {
print(x)
x <- x + 1
}
## [1] 1
## [1] 2
## [1] 3
## [1] 4
## [1] 5
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.