Created
September 26, 2025 08:04
-
-
Save thanhyds1998/2521e42972465cb8a81881f232469045 to your computer and use it in GitHub Desktop.
Basic setting up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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