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

unByteCode

Convert a Byte-Code Function to an Interpreted-Code Function


Description

Convert a byte-code function to an interpreted-code function

Usage

unByteCode(fun)
assignEdgewise(name, env, value)
unByteCodeAssign(fun)

Arguments

fun

function to be modified

name

object name

env

namespace

value

new function body

Details

The purpose of these functions is to allow a byte coded function to be converted back into a fully interpreted function as a temporary work around for issues in byte-code interpretation.

unByteCode returns a copy of the function that is directly interpreted from text rather than from byte-code.

assignEdgewise makes an assignment into a locked environment.

unByteCodeAssign changes the specified function in its source environment to be directly interpreted from text rather than from byte-code.

Value

All three functions return a copy of the modified function or assigned value.

Note

These functions are not intended as a permanent solution to issues with byte-code compilation or interpretation. Any such issues should be promptly reported to the R maintainers via the R Bug Tracking System at https://bugs.r-project.org and via the R-devel mailing list https://stat.ethz.ch/mailman/listinfo/r-devel.

Author(s)

Gregory R. Warnes greg@warnes.net

References

These functions were inspired as a work-around to R bug https://bugs.r-project.org/bugzilla/show_bug.cgi?id=15215.

See Also

Examples

data(badDend)
dist2 <- function(x) as.dist(1-cor(t(x), method="pearson"))
hclust1 <- function(x) hclust(x, method = "single")

distance <- dist2(badDend)
cluster  <- hclust1(distance)

dend <- as.dendrogram(cluster)

## Not run: 
    ## In R 2.3.0 and earlier crashes with a node stack overflow error
    plot(dend)
    ## Error in xy.coords(x, y, recycle = TRUE) : node stack overflow

## End(Not run)

## convert stats:::plotNode from byte-code to interpreted-code
unByteCodeAssign(stats:::plotNode)

# increase recursion limit
options("expressions"=5e4)

# now the function does not crash
plot(dend)

gtools

Various R Programming Tools

v3.8.2
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, and Thomas Lumley
Initial release
2020-03-23

We don't support your browser anymore

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