Reval: R Utilities: Evaluates a String as an Expression in R

Description Usage Arguments Details Author(s) Examples

View source: R/Reval.R

Description

This function evaluates a string as an R expression.

Usage

1
2
3
4
5
Reval(Rstring, print.string=TRUE)

Revalpr(Rstring, print.string=TRUE)	# = Reval( print(Rstring) )

Revalprstr(Rstring, print.string=TRUE)   #  = Reval( print(str(Rstring)) )

Arguments

Rstring

String which shall be evaluated in R

print.string

Should the string printed on the console?

Details

The string is evaluated in the parent environment. See base::eval for the definition of environments in R.

Author(s)

Alexander Robitzsch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# This function is simply a shortage function
# See the definition of this function:
Reval <- function( Rstring , print.string=TRUE){ 
    if (print.string){ cat( paste( Rstring ) , "\n"  ) }
    	eval.parent( parse( text = paste( Rstring )) , n=1 )
            }
  
Reval( "a <- 2^3" )
  ## a <- 2^3 
a
  ## [1] 8  

miceadds documentation built on Aug. 25, 2017, 1:03 a.m.