简体   繁体   中英

How to avoid importing blanks from CSV to R

I have tried using the below codes to import multiple CSV files from a folder into one data frame in R. Unfortunately, all the blanks were imported into my data frame. The number of rows should be 354 but when I imported all the CSV into my R, there are 13806 rows imported. All the rows after the 354th appeared to be NA. How do I fix this?

setwd("C:/Users/Documents/Folder1")
library(plyr)
alldataset <- ldply(list.files(), read.csv, header= TRUE)

read_csv from the readr package has the skip_empty_rows option.

I generally recommend using read_csv rather than read.csv , as the former is much faster.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM