[R] Fwd: Merging multiple csv files to new file

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Nov 3 20:32:26 CET 2021

On 02/11/2021 6:30 p.m., gabrielle aban steinberg wrote:
> Hello, I would like to merge 18 csv files into a master data csv file, but
> each file has a different number of columns (mostly found in one or more of
> the other cvs files) and different number of rows.
> I have tried something like the following in R Studio (cloud):
> all_data_fit_files <- rbind("dailyActivity_merged.csv",
> "dailyCalories_merged.csv", "dailyIntensities_merged.csv",
> "dailySteps_merged.csv", "heartrate_seconds_merged.csv",
> "hourlyCalories_merged.csv", "hourlyIntensities_merged.csv",
> "hourlySteps_merged.csv", "minuteCaloriesNarrow_merged.csv",
> "minuteCaloriesWide_merged.csv", "minuteIntensitiesNarrow_merged.csv",
> "minuteIntensitiesWide_merged.csv", "minuteMETsNarrow_merged.csv",
> "minuteSleep_merged.csv", "minuteStepsNarrow_merged.csv",
> “minuteStepsWide_merged.csv", "sleepDay_merged.csv",
> "minuteStepsWide_merged.csv", "sleepDay_merged.csv",
> "weightLogInfo_merged.csv")

That just puts the names together.  You need to read each file, figure 
out how the resulting dataframes get merged (they have different 
columns, so that will take some thinking), and then do it and write it out.

Duncan Murdoch

More information about the R-help mailing list