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?
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.
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.
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?
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.
You can try this:
library(xlsx)
read.xlsx("my_path\\my_file.xlsx", "sheet_name", rowIndex = 5:700, colIndex = 1:10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With