From the course: R Programming in Data Science: High Variety Data
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Read rows and columns from Excel
From the course: R Programming in Data Science: High Variety Data
Read rows and columns from Excel
- When you're working with excel files, there will be times when you want to import an entire row or entire column. And to do that, you'll want to use the openxlsx package. So let's see how that works. The first thing I've done is create a vector called spreadSheetRangeFile, which contains the name of a file that I want to import. Be sure to set your working directory to chapter one. And if you haven't done this already install the packages for openxlsx as shown in line 11. And then use the library command to bring openxlsx into play. For columns, you'll use the read.xlsx command. It looks like this. And then you specify the name of the excel spreadsheet that you want to bring information in from. In this case we're going to use spreadSheetRangeFile. And to bring in a column, I use cols = and I give it a collection of values. In this case, I'm just going to give it a collection of one value. And in this case, I'm going to specify the fourth column. Now let's take a look at what that…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Excel packages compared3m 29s
-
Read a workbook from Excel2m 53s
-
(Locked)
Write a workbook to Excel2m 16s
-
(Locked)
Read ranges from Excel3m 10s
-
(Locked)
Write ranges to Excel4m 52s
-
(Locked)
Read rows and columns from Excel2m 57s
-
(Locked)
Write rows and columns to Excel5m 12s
-
(Locked)
Read individual cells from Excel2m 55s
-
(Locked)
Write individual cells to Excel3m 50s
-
-
-
-
-