Margherita Di Leo
2014-Aug-03 16:33 UTC
[R] Reading specific rows and columns xlsx file: Error in strsplit(names(res), "\\.") : non-character argument
Hi,
I am trying to read specific rows and columns from a xlsx file using the
following commands:
# Read rows 18-23 and columns 7-15 into R and assign the result to a
variable
# called dat
colIndex <- 18:23
rowIndex <- 7:15
dat <- read.xlsx("./data/natural_gas.xlsx", sheetIndex = 1, header
= TRUE,
colIndex = colIndex, rowIndex = rowIndex)
But I get this error:
Error in strsplit(names(res), "\\.") : non-character argument
I don't understand where that non-character comes from.
When I read the whole file with:
naturalGas <- read.xlsx("./data/natural_gas.xlsx", sheetIndex = 1,
header TRUE)
I don't get any problem.
Should you be willing to try to reproduce this behavior, the file comes
from:
https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FDATA.gov_NGAP.xlsx
sessionInfo()R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)
I'm on debian Jessie.
Disclaimer: this is a homework.
Thank you in advance
--
Best regards,
Dr. Margherita DI LEO
Scientific / technical project officer
European Commission - DG JRC
Institute for Environment and Sustainability (IES)
Via Fermi, 2749
I-21027 Ispra (VA) - Italy - TP 261
Tel. +39 0332 78 3600
margherita.di-leo@jrc.ec.europa.eu
Disclaimer: The views expressed are purely those of the writer and may not
in any circumstance be regarded as stating an official position of the
European Commission.
[[alternative HTML version deleted]]
Margherita Di Leo
2014-Aug-03 17:37 UTC
[R] Reading specific rows and columns xlsx file: Error in strsplit(names(res), "\\.") : non-character argument
Ahem.. solved. I had switched between rows and columns.. Sorry for the noise. Best, m On Sun, Aug 3, 2014 at 6:33 PM, Margherita Di Leo <diregola@gmail.com> wrote:> Hi, > > I am trying to read specific rows and columns from a xlsx file using the > following commands: > > # Read rows 18-23 and columns 7-15 into R and assign the result to a > variable > # called dat > > colIndex <- 18:23 > rowIndex <- 7:15 > dat <- read.xlsx("./data/natural_gas.xlsx", sheetIndex = 1, header = TRUE, > colIndex = colIndex, rowIndex = rowIndex) > > But I get this error: > > Error in strsplit(names(res), "\\.") : non-character argument > > > I don't understand where that non-character comes from. > When I read the whole file with: > > naturalGas <- read.xlsx("./data/natural_gas.xlsx", sheetIndex = 1, header > = TRUE) > > I don't get any problem. > > Should you be willing to try to reproduce this behavior, the file comes > from: > https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FDATA.gov_NGAP.xlsx > > sessionInfo()R version 3.1.1 (2014-07-10) > Platform: x86_64-pc-linux-gnu (64-bit) > > > I'm on debian Jessie. > > Disclaimer: this is a homework. > > Thank you in advance > > > -- > Best regards, > > Dr. Margherita DI LEO > Scientific / technical project officer > > European Commission - DG JRC > Institute for Environment and Sustainability (IES) > Via Fermi, 2749 > I-21027 Ispra (VA) - Italy - TP 261 > > Tel. +39 0332 78 3600 > margherita.di-leo@jrc.ec.europa.eu > > Disclaimer: The views expressed are purely those of the writer and may not > in any circumstance be regarded as stating an official position of the > European Commission. >-- Best regards, Dr. Margherita DI LEO Scientific / technical project officer European Commission - DG JRC Institute for Environment and Sustainability (IES) Via Fermi, 2749 I-21027 Ispra (VA) - Italy - TP 261 Tel. +39 0332 78 3600 margherita.di-leo@jrc.ec.europa.eu Disclaimer: The views expressed are purely those of the writer and may not in any circumstance be regarded as stating an official position of the European Commission. [[alternative HTML version deleted]]