Chapter 1 Chapter 1: Getting Acqainted with R

1.1 Using R as a giant calculator

Produce a sequence of numbers:

seq(from = 0,
    to = 10, 
    by = 1) #interval 
##  [1]  0  1  2  3  4  5  6  7  8  9 10

1.2 Your first script

Creating objects:

x<-seq(from = 0, to = 10, by =0.5)
x
##  [1]  0.0  0.5  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0
## [16]  7.5  8.0  8.5  9.0  9.5 10.0
y<-seq(from = 101, to = 110, by =0.5)

Add the objects together to create a new object:

z <- x + y  
## Warning in x + y: longer object length is not a multiple of shorter object
## length
z
##  [1] 101.0 102.0 103.0 104.0 105.0 106.0 107.0 108.0 109.0 110.0 111.0 112.0
## [13] 113.0 114.0 115.0 116.0 117.0 118.0 119.0 110.5 111.5

Print the session information:

sessionInfo()
## R version 4.1.1 (2021-08-10)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Monterey 12.4
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## loaded via a namespace (and not attached):
##  [1] bookdown_0.26   digest_0.6.29   R6_2.5.1        jsonlite_1.7.3 
##  [5] magrittr_2.0.3  evaluate_0.14   stringi_1.7.6   rlang_1.0.2    
##  [9] cli_3.2.0       rstudioapi_0.13 jquerylib_0.1.4 bslib_0.3.1    
## [13] rmarkdown_2.14  tools_4.1.1     stringr_1.4.0   xfun_0.31      
## [17] yaml_2.2.1      fastmap_1.1.0   compiler_4.1.1  htmltools_0.5.2
## [21] knitr_1.34      sass_0.4.0