Show the code
getwd()
#> [1] "D:/.GitHub/RDataScience/R_data_science"
# setwd("My\\Path")
# setwd("My/Path") # Equivalent
getwd()
#> [1] "D:/.GitHub/RDataScience/R_data_science"
# setwd("My\\Path")
# setwd("My/Path") # Equivalent
x <- "Hello world"
save(x,file = "data/intro/mydata.RData")
load("data/intro/mydata.RData")
my_model <- lm(hwy~ displ, data = mpg)
saveRDS(my_model, file = "data/intro/my_model.rds")
readRDS("data/intro/my_model.rds")
#>
#> Call:
#> lm(formula = hwy ~ displ, data = mpg)
#>
#> Coefficients:
#> (Intercept) displ
#> 35.698 -3.531
# 新建
dir.create("data/file_create_ccccccccccccccc")
# 删除
unlink("data/file_create_ccccccccccccccc", recursive = TRUE)
# 列出文件夹里的文件
list.files(path = "data/",pattern = "\\.xlsx$", full.names = TRUE, recursive =T)
#> [1] "data/read_write/multi-sheet-iris_data.xlsx"
dir(path = "data/",pattern = "\\.xlsx$", full.names = TRUE, recursive =T) # Equivalent
#> [1] "data/read_write/multi-sheet-iris_data.xlsx"
file.create("data/create.R")
#> [1] TRUE
file.remove("data/create.R")
#> [1] TRUE
system.file("data",package = "MatrixEQTL")
#> [1] ""
file.path(system.file("data",package = "MatrixEQTL"),"exprsData.txt")
#> [1] "/exprsData.txt"
# 复制
# file.copy("my_file.R", "my_copied_file.R")
unzip("data/read_write/leadership.zip", exdir = "data/read_write/解压缩")
# CRAN
install.packages("package_name")
# R Forge
install.packages("MPAgenomics", repos = "http://R-Forge.R-project.org",
dependencies = TRUE)
# Bioconductor
install.packages("BiocManager")
BiocManager::install()
# 本地
install.packages("./GenomeInfoDbData_1.2.12.tar.gz", repos = NULL, type = "source")
install.packages("./GenomeInfoDbData_1.2.12.zip", repos = NULL, type = "binary")
# Github
remotes::install_github("tidyverse/ggplot2")
# 更新
update.packages(ask = FALSE)
remotes::update_packages()
# If FALSE, install the package
if (require("MASS")) install.packages("MASS")
(.packages())
#> [1] "stats" "graphics" "grDevices" "utils" "datasets"
#> [6] "writexl" "readxl" "lubridate" "forcats" "stringr"
#> [11] "dplyr" "purrr" "readr" "tidyr" "tibble"
#> [16] "ggplot2" "tidyverse" "conflicted" "showtext" "showtextdb"
#> [21] "sysfonts" "methods" "base"
sessionInfo()
#> R version 4.4.1 (2024-06-14 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 11 x64 (build 22631)
#>
#> Matrix products: default
#>
#>
#> locale:
#> [1] LC_COLLATE=Chinese (Simplified)_China.utf8
#> [2] LC_CTYPE=Chinese (Simplified)_China.utf8
#> [3] LC_MONETARY=Chinese (Simplified)_China.utf8
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=Chinese (Simplified)_China.utf8
#>
#> time zone: Asia/Shanghai
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] writexl_1.5.1 readxl_1.4.3 lubridate_1.9.3 forcats_1.0.0
#> [5] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5
#> [9] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0
#> [13] conflicted_1.2.0 showtext_0.9-7 showtextdb_3.0 sysfonts_0.8.9
#>
#> loaded via a namespace (and not attached):
#> [1] utf8_1.2.4 generics_0.1.3 stringi_1.8.4 hms_1.1.3
#> [5] digest_0.6.37 magrittr_2.0.3 evaluate_1.0.1 grid_4.4.1
#> [9] timechange_0.3.0 fastmap_1.2.0 jsonlite_1.8.9 cellranger_1.1.0
#> [13] fansi_1.0.6 scales_1.3.0 cli_3.6.3 rlang_1.1.4
#> [17] munsell_0.5.1 withr_3.0.2 cachem_1.1.0 tools_4.4.1
#> [21] tzdb_0.4.0 memoise_2.0.1 colorspace_2.1-1 vctrs_0.6.5
#> [25] R6_2.5.1 lifecycle_1.0.4 htmlwidgets_1.6.4 pkgconfig_2.0.3
#> [29] pillar_1.9.0 gtable_0.3.6 glue_1.8.0 xfun_0.49
#> [33] tidyselect_1.2.1 rstudioapi_0.17.1 knitr_1.48 htmltools_0.5.8.1
#> [37] rmarkdown_2.29 compiler_4.4.1
remove.packages("airway")
Sys.getenv()["HOMEPATH"]
#> HOMEPATH \Users\WANGANLIN
Sys.getenv()["LANGUAGE"]
#> LANGUAGE en
Sys.setenv(LANGUAGE = "en")