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

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Wed Nov 3 17:12:28 CET 2021

1. Think more carefully about the appropriate data structure for what you
wish to do. It's unlikely to be .csv files, however.

In the absence of the above, a simple (but perhaps inappropriate) default

2. Read the files into R and combine into a list.(You will need to read
about lists in R if you don't know what these are, of course).

3. Save your list as an .Rdata file. See ?save and ?load for details. But
do note that such files are special binary files only (easily anyway)
readable by R.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Wed, Nov 3, 2021 at 8:36 AM gabrielle aban steinberg <
gabrielleabansteinberg using gmail.com> 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")
> But I am getting the following error:
> Error: unexpected input in "rlySteps_merged.csv",
> "minuteCaloriesNarrow_merged.csv", "minuteCaloriesWide_merged.csv",
> "minuteIntensitiesNarrow_merged.csv",
> "minuteIntensitiesWide_merged.csv", "minuteMETsNarrow_merged.csv"
> (Maybe the R Studio free trial/usage is underpowered for my project?)
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list