R code that uses the "osfr" package to interact with the Open Science Framework (OSF) and upload files to a project on OSF. This code is used to authenticate with OSF, retrieve a project node, and upload files to it.
-
Loading the
"osfr"
Library: The code starts by loading the "osfr" library, which is used for interacting with the OSF. -
Authentication: You need to provide a Personal Access Token (PAT) from your OSF account. You can generate this token in your OSF account settings. The token is then used to authenticate your R session with OSF using the
osf_auth()
function. -
Project Identifier (GUID): You specify the Global Unique Identifier (GUID) of the OSF project you want to interact with. This is the project where you will upload files.
-
Retrieve Project Node: The
osf_retrieve_node()
function is used to retrieve the project node based on its GUID. This sets the context for the subsequent operations. -
OSF Upload: The
osf_upload()
function is used to upload files to the specified project node. It takes parameters such as the node (project node), the local file path you want to upload, options for recursion into subfolders, and whether to display a progress bar during the upload. -
node: The project node you retrieved earlier.
"filepath/to/local/machine"
: Replace this with the actual file path on your local machine.recurse = TRUE
: This option allows you to upload files recursively, including files in subfolders.progress = TRUE
: This option shows a progress bar during the upload. The comments in the code provide additional information and usage instructions.
Remember to replace "Paste your PAT here" and "xxxxx" with your actual PAT and project GUID.
Make sure you have the "osfr" package installed in your R environment to run this code successfully. You can install it using install.packages("osfr")
if you haven't already.