Skip to content

Using R tool to generate simple rst tables

Bill Sacks edited this page Jan 30, 2018 · 1 revision

There is a package in R that could easily convert matrix data into reStructuredText simple table. https://www.rforge.net/doc/packages/knitr/kable.html. With the tool kable in R, you could easily read in a any data sheet (.csv, .txt, ASCII, etc.) into R, or create your own matrix data in R, use the command kable(dataname,format='rst',digit=2) , and then copy and paste the rst table in to your .rst file. There will be only slightly modifications for where you have inline math.

To use R on yellowstone or cheyenne, load R first (module load R), then type R. You could copy and paste R scripts at the interface just like using the interactive ncl. to exit R, type q(). You could run R at background use R CMD BATCH script.R, which will allow you to submit large R jobs to queue.

Here is a simple R script to read in CLM5 parameter file to get crop phenology parameters: /glade/u/home/yaqiong/rsttable/script1.R

Another script that read in an pre-generated .csv file : /glade/u/home/yaqiong/rsttable/script2.R

It will generate rst simple table text, copy and paste the text into .rst and modify the inline math to be correct, then you done.

Clone this wiki locally