2025-07-24
~ your Home
.. one folder up
. current folder
.Rproj file stores project configuration
When you open this project next time, it tries to restore the work space from last time.
Project List in RStudio
store part of file path in a variable
combine it with file names by using file.path()
[1] "billionaires_combined.tsv"
[2] "DataGeographies-v2-by-Gapminder.xlsx"
[3] "ddf--gapminder--systema_globalis_files_from_GitHubAPI.json"
[4] "Founders_Network.csv"
[5] "gapminder_billionaires_ddf--entities--person.csv"
[6] "gapminder_countries.tsv"
[7] "gapminder_ddf--concepts.csv"
[8] "gapminder_ddf--datapoints--daily_income--by--person--time.csv"
[9] "gapminder_firstmarriage.csv"
[10] "gapminder_geonames.xlsx"
[11] "gapminder_hourly_labour_cost_constant_2017_ usd--by--geo--time.csv"
[12] "gapminder_hourly_labour_cost_constant_2017_usd--by--geo--time.csv"
[13] "gapminder_laborcost_cze_deu.csv"
[14] "gapminder_metadata_filenames.tsv"
[15] "GitHubURLs_Gapminder_SystemaGlobalis.tsv"
[16] "jrc_1.tsv"
[17] "jrc_2.tsv"
[18] "jrc_3.tsv"
[19] "jrc_4.tsv"
[20] "jrc_latin_4.tsv"
[21] "jrc_latin.tsv"
[22] "JRC_Names"
[23] "JRC_Names.tsv"
[24] "migrants.tsv"
[25] "titanic.csv"
library(glue) # enables multiline with \\
URL <- glue("https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/refs/heads/master/countries-etc-datapoints/ddf--datapoints--hourly_labour_cost_constant_2017_usd--by--geo--time.csv")
my_destination <- glue(file.path(project_path, datasaving_folder, "\\
gapminder_hourly_labour_cost_constant_2017_\\
usd--by--geo--time.csv"))tidyverseFile too big to open in a text editor?
Inspect it reading it as text lines (first 3 lines)
readrread_csv, read_csv2, read_tsv: tailored to the common separators ,, ;, tab
read_delim : you name the separator (aka delimiter), more arguments
read_csvURL2 <- glue("https://raw.githubusercontent.com/open-numbers/ddf--gapminder--\\
systema_globalis/refs/heads/master/countries-etc-datapoints/\\
ddf--datapoints--hourly_labour_cost_constant_2017_usd--by--geo--\\
time.csv")
read_csv(file = URL2,
n_max = 3)# A tibble: 3 × 3
geo time hourly_labour_cost_constant_2017_usd
<chr> <dbl> <dbl>
1 arg 2011 0.92
2 arg 2012 1.04
3 arm 2011 4.23
readxl reads only local file paths, not URLs.library(readxl)
read_xlsx(path = file.path(project_path, datasaving_folder, "gapminder_geonames.xlsx"),
n_max = 3) # just three rows# A tibble: 3 × 7
Data: Geographies — v…¹ ...2 ...3 Free data from www.g…² ...5 id version
<chr> <chr> <lgl> <chr> <lgl> <chr> <chr>
1 Updated: July 1, 2021 <NA> NA CC BY 4.0 LICENCE NA geo v2
2 Concept: Geog… NA Are you seeing this o… NA <NA> <NA>
3 Unit: <NA> NA gapm.io/datageo NA <NA> <NA>
# ℹ abbreviated names: ¹`Data: Geographies — v2`,
# ²`Free data from www.gapminder.org`
read_xlsx reads the first sheet by default[1] "ABOUT" "list-of-countries-etc" "list-of-regions"
[4] "list-of-income-levels" "global" "geo-names"
readxl::read_xlsx(path = file.path(project_path, datasaving_folder, "gapminder_geonames.xlsx"), sheet = 2,
n_max = 3) # or sheet = "list-of-countries-etc"# A tibble: 3 × 13
geo name four_regions eight_regions six_regions members_oecd_g77 Latitude
<chr> <chr> <chr> <chr> <chr> <chr> <dbl>
1 aus Austra… asia east_asia_pa… east_asia_… oecd -25
2 brn Brunei asia east_asia_pa… east_asia_… g77 4.5
3 khm Cambod… asia east_asia_pa… east_asia_… g77 13
# ℹ 6 more variables: Longitude <dbl>, `UN member since` <dttm>,
# `World bank region` <chr>, `World bank, 4 income groups 2017` <chr>,
# `World bank, 3 income groups 2017` <chr>, UNHCR <chr>
library(googlesheets4)
shURL <- glue("https://docs.google.com/spreadsheets/d/1qHalit8sXC\\
0R8oVXibc2wa2gY7bkwGzOybEMTWp-08o/edit?gid=425865495#gid=425865495")
gs4_deauth() # skip logging in at GoogleDrive
googlesheets4::read_sheet(shURL, sheet = 2,
n_max = 3)# A tibble: 3 × 13
geo name four_regions eight_regions six_regions members_oecd_g77 Latitude
<chr> <chr> <chr> <chr> <chr> <chr> <dbl>
1 aus Austra… asia east_asia_pa… east_asia_… oecd -25
2 brn Brunei asia east_asia_pa… east_asia_… g77 4.5
3 khm Cambod… asia east_asia_pa… east_asia_… g77 13
# ℹ 6 more variables: Longitude <dbl>, `UN member since` <dttm>,
# `World bank region` <chr>, `World bank, 4 income groups 2017` <chr>,
# `World bank, 3 income groups 2017` <chr>, UNHCR <chr>
list.files(path = project_path, recursive = FALSE,
include.dirs = FALSE, pattern = "qmd", full.names = TRUE)character(0)
list files in a folder
just those with qmd in their names
recursive: search in subfolders?