Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read Excel file and select specific rows and columns

Tags:

r

I want to read a xls file into R and select specific columns.

For example I only want columns 1 to 10 and rows 5 - 700. I think you can do this with xlsx but I can't use that library on the network that I am using.

Is there another package that I can use? And how would I go about selecting the columns and rows that I want?

like image 688
Mrmoleje Avatar asked Aug 20 '18 12:08

Mrmoleje


People also ask

How do I extract specific rows and columns in excel?

Select a cell in the database. On the Excel Ribbon's Data tab, click the Advanced button. In the Advanced Filter dialog box, choose 'Copy to another location'. For the List range, select the column(s) from which you want to extract the unique values.

How do I pull specific data from an excel spreadsheet?

To use VLOOKUP to pull data from another sheet in Excel: Click in the cell where you want the pulled data to appear. Type =VLOOKUP( then click on the cell to the left. This will be the reference that the VLOOKUP function will look for. Type a comma, and then click on the sheet that you want to pull data from.

How can I pull specific data from one excel sheet and import it into the correct fields on another sheet?

Type = in your cell, then click the other sheet and select the cell you want, and press enter. That'll type the function for you. Now, if you change the data in the original B3 cell in the Names sheet, the data will update everywhere you've referenced that cell. Need to calculate values from that cell?

How do I import certain rows in excel?

Switch to Excel and open the worksheet that has data that you want to import. Select the range of cells that contain the data that you want to import. Right-click within the selected range and then click Name a Range or Define Name. In the New Name dialog box, specify a name for the range in the Name box and click OK.


1 Answers

You can try this:

 library(xlsx)
 read.xlsx("my_path\\my_file.xlsx", "sheet_name", rowIndex = 5:700, colIndex = 1:10)
like image 57
s__ Avatar answered Oct 23 '22 04:10

s__