Learn R Programming

gtools (version 3.9.5)

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

Description

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.

Usage

unByteCode(fun)

assignEdgewise(name, env, value)

unByteCodeAssign(fun)

Value

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

Arguments

fun

function to be modified

name

object name

env

namespace

value

new function body

Author

Gregory R. Warnes greg@warnes.net

Details

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.

The latter two functions no longer work out of the box because assignEdgewise (which unByteCodeAssign uses) makes use of an unsafe unlockBinding call, but running assignEdgewise() will

References

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

See Also

Examples

Run this code

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)
if (FALSE) {
## 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
}

## convert stats:::plotNode from byte-code to interpreted-code
## (no longer available unless assignEdgewise is defined by the user)
## unByteCodeAssign(stats:::plotNode)
## illustrated in https://stackoverflow.com/questions/16559250/error-in-heatmap-2-gplots

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

# now the function does not crash
plot(dend)

Run the code above in your browser using DataLab