-1

(Snipped of data included)enter image description here

Trying to create a long data set using pivot_longer(). Tried the following code:

pivot_longer(problemset7, cols = c(time1, time2, time3, time4), names_to = "time", names_prefix = NULL,
             names_sep = NULL, names_pattern = NULL, names_ptypes = list(),
             names_repair = "check_unique", values_to = "value",
             values_drop_na = FALSE, values_ptypes = list())

With the following error message:

Error: unexpected symbol in:
"             values_drop_na = FALSE, values_ptypes = list()
pivot_longer"
>              names_sep = NULL, names_pattern = NULL, names_ptypes = list(),
Error: unexpected ',' in "             names_sep = NULL,"
>              names_repair = "check_unique", values_to = "value",
Error: unexpected ',' in "             names_repair = "check_unique","
>              values_drop_na = FALSE, values_ptypes = list())
Error: unexpected ',' in "             values_drop_na = FALSE,"

Any advice?

Data set: dput(problemset7)

Lee Drown
  • 35
  • 2
  • 6
  • Please provide the `problemset7` dataframe using `dput`. – Iaroslav Domin Oct 31 '19 at 16:39
  • 1
    Those errors are indicative of code different from what you provided: it suggests that you have a previous call to `pivot_longer` that is missing a right-paren. But since *this* code does not produce those errors (and we don't have sample data), this is unfortunately not something we can reproduce. – r2evans Oct 31 '19 at 16:39
  • Writing `dput(data)` doesn't give us your data—we need the actual output of running that code. Take a look [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on including data in a post. – camille Oct 31 '19 at 17:14

1 Answers1

0
Error: unexpected symbol in:
"             values_drop_na = FALSE, values_ptypes = list()
pivot_longer"

See this line here? It's telling you that before your pivot_longer line, there was a line that ended with values_drop_na = FALSE, values_ptypes = list(), and is clearly missing a second closing parenthesis after the list() (i.e., should be list())).

That should fix it.

iod
  • 7,412
  • 2
  • 17
  • 36