Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to evaluate SSA R code #5

Open
clarkfitzg opened this issue Feb 15, 2018 · 0 comments
Open

not able to evaluate SSA R code #5

clarkfitzg opened this issue Feb 15, 2018 · 0 comments

Comments

@clarkfitzg
Copy link
Contributor

How can the following code be converted to SSA?

library(rstatic)

node0 = quote_ast({
    x = data.frame(a = 1:10, b = letters[1:10])
    x$c = rnorm(10)
    sum(x$a)
    head(x)
})

# We can evaluate this.
eval(to_r(node0))

# Seems to go from a brace to a function
node = to_cfg(node0)
nr = to_r(node)
f = eval(nr)

# But we can't evaluate it here.
f()

Some relevant output:

> f()
Error in x_2$c = rnorm(10) : object 'x_2' not found
> f
function () 
{
    x_1 = data.frame(a = 1:10, b = letters[1:10])
    x_2$c = rnorm(10)
    sum(x_2$a)
    return(head(x_2))
}

It seems we need to add the line x_2 = x_1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant