How to Import XLSX & CSV Files into RStudio
Updated: Oct 13
RStudio is an integrated development environment for R, a programming language for statistical computing and graphics.
In this blog, we go over importing xlsx and csv files into RStudio. Not all files are the same. Which means they get imported differently with different functions. The key takeaway here is making sure the directory is the same in order to find the files.
Here's an example for further understanding. We have created hypothetical test scores in xlsx and csv files (both contain the same data). They are both in the same folder location.
Steps to Rename Columns in RStudio
In RStudio, make sure to have the required packages: tidyverse and readxl
After those packages have been installed, you can Run the libraries and make sure they are loaded in
Once packages have been unpacked, you want to make sure that R's working directory is set to the same directory that you have your files in
To do that, you go to Session (at the top left), go down the drop down to Set Work Directory, and click Choose Directory
A files window will show up and choose the folder that your xlsx and csv files are in, if it already shows that then click Open
Create a variable (we called it Tests)
Tests gets assigned read_excel function with the TestScores xlsx file
Tests <- read_excel("TestScores.xlsx")
You can go ahead and Run that line
The Tests variable should show up in the Environment window (on the right) and the data set has been imported
Repeat the process with the csv file, with a slightly different function
Create another variable (we called it CVSTests)
CSVTests gets assigned read_csv with the TestScores csv file
CSVTests <- read_csv("CSVTestScores.csv")
Same thing with the first variable, the second variable will show up in the Environment and you can see that it has been imported correctly into RStudio
For a more step by step visual tutorial, here's a video.
Check out this blog where you can import data via web scraping into RStudio.
#rstudio #r #coding #program #language #statistical #computing #howto #xlsx #csv #files #variable #directory #session #packages #import #function #table #data #qbo #excel #bookkeeping #financialservices #accounting #financialgps