Hi Gabrielle, I get the feeling that you are trying to merge data in which each file contains different variables, but the same subjects have contributed the data. This a very wild guess, but it may provide some insight.
# assume that subjects are identified by a variable named "subjectID" # create a vector of all your filenames my_filenames<-c("dailyActivity_merged.csv", "dailyCalories_merged.csv", "dailyIntensities_merged.csv", ...) # step through the filenames, reading each one and merging it into the final data frame for(filename in my_filenames) { if(!exists(my_df)) my_df<-read.csv(filename) else { next_df<-read.csv(filename) my_df<-merge(my_df,next_df,by="subjectID",fill=TRUE) } } I doubt that this will work first time, but it will be a lot easier to debug than throwing it all into a black box and seeing what comes out. Jim On Thu, Nov 4, 2021 at 2:36 AM gabrielle aban steinberg <gabrielleabansteinb...@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@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. ______________________________________________ R-help@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.