-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I posted a question on Stack Exchange (https://stackoverflow.com/questions/78813213/inline-code-example-for-using-the-symbolic-code-maxima-in-r-via-the-package), and it was recommended that I also post it here:
Does anybody have a worked example for using the package "rim" to run maxima in R with inline code (not RMarkdown)? We currently use maxima in a modelling class, and it would be great to allow students to explore equations symbolically in R. They could then do all numerical work in R (plotting etc.), but call maxima for the analytical pieces.
Thank you for any tips!
For example, some of this code works and some doesn't:
library(rim)
myeqn <- maxima.get("solve((1 + r*(1 - x/K))*x = x, x);")
myint <- maxima.get("integrate(1/(1-x), x);")
df <- data.frame(x = seq(0, 1, by = 0.1))
maxima.eval(myint, code = TRUE, envir = df)
mymat <- maxima.get("matrix([0, 1, a], [1, 0, 1], [1, 1, 0]);")
maxima.get("determinant(mymat);") # Doesn't work
maxima.get("determinant(%o12);") # Does work, using the right output line number for mymat
I would love to see more worked examples of how to go back and forth between R and maxima on the command line.
PS - Thank you for your work on the rim package! It is a much needed addition to the R suite of tools.