0

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.

Kian
  • 149
  • 6
  • You must create an object with name x like `x <- ...` to be able to do `result <- fun(x)` – danlooo Sep 09 '21 at 11:19
  • 1
    Would you have a dataset example ? I don't have any error with your code – Basti Sep 09 '21 at 11:20
  • What exactly does "running the code" mean? – Roland Sep 09 '21 at 11:25
  • 1
    Please provide a [reproducible minimal example](https://stackoverflow.com/q/5963269/8107362). Especially, provide some sample data, e.g. with `dput()` and use the [reprex-package](https://reprex.tidyverse.org/). – mnist Sep 09 '21 at 11:59

0 Answers0