User Tools

Site Tools


how_to_write_the_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
how_to_write_the_script [2012/12/03 22:57] – [How to write the R script for JUICE?] davidhow_to_write_the_script [2015/12/15 20:18] (current) – david
Line 1: Line 1:
 ====== How to write the R script for JUICE? ====== ====== How to write the R script for JUICE? ======
 JUICE exports data into R via the //bin// folder of R installation (usually at c:/Program files/R/R-x.x.x/bin), and these data could be automatically loaded by appended R script. Files, which should be exported from JUICE, could be either manually selected in JUICE-R wizard, or could be selected automatically according to [[how_to_write_the_script#juice-r_tags|JUICE-R tags]] in R script header. The script, which is uploaded into R from JUICE, has two parts:  JUICE exports data into R via the //bin// folder of R installation (usually at c:/Program files/R/R-x.x.x/bin), and these data could be automatically loaded by appended R script. Files, which should be exported from JUICE, could be either manually selected in JUICE-R wizard, or could be selected automatically according to [[how_to_write_the_script#juice-r_tags|JUICE-R tags]] in R script header. The script, which is uploaded into R from JUICE, has two parts: 
-  *the part created and appended automatically by JUICE, which contains script for uploading data exported from JUICE into appropriate R variables; +  - the part created and appended automatically by JUICE, which contains script for uploading data exported from JUICE into appropriate R variables; 
-  *the part created by the user, which contains the original R script.+  - the part created by the user, which contains the original R script.
  
 ===== JUICE part of the script ===== ===== JUICE part of the script =====
-The complete R script, which JUICE automatically appends to the script file and which is intended for import of the data from JUICE to R, has following structure:+The complete R script, which JUICE automatically appends to the script file (i.e. **this part should not be in the script**, because it will be automatically appended) and which is intended for import of the data from JUICE to R, has the following structure:
 <code rsplus> <code rsplus>
 setwd("C:/Program Files/R/R-x.xx.x/bin/") setwd("C:/Program Files/R/R-x.xx.x/bin/")
Line 13: Line 13:
 JUICE.head <- read.table ('TableHead.txt', sep='\t', head = T) JUICE.head <- read.table ('TableHead.txt', sep='\t', head = T)
 </code> </code>
-The files which JUICE exports in current session depends on JUICE setting. The command //setwd// sets the R working directory, into which the JUICE files are exported and from which R can read them.+The files which JUICE exports in current session depends on which data are being exported. The command //setwd// sets the R working directory, into which the JUICE files are exported and from which R can read them.
  
  
Line 22: Line 22:
 |{{:downloads:table.txt|table.txt}}|JUICE.table  |sample x species matrix  |samples in rows, species in columns; first row - species names((species names are given in a format //genus species_layer//, where layer is represented by a number code: 0 - merged layers, 1 - tree layer, 4 - shrub layer, 6 - herb layer, 7 - juveniles and 9 - mosses))), first column - releve numbers  |samples in rows, species in columns, releve numbers as //rownames//, species names as //names//  | |{{:downloads:table.txt|table.txt}}|JUICE.table  |sample x species matrix  |samples in rows, species in columns; first row - species names((species names are given in a format //genus species_layer//, where layer is represented by a number code: 0 - merged layers, 1 - tree layer, 4 - shrub layer, 6 - herb layer, 7 - juveniles and 9 - mosses))), first column - releve numbers  |samples in rows, species in columns, releve numbers as //rownames//, species names as //names//  |
 |{{:downloads:shorthead.txt|ShortHead.txt}}|JUICE.short.head  |short header data  |samples in rows, three columns with names //Releve_Number//, //Group_Number//, //Short_Head// |samples in rows, short header data in columns (//Releve_Number//, //Group_Number// and //Short_Head//)  | |{{:downloads:shorthead.txt|ShortHead.txt}}|JUICE.short.head  |short header data  |samples in rows, three columns with names //Releve_Number//, //Group_Number//, //Short_Head// |samples in rows, short header data in columns (//Releve_Number//, //Group_Number// and //Short_Head//)  |
-|{{:downloads:speciesdata.txt|SpeciesData.txt}}|JUICE.species.data  |data associated to species  |species in rows, ten columns with names //SpecName_Layer//, //Species_name//, //Layer//, //Species_Data// and species Ellenberg indicator values: //Ellenberg_Light//, //Ellenberg_Temperature//, //Ellenberg_Continentality//, //Ellenberg_Moisture//, //Ellenberg_Soil_Reaction// and //Ellenberg_Nutrients//  |species in rows, species attributes in columns (//SpecName_Layer//, //Species_name//, //Layer//, //Species_Data//, //Ellenberg_Light//, //Ellenberg_Temperature//, //Ellenberg_Continentality//, //Ellenberg_Moisture//, //Ellenberg_Soil_Reaction// and //Ellenberg_Nutrients//)  |+|{{:downloads:speciesdata.txt|SpeciesData.txt}}|JUICE.species.data  |data associated to species  |species in rows, ten columns with names //SpecName_Layer//, //Species_Name//, //Layer//, //Species_Data// and species Ellenberg indicator values: //Ellenberg_Light//, //Ellenberg_Temperature//, //Ellenberg_Continentality//, //Ellenberg_Moisture//, //Ellenberg_Soil_Reaction// and //Ellenberg_Nutrients//  |species in rows, species attributes in columns (//SpecName_Layer//, //Species_name//, //Layer//, //Species_Data//, //Ellenberg_Light//, //Ellenberg_Temperature//, //Ellenberg_Continentality//, //Ellenberg_Moisture//, //Ellenberg_Soil_Reaction// and //Ellenberg_Nutrients//)  |
 |{{:downloads:tablehead.txt|TableHead.txt}}|JUICE.head  |(long) header data  |samples in rows, first two columns are //Table number// and //Releve number//, other columns and their names depends on the original JUICE file  |samples in rows, header data as columns (first two are //Table.number// and //Releve.number//)  | |{{:downloads:tablehead.txt|TableHead.txt}}|JUICE.head  |(long) header data  |samples in rows, first two columns are //Table number// and //Releve number//, other columns and their names depends on the original JUICE file  |samples in rows, header data as columns (first two are //Table.number// and //Releve.number//)  |
  
  
 ===== User's part of the script ===== ===== User's part of the script =====
-The script written by the user and stored in the file with *.r extension. It consists of following parts:+The script **written by the user** and stored in the file with *.r extension. It consists of following parts:
   - header information   - header information
   - JUICE-R tags (setting of export options in JUICE)   - JUICE-R tags (setting of export options in JUICE)
Line 52: Line 52:
 |no.transf  |sample x species data will not be transformed (the transformation setting will be ignored)  | |no.transf  |sample x species data will not be transformed (the transformation setting will be ignored)  |
  
-The line with tags **MUST** begin with # JUICE-R (this is the sign for JUICE that JUICE-R tags follows) and should be located within the first 10 lines of the R script. Tags must be separated by space, and their order does not matter. +The line with tags **MUST** begin with a string **# JUICE-R**((with or without the space between # and JUICE-R)) (this is the sign for JUICE that JUICE-R tags follows) and should be located within the first 10 lines of the R script. Tags must be separated by space, and their order does not matter. 
-Example, which will export sample x species data, header data and run the script in interactive mode (Rgui.exe).+Example, which will export sample x species data, header data and run the script in interactive mode (Rgui.exe((note that Rgui.exe, as well as R.exe, should be written with capital 'R'!))). 
 + 
 +JUICE-R tags can also contain link to website with detail instructions about how to use the script. This link must be the last tag in the sequence, and should start with **<nowiki>http://</nowiki>**. 
 + 
 +Example of JUICE-R tags:
 <code> <code>
-# JUICE-R JUICE.table JUICE.head Rgui.exe+# JUICE-R JUICE.table JUICE.head Rgui.exe http://www.davidzeleny.net/juice-r/doku.php?id=scripts:generalists-specialists
 </code> </code>
 ==== 3. The body of the script ==== ==== 3. The body of the script ====
-This part is up to the R script creater. Try to make it convenient for the user! See [[tips|tips for writing the R script for JUICE-R]].+This part is up to the R script creator. If possible, try to make it convenient for potential users. See [[tips|tips for writing the R script for JUICE-R]].
  
  
how_to_write_the_script.1354546637.txt.gz · Last modified: (external edit)