0

I am quite new to R and tried t do some data visualization in an R Markdown file. I got the following error when trying to create a piechart using the ggpie package:

Code: ggpie(mydataset, myvariable)

And I got the following error:

Error in PrepareData(data = data, group_key = group_key, count_type = count_type, : object 'myvariable' not found

The variable however exists. When I call mydataset$myvariable in the console, it exists.

When I change the code to ggpie(mydataset, mydataset$myvariable), I get the following Error:

Error in vectbl_as_col_location2(): ! Must extract column with a single valid subscript. ✖ Subscript group_key has size 80 but must be size 1. Backtrace:

  1. ggpie::ggpie(mydataset, mydataset$myvariable)
  2. ggpie:::PrepareData(...)
  3. tibble:::[[.tbl_df(data, group_key)
  4. tibble:::tbl_subset2(x, j = i, j_arg = substitute(i))
  5. tibble:::vectbl_as_col_location2(j, length(x), names(x), j_arg = j_arg)
  6. vctrs::vec_as_location2(j, n, names)
  7. vctrs:::result_get(...) Error in vectbl_as_col_location2(j, length(x), names(x), j_arg = j_arg) :

✖ Subscript group_key has size 80 but must be size 1.

Any ideas? Thanks!

newbie
  • 1
  • Accoding to the docs `ggpie` requires to pass column names as strings, i.e. try `ggpie(mydataset, "myvariable")`. – stefan Jul 13 '22 at 13:31
  • Thank you for your help stefan! I got another error and I have no idea how to solve it... Google is also not of any help: Error in PrepareData(data = data, group_key = group_key, count_type = count_type, : count column is missing in your data. – newbie Jul 19 '22 at 11:43
  • To help you with your second issue you have to provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. If you want to post your data type `dput(NAME_OF_DATASET)` into the console and copy the output starting with `structure(....` into your post. If your dataset has a lot of observations you could do e.g. `dput(head(NAME_OF_DATASET, 10))` for the first ten rows of data. – stefan Jul 19 '22 at 17:48

0 Answers0