Ryacas (google code name ryacas) is an R package that allows R users to access the yacas computer algebra system from within R. It can be used for computer algebra, exact arithmetic, ASCII pretty printing and R to TeX output. R, yacas and Ryacas are all free software packages distributed under the GPL. Samples of Ryacas are in this sample session and in the package vignette. Ryacas is available on CRAN now. Note that work has shifted from this project to http://rsympy.googlecode.com
Below on this page are sections on:
- NEWS
- TECHNOLOGY
- SOURCE REPOSITORY
- STATUS
- R INTERFACE
- SAMPLE SESSION
- MORE INFORMATION
- TEAM
- INSTALLATION
- TROUBLESHOOTING
NEWS
In addition to the NEWS items below see the NEWS file that comes with Ryacas. It is more focused on changes in the package itself than the news listed here.
Mar 12/09. Just found an incompatibility between Ryacas 0.2-9 and XML 2.3-0. Until this is fixed use Ryacas 0.2-7 and XML 1.96-0. If you are having difficulty with this try the rSymPy package instead.
Mar 9/09. UNIX/Linux Installation section further down on this page has been rewritten.
Mar 3/09. Ryacas 0.2-9 is now available on CRAN. Primary change is to require XML 2.1-0 or higher and some fixes to the documentation to pass R CMD CHECK on R 2.9.0. Note that Ryacas seems to work once again with the latest version the XML package, XML 2.1-0. It also worked with XML 1.96-0 but versions of the XML package after XML 1.96-0 but before XML 2.1-0 did not work with Ryacas.
Dec 21/08. Added Troubleshooting instructions on how to use XML 1.96-0 with Ryacas even if you have a newer version of XML installed at the same time.
Nov 16/08. In Troubleshooting section below, Ryacas works with XML package version 1.96-0 but not with XML package version 1.98-1.
May 07/08. In Troubleshooting section below added a tip about deleting .yacCon .
Feb 04/08. Gregor Gorjanc's blog has an article on how to use Ryacas via Sweave in LyX.
Oct 17/07. Added an item to the troubleshooting section that Ryacas 0.2-7 has only been tested with yacas 1.0.63. Windows users of Ryacas 0.2-7 will automatically get yacas 1.0.63 if they use the Ryacas yacasInstall() command to install yacas but users on Mac and UNIX platforms currently need to be aware of this so they install yacas 1.0.63 and not a different version of yacas. The SystemRequirements: line of the Ryacas DESCRIPTION file indicates that yacas 1.0.63 or greater should be used; however, versions greater than 1.0.63 have not been tested and so might not work with Ryacas 0.2-7.
Oct 15/07. Reorganized multiple Installation and multiple Troubleshooting sections (end of this page) into a single section for each with subsections.
Sep 9/07. Version 0.2-7 of Ryacas uploaded to CRAN. Changes include socket timing improvement in yacas.R suggested by Petr Savicky, a new Encoding: line in DESCRIPTION file to handle R 2.6.0 warnings and several other minor changes to handle R 2.6.0 compatability.
Aug 19/07. dep=TRUE is the default for install.packages so instructions have been simplified.
May 13/07. The install.packages('Ryacas', dep = TRUE) command for installing Ryacas on Mac is now the same as on UNIX so the installation sections for Mac and UNIX have been combined into one below.
May 12/07. Ryacas 0.2-6 now on CRAN. Bug fix version. See NEWS.
May 5/07. In Links section to right added new link to CRAN. (Removed links to Omegahat and Ryacas Yahoo group since Ryacas distribution is now via CRAN.)
May 1/07. Ryacas has been uploaded to CRAN. (Previously it was on Omegahat.) Also Ryacas is upgraded to 0.2-5 to accomodate changes in R that were made with R 2.5.0. Earlier versions of R will not work with this version of Ryacas. Note that yacas.exe is no longer included with Ryacas but for Windows users only there does exist a yacasInstall() command that can be issued without arguments from within R to download and install yacas.
Jan 17/06. Added Wikipedia CAS Comparison to Links section on right.
Jan 9/06. The Downloads tab above contains yacas 1.0.63 source code in a .tar.gz file as well as the Windows yacas 1.0.63 binaries in a .zip file. yacas.exe and scripts.dat have been removed from the svn repository in preparation for CRAN -- as CRAN packages cannot have binaries in their source :(
Dec 28/06. Added a note for installing Ryacas under Gentoo on this page in the UNIX TROUBLESHOOTING section below.
Dec 23/06. The Sample Session formerly on this page has been moved to the Wiki. See Wiki tab above.
Dec 6/06. The two vignettes are now combined into one. Click on Ryacas - vignette in Links section to right.
Nov 19/06. The very latest (development) version (to become 0.2-4) is available via svn from the Source tab at top of this page. It is expected that this version will become eventually be available from CRAN. Until then use Ryacas 0.2-3 as in following news items. Anyone who would like to test the development version out, any feedback (to the developers listed under TEAM) would be appreciated.
Nov 19/06. Ryacas 0.2-3 is now available for download from Omegahat via the install.packages command (or the Ryacas on Omegahat - Download links)
Nov 16/06. Ryacas 0.2-3 is available from google groups (see Ryacas on google groups - Download link to right). Note that google groups has the annoying habit of translating dashes in filenames to spaces so after downloading the file you will have to change the name so that any spaces are replaced with dashes.
TECHNOLOGY
Ryacas is written in R. It uses a recursive decent R-to-yacas translator and an XML-based OpenMath yacas-to-R translator. yacas is run as a second process and communicates via a socket interface with R. The design allows for the future possibility of running Ryacas on a low powered client connected to a high power remote yacas compute server over the internet.
SOURCE REPOSITORY
The svn repository on this site (click on Source tab above) contains the source code to Ryacas and generated PDF file for the vignette.
On Windows, yacas.exe and scripts.dat are included in the Ryacas 0.2-3 distribution but not in the Ryacas 0.2-4 or later distributions; however, in those Windows versions not having yacas.exe and scripts.dat there is a yacasInstall() command in Ryacas which allows one to easily fetch and install them from the internet by simply issuing the command yacasInstall() from within R.
STATUS
The package is under development and all aspects of the package are subject to change.
R INTERFACE
There are 8 interfaces. All except runYacas are built on top of yacas.character:
- yacas.character. Pass a raw yacas character string to yacas function. e.g. yacas('x*x')
- yacas.expression. Pass an R expression to yacas function. e.g. yacas(expression(x*x))
- yacas.function. Pass an R function name which defines a one-line R function. e.g. f <- function(x) x*x; yacas(f)
- yacas.formula. Pass an R formula object whose right hand side will be regarded as an expression to pass to yacas.expression. e.g. yacas(~ x*x)
- Sym object. These objects are internally yacas strings. They can be combined with arithmetic operators The print method calls yacas. e.g. x <- Sym('x'); x*x
- Expr object. These objects are internally R expressions. They can be combined with artithmetic operators. e.g. x <- Exprq(x); x*x
- yacmode() which places the session in a mode where one can directly type in yacas commands.
- runYacas(). Shells out to a yacas session.
SAMPLE SESSION
Click on Wiki tab above and then click on Sample Session.
MORE INFORMATION
The R commands
library(Ryacas) package?Ryacas
will display pointers to the help commands, vignette, home page, demos and THANKS, WISHLIST and NEWS files. These files, including pdf versions of the vignette, can also be found in the Source repository by clicking on the Source tab above.
TEAM
- Rob Goedman, goedman at mac dot com
- Gabor Grothendieck, ggrothendieck at gmail dot com
- Søren Højsgaard, Soren.Hojsgaard at agrsci dot dk
- Ayal Pinkus, apinkus at xs4all dot nl
Contact Gabor if you need assistance or Rob if its Mac-related.
INSTALLATION
Choosing a Platform
Ryacas 0.2-4 and later on Windows contains a command, yacasInstall(), that is issued without arguments that will automatically download and install yacas for you, so Ryacas is particularly easy to install on Windows. Also there are a few extra commands available on Windows: yacasFile and yacasCheck that are not available on Ryacas in other operating systems. Thus if you have a choice of platforms you may wish to use Windows.
The development of Ryacas was primarily done on Windows and Mac so next best choice would be Mac.
We have had reports of successful use on UNIX too; however, because there has not been recent development on that platform some troubleshooting of the installation may be necessary on UNIX. There is a UNIX troubleshooting section below just in case.
Windows Installation
Note that this information is not currently correct. Instead you must use Ryacas 0.2-7 and XML 1.96-0. If you are having difficulty with this try the rSymPy package instead.
Note: Ryacas on Windows has been tested under Windows XP but we have run it on Vista and not noticed any problems. On Vista you may need to run R as Administrator (right click R icon and choose Run As Administrator) while installing Ryacas depending on your configuration. We do not have any pre Windows XP machines available to test it on but if you do the team would appreciate any feedback on whether or not it works in such an environment.
Issue these three commands in R. They will install Ryacas from CRAN, load it and download yacas from the internet into R_HOME\library\Ryacas\yacdir (where R_HOME refers to your R installation folder:
install.packages('Ryacas')
# library(XML)
library(Ryacas)
yacasInstall()Replace the commented out library command with something like:
library(XML, lib = file.path(Sys.getenv("R_LIBS_USER"), "../2.7"))or possibly just this:
library(XML, lib = "~/R/win-library/2.7")
if you don't have XML 1.96-0 installed under your current version of R but do have it under an installation of R 2.7 on the same machine.
UNIX/Linux/Mac Installation
Note that this information is not currently correct. Instead you must use Ryacas 0.2-7 and XML 1.96-0. If you are having difficulty with this try the rSymPy package instead.
- Install GSL
- Download "http://ryacas.googlecode.com/files/yacas-1.0.63.tar.gz" and extract.
- Follow the instructions in section C in yacas-1.0.63/INSTALL, where in the confuguration step, be sure to include the option "--enable-server":
- Install Ryacas. i.e. from within R issue this command:
wget http://ryacas.googlecode.com/files/yacas-1.0.63.tar.gz tar zvxf yacas-1.0.63.tar.gz
./configure --enable-server
install.packages("Ryacas")or, alternately, from the shell enter:R CMD INSTALL Ryacas_1.0.63.tar.gz
TROUBLESHOOTING
There seems to be an incompatibility between Ryacas 0.2-9 and XML 2.3-0. Until this is fixed use Ryacas 0.2-7 and XML 1.96-0.
Most installation problems are caused by one of these:
- using the wrong version of the XML package. The latest version of the XML package, version 2.1-0, should work ok as should version 1.96-0 and prior; however, a number of versions of the XML package between those two versions did not work with Ryacas.
- not using yacas 1.0.63 with Ryacas 0.2-9 (Windows users can use the Ryacas yacasInstall() command which will automatically find the correct yacas version on the net and install it. Others can find yacas here.
- forgetting to download and install yacas (see last point)
- yacas was not built with the server enabled
- yacas is not started in server mode -- this is different from its normal interactive mode
- a left over .yacCon variable in your workspace from a failed attempt can be a problem. In that case just delete it: rm(.yacCon)
- yacas is not being intialized to start in OpenMath mode. This is the mode where XML output is generated. A yacas command is normally issued automatically to do that but if somehow this command does not get issued the session will fail to work:
PrettyPrinter("OMForm");UNIX/Linux Troubleshooting
Here are some of the common problems that UNIX/Linux/Mac users encounger:
1. Startup Timing Issues. (Ryacas 0.2-7 has fixed this but we have left this point in just case.) The first time you issue the yacas command in each session Ryacas is supposed to start the yacas process; however, there can be timing problems on some systems so if it does not start up just issue another yacas command and it will likely start.
2. Telnet problems. If you are unable to get a connection at all try to connect to yacas manually using
telnet localhost 9734
making sure that yacas is indeed running since you cannot telnet to a process that is not there! Also read the link 'Ryacas & Telnet' in the links section of this page. If you think you have telnet problems that you cannot resolve then you can run Ryacas without telnet but that will result in no memory from one command to the next. To run without telnet use the method = 'system' argument on yacas or set the yacas.method option to 'system'.
options(yacas.method = 'system')
x <- Sym('x')
x*x3. Startup Configuration Problems. The following should normally not be needed but if you are having problems even after the above, try entering this into R to configure your system. One Debian user indicated that this solved his problem in getting Ryacas to work:
cat("PrettyPrinter('OMForm');\n", file = "~/.yacasrc")
Sys.setenv(YACAS_INVOKE_STRING = 'yacas -pc --server 9734')The cat line above only has to be done once while the second line needs to be done before each Ryacas session. Please contact one of the developers if you find this is necessary so we can keep track of this.
4. FC and Others. HowTo: Ryacas Installation on FC discusses how to get Ryacas working on Fedora systems. Some of the information here may apply to other UNIX systems too. Warning: Some of the info in that link may be outdated now.
5. Gentoo. One Gentoo user of Ryacas found that Gentoo does have Yacas in its Portage package repository, but it installs without the '--enable-server' option so install Yacas from source and configure with the '--enable-server' option as Marc Schwartz did on Fedora Core (see previous point, #4). Then change the Use statement in R.ys to an absolute path so that R.ys looks like this:
// Start with the default initialization, R-specific initialization to follow
Use('/usr/local/share/yacas/yacasinit.ys');
PrettyPrinter('OMForm'); 6. One user was finding he could only launch yacas when logged in as root. After deleting the .yacCon variable -- rm(.yacCon) -- that had been left over from a failed attempt this rectified itself.
7. Note that on UNIX you may need to detach the Ryacas package prior to exiting R:
detach() # assuming Ryacas was last one loaded
or
stopYacas()
8. Make sure that yacas is in the PATH environment variable. This is usually guaranteed by the "make install" step of the compilation of Yacas. However, you may easily verify it. Typing "yacas" to the command line should start an interactive Yacas session.
9. When installing Ryacas be sure to use
./configure --enable-server