I'm trying to convert from wide format into long format, but can't find good result. The point is that i need to make it in two ways- using packet Tidyverse, and without it, while i have problems with one way.
that is my data frame:
df2 <- data.frame(name = c("John", "Anna", "Jonte"),
Matematyka = c(2, 3, 5),
Polski = c(5, 5, 4))
and i need to convert the data frame into this:
name subject mark
1 John math 2
2 Anna math 3
3 Jonte math 5
4 John eng 5
5 Anna eng 5
6 Jonte eng 4
i have something like this, but it have some errors (look down)
reshape(df2, direction="long", varying = list(names(df2)[2:3]), v.names =list ("subject","mark"),
idvar = "name")
but its only in one way... I need to make it using tidyverse and without tidyverse package, any ideas?
Error in min(j) : invalid 'type' (list) of argument