RetoSchmucki / rbms

A home for the latest rbms R package
https://retoschmucki.github.io/rbms/
Other
4 stars 4 forks source link

code after update #17

Closed cperk closed 1 year ago

cperk commented 2 years ago

Hello,

Thank you so much for implementing my suggestion of month labels on the X axis!

I am trying to plot my curves after the most recent update to your package and having a bit of trouble; hoping you can advise.

Here is my code

#now set up time series
ts_date <- rbms::ts_dwmy_table(InitYear = 2020, LastYear = 2020, WeekDay1 = 'monday')

ts_season_all <- rbms::ts_monit_season(ts_date, StartMonth = 6, EndMonth = 10, StartDay = 02, EndDay = 21, CompltSeason = TRUE, Anchor = TRUE, AnchorLength = 2, AnchorLag = 2, TimeUnit = 'w')

#  We have changed the order of the input arguments, with ts_seaon now in first place, before m_visit.
ts_season_visit_all_fruits_CB <- rbms::ts_monit_site(ts_season_all,m_visit_region_all_fruits_CB)
ts_season_count_all_fruits_CB <- rbms::ts_monit_count_site(ts_season_visit_all_fruits_CB, m_count_region_all_fruits_CB, sp = 2)
ts_flight_curve_all_fruits_CB <- rbms::flight_curve(ts_season_count_all_fruits_CB, NbrSample = 100, MinVisit = 2, MinOccur = 0, MinNbrSite = 5, MaxTrial = 3, GamFamily = 'quasipoisson', SpeedGam = FALSE, CompltSeason = TRUE, SelectYear = NULL, TimeUnit = 'w')
pheno_CB_all_fruits <- ts_flight_curve_all_fruits_CB$pheno
plot(pheno_CB_all[M_YEAR == yr[1] , trimWEEKNO], pheno_CB_all[M_YEAR == yr[1], NM], type = 'l', col="gray0", xlab="Week",ylab="Relative Abundance",ylim = c(0, max(pheno_HR_all[, NM])))

The last line throws an error, says yr not found.

This works:

plot(ts_flight_curve_all_fruits_CB, year = 2020, col = 'dodgerblue4')

So is extracting the phenology part using the second-to-last line of my script now unnecessary?

pheno_CB_all_fruits <- ts_flight_curve_all_fruits_CB$pheno

Thank you!

cperk commented 2 years ago

With the new plotting code syntax, I also find that I cannot specify y limit:

plot(ts_flight_curve_all_fruits_CB, year = 2020, col = 'gray0', ylim = c(0, 0.4))

Error: formal argument "ylim" matched by multiple actual arguments

Is there another way to do it? Thank you, any help is much appreciated.

cperk commented 2 years ago

Actually the code above works, please disregard. Not sure what was happening, but it is working now! However, it still prints Week numbers as the x axis rather than months. How would I get the month labels?