Skip to content

Commit fa498ef

Browse files
committed
Add a new print version
1 parent 28e3af0 commit fa498ef

127 files changed

Lines changed: 1487 additions & 19339 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rprofile

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Set session ID -----
2+
3+
session_id <- Sys.time() |> as.character()
4+
15
# Load functions -----
26

37
single_quote <- function(x) paste0("'", x, "'")
@@ -64,13 +68,34 @@ require_pkg <- function(...) {
6468
invisible()
6569
}
6670

67-
rprofile_message <- function(x, id) {
68-
if (Sys.getenv(paste0("RPROFILE_MESSAGE_", id)) == "") {
71+
rprofile_cat_line <- function(session_id, env_var = "RPROFILE_MESSAGES") {
72+
if (Sys.getenv(env_var) == session_id) cat("\n")
73+
74+
invisible()
75+
}
76+
77+
rprofile_message <- function(
78+
x,
79+
session_id,
80+
env_var = "RPROFILE_MESSAGES",
81+
cat_line = TRUE,
82+
info = FALSE
83+
) {
84+
if (Sys.getenv(env_var) %in% c("", session_id)) {
6985
do.call(
7086
what = Sys.setenv,
71-
args = list(TRUE) |> magrittr::set_names(paste0("RPROFILE_MESSAGE_", id))
87+
args =
88+
list(session_id) |>
89+
magrittr::set_names(env_var)
7290
)
73-
cli::cli_alert(x, wrap = TRUE)
91+
92+
if (isTRUE(info)) {
93+
cli::cli_alert_info(x, wrap = TRUE)
94+
} else {
95+
cli::cli_alert(x, wrap = TRUE)
96+
}
97+
98+
if (isTRUE(cat_line)) cat("\n")
7499
}
75100

76101
invisible()
@@ -85,13 +110,21 @@ require_pkg(c("cli", "here" ,"magrittr", "ragg", "renv", "stats", "stringr"))
85110
library(magrittr)
86111
library(ragg)
87112

113+
# Show session message -----
114+
115+
rprofile_message(
116+
x = "The messages below are shown only once per R session.",
117+
session_id = session_id,
118+
info = TRUE
119+
)
120+
88121
# Activate `renv` -----
89122

90-
rprofile_message("`renv` activation settings:", 1)
123+
rprofile_message("`renv` activation settings:", session_id)
91124

92125
source(here::here("renv", "activate.R"))
93126

94-
cat("\n")
127+
rprofile_cat_line(session_id)
95128

96129
# Set options -----
97130

@@ -102,24 +135,22 @@ options(scipen = 999)
102135
rprofile_message(
103136
paste0(
104137
"If you haven't already set it, configure {.strong AGG} ",
105-
"as the RStudio graphic device backend. Learn more in ",
138+
"as the RStudio graphic device backend. Learn more at ",
106139
"<https://ragg.r-lib.org/#use-ragg-in-rstudio>."
107140
),
108-
2
141+
session_id
109142
)
110143

111-
cat("\n")
112-
113144
# Set system locale -----
114145

115146
source(here::here("R", "set_locale.R"))
116147

117-
set_locale()
148+
set_locale(session_id)
118149

119-
# Clean the global environment -----
150+
# End line -----
120151

121-
rm(list = ls())
152+
rprofile_cat_line(session_id = session_id, env_var = "SET_LOCALE_MESSAGES")
122153

123-
# .Rprofile end -----
154+
# Clean the global environment -----
124155

125-
cat("\n")
156+
rm(list = ls())

R/_post-render-gfm.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ groomr::remove_blank_line_dups(here::here("README.md"))
1010

1111
# Update project year -----
1212

13-
files <- here::here("LICENSE.md")
13+
files <- c(
14+
here::here("CITATION.cff"),
15+
here::here("LICENSE.md")
16+
)
1417

1518
for (i in files) {
1619
data <-

R/_pre-render-pdf.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ swap_list <- list(
105105
end_tag = "%:::% foreign-abstract keywords end %:::%",
106106
value = NULL,
107107
quarto_render = FALSE
108+
),
109+
other_in_header = list(
110+
from = here::here("qmd", "_config.qmd"),
111+
to = here::here("tex", "include-in-header.tex"),
112+
begin_tag = "%:::% other-in-header begin %:::%",
113+
end_tag = "%:::% other-in-header end %:::%",
114+
value = NULL,
115+
quarto_render = FALSE
116+
),
117+
other_before_body = list(
118+
from = here::here("qmd", "_config.qmd"),
119+
to = here::here("tex", "include-before-body.tex"),
120+
begin_tag = "%:::% other-before-body begin %:::%",
121+
end_tag = "%:::% other-before-body end %:::%",
122+
value = NULL,
123+
quarto_render = FALSE
124+
),
125+
other_after_body = list(
126+
from = here::here("qmd", "_config.qmd"),
127+
to = here::here("tex", "include-after-body.tex"),
128+
begin_tag = "%:::% other-after-body begin %:::%",
129+
end_tag = "%:::% other-after-body end %:::%",
130+
value = NULL,
131+
quarto_render = FALSE
108132
)
109133
)
110134

R/_setup.R

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ options(
3030
pillar.max_footer_lines = 2,
3131
pillar.min_chars = 15,
3232
scipen = 10,
33-
digits = 5,
33+
digits = 10,
3434
stringr.view_n = 6,
3535
pillar.bold = TRUE,
3636
width = 77 # 80 - 3 for #> comment
@@ -83,29 +83,19 @@ sysfonts::font_paths(
8383
c(
8484
here::here("otf"),
8585
here::here("ttf"),
86+
here::here("_extensions", "abnt", "otf"),
8687
here::here("_extensions", "abnt", "ttf")
8788
)
8889
)
8990

90-
if (env_vars$format == "pdf") {
91-
sysfonts::font_add(
92-
family = "helvetica-neue",
93-
regular = here::here("otf", "helveticaneueltstd-roman.otf"),
94-
bold = here::here("otf", "helveticaneueltstd-bd.otf"),
95-
italic = here::here("otf", "helveticaneueltstd-it.otf"),
96-
bolditalic = here::here("otf", "helveticaneueltstd-bdit.otf"),
97-
symbol = NULL
98-
)
99-
} else {
100-
sysfonts::font_add(
101-
family = "dm-sans",
102-
regular = here::here("ttf", "dmsans-regular.ttf"),
103-
bold = here::here("ttf", "dmsans-bold.ttf"),
104-
italic = here::here("ttf", "dmsans-italic.ttf"),
105-
bolditalic = here::here("ttf", "dmsans-bolditalic.ttf"),
106-
symbol = NULL
107-
)
108-
}
91+
sysfonts::font_add(
92+
family = "dm-sans",
93+
regular = here::here("ttf", "dmsans-regular.ttf"),
94+
bold = here::here("ttf", "dmsans-bold.ttf"),
95+
italic = here::here("ttf", "dmsans-italic.ttf"),
96+
bolditalic = here::here("ttf", "dmsans-bolditalic.ttf"),
97+
symbol = NULL
98+
)
10999

110100
showtext::showtext_auto()
111101

@@ -120,11 +110,7 @@ ggplot2::theme_set(
120110
ggplot2::theme(
121111
text = ggplot2::element_text(
122112
color = get_brand_color("secondary"),
123-
family = ifelse(
124-
env_vars$format == "pdf",
125-
"helvetica-neue",
126-
"dm-sans"
127-
),
113+
family = "dm-sans",
128114
face = "plain"
129115
),
130116
panel.background = ggplot2::element_rect(fill = "transparent"),

R/set_locale.R

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# library(stats)
1212
# library(stringr)
1313

14-
set_locale <- function() {
14+
set_locale <- function(session_id = Sys.time() |> as.character()) {
1515
locale_values <- c(
1616
"en_US.utf8", "en_US.UTF-8", "en_US", "en-US", "en", "English_United States"
1717
)
@@ -68,30 +68,17 @@ set_locale <- function() {
6868
}
6969

7070
if (Sys.getenv("SET_LOCALE_MESSAGES") == "") {
71-
Sys.setenv(SET_LOCALE_MESSAGES = TRUE)
71+
Sys.setenv(SET_LOCALE_MESSAGES = session_id)
7272

73-
get_locale(periodic_message = TRUE)
73+
get_locale()
7474
}
7575

7676
invisible()
7777
}
7878

7979
# library(cli)
8080

81-
get_locale <- function(periodic_message = FALSE) {
82-
prettycheck:::assert_flag(periodic_message)
83-
84-
if (isTRUE(periodic_message)) {
85-
cli::cli_alert_info(
86-
paste0(
87-
"The messages below are shown only once per R session."
88-
),
89-
wrap = TRUE
90-
)
91-
}
92-
93-
cat("\n")
94-
81+
get_locale <- function() {
9582
cli::cli_alert(
9683
paste0(
9784
"The current system locale is:\n\n",

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ write_in_results_yml <- function(
104104

105105
for (i in seq_along(x)) {
106106
if (is.numeric(x[[i]])) {
107-
x[[i]] <- x[[i]] |> signif(10)
107+
x[[i]] <- x[[i]] |> signif(digits)
108108
}
109109

110110
if (names(x)[i] %in% names(out)) {

README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
2-
31
# mastersthesis
42

53
<!-- quarto render --profile gfm -->
64

75
<!-- badges: start -->
8-
96
[![Project Status: Active – The project has reached a stable, usable
107
state and is being actively
118
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
@@ -45,30 +42,31 @@ It’s important to note that some restrictions apply to the availability
4542
of the main research data, which contain personal and sensitive
4643
information. As a result, this data cannot be publicly shared. To run
4744
the analyses, users must have an internet connection and request a set
48-
of access keys from the author (see the keys section below).
45+
of access keys from the author (see *Keys* section).
46+
47+
If you don’t feel comfortable with R, I strongly recommend checking
48+
Hadley Wickham and Garrett Grolemund’s free and online book [R for Data
49+
Science](https://r4ds.hadley.nz/) and the Coursera course from John
50+
Hopkins University [Data Science: Foundations using
51+
R](https://www.coursera.org/specializations/data-science-foundations-r).
4952

5053
To reproduce the analyses do the following steps:
5154

5255
1. Make sure that you have the latest R version and the following R
5356
packages installed in your machine:
54-
`install.packages(c("cli", "here", "magrittr", "renv", "stats", "stringr"))`.
57+
`install.packages(c("cli", "here" ,"magrittr", "ragg", "renv", "stats", "stringr"))`.
5558
2. Clone this repository.
5659
3. Open the R project (`mastersthesis.Rproj`).
5760
4. Run
5861
[`renv::restore()`](https://rstudio.github.io/renv//reference/restore.html)
5962
to install all software dependencies.
6063
5. Set all the keys provided by the author in the `.Renviron` file and
6164
the `_ssh` folder.
62-
6. Run `targets::tar_make()` to create and get every point of the data
63-
wrangling process (from the raw_data to the cleaned and weighted
65+
6. Run `targets::tar_make()` to create every point of the data
66+
wrangling process (from the raw data to the cleaned and weighted
6467
data).
65-
7. Open and run any analysis present in the computational notebooks.
66-
67-
If you don’t feel comfortable with R, I strongly recommend checking
68-
Hadley Wickham and Garrett Grolemund’s free and online book [R for Data
69-
Science](https://r4ds.hadley.nz/) and the Coursera course from John
70-
Hopkins University [Data Science: Foundations using
71-
R](https://www.coursera.org/specializations/data-science-foundations-r).
68+
7. Run any analysis present in the computational notebooks (`qmd`
69+
directory).
7270

7371
## Keys
7472

@@ -114,28 +112,29 @@ available due to privacy and ethical considerations.
114112

115113
To cite this work, please use the following format:
116114

117-
Vartanian, D. (2024). *Is latitude associated with chronotype?*
118-
\[Master’s thesis, University of São Paulo\].
115+
Vartanian, D. (2025). *Is latitude associated with chronotype?*
116+
\[Master’s Thesis, University of São Paulo\].
119117
<https://doi.org/10.17605/OSF.IO/YGKTS>
120118

121119
A BibTeX entry for LaTeX users is:
122120

123-
@mastersthesis{vartanian2024,
121+
@mastersthesis{vartanian2025,
124122
title = {Is latitude associated with chronotype?},
125123
author = {Daniel Vartanian},
126124
year = {2025},
127125
address = {São Paulo},
128126
school = {University of São Paulo},
129127
langid = {en},
130128
url = {https://doi.org/10.17605/OSF.IO/YGKTS},
131-
note = {Original version}
129+
note = {Corrected version}
132130
}
133131

134132
## Acknowledgments
135133

136134
The thesis was developed in the Graduate Program in Modeling Complex
137-
Systems ([PPG-SCX](https://sites.usp.br/scx/en/apresentacao/)) at the
138-
University of São Paulo ([USP](https://www5.usp.br/)), under the
135+
Systems
136+
([PPG-SCX](https://www.prpg.usp.br/pt-br/faca-pos-na-usp/programas-de-pos-graduacao/621-modelagem-de-sistemas-complexos))
137+
at the University of São Paulo ([USP](https://www5.usp.br/)), under the
139138
supervision of [Prof. Dr. Camilo Rodrigues
140139
Neto](https://orcid.org/0000-0001-6783-6695).
141140

0 commit comments

Comments
 (0)