Hi,
I'm stacked with this task. It seems pretty easy, but I don't know how to fix it. I share with you my dataset.
> dput(head(H.D, n =20))
structure(list(Bovine = c("BIN", "BIN", "BIN", "BIN", "BIN",
"BIN", "BIN", "BIN", "BIN", "BTA", "BTA", "BTA", "BTA", "BTA",
"BTA", "BTA", "BTA", "CAQ", "CAQ", "CAQ"), H.D = c(1.04, 1.015,
1.03, 1.051, 1.04, 1.057, 1.078, 1.062, 1.02, 1.024, 1.054, 1.038,
1.023, 1.019, 1.014, 1.016, 1.041, 1.014, 1.027, 1.024)), row.names = c(NA,
20L), class = "data.frame")
I want to built a data frame as follows:
BIN BTA CAQ
values values values
values values values
values values values
... ... ...
I was running this code, but I got this error:
new.df <- df %>%
pivot_longer(names_to = "Bovine", values_to = "H.D")
Error in `$<-.data.frame`(`*tmp*`, "call_text", value = c("data %>% select(Bovine, H.D) %>% data.frame(t(H.D)) %>% ...", :
replacement has 4 rows, data has 3
Thanks in advance