Unavoidable task in writing up any scientific paper is to prepare a data table, or rather several of them. You will probably agree that it quite easy to waste a lot of time trying to format such a table so that it complies with in-house rules of the given Journal or just (often worse) our own needs/wishes. Most commonly, we would like to arrange the analyses according to some key, for instance grouping together the analyses coming from the same intrusion or locality. Moreover, we may want to order the analyses within each of the groups according to an additional criterion, say the increasing silica contents. Lastly, the page width is finite and thus there is likely to be a limit on number of analyses we can fit across a page.
Fortunately the new GCDkit comes with a function which makes this ask easier. In fact, it is currently not attached to the menu system and this is exactly the moment when it is good to be a power user, i.e. not afraid to type in a few lines of code. ;-)
The function in question is called
HTMLtableOrderedand outputs the data stored in the numeric matrix specified by parameter
'what'. Optional argument
'which'gives the list of sample names (rows) in the matrix to be saved. The data are first sorted based on
'key2', which typically gives a grouping information (name of a column in
'labs'). Within each of the groups, the data are further sorted based on the numeric variable
'key1'. And the number of analyses across a page is indicated by the parameter
'split.by'.For example, we can produce a table of Large Ion Lithophile Elements (LILE) from our sample datafile,
# Read in the sample data data(sazava) accessVar("sazava") HTMLtableOrdered(WR[,LILE],digits=1,key1="SiO2",key2="Intrusion", title="LILE (ppm)",split.by=7)
There are some other parameters which can be included, for instance the table can have samples in rows, as we are used to from the GCDkit system, and the analyses summed up:
HTMLtableOrdered(WR[,major],digits=2,key1="SiO2",key2="Intrusion", title="Major-element data (wt. %)",split.by=14,rotate=FALSE,sum.up=TRUE)
And here is the last example, generating the table from results, here of the CIPW norm calculation.
results<-CIPW(WR) HTMLtableOrdered(results,digits=2,key1="SiO2",key2="Intrusion", title="CIPW norm",split.by=5)
I just hope you have found the today's tip useful and that it will save you some time to do something more sensible than formatting tables.......