Reputation: 22260
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.
Upvotes: 4
Views: 904
Reputation: 2056
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()))
Upvotes: 3
Reputation: 766
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
Upvotes: 1