Adding a missing GAP package to Sage - sage

A function I want to use in Sage throws an exception because it is missing GAP's package "HAP". I can download this package, but I don't know how to make Sage recognize it.

Well, to answer myself, the relevant page is this.
To install one of these packages, type e.g., the following at the UNIX shell prompt:
sage -i db-jones-2005-11-02
Note that the package name contains the version number, and it will be
downloaded automatically if necessary.

you can type in
sage -optional
to get a list of optional sage packages. install them like
sage -i database_gap
PS: if your download is slow, go into the packages directory on a sage mirror. then copy/paste the full URL.

Related

Julia: Use an older version of a package

I am really new to Julia and confused about using an old version of the SISL Vec package.
I am trying to setup ngsim_env and their instructions require you to use an older v0.1.0 of Vec. But, when I followed the instructions to install the Vec package and then checkout the v0.1.0 tag it didn't work.
Here's what I did
$ julia ../build.jl for some package which includes this block
packages = keys(Pkg.installed())
if !in("Vec", packages)
Pkg.clone("https://github.com/tawheeler/Vec.jl.git")
end
Note: This git URL actually goes to the SISL Vec page.
cd ~/.julia/packages/Vec
git fetch tags
git checkout v0.1.0
I did a bunch of other installations with many other packages. At some point I noticed that there is a package ~/.julia/dev/Vec and ~/.julia/packages/Vec. The one in dev has the correct v0.1.0 code and the one in packages has the newer wrong code. When I tried to use other packages that needed the older Vec they were throwing errors and the paths were to files in the packages directory.
I tried Pkg.rm("Vec"). This did something to the project manifest. After nothing worked, every package would throw errors like KeyError: key "Vec" not found and Pkg.add("Vec") nor original Vec installation helped. I even tried removing both the Vec directories from ~/.julia but that didn't help.
I guess a big question is why does Julia put some packages into packages/ and others into dev/ and how to control which one's get used if the same package appears in both places like Vec is.
Would greatly appreciate any assistance, totally confused.
The dev command fetches a full clone of the package to ~/.julia/dev/
via the docs. The only things I have in my dev directory there are the ones I am developing on my own.
I think that triggered when you did a check out manually with git checkout.
Accordingly:
to stop tracking a path and use the registered version again, use free
Try deleting the packages, and whipping mentions of Vec.jl from your manifest:
(v1.0) pkg> rm Vec
(v1.0) pkg> add https://github.com/tawheeler/Vec.jl.git#0.1.0
In general, try using Pkg when possible, cause it does a lot of house keeping magic in the back
(Also, the repl interface with pkg makes everything easier, so hit ] from a blank julia> to get there. And a quick Pkg.status() or ] st will show you what youre tracking and whats in dev and what version you have pinned, etc.)

Installing Julia on Atom

I am trying to install Julia on Atom. What I made already is that I installed Julia in this folder :
E:\Program files\Users\Zeedo\AppData\Local\Julia-0.6.3
and I installed Atom. Then, I also installed language-Julia package.
Now, when I want to run a code, I get this error:
Julia could not be started.
We tried to launch Julia from:
julia
This path can be changed in the settings.
Details:
'"julia"' is not recognized as an internal or external command,
operable program or batch file.
So, I don't know where should I give the Julia address to the Atom.Or, if you know something that I am doing wrong, please let me know.
Thanks :)
Atom cannot run code by default, so that error message must be being thrown by a community package you've installed. Searching shows me the package is most likely atom-julia-client. And the error seems to be because it can't find the Julia binary it needs to run the program.
First, you should make sure you can run the julia command from the command line directly, which you can check by running julia --version. If this doesn't work, then you need to add the Julia binary to your path.
If the above didn't work, try go to Settings -> Packages -> julia-client. In here, the first setting is Julia Path, which is defaulted to julia (like in the error). Change this to an absolute path, directly to the binary (or to the folder containing the binary; try both if the first doesn't work).
FYI, the language-julia package just gives you syntax highlighting and snippets, and doesn't actually need any Julia stuff to work.

R 3.4.1 "Single Candle" Personal Library Path Error: unable to create ‘NA’

I just updated to R (3.4.1 "Single Candle") on my Linux Mint 18.1 Cinnamon machine and I attempted to install a package. R returned the following:
> install.packages('ggplot2')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("ggplot2") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (y/n) y
Would you like to create a personal library
NA
to install packages into? (y/n) y
Error in install.packages("ggplot2") : unable to create ‘NA’
I have encountered the 'lib not writable' output before but typically it offers a solution like this one:
Would you like to create a personal library
~/R/x86_64-pc-linux-gnu-library/3.4
to install packages into? (y/n) y
Any ideas why the personal library is suggesting NA? Is there a way to manually override this?
I don't know what's causing this problem (i'm also experiencing it on Ubuntu 16.04), but here's a quick workaround:
.libPaths(c("/home/your_username/R/x86_64-pc-linux-gnu-library/3.4/", .libPaths()))
Of course, you can replace "/home/your_username/..." for any another directory (that will store your personal library).
This solution makes install.packages() and library() work. Waiting for a full fix!
EDIT: I should note that this solution is not persistent. That is, it won't last after restarting R. You can fix this by adding the same line of code described above to the /home/your_username/.Rprofile file.
Looking at the details in #Dirk 's comment (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866768) this is a planned behaviour so that packages are installed once for all users of the system.
The solution is to make /usr/local/lib/R/ writable for all users, rather than to re-instate the old behaviour of having a personal package library for every individual user.
Open up a terminal and:
Navigate to /usr/local/lib/ with cd /usr/local/lib/
Change the owner:group so that all users can write to the folder. I happen to have a group on my computer that all users are a member of, so I used that, but see https://askubuntu.com/questions/66718/how-to-manage-users-and-groups for help with setting up a group if necessary
To change ownership use sudo chown owner:group -R R/. owner is an any user, it doesn't really matter. group is the key one; make sure anyone wanting to use R on your system is a member of this group. -R is recursive (i.e. do it to all files and folders in R/).
If you need to change group permissions, use chmod -R 775 R/. This gives the owner and group read, write, and execute permissions, and gives all others read and execute permissions.
Now restart R and you should be able to install packages to your this shared location.
My solution was the following:
In the file /usr/lib/R/etc/Renviron there is a configuration of R.
In lines 43-45 there is:
# edd Jun 2017 Comment-out R_LIBS_USER
#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}
##R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.4/library'}
I have uncommented R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}, restarted RStudio and now it works.
EDIT: Looking at the comments, it seems like a planned behaviour. Here is another solution.
After July 8, 2017 this will resolve all problems
sudo apt-get update
The same happened to me while running the installation procedure for some Bioconductor packages.
Then I realized also I could write this (or similar) on the bash command line:
export R_LIBS_USER=$HOME/R/x86_64-pc-linux-gnu-library/3.4 && R
or
export R_LIBS_USER=$HOME/R/x86_64-pc-linux-gnu-library/3.4 && rstudio
and then run upgrade.packages() (or install.packages(), or biocLite()) inside R.
This way the change is temporary, and you don't have to update any config files.
This shell command is useless if subsequently a command in .Renvironor.Rprofile` sets R_USER_LIBS to a different location during R startup (-check your configuration).
Sticking with in $HOME/R/x86_64-pc-linux-gnu-library/3.X can be desirable
if you have already lots of packages in this location, you want them upgraded/installed there.
I have lots of Bioconductor packages in there, and I don't want them to download again, some of these packages download huge "Omics" datasets when used.
Maybe the partition where /usr/local/lib/R resides has too little disk space or is on a slow drive.
May be this is a bug of R 3.4.1, and my solution is change the line of
R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}
in /etc/R/Renviron file into
R_LIBS_SITE=${R_LIBS_SITE-'~/R/x86_64-pc-linux-gnu-library/3.4.1:/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library'}

r modify and rebuild package

I'm trying to use the SemiMarkov package and I want to change one small line of code in there. I've done some digging via:
getAnywhere("semiMarkov")
& I've identified that I want to change this line:
hessian <- diag(ginv(hessian(V, solution)))
to try something like:
hessian <- diag(ginv(pracma::hessian(V, solution)))
How do I go about this? Do I need to rebuild the package from scratch, and if so do I need rTools etc for this, or is there a simple-ish workaround (I'm a relevant R novice)? I've done some searching online and can't find anything obvious. Any ideas/pointers gratefully appreciated.
If you'd like to simply test out the effect of that change in an interactive R session, you can do so using trace(). Here's how:
Type trace("semiMarkov", edit=TRUE)
In the text editor that that launches, edit the line of interest.
Save the modified file.
Close the text editor
Back in R, use the modified function.
Linux environment
Starting with downloading the package source from CRAN.
This is the landing page: https://cran.r-project.org/web/packages/SemiMarkov/index.html
This is the package source: https://cran.r-project.org/src/contrib/SemiMarkov_1.4.2.tar.gz
Download and extract the source:
wget https://cran.r-project.org/src/contrib/SemiMarkov_1.4.2.tar.gz
tar -xvzf SemiMarkov_1.4.2.tar.gz
This should result in a directory named SemiMarkov. Open up the source (cd SemiMarkov), and modify as necessary.
Next, build the changes:
cd ..
R CMD build SemiMarkov/
This will result in a new archive file named SemiMarkov_1.4.2.tar.gz.
Lastly, install your modified archive:
R CMD INSTALL SemiMarkov_1.4.2.tar.gz
Windows environment
I'm less familiar with the Windows platform. *nix tooling is available in Cygwin, but it's painful. Instead, as Josh O'Brien points out, you should follow the Windows-specific instructions in the R Installation and Administration manual.

Building R igraph package in Win7

I made a small change to the source code of the igraph package because I want to implement the forest fire method based on the breadth first search method.
I used Rtools to build the package and followed the steps as this link. But, I got a error message:
foreign-graphml.c:38:29: fatal error: libxml/encoding.h: No such file or directory.
I tested using the source code, but still had the same error.
I also used the install.packages() method. It still showed the same error.
Update:
I downloaded the Libxml2 and set the bin location to the path. The libxml/encoding.h file is actually in the 'include' folder. Why does this error show?
You can build it at http://win-builder.r-project.org/upload.aspx, just don't forget to change the DESCRIPTION file to include your email address as maintainer.
It is actually quite tricky to build it because Rtools has some fixed (?) paths and it is looking for libraries at specific places, so you need to put them there. We build it with something like
...
if ! (subst | grep -qi ^d:); then
subst d: c:\\
fi
pkg=`ls igraph*.tar.gz`
zip=`echo $pkg | sed 's/.tar.gz/.zip/'`
rfile="r-win/${zip}"
OLDPATH=$PATH
PATH=/cygdrive/c/Program\ Files/R/R-default/bin:/cygdrive/c/Rtools/bin:/cygdrive/c/Rtools/gcc-4.6.3/bin:$PATH
LIB_XML=c:/RCompile/CRANpkg/extralibs64/local R CMD INSTALL -l . $pkg
zip -r ${zip} igraph
PATH=$OLDPATH
...
This uses a cygwin shell. You can get the extra libraries here:
http://www.stats.ox.ac.uk/pub/Rtools/libs.html

Resources