Tuesday 23 May 2017

Batch / Console mode

One of the nice features in the recent versions of GCkit is that it can be ran without any graphical user interface, just by typing commands in the console.

What good is it, will you say ? Well:
  • It saves time. After a while it gets a bit annoying to have to go to "plot", "binary", select X variable, select Y variable "ok", "ok"... Isn't it easier, and faster, to just type binary("SiO2","Rb/Sr") ? I think so.
  • It is reproducible. You can copy a string of commands to a file, and re-run the file every time you need it, perhaps because you've updated the dataset, or you're doing the same thing with all of your data anyway.
  • Since it does not rely on the GUI, it is platform-independent (ha-ha !).  So this allows to use GCDkit on platforms other than windows.

All the commands that are found in the menus can be used from the command line (and, in fact, even more or at least with more flexibility). So you may, for instance, run the following scripts (borrowed from the latest workshop in Catania).
In all examples, you may either copy the commands to a text file, that you save as "something.r", and then drag and drop the r-file to your console; or type each command in succession into the console.
Also, we assume in each example that you have the relevant data files, stored in a directory that happens to be, in this case, C:\\Users\\admin\\Documents\\R code\\.The datafiles are from the book.

Example 1 (loading and grouping data; simple calculations)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("sazava.data",sep="\t")
print(WR[,"A/CNK"])

     Sa-1      Sa-2      Sa-3      Sa-4      Sa-7     SaD-1     Gbs-1    Gbs-20     Gbs-2     Gbs-3
0.8355344 0.7618697 0.8078703 0.7193632 0.9617544 0.8418038 0.4370269 0.5549208 0.7506752 0.8598510
     Po-1      Po-3      Po-4      Po-5
0.9716144 1.0248678 1.0129914 1.169989

groupsByLabel("Intrusion")
summaryByGroup(LILE,show.boxplot=TRUE)
print(results)
results<-CIPW(WR)
spider(WR,"Boynton",plot=FALSE) # Calculation only
print(results)

Example 2 (simple diagrams)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("dolerites_test.data",sep="\t")

# Binary plot

binary(x="SiO2",y="Y",ymin=0,ymax=50,main="My Binary plot")

figCex(1.8)

# A single classification diagram, zoom in

plotDiagram("LarochePlut",F,F)

figXlim(c(1000,2700))

figYlim(c(1000,2500))

figRemove()

# Harker plot (a simple plate)

multipleMjr("SiO2")

plateCex(1.7)

plateCexLab(1.2)

plateXLim(c(45,60))

plateBW()

Example 3 (Custom plates)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("dolerites_test.data",sep="\t")

# Custom plate

multiplePerPage(4,nrow=2,ncol=2,dummy=F,title="Geotectonic")

plotDiagram("Meschede",F,F,main=" ")

plateExtract("Wood",3,main=" ")

plotDiagram("PearceNbThYb",F,F,main=" ")

plotDiagram("PearceNbTiYb",F,F,main=" ")

plateLabelSlots(text=letters,cex=1.5,pos="topleft")

plateCex(1.7)

plateCexLab(1.2)





(this example involves still a lot of clicking in dialogs, so it is not too likely to work in non-windows environments)

Example 4 (spiderplots)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("dolerites_test.data",sep="\t")

groupsByLabel("region")

# REE spider

spider(WR,"Boynton",1,100,pch="*",col="blue",cex=2)

spider.contour("Boynton","MgO","jet.colors",ymin=1,ymax=100,
 
pch=15)


# NMORB Sun and McDonough

spider(WR,"^NMORB..Sun",0.1,500,offset=TRUE)

figMulti(shaded.col="khaki",plot.symb=FALSE,nrow=2,ncol=2)

plateLabelSlots(text=letters,cex=1.5,pos="bottomright")

plateCex(2)

plateCexLab(2)

plateBW()