silastittes
silastittes

Reputation: 65

Missing data frame column reading excel file into R with readxl

I'm having some trouble reading an xls file into R using the read_excel function from the readxl package. The data frame is generated, but it's missing at least one column, and I get the following message printed several times:

fread: wanted 1 got 0 loc=30208

Here is the command I'm attempting:

df <- read_excel(path = "Emery0114Aug16-1656_log2.xls",
       sheet = 2, col_names = F,  skip = 3)

The first two rows of the spreadsheet (skipping the first three lines) look like this:

8/13/2016 2:20 PM   0   753 738 881 1234
8/13/2016 2:30 PM   0   757 739 881 1245

The first two rows of the data frame after being read into R look like this, and appear to be missing the last column.

                    X1    X2    X3    X4    X5
                 <time> <dbl> <dbl> <dbl> <dbl>
1  2016-08-13 14:19:59     0   753   738   881
2  2016-08-13 14:29:59     0   757   739   881

Here is a link to the xls file. The file is generated from a water moisture logger, and is unchanged from the defaults that the software produces. https://drive.google.com/file/d/0BzGqPx_G2wnhUzk2eWpNYlBYdHM/view?usp=sharing

I'm running readxl version 0.1.1.9000, R version 3.2.4, and Ubuntu 16.04.1

Thanks for any and all help!

Upvotes: 3

Views: 2505

Answers (1)

Cyrus Mohammadian
Cyrus Mohammadian

Reputation: 5193

library(gdata)
mydata = read.xls("Emery0114Aug16-1656_log2.xls")

head(mydata)
             Emery01             Port.1             Port.2             Port.3             Port.4             Port.5
1        159 records EC-5 Soil Moisture EC-5 Soil Moisture EC-5 Soil Moisture EC-5 Soil Moisture EC-5 Soil Moisture
2   Measurement Time    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC
3 8/13/2016  2:20 PM              #N/A!              0.159              0.146              0.268              0.568
4 8/13/2016  2:30 PM              #N/A!              0.162              0.147              0.268              0.577
5 8/13/2016  2:40 PM              #N/A!              0.168              0.154              0.332              0.590
6 8/13/2016  2:50 PM              #N/A!              0.171              0.156              0.353              0.596

That works for me...

So does the following...

library(xlsx)
mydata <- read.xlsx("Emery0114Aug16-1656_log2.xls")
head(mydata)
             Emery01             Port.1             Port.2             Port.3             Port.4             Port.5
1        159 records EC-5 Soil Moisture EC-5 Soil Moisture EC-5 Soil Moisture EC-5 Soil Moisture EC-5 Soil Moisture
2   Measurement Time    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC    m\xb3/m\xb3 VWC
3 8/13/2016  2:20 PM              #N/A!              0.159              0.146              0.268              0.568
4 8/13/2016  2:30 PM              #N/A!              0.162              0.147              0.268              0.577
5 8/13/2016  2:40 PM              #N/A!              0.168              0.154              0.332              0.590
6 8/13/2016  2:50 PM              #N/A!              0.171              0.156              0.353              0.596

Upvotes: 1

Related Questions