Hello,
I need to insert new products in just one column by the id:
uno <- data.frame(id = c(222,223,224,225, 226),
product = c(11,12,13,14,14),
product2 = c(15,16,17,18,19))
How I can obtain this output?
id product
1 222 11
2 222 15
3 223 12
4 223 16
5 224 13
6 224 17
7 225 14
8 225 18
9 226 14
10 226 19
Any alternatives? please
The data set it´s large, so if you have some options, will be very useful
Thank you!
uno <- data.frame(id = c(222,223,224,225, 226),
product = c(11,12,13,14,14),
product2 = c(15,16,17,18,19))
library(tidyverse)
pivot_longer(uno,-id) |>
select(id,product=value)
1 Like
Thank you very much
Thanks!
Note: In the long data set, it appears with a RUT duplicated but I can do it with your code and I added:
uno[!duplicated(uno[c("id")]),]
Regards.
system
Closed
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.