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:
z<-c(723,15,1234,-10,99983)
z[3:3]
## [1] 1234
z[3:4]
## [1] 1234 -10
z[c(3,4,5)]
## [1] 1234 -10 99983
x<-4.5678
class(x)
## [1] "numeric"
x<-as.integer(x)
x<-6.87
x<-as.numeric(x)
x<-as.character(x)
class(x)
## [1] "character"
#Create a vector
##Numeric vector
x<-5.6
class(x)
## [1] "numeric"
y<-c(3,4,6,7,8)
y
## [1] 3 4 6 7 8
class(y)
## [1] "numeric"
z<-c(3.4, 7.8, 6.7, 7, 9)
z
## [1] 3.4 7.8 6.7 7.0 9.0
class(z)
## [1] "numeric"
name<-c("Tom","Harry", "Swan")
class(name)
## [1] "character"
name
## [1] "Tom" "Harry" "Swan"
z[2:4] #consecutive
## [1] 7.8 6.7 7.0
z[c(1,3,5)] #Square brackets are always used for slicing
## [1] 3.4 6.7 9.0
z<-c(2,3,6,9,10,14)
plot(z)
plot(z[2: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.