4

From this code:

require(readr)
readK6 <- read_csv("./data/K6.csv.zip", 
                   col_types = c("character", "numeric"))

I'm getting:

Error: Unknown shortcut: h In addition: Warning message: Missing column names filled in: 'X1' 1

When trying to load this dataset.

Any ideas?


edit: I want the first col to read as char and

readK6 <- read_csv("./data/K6.csv.zip", 
                    col_types=cols(
                      s = col_character(), 
                      x = col_double()
                      )
                    )

ain't working either.

andandandand
  • 21,946
  • 60
  • 170
  • 271

2 Answers2

3

As your first column is missing a name it gets filled in automatically with X1 (http://readr.tidyverse.org/reference/read_delim.html) as you can also see from the warning message you get. To force that column to read as chr you can use the following

library(readr)
readK6 <- read_csv("K6.csv.zip",
               col_types = cols(X1 = col_character(),
                                x = col_double()))
GordonShumway
  • 1,980
  • 13
  • 19
1

Just use:

require(readr)
setwd("your work directory")
readK6 <- read_csv("K6.csv.zip")

You will receive the mensage Missing column names filled in: 'X1' because in the csv file the head of column one is missing.

> class(readK6)
[1] "tbl_df"     "tbl"        "data.frame"
> length(readK6)
[1] 2
> nrow(readK6)
[1] 2196277
> ncol(readK6)
[1] 2
Artur_Indio
  • 736
  • 18
  • 35
  • Thanks, but I need to read the first column as character too. ```readK6 <- read_csv("./data/K6.csv.zip", col_types=cols( s = col_character(), x = col_double() ) ) ``` ain't working. – andandandand Apr 10 '18 at 02:14