Joining csv files in a directory having more than 10 rows in R -



Joining csv files in a directory having more than 10 rows in R -

i have lot of csv files same type of columns in directory , want bring together them form single csv file. next code imports of them 1 info frame:

filenames <- list.files(full.names=true, pattern="*.csv") abc = do.call(rbind, lapply(filenames, read.table, header = true, sep = ','))

now, in directory, csv files having less 10 rows have 1 column less others. so, when run code files in directory, next error message: error in rbind(deparse.level, ...) : numbers of columns of arguments not match

so, want either of 2 things:

join files irrespective of having column less others (which believe little much ask!) or, more rationally, involve status involving nrow>=10 while joining , bring together having more 10 rows , identical no. of columns.

but, can't add together status involving nrow files. please help.

filenames <- list.files(full.names=true, pattern="*.csv") dfs <- lapply(filenames, read.table, header = true, sep = ',') dfs1 <- do.call(rbind, datasets[sapply(datasets, nrow) != 10] dfs2 <- do.call(rbind, datasets[sapply(datasets, nrow) == 10]

this assumes have less 10 columns have same number of columns (say 9). otherwise, can inspect sapply(datasets, nrow) see how many variations have , adjust accordingly.

r csv

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -