rmacroliteChange1Param: Change the value of one parameter from an imported MACRO...

Description Usage Arguments Value Examples

Description

Change the value of one parameter from an imported MACRO parameter file (PAR). If several rows are found that match the parameter tag, all values are changed.

Usage

1
2
rmacroliteChange1Param(x, pTag, type = NULL, value,
  tagNb = NA_integer_)

Arguments

x

A macroParFile object, as obtained with rmacroliteImportParFile-methods.

pTag

Single character string. Text string containing the parameter value that should be searched and replaced in the PAR file, with the parameter value replaced by the string %s. NOTE: CASE SENSITIVE!

type

Single character string. Parameter category (category's header in the PAR file).

tagNb

Vector of integer values. If several rows have the same pTag, indicates which one to change (1 for the 1st, 2 for the 2nd, etc.).

values

New values for the parameter in pTag. Single or vector of integer or real or character (etc.) value(s).

Value

Returns vector of character strings.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library( "rmacrolite" )

#   Path to an example par-file
par_file_path <- system.file( "par-files", 
    "chat_winCer_GW-X_900gHa_d182.par", 
    package = "rmacrolite" )  

#   Import the example par-file
par_file <- rmacroliteImportParFile( 
    file = par_file_path ) 

#   Current value of RUNID
as.numeric( rmacroliteGet1Param( 
     x    = par_file, 
     pTag = "RUNID\t%s", 
     type = "HEAD" ) )

#   Change the RUNID
par_file <- rmacroliteChange1Param( 
    x     = par_file, 
    pTag  = "RUNID\t%s", 
    type  = "HEAD", 
    value = 2L ) 

#   Check new value
new_run_id <- as.numeric( rmacroliteGet1Param( 
     x    = par_file, 
     pTag = "RUNID\t%s", 
     type = "HEAD" ) ) 

new_run_id

#   Internal checks
if( !(new_run_id == 2L) ){
    stop( "Test of rmacroliteChange1Param() failed" )
}   

#   Clean-up
rm( par_file_path, par_file, new_run_id )

julienmoeys/rmacrolite documentation built on May 22, 2019, 6:31 p.m.