Hello @Jogr ,
I am assuming that each file in the zip folder has to be read in and should have a distinct name. Hopefully I have not misunderstood the problem. I have tried to do this on the Posit cloud, you can access it here in case needed (Posit Cloud). Below is the code. Hope this helps.
> # list all the files in the zip folder --------------
>
> list.files("Fitabase Data 4.12.16-5.12.16/") -> names_data_files
>
> names_data_files
[1] "dailyActivity_merged.csv" "dailyCalories_merged.csv"
[3] "dailyIntensities_merged.csv" "dailySteps_merged.csv"
[5] "heartrate_seconds_merged.csv" "hourlyCalories_merged.csv"
[7] "hourlyIntensities_merged.csv" "hourlySteps_merged.csv"
[9] "minuteCaloriesNarrow_merged.csv" "minuteCaloriesWide_merged.csv"
[11] "minuteIntensitiesNarrow_merged.csv" "minuteIntensitiesWide_merged.csv"
[13] "minuteMETsNarrow_merged.csv" "minuteSleep_merged.csv"
[15] "minuteStepsNarrow_merged.csv" "minuteStepsWide_merged.csv"
[17] "sleepDay_merged.csv" "weightLogInfo_merged.csv"
>
> ## it is clear from the file names that there are multiple files that may have
> ## different sets of columns. These best be read individually. All are csv files.
>
>
> # Read all files --------------------------------------
>
>
> purrr::map(names_data_files,
+ ~readr::read_csv(here::here("Fitabase Data 4.12.16-5.12.16/",.x))) |>
+ setNames(stringr::str_remove(names_data_files,".csv")) -> all_data_files
Rows: 940 Columns: 15
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityDate
dbl (14): Id, TotalSteps, TotalDistance, TrackerDistance, LoggedActivitiesDistance, VeryActiveDistance...
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 940 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityDay
dbl (2): Id, Calories
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 940 Columns: 10
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityDay
dbl (9): Id, SedentaryMinutes, LightlyActiveMinutes, FairlyActiveMinutes, VeryActiveMinutes, Sedentary...
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 940 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityDay
dbl (2): Id, StepTotal
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 2483658 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): Time
dbl (2): Id, Value
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 22099 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityHour
dbl (2): Id, Calories
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 22099 Columns: 4
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityHour
dbl (3): Id, TotalIntensity, AverageIntensity
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 22099 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityHour
dbl (2): Id, StepTotal
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 1325580 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityMinute
dbl (2): Id, Calories
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 21645 Columns: 62
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityHour
dbl (61): Id, Calories00, Calories01, Calories02, Calories03, Calories04, Calories05, Calories06, Calo...
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 1325580 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityMinute
dbl (2): Id, Intensity
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 21645 Columns: 62
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityHour
dbl (61): Id, Intensity00, Intensity01, Intensity02, Intensity03, Intensity04, Intensity05, Intensity0...
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 1325580 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityMinute
dbl (2): Id, METs
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 188521 Columns: 4
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): date
dbl (3): Id, value, logId
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 1325580 Columns: 3
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityMinute
dbl (2): Id, Steps
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 21645 Columns: 62
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): ActivityHour
dbl (61): Id, Steps00, Steps01, Steps02, Steps03, Steps04, Steps05, Steps06, Steps07, Steps08, Steps09...
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 413 Columns: 5
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): SleepDay
dbl (4): Id, TotalSleepRecords, TotalMinutesAsleep, TotalTimeInBed
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Rows: 67 Columns: 8
ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): Date
dbl (6): Id, WeightKg, WeightPounds, Fat, BMI, LogId
lgl (1): IsManualReport
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
>
> # names of all files -------------
>
> # All files are read in as data frames and each df is a distinct element fo a list (all_data_files)
>
> names(all_data_files)
[1] "dailyActivity_merged" "dailyCalories_merged" "dailyIntensities_merged"
[4] "dailySteps_merged" "heartrate_seconds_merged" "hourlyCalories_merged"
[7] "hourlyIntensities_merged" "hourlySteps_merged" "minuteCaloriesNarrow_merged"
[10] "minuteCaloriesWide_merged" "minuteIntensitiesNarrow_merged" "minuteIntensitiesWide_merged"
[13] "minuteMETsNarrow_merged" "minuteSleep_merged" "minuteStepsNarrow_merged"
[16] "minuteStepsWide_merged" "sleepDay_merged" "weightLogInfo_merged"
>
> ## one can acess individual df as follows
>
> all_data_files$dailyIntensities_merged
# A tibble: 940 Γ 10
Id ActivityDay SedentaryMinutes LightlyActiveβ¦ΒΉ Fairlβ¦Β² VeryAβ¦Β³ Sedenβ¦β΄ Lightβ¦β΅ Moderβ¦βΆ VeryAβ¦β·
<dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1503960366 4/12/2016 728 328 13 25 0 6.06 0.550 1.88
2 1503960366 4/13/2016 776 217 19 21 0 4.71 0.690 1.57
3 1503960366 4/14/2016 1218 181 11 30 0 3.91 0.400 2.44
4 1503960366 4/15/2016 726 209 34 29 0 2.83 1.26 2.14
5 1503960366 4/16/2016 773 221 10 36 0 5.04 0.410 2.71
6 1503960366 4/17/2016 539 164 20 38 0 2.51 0.780 3.19
7 1503960366 4/18/2016 1149 233 16 42 0 4.71 0.640 3.25
8 1503960366 4/19/2016 775 264 31 50 0 5.03 1.32 3.53
9 1503960366 4/20/2016 818 205 12 28 0 4.24 0.480 1.96
10 1503960366 4/21/2016 838 211 8 19 0 4.65 0.350 1.34
# β¦ with 930 more rows, and abbreviated variable names ΒΉβLightlyActiveMinutes, Β²βFairlyActiveMinutes,
# Β³βVeryActiveMinutes, β΄βSedentaryActiveDistance, β΅βLightActiveDistance, βΆβModeratelyActiveDistance,
# β·βVeryActiveDistance
# βΉ Use `print(n = ...)` to see more rows
>
Best,
Ayush