Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7198

R function crashes but works when re-assigning parameters of the function before calling it with the same defined parameters

$
0
0

I defined a function called "parseJson".

My function takes 3 parameters i.e. df, id and json.

    parseJson <- function(df,id,json) {...}

When calling my function, I specify the 3 parameters

    dfFinal <- parseJson(df=dfChoices,id="id",json="choices_temp")

which crashes, resulting in this error showing up here :

> dfFinal <- parseJson(df=dfChoices,id="id",json="choices_temp")
     Error in (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x,  : 
     object 'json' not found
     Called from: (function(x, i, exact) if (is.matrix(i)) as.matrix(x)[[i]] else .subset2(x, 
     i, exact = exact))(x, ..., exact = exact)

Though, if I re-assign the values of the 3 parameters of my function before calling the function, there is no problem :

    df=dfChoices
    id="id"
    json="choices_temp"
    dfFinal <- parseJson(df=dfChoices,id="id",json="choices_temp")

I dont have any error, the dataframe dfFinal is produced and is correct.

Any one can help me understand that ?

Thanks


Viewing all articles
Browse latest Browse all 7198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>