Closed Kaoping closed 1 year ago
Hey @Kaoping, Thank you for reporting this bug. Just for clarity you're trying to get this line of code to run from our other repo correct:
https://github.com/MoBiodiv/elev_gradient/blob/master/scripts/univariate_gradients.R#L103-L107
it is strange because the examples in mobr run without error, specifically:
data(inv_comm)
data(inv_plot_attr)
inv_mob_in = make_mob_in(inv_comm, inv_plot_attr, coord_names = c('x', 'y'))
inv_mob_out = get_delta_stats(inv_mob_in, 'group', ref_level='uninvaded',
type='discrete', log_scale=TRUE, n_perm=3)
plot(inv_mob_out)
However, I was able to reproduce the error you observed. It appears to be due to these lines:
https://github.com/MoBiodiv/mobr/blob/dev/R/mobr.R#L993-L996
The solution seems simple enough just to remove the .data$
portion of those lines. I honestly can't remember why I thought I needed .data$
in the first place. Maybe @T-Engel or @sablowes who know more about dplyr
than I can comment if they have any thoughts. I'm going to remove those errant lines from the dev branch. I'll post to this thread when you can re-install and retry to generate that result.
all line references refer to commit [3bf11d3] of mobr dev branch (https://github.com/MoBiodiv/mobr/commit/3bf11d385e6a669f6388150a3ea8bc890343dbbd)
The bug is patched now on the dev
branch of the repo. You can install this version with:
remotes::install_github('MoBiodiv/mobr', ref = 'dev')
Hi Prof. McGlinn,
Thank you for your kind help. I re-intsall the mobr packages following your instruction and Yes, it is really works.
I have run into an issue when calculating the density effects from get_delta_stats() in mobr_2.0.2. I used your example code: deltas = get_delta_stats(ant_mob_in, env_var = 'elevation_m', group_var = 'site', stats = c('betas', 'r'), type = 'continuous', spat_algo = 'kNCN', n_perm = 199, overall_p = TRUE, log_scale = TRUE). There is an error message "Can't subset '.data' outside of a data mask context. ". I suppose the error comes from dplyr package (1.1.0). Could you help to fix this? Thanks a lot.