Skip to content

Instantly share code, notes, and snippets.

@hadley
Created March 3, 2011 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hadley/852917 to your computer and use it in GitHub Desktop.
Save hadley/852917 to your computer and use it in GitHub Desktop.
windows.r

Installing rggobi

The two scripts below give the most up-to-date instructions for installing rggobi on windows and mac. They should install everything you need, from Gtk2 to ggobi to rggobi.

To install:

  • On windows, copy and paste windows.r into R, and then run install_all().

  • On the mac, open the terminal, and copy and paste the commands from mac.sh below

If you have problems, try:

  • Installing the latest version of R

  • (On windows) Running R as administrator (right click on the shortcut to R and click "Run as administrator")

If you still have problems, please email the ggobi mailing list, providing any error messages as well as the output from sessionInfo() in R.

# Install gtk
curl -O http://r.research.att.com/libs/GTK_2.18.5-X11.pkg
open GTK_2.18.5-X11.pkg
# Install ggobi
curl -O http://r.research.att.com/libs/ggobi-2.1.8-darwin9-bin3.tar.gz
sudo tar fvxz ggobi-2.1.8-darwin9-bin3.tar.gz -C /
# Install rggobi
export PATH=/usr/local/ggobi/bin:/Library/Frameworks/GTK+.framework/Resources/bin:$PATH
export PKG_CONFIG_PATH=/usr/local/ggobi/lib/pkgconfig:/Library/Frameworks/GTK+.framework/Resources/lib/pkgconfig
R
install.packages("rggobi", type = "source")
## depending on where you installed GTK+, you may need to run this script as administrator
## (right click on the shortcut of R --> Run as administrator)
#' @param reinstall If TRUE, reinstall everything
install_all <- function(reinstall = FALSE) {
oldwd <- setwd(tempdir())
on.exit(setwd(oldwd))
cran <- "http://cran.r-project.org/"
# Gtk and RGtk2 ------------------------------------------------------------
if (!is_installed("gtk") || reinstall) {
message("Installing Gtk")
url <- "http://downloads.sourceforge.net/gtk-win/gtk2-runtime-2.22.0-2010-10-21-ash.exe?download"
download.file(url, basename(url), mode = "wb")
shell.exec(basename(url))
}
if (!is_installed("rgtk2") || reinstall) {
message("Installing RGtk2")
install.packages("RGtk2", repos = cran)
}
# Missing dlls -------------------------------------------------------------
gtk_path <- dirname(Sys.which("libcairo-2.dll"))
if (!is_installed("libxml2")) {
message("Installing libxml2")
url <- "http://yihui.name/fun/libxml2.dll"
download.file(url, file.path(gtk_path, "libxml2.dll"), mode = "wb")
}
if (!is_installed("iconv")) {
message("Installing iconv")
url <- "http://yihui.name/fun/iconv.dll"
download.file(url, file.path(gtk_path, "iconv.dll"), mode = "wb")
}
# GGobi and rggobi ---------------------------------------------------------
if (!is_installed("ggobi") || reinstall) {
message("Installing GGobi")
ggobi.url <- "http://www.ggobi.org/downloads/ggobi-2.1.8.exe"
download.file(ggobi.url, basename(ggobi.url), mode = "wb")
shell.exec(ggobi.exe)
}
if (!is_installed("rggobi") || reinstall) {
message("Installing rggobi")
install.packages("rggobi", repos = cran)
}
message("Installation completed. Run the following code to test")
message("library(rggobi); ggobi(mtcars)")
}
is_installed <- function(pkg) {
in_path <- function(x) length(Sys.which(x)) > 0
pkg_installed <- function(x) system.file(package = x) != ""
switch(pkg,
ggobi = in_path("ggobi"),
rggobi = pkg_installed("rggobi"),
gtk = in_path("libcairo-2.dll"),
rgtk2 = pkg_installed("RGtk2"),
libxml2 = in_path("libxml2.dll"),
iconv = in_path("iconv.dll")
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment