Open Danioy opened 4 years ago
Have you also installed the mosaicCalc
package?
> remotes::install_github("ProjectMOSAIC/mosaicCalc", ref="beta")
Downloading GitHub repo ProjectMOSAIC/mosaicCalc@beta ✓ checking for file ‘/tmp/Rtmp8QaT6B/remotes17c4963245010/ProjectMOSAIC-mosaicCalc-142f94d/DESCRIPTION’ ... ─ preparing ‘mosaicCalc’: ✓ checking DESCRIPTION meta-information ... ─ checking for LF line-endings in source and make files and shell scripts ─ checking for empty or unneeded directories ─ building ‘mosaicCalc_0.5.6.tar.gz’
Installing package into ‘/home/kalmer/R/x86_64-pc-linux-gnu-library/3.6’ (as ‘lib’ is unspecified)
library(mosaicCalc)
slice_plot(epi$S(t) ~ t, domain(t = 0:20)) %>% slice_plot(epi$I(t) ~ t, color = "red")
Error in slice_plot(., epi$I(t) ~ t, color = "red") : could not find function "slice_plot"
I'm interested to find out what's going wrong here. Is it possible that the version of {mosaicCalc}
being loaded is not the one you (correctly) installed from the beta branch of the github repo? Sometimes there's both a personal library and a system library. If you're using RStudio, try removing {mosaicCalc}
on the packages tab, then reinstalling (from "beta", as you did).
I get the following when I try to reproduce the penultimate example (I don't have access to the epi
object so can't try that one):
library(mosaicCalc)
#> Loading required package: mosaicCore
#> Registered S3 method overwritten by 'mosaic':
#> method from
#> fortify.SpatialPolygonsDataFrame ggplot2
#>
#> Attaching package: 'mosaicCalc'
#> The following object is masked from 'package:stats':
#>
#> D
slice_plot(A * x^2 ~ x, domain(x <- range(-2, 3)))
#> Warning in validate_domain(domain, free_args): Using -5 to 5 in domain for
#> missing domain names.
#> Warning in validate_domain(domain, free_args): Missing domain names: x, A
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.1.0 (2021-05-18)
#> os macOS Big Sur 10.16
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2022-02-08
#> pandoc 2.11.4 @ /Applications/RStudio.app/Contents/MacOS/pandoc/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.1.0)
#> backports 1.4.1 2021-12-13 [1] CRAN (R 4.1.0)
#> broom 0.7.12 2022-01-28 [1] CRAN (R 4.1.0)
#> checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.1.0)
#> cli 3.1.1 2022-01-20 [1] CRAN (R 4.1.2)
#> colorspace 2.0-2 2021-06-24 [1] CRAN (R 4.1.0)
#> crayon 1.4.2 2021-10-29 [1] CRAN (R 4.1.0)
#> crosstalk 1.2.0 2021-11-04 [1] CRAN (R 4.1.0)
#> data.table 1.14.2 2021-09-27 [1] CRAN (R 4.1.0)
#> DBI 1.1.2 2021-12-20 [1] CRAN (R 4.1.0)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.0)
#> dplyr * 1.0.7 2021-06-18 [1] CRAN (R 4.1.0)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.0)
#> fansi 1.0.2 2022-01-14 [1] CRAN (R 4.1.2)
#> farver 2.1.0 2021-02-28 [1] CRAN (R 4.1.0)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0)
#> forcats 0.5.1 2021-01-27 [1] CRAN (R 4.1.0)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.0)
#> generics 0.1.2 2022-01-31 [1] CRAN (R 4.1.2)
#> ggdendro 0.1.22 2020-09-13 [1] CRAN (R 4.1.0)
#> ggforce 0.3.3 2021-03-05 [1] CRAN (R 4.1.0)
#> ggformula * 0.10.1 2021-01-13 [1] CRAN (R 4.1.0)
#> ggplot2 * 3.3.5 2021-06-25 [1] CRAN (R 4.1.0)
#> ggrepel 0.9.1 2021-01-15 [1] CRAN (R 4.1.0)
#> ggridges * 0.5.3 2021-01-08 [1] CRAN (R 4.1.0)
#> ggstance * 0.3.5 2020-12-17 [1] CRAN (R 4.1.0)
#> glue 1.6.1 2022-01-22 [1] CRAN (R 4.1.2)
#> gridExtra 2.3 2017-09-09 [1] CRAN (R 4.1.0)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 4.1.0)
#> haven 2.4.3 2021-08-04 [1] CRAN (R 4.1.0)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.1.0)
#> hms 1.1.1 2021-09-26 [1] CRAN (R 4.1.0)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.0)
#> htmlwidgets 1.5.4 2021-09-08 [1] CRAN (R 4.1.0)
#> httr 1.4.2 2020-07-20 [1] CRAN (R 4.1.0)
#> jsonlite 1.7.3 2022-01-17 [1] CRAN (R 4.1.2)
#> knitr 1.37 2021-12-16 [1] CRAN (R 4.1.0)
#> labeling 0.4.2 2020-10-20 [1] CRAN (R 4.1.0)
#> labelled 2.9.0 2021-10-29 [1] CRAN (R 4.1.0)
#> lattice * 0.20-45 2021-09-22 [1] CRAN (R 4.1.0)
#> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.1.0)
#> leaflet 2.0.4.1 2021-01-07 [1] CRAN (R 4.1.0)
#> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.0)
#> lubridate 1.8.0 2021-10-07 [1] CRAN (R 4.1.0)
#> magrittr 2.0.2 2022-01-26 [1] CRAN (R 4.1.2)
#> MASS 7.3-55 2022-01-13 [1] CRAN (R 4.1.2)
#> Matrix * 1.4-0 2021-12-08 [1] CRAN (R 4.1.0)
#> metR 0.11.0 2021-09-20 [1] CRAN (R 4.1.0)
#> mosaic 1.8.3 2021-01-18 [1] CRAN (R 4.1.0)
#> mosaicCalc * 0.5.6 2022-02-08 [1] Github (ProjectMOSAIC/mosaicCalc@142f94d)
#> mosaicCore * 0.9.0 2021-01-16 [1] CRAN (R 4.1.0)
#> mosaicData * 0.20.2 2021-01-16 [1] CRAN (R 4.1.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.1.0)
#> pillar 1.7.0 2022-02-01 [1] CRAN (R 4.1.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0)
#> plotly 4.10.0 2021-10-09 [1] CRAN (R 4.1.0)
#> plyr 1.8.6 2020-03-03 [1] CRAN (R 4.1.0)
#> polyclip 1.10-0 2019-03-14 [1] CRAN (R 4.1.0)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0)
#> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.0)
#> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.0)
#> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.0)
#> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.0)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0)
#> Rcpp 1.0.8 2022-01-13 [1] CRAN (R 4.1.2)
#> readr 2.1.2 2022-01-30 [1] CRAN (R 4.1.2)
#> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.0)
#> rlang 1.0.1 2022-02-03 [1] CRAN (R 4.1.2)
#> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.0)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0)
#> scales 1.1.1 2020-05-11 [1] CRAN (R 4.1.0)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.0)
#> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.0)
#> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.0)
#> tibble 3.1.6 2021-11-07 [1] CRAN (R 4.1.0)
#> tidyr 1.2.0 2022-02-01 [1] CRAN (R 4.1.2)
#> tidyselect 1.1.1 2021-04-30 [1] CRAN (R 4.1.0)
#> tweenr 1.0.2 2021-03-23 [1] CRAN (R 4.1.0)
#> tzdb 0.2.0 2021-10-27 [1] CRAN (R 4.1.0)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0)
#> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0)
#> viridisLite 0.4.0 2021-04-13 [1] CRAN (R 4.1.0)
#> withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.0)
#> xfun 0.29 2021-12-14 [1] CRAN (R 4.1.0)
#> yaml 2.2.2 2022-01-25 [1] CRAN (R 4.1.2)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2022-02-08 by the reprex package (v2.0.1)
It is unclear what this example is supposed to do with the A variable. A quick scan of the documentation didn't make it clear to me what the intended behavior is. If you set the domain for A to a single value, you get a nice plot of the the function with A held constant.
@dtkaplan, is slice_plot()
supposed to be choosing several values of A and plotting them separately? Are you missing a group
somewhere so that ggplot
knows which dots should be connected?
@piiskop , After installing {mosaicCalc} from github, did you restart R? If not, you may have an unstable cache of R packages. See if restarting R resolves the issue.
Here's Nick's example:
slice_plot(A * x^2 ~ x, domain(x <- range(-2, 3)))
The problem is that <-
is being used rather than x=
. With x<-
there's no name for the argument. slice_plot() checks that the domain corresponds to the name given in the RHS of the tilde expression.
As for the A
matter. makeFun()
and the related functions---slice_plot()
builds a function from the tilde expression using makeFun()
. Symbolic parameters such as A
(which isn't listed on the RHS of the tilde) are made formal arguments for the created function. To graph the function, you need to provide a numerical value for such parameters. For instance:
f <- makeFun(A * x^2 ~ x)
slice_plot(f(x, A=2) ~ x, domain(x=-2:2))
The case for plotting the function for several values of A
in the same frame is to pipe into additional slice_plot() commands.
@piiskop , After installing {mosaicCalc} from github, did you restart R? If not, you may have an unstable cache of R packages. See if restarting R resolves the issue.
I can't remember what I did, probably tried several things until I can use _sliceplot again.
There was a
graphFun()
in an earlier version of{mosaicCalc}
. It was introduced with an eye toward making a ggplot2-compatible system of plotting for functions. But we decided to move in a different direction and have written a new suite of ggplot2-compatible graphics for{mosaicCalc}
. These will be deployed in the next CRAN release. We we're delayed from finalizing them due to the ... well ... you know.@Danioy I've put the current version of the new suite in the DEVELOPMENT version of mosaicCalc. You can install it with
remotes::install_github("ProjectMOSAIC/mosaicCalc", ref="beta")
The functions to look at are
contour_plot()
andslice_plot()
.