getting error when making Function: Error in value.var %in% names(data) : object 'x' not found

There is something wrong in my function getting error:

Here is the code:

fun <- function(x){
        reshape2::dcast(x, formula = PROVINCE + DISTRICT ~ DAILY_LANG,
                        value.var = "WEIGHT", fun.aggregate = sum)
}

By running the code getting this error:

Error in value.var %in% names(data) : object 'x' not found

Appreciate your help.

We need a reproducible example (reprex)

I think though that we ma just teed some usable data. A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.