Sign in to confirm you’re not a bot
This helps protect our community. Learn more
Load Excel Data into R (readxl package, code in description; quick code up front + details later)
14Likes
2,308Views
2021Jan 6
Code: setwd("C:/My Data Folder/Project1") if (!require(readxl)) install.packages('readxl') library(readxl) d = read_excel("sampledatafoodsales.xlsx", sheet = "FoodSales") Textbook: http://tinyurl.com/he902stats Set working directory: http://tinyurl.com/RStudioSetWD Entire code file from video: LOAD EXCEL DATA IN R WITHIN RSTUDIO ##### All the code in one place, for intermediate or advanced users ##### setwd("C:/My Data Folder/Project1") if (!require(readxl)) install.packages('readxl') library(readxl) d = read_excel("sampledatafoodsales.xlsx", sheet = "FoodSales") Data source: Data source: Excel Sample Data. Contextures. https://www.contextures.com/xlsampled.... ##### Detailed procedure, for beginners ##### Fix RStudio layout, if desired Make new R script file (not shown in video) Prepare and inspect Excel file on your computer Set working directory (instructions: https://tinyurl.com/RStudioSetWD) setwd("C:/My Data Folder/Project1") Inspect working directory in Files viewer Make sure Excel file is in working directory Data source: Data source: Excel Sample Data. Contextures. https://www.contextures.com/xlsampled.... Load readxl package (and install if needed) if (!require(readxl)) install.packages('readxl') library(readxl) See Environment tab Load Excel data into R d = read_excel("sampledatafoodsales.xlsx", sheet = "FoodSales") See Environment tab again See console Inspect data in R (via Environment - Data or with View() command) View(d) Use the data in R (for example, you can make a table) table(d$City)

Follow along using the transcript.

Anshul Kumar

50 subscribers