3
Hi,
I have the following situation:
I have a data frame with several columns, a group of them I want to transform into key value. So far so good, but there are 2 groups and they can’t just sort of repeat themselves. Like, it’s a group of 3 and another group of 3
NOME A1 A2 A3 B1 B2 B3
batata 6 4 7 2 1 1
maçã 9 4 8 1 2 0
I did Gather 2 times, one for A1 A2 A3 and one for B1 B2 B3. The problem is that the resulting line number is 2*3*3 = 18, as it takes a result from A and makes a row for each result of B
NOME keyA valueA keyB valueB
batata A1 6 B1 2
batata A1 6 B2 1
batata A1 6 B3 1
maçã A1 9 B1 2
maçã A1 9 B2 1
maçã A1 9 B3 1
..........(same process with A2 and A3)
What I need is for each value of A1, I have only key B1, A2 only B2, etc. So:
NOME keyA valueA keyB valueB
batata A1 6 B1 2
batata A2 4 B2 1
batata A3 7 B3 1
maçã A1 9 B1 1
maçã A2 4 B2 2
maçã A3 8 B3 0
Only 6 lines
Can anyone help me? xd
Daniel, I had done just that. Just go open here to post the same answer that you put kkkkkk. Still thank you so much!
– Geovani Ferreira
kkkk that good! read your thought :P
– Daniel Falbel