Skip to content

drop option fails with fread(col.names=,...)  #3459

@malcook

Description

@malcook

# Minimal reproducible example

fread("a,b,d\n1,2,3\n4,5,6",drop='b')

   a d
1: 1 3
2: 4 6

so far so good.

Arguably the next three expressions should yield the same result, but do not:

fread(col.names=c("a","b","c"),"1,2,3\n4,5,6",drop='b')

   a b c
1: 1 2 3
2: 4 5 6
Warning message:
In fread(col.names = c("a", "b", "c"), "1,2,3\n4,5,6", drop = "b") :
     Column name 'b' in 'drop' not found


fread(col.names=c("a","b","c"),"1,2,3\n4,5,6",drop=2)
Error in setnames(ans, col.names) : 
  Can't assign 3 names to a 2 column data.table

fread(col.names=c("a","b","c"),"1,2,3\n4,5,6",colClasses=c(b="NULL"))
   a b c
1: 1 2 3
2: 4 5 6
Warning message:
In fread(col.names = c("a", "b", "c"), "1,2,3\n4,5,6", colClasses = c(b = "NULL")) :
  Column name 'b' in 'drop' not found


# Output of sessionInfo()
`

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /n/apps/CentOS7/install/r-3.5.2/lib64/R/lib/libRblas.so
LAPACK: /n/apps/CentOS7/install/r-3.5.2/lib64/R/lib/libRlapack.so

locale:
[1] C

attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods base

other attached packages:
[1] rtracklayer_1.42.1 GenomicRanges_1.34.0 GenomeInfoDb_1.18.2 IRanges_2.16.0 S4Vectors_0.20.1 BiocGenerics_0.28.0 data.table_1.12.0 rfigshare_0.3.7.100 usethis_1.4.0 devtools_2.0.1

loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 lattice_0.20-38 prettyunits_1.0.2 Rsamtools_1.34.1 ps_1.3.0 Biostrings_2.50.2 assertthat_0.2.0 rprojroot_1.3-2 digest_0.6.18 R6_2.4.0 plyr_1.8.4 backports_1.1.3 httr_1.4.0 ggplot2_3.1.0 pillar_1.3.1 zlibbioc_1.28.0 rlang_0.3.1 lazyeval_0.2.1 curl_3.3 callr_3.1.1 Matrix_1.2-15
[22] desc_1.2.0 BiocParallel_1.16.6 RCurl_1.95-4.11 munsell_0.5.0 DelayedArray_0.8.0 compiler_3.5.2 httpuv_1.4.5.1 pkgconfig_2.0.2 askpass_1.1 pkgbuild_1.0.2 tcltk_3.5.2 openssl_1.2.1 tidyselect_0.2.5 SummarizedExperiment_1.12.0 tibble_2.0.1 GenomeInfoDbData_1.2.0 matrixStats_0.54.0 XML_3.98-1.17 crayon_1.3.4 dplyr_0.8.0.1 withr_2.1.2
[43] later_0.8.0 GenomicAlignments_1.18.1 bitops_1.0-6 grid_3.5.2 gtable_0.2.0 magrittr_1.5 scales_1.0.0 cli_1.0.1 XVector_0.22.0 fs_1.2.6 promises_1.0.1 remotes_2.0.2 testthat_2.0.1 tools_3.5.2 RJSONIO_1.3-1.1 Biobase_2.42.0 glue_1.3.0 purrr_0.3.0 processx_3.2.1 pkgload_1.0.2 yaml_2.2.0
[64] colorspace_1.4-0 sessioninfo_1.1.1 memoise_1.1.0

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions