marcusvolz / strava

Create artistic visualisations with your exercise data
Other
508 stars 57 forks source link

plot_3D error: "Problem while computing `id = as.integer(id)` #49

Closed TylerHext closed 2 years ago

TylerHext commented 2 years ago

Hi, when attempting to use the plot_3D() function I receive the following error:

Reading the tracklog
Error in `dplyr::mutate()`:
! Problem while computing `id = as.integer(id)`.
Caused by error in `as.integer()`:
! cannot coerce type 'closure' to vector of type 'integer'

I'm feeding it a GPX file that works with all other functions in this repo so I don't believe it is a file issue. Obviously some sort of type issue...

I'm coming from Python/SQL and still pretty new to R...I've begun attempting to identify the cause but wanted to post here in case you've encountered this issue before.

Thank you for such a fun and educational collection of code here. I've already learned so much while playing with my Strava data.

TylerHext commented 2 years ago

Update: If I point process_data() to a directory containing one GPX file, it processes the data without error.

When I use the same path in the plot_3d() function, I run into the error posted above.

BalintKomjati commented 2 years ago

Hi @TylerHext! Thanks for pointing out this (seems-to-be-a-) bug.

I think this line in the plot_3D() function that causes the issue: tracklog <- strava::process_data(system.file(tracklog_file, package = "strava")) It only works for the demo gpx file, or files placed inside the source of the package, but will not if you provide a full path of a file outside the package.

I will fix this nicely in the coming days, until then you can replace this line in the function with the following: tracklog <- strava::process_data(tracklog_file) And make sure to provide the full path of your gpx file.

PS: to be honest I have not tested if this was really the issue (or the only issue) and if my fix above will work. So please report me back if it did - I would be grateful!

TylerHext commented 2 years ago

Hi @BalintKomjati ! Thank you for the response.

The issue does appear to be caused by the line you pointed out. I replaced it with your suggestion and have it working.

Interestingly, if I provide the full path of my GPX file it throws the same error as above. However, if I merely provide a path to the folder containing a single GPX file it successfully maps my route.

It is an easy work-around for me, just thought this info might be useful for you.

All that to say I'm now successfully mapping my running routes into 3D plots and couldn't be happier. Thank you for your help :)

marcusvolz commented 2 years ago

Thanks for looking into this @BalintKomjati

BalintKomjati commented 2 years ago

@marcusvolz Created a PR for this issue. Checks passed. Can you please review it? @TylerHext thanks again for reporting. Renamed the argument to tracklog_folder because as you wrote it expects a folder not a file path. It will read in and plot all the tracklogs within the folder so to be in line with the intended usage of the function plot_3D() place only one file there at once. (Not the smoothest design but does the job.)