Skip to content

Instantly share code, notes, and snippets.

@thanhyds1998
Created September 26, 2025 08:04
Show Gist options
  • Save thanhyds1998/2521e42972465cb8a81881f232469045 to your computer and use it in GitHub Desktop.
Save thanhyds1998/2521e42972465cb8a81881f232469045 to your computer and use it in GitHub Desktop.
Basic setting up
#1. Check Current Working Directory
getwd()
###########################
#2. Set Working Directory
setwd("C:/Users/YourName/Documents/Project")
############################
#3. Use RStudio Menu
## Session → Set Working Directory → Choose Directory…
############################
#4. Use here Package (Project-Oriented)
install.packages("here")
library(here)
#### Automatically finds the project root (where .Rproj or .git exists)
here() # returns the root path
read.csv(here("data", "file.csv"))
#5. Use file.choose() for Interactive Selection
file_path <- file.choose() # Opens a dialog to pick a file
df <- read.csv(file_path)
#6. Use relative paths
df <- read.csv(file.path("data", "myfile.csv"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment