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:
## 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] jquerylib_0.1.4 pillar_1.7.0 compiler_4.1.1 bslib_0.3.1
## [5] tools_4.1.1 downlit_0.4.0 digest_0.6.29 memoise_2.0.1
## [9] jsonlite_1.7.3 evaluate_0.15 lifecycle_1.0.1 tibble_3.1.6
## [13] gtable_0.3.0 pkgconfig_2.0.3 rlang_1.0.2 DBI_1.1.2
## [17] cli_3.2.0 rstudioapi_0.13 yaml_2.2.1 xfun_0.31
## [21] fastmap_1.1.0 stringr_1.4.0 xml2_1.3.3 dplyr_1.0.9
## [25] knitr_1.39 fs_1.5.2 generics_0.1.2 vctrs_0.4.1
## [29] sass_0.4.0 grid_4.1.1 tidyselect_1.1.2 glue_1.6.1
## [33] R6_2.5.1 fansi_1.0.2 rmarkdown_2.14 bookdown_0.27
## [37] ggplot2_3.3.6 purrr_0.3.4 magrittr_2.0.3 scales_1.1.1
## [41] ellipsis_0.3.2 htmltools_0.5.2 assertthat_0.2.1 colorspace_2.0-3
## [45] utf8_1.2.2 stringi_1.7.6 munsell_0.5.0 cachem_1.0.6
## [49] crayon_1.5.0