[complete beginner]How do I upload many CSV file as one? Using Rstudio desktop

I uploaded 12 csv files one by one, however I tried zip file but it didn't work. I used Rar extension.

Can you explain more about what you want to do? Do you want to combine the 12 separate data frames that you now have into one data frame and save that as a file?
Do all of your csv files have the same number of columns and the same column names?

Yes, I want to combine them, number of columns are same in 11 files and the other one has more.

You can easily combine the 11 matching data frames with the methods shown below. For the one with extra columns, I would use bind_rows(). It will add columns as necessary to the final data frame.

DF1 <- data.frame(Name = c("A", "B", "C"), Value = 1:3)
DF2 <- data.frame(Name = c("AA", "BB", "CC"), Value = 11:13)
DF3 <- data.frame(Name = c("AAA", "BBB", "CCC"), Value = 21:23)

#Combine with rbind
AllDat1 <- rbind(DF1, DF2, DF3)
AllDat1
#>   Name Value
#> 1    A     1
#> 2    B     2
#> 3    C     3
#> 4   AA    11
#> 5   BB    12
#> 6   CC    13
#> 7  AAA    21
#> 8  BBB    22
#> 9  CCC    23

#Use bind_rows
library(dplyr)

AllDat2 <- bind_rows(DF1, DF2, DF3, .id = "Origin")
AllDat2
#>   Origin Name Value
#> 1      1    A     1
#> 2      1    B     2
#> 3      1    C     3
#> 4      2   AA    11
#> 5      2   BB    12
#> 6      2   CC    13
#> 7      3  AAA    21
#> 8      3  BBB    22
#> 9      3  CCC    23

#Data frames in a list
DF_List <- list(First=DF1, Second = DF2, Third = DF3)
AllDat3 <- bind_rows(DF_List, .id = "Origin")
AllDat3
#>   Origin Name Value
#> 1  First    A     1
#> 2  First    B     2
#> 3  First    C     3
#> 4 Second   AA    11
#> 5 Second   BB    12
#> 6 Second   CC    13
#> 7  Third  AAA    21
#> 8  Third  BBB    22
#> 9  Third  CCC    23

Created on 2022-02-15 by the reprex package (v2.0.1)

1 Like

Thank you mate, it's really helpful.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.