Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取csv文件并使用R进行筛选_R_Performance_Csv_Filter_Tidyverse - Fatal编程技术网

获取csv文件并使用R进行筛选

获取csv文件并使用R进行筛选,r,performance,csv,filter,tidyverse,R,Performance,Csv,Filter,Tidyverse,有没有更快的方法来获取一堆csv文件,将它们合并在一起(它们都具有相同的结构),但只保留那些大于5的值(一列) csv文件将有数千行,而通常少于100行(每个csv)将大于5行 我的工作守则是: library(tidyverse) filelocns <-"C:/Data/test/" # get files list from folder file.list <- list.files(path=filelocns, recursive=T,pattern='*.csv')

有没有更快的方法来获取一堆csv文件,将它们合并在一起(它们都具有相同的结构),但只保留那些大于5的值(一列)

csv文件将有数千行,而通常少于100行(每个csv)将大于5行

我的工作守则是:

library(tidyverse)

filelocns <-"C:/Data/test/"

# get files list from folder
file.list <- list.files(path=filelocns, recursive=T,pattern='*.csv')  

# row bind the listed CSVs and filter for Values >= 5
rows_gt5 <- lapply(paste0(filelocns,file.list),read.csv) %>% 
    bind_rows() %>% 
    filter(Value>=5)
库(tidyverse)
filelocns%
过滤器(值>=5)

试试看
read\u csv
是否适合您,即更改行

rows_gt5 <- lapply(paste0(filelocns,file.list),read.csv) %>%
rows_gt5%

rows_gt5%
一般来说,它比
read.csv
快。
有关如何使用它的详细信息,请查看

以下是我的做法:

# source dependencies
library(dplyr)

# declare path to desired directory
filelocns <-"C:/Data/test/"

# list all of the files within this directory
file.list <- list.files(path=filelocns
    ,pattern='\\.csv$'
    ,all.files = FALSE
    ,full.names = TRUE
    ,ignore.case = FALSE
)  

# apply the read_csv function to our list of files
row_gt5 <- ldply(file.list, read_csv) %>%

# and filter out values less than five
    filter(Values>=5)
#源依赖项
图书馆(dplyr)
#声明所需目录的路径

filelocns确实快多了!
# source dependencies
library(dplyr)

# declare path to desired directory
filelocns <-"C:/Data/test/"

# list all of the files within this directory
file.list <- list.files(path=filelocns
    ,pattern='\\.csv$'
    ,all.files = FALSE
    ,full.names = TRUE
    ,ignore.case = FALSE
)  

# apply the read_csv function to our list of files
row_gt5 <- ldply(file.list, read_csv) %>%

# and filter out values less than five
    filter(Values>=5)