I have the following code:
- files = list.files(path = "documents", pattern = "csv$")
- data = lapply(files, read.csv)
- data = as.data.frame(data)
- data = as.data.frame(t(data)
- data = dplyr::as_tibble(data, rownames = "X")
When I perform the last three lines of code on each csv file, they work perfectly fine. My issue is that I want to run this code on all csv files, but not all the files have the same number of rows and columns, and therefore I cannot run everything in one code like I've included above. How can I get around this issue of having different numbers of columns/rows per csv file?