Example notebook.
library(pacman)
p_load(osfr, tidyverse)
#settings
#you need to set up a personal token
#good idea is to then place it somewhere safe for reuse
osf_auth(read_lines("~/.config/osf_token"))
## Registered PAT from the provided token
#the project we will use
osf_proj = osf_retrieve_node("https://osf.io/k7sj9/")
#list files
#should be empty to begin with
osf_ls_files(osf_proj)
## Warning in `[<-.data.frame`(`*tmp*`, is_list, value = list(`3` = "<>")):
## replacement element 1 has 1 row to replace 0 rows
#make some dirs for files
dir.create("data", showWarnings = F)
dir.create("figs", showWarnings = F)
#plot iris and save it to figs dir
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_count() +
theme_bw()
ggsave("figs/iris.png")
## Saving 7 x 5 in image
#save iris data to data dir
iris %>%
write_tsv("data/iris.tsv")
#upload all files in project
#overwrite existing (versioning)
osf_upload(osf_proj, path = list.files(), conflicts = "overwrite")
## Searching for conflicting files on OSF
## Uploading 6 new file(s) to OSF
#list files
osf_ls_files(osf_proj)