How can I read the header but also skip lines - read.table()?

后端 未结 5 792
谎友^
谎友^ 2020-12-01 09:17

Data.txt:

Index;Time;
1;2345;
2;1423;
3;5123;

The code:

dat <- read.table(\'data.txt\', skip = 1, nrows = 2, header =TRU         


        
5条回答
  •  被撕碎了的回忆
    2020-12-01 09:48

    Instead of read.table(), use a readr function such as read_csv(), piped to dplyr::slice().

    library(readr)
    library(dplyr)
    dat <- read_csv("data.txt") %>% slice(-1)
    

    It's very fast too.

提交回复
热议问题