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:

convMeters <- function(val, to="inch") {
  mult <- switch(to, 
                 inch = 39.3701, 
                 foot = 3.28084, 
                 yard = 1.09361, 
                 mile = 0.000621371, 
                 cm = 100,
                 NA)
  
  if (is.na(mult)) 
    stop("Unknown target unit of length.") 
  else 
    return(val * mult)
}
print(convMeters(23, "foot"))  
## [1] 75.45932
Inches <- convMeters(40, "inch")  
print(Inches)
## [1] 1574.804
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"

Including Plots

You can also embed plots, for example:

x<-rnorm(50)
x
##  [1] -0.29527120  0.24455195 -2.05787074  0.27250423 -0.02071186 -1.21482161
##  [7]  0.55487484 -1.51844594 -0.22567576 -0.46919945  0.51454520  0.36590156
## [13]  1.05251278 -2.42966393 -0.01061552 -0.89454894  0.92959338 -2.00081561
## [19]  0.37423520 -1.56918444 -0.09350371 -0.09572722 -1.83412356 -1.23703300
## [25]  0.54685654 -1.65452659 -0.15172427  0.77264375 -0.38317014  1.61377376
## [31] -0.76334443  0.31730762  0.85280384  1.28196212 -0.56343672 -0.17812220
## [37]  0.51164430 -0.23529032  0.45065923 -0.40506342  0.38705872 -0.72156747
## [43] -0.23567499 -2.09975395 -0.22263702 -0.10368541 -0.59357377 -0.37023088
## [49]  0.84053124  0.64702680
y= mean(x)
y
## [1] -0.2423605
x<- rnorm(50)
y<-x+rnorm(50, mean=50, sd=.1)
cor(x,y)
## [1] 0.9966584
x2<-rnorm(50, mean=50, sd=.1)
x2
##  [1] 49.95373 49.94775 50.08783 49.93710 50.16785 50.06999 50.11721 50.06170
##  [9] 49.94493 49.99469 50.13250 50.01144 50.12387 49.93092 50.23977 49.87274
## [17] 50.08460 50.13450 50.00252 49.94264 50.09432 50.16435 50.00921 50.05676
## [25] 50.00221 49.98606 49.82860 49.91836 49.92788 49.83462 49.98706 49.93300
## [33] 50.08829 49.87427 50.09168 49.98795 50.11547 49.96675 50.29870 50.04136
## [41] 50.07788 50.01330 49.92909 49.92486 50.09165 50.04853 50.08009 50.11976
## [49] 49.97576 50.20162
x<-rnorm(50)
x
##  [1]  3.01147134 -0.25195904 -1.43876569  0.64179600  0.53875966 -2.52844863
##  [7]  0.38617835 -0.65703587  1.00873781  1.04743747  0.56358019  0.34104743
## [13]  0.91351350  1.46119461  0.08571735  1.21876104 -0.53664747  1.27191040
## [19] -1.61092413  1.17379072 -0.19965549  0.62720489 -0.14852495 -1.82905238
## [25] -2.64777758 -0.50313958  0.50404596  1.07827829  2.32879116 -0.53014438
## [31] -0.49034579  1.43055302 -0.03007389 -0.11207072 -0.18395719 -0.85433247
## [37] -0.38430336  0.08725854 -0.29998532 -0.52554909 -0.85018198 -0.15841592
## [43] -2.74550863  0.94727303  0.60159316 -0.73197933 -0.60721812  1.55858773
## [49] -0.28426111 -1.72673559
y= mean(x)
y
## [1] -0.0007902404
x<- rnorm(50)
y<-x+rnorm(50, mean=50, sd=.1)
cor(x,y)
## [1] 0.9979435
x2<-rnorm(50, mean=50, sd=.1)
x2
##  [1] 49.94663 49.98423 49.92821 50.03599 50.16415 50.09027 49.90381 50.11016
##  [9] 49.96760 49.93330 50.10808 50.19238 49.96237 50.04710 50.16118 50.05391
## [17] 49.94471 50.10409 50.13551 49.95232 50.07718 50.01864 49.95168 49.87658
## [25] 49.86239 50.07478 50.03907 49.86102 50.18585 49.83656 49.98452 50.10533
## [33] 49.83542 49.96849 50.09300 49.95626 50.00451 49.88217 50.05968 50.07792
## [41] 50.00329 50.06860 50.09602 49.93697 50.17746 49.96470 50.01733 49.98083
## [49] 50.06559 49.94164

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