Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Reval

R Utilities: Evaluates a String as an Expression in R


Description

This function evaluates a string as an R expression.

Usage

Reval(Rstring, print.string=TRUE, n.eval.parent=1)

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

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

#  Reval( print(round(Rstring, digits)) )
Revalpr_round( Rstring, digits=5, print.string=TRUE)

#  Reval( print(max(abs(Rstring_x - Rstring_y)) ) )
Revalpr_maxabs( Rstring_x, Rstring_y, print.string=TRUE, na.rm=FALSE)

Arguments

Rstring

String which shall be evaluated in R

print.string

Should the string printed on the console?

n.eval.parent

Index of parent environment in which the R command should be evaluated.

digits

Number of digits after decimal.

Rstring_x

String corresponding to an R object

Rstring_y

String corresponding to an R object

na.rm

Logical indicating whether missing values should be removed from calculation

Details

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

Examples

# 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

Some Additional Multiple Imputation Functions, Especially for 'mice'

v3.11-6
GPL (>= 2)
Authors
Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>), Simon Grund [aut] (<https://orcid.org/0000-0002-1290-8986>), Thorsten Henke [ctb]
Initial release
2021-01-21 11:48:47

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.