-
Notifications
You must be signed in to change notification settings - Fork 1
/
01_intro_rstudio.R
151 lines (118 loc) · 5.24 KB
/
01_intro_rstudio.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
## ----install_rsthemes, eval = FALSE----------------------------------------------------------------------
## remotes::install_github(c(
## "gadenbuie/rsthemes"
## ))
## remotes::install_cran("suncalc")
## rsthemes::install_rsthemes(include_base16 = TRUE)
## ----r_profile, eval = FALSE-----------------------------------------------------------------------------
## usethis::edit_r_profile()
##
## ## From https://www.garrickadenbuie.com/project/rsthemes/
## if (interactive() && requireNamespace("rsthemes", quietly = TRUE)) {
## # Set preferred themes if not handled elsewhere..
## rsthemes::set_theme_light("Solarized Light {rsthemes}") # light theme
## rsthemes::set_theme_dark("base16 Monokai {rsthemes}") # dark theme
## rsthemes::set_theme_favorite(c(
## "Solarized Light {rsthemes}",
## "base16 Monokai {rsthemes}",
## "One Dark {rsthemes}"
## ))
##
## # Whenever the R session restarts inside RStudio...
## setHook("rstudio.sessionInit", function(isNewSession) {
## # Automatically choose the correct theme based on time of day
## ## Used rsthemes::geolocate() once
## rsthemes::use_theme_auto(lat = 39.2891, lon = -76.5583)
## }, action = "append")
## }
##
## ## https://blog.rstudio.com/2013/06/10/rstudio-cran-mirror/
## options(repos = c(CRAN = "https://cloud.r-project.org"))
## ----proj, eval = FALSE----------------------------------------------------------------------------------
## usethis::create_project("~/rnaseq_2022_notas")
## ----create_setup, eval = FALSE--------------------------------------------------------------------------
## ## Start a setup file
## usethis::use_r("01-notas.R")
## ----create_01-visualizar-mtcars, eval = FALSE-----------------------------------------------------------
## ## Creemos el archivo R/02-visualizar-mtcars.R
## usethis::use_r("02-visualizar-mtcars.R")
## ----vis_mtcars, eval = FALSE----------------------------------------------------------------------------
## library("sessioninfo")
## library("here")
## library("ggplot2")
##
## ## Hello world
## print("Soy Leo")
##
## ## Directorios
## dir_plots <- here::here("figuras")
## dir_rdata <- here::here("processed-data")
##
## ## Crear directorio para las figuras y archivos
## dir.create(dir_plots, showWarnings = FALSE)
## dir.create(dir_rdata, showWarnings = FALSE)
##
## ## Hacer una imagen de ejemplo
## pdf(file.path(dir_plots, "mtcars_gear_vs_mpg.pdf"),
## useDingbats = FALSE
## )
## ggplot(mtcars, aes(group = gear, y = mpg)) +
## geom_boxplot()
## dev.off()
##
## ## Para reproducir mi código
## options(width = 120)
## sessioninfo::session_info()
## ----use_git_init, eval = FALSE--------------------------------------------------------------------------
## ## Para poder conectar tu compu con GitHub
## usethis::create_github_token() ## Abrirá una página web, escoje un nombre único
## ## y luego da click en el botón verde al final. Después copia el token
## ## (son 40 caracteres)
## ----gitcreds_set, eval = FALSE--------------------------------------------------------------------------
## gitcreds::gitcreds_set() ## Ojo, copia el token, no tu password de git!
## ## Si no, terminaras en la situación descrita en
## ## https://github.com/r-lib/usethis/issues/1347
## ----edit_r_envir, eval = FALSE--------------------------------------------------------------------------
## usethis::edit_r_environ()
## ----use_git_cont_parte1, eval = FALSE-------------------------------------------------------------------
## ## Configura tu usuario de GitHub
## usethis::edit_git_config()
## ----use_git_cont_parte2, eval = FALSE-------------------------------------------------------------------
## ## Para inicializar el repositorio de Git
## usethis::use_git()
##
## ## Para conectar tu repositorio local de Git con los servidores de GitHub
## usethis::use_github()
## git clone https://github.com/lcolladotor/rnaseq_LCG-UNAM_2022.git
##
## ## Si tienen su SSH key configurarda pueden usar
## ## Info sobre SSH keys de GitHub:
## ## https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
## git clone [email protected]:lcolladotor/rnaseq_LCG-UNAM_2022.git
## ----clone_repo, eval = FALSE----------------------------------------------------------------------------
## ## Opción más nueva:
## library("gert")
## repo <- git_clone(
## "https://github.com/lcolladotor/rnaseq_LCG-UNAM_2022",
## "~/rnaseq_LCG-UNAM_2022"
## )
## setwd(repo)
##
## ## Otra opción:
## git2r::clone(
## "https://github.com/lcolladotor/rnaseq_LCG-UNAM_2022",
## "~/rnaseq_LCG-UNAM_2022"
## )
## ----postcards_proj, eval = FALSE------------------------------------------------------------------------
## ## Creen el RStudio project
## usethis::create_project("Su_Usuario.github.io")
##
## ## Configura Git y GitHub
## usethis::use_git()
## usethis::use_github()
## ----postcards_create, eval = FALSE----------------------------------------------------------------------
## ## Solo uno de estos, de acurdo al templado que más les gustó
## postcards::create_postcard(template = "jolla")
## postcards::create_postcard(template = "jolla-blue")
## postcards::create_postcard(template = "trestles")
## postcards::create_postcard(template = "onofre")