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

Read rows and columns from Excel

From the course: R Programming in Data Science: High Variety Data

Start my 1-month free trial

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…

Contents