I have a question about how to handle R on MacOS.
I'm trying to select CSV data from the menu bar "Other → Change working directory", but it's grayed out and I can't select the data.
If anyone knows how to solve this problem, would it be possible to ask?
Sorry for the inconvenience, but I appreciate your cooperation.
Changing the working directory is literally a menu item to change the directory you are working on, so you cannot load CSV.
The result of entering getwd()
on the console is the directory you are currently working on, and this is the menu to change it.
CSV loading is
read.csv()
Use the function
It needs to be installed separately, but if you use software called RStudio instead of R.app, there is a menu to load CSV (File>Import Dataset>From CSV).
Instead of choosing the csv file directly under Change working directory, select the directory containing the csv file and load it in df<-read.csv("hogehoge.csv")
.
Incidentally, the change to the working directory is setwd("directory path")
in the command.
To add a little bit more, if the file is large and takes a long time to read, the read()
function in the data.table
package or the readr
or tidyverse
function will read much faster.
© 2024 OneMinuteCode. All rights reserved.