Skip to content

reshape with multiple values #545

Answered by aborruso
masgo asked this question in Q&A
May 30, 2021 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

Hi @masgo ,
starting from

id,item,value1,value2,value3
x,a,1,2,3
x,b,4,5,6
x,c,7,8,9
y,a,10,11,12
y,b,13,14,15
y,c,16,17,18

and running

mlr --csv reshape -r "value" -o k,v then put '$j=$item."-".$k' then cut -x -f item,k then reshape -s j,v input.csv

you will have

id,a-value1,a-value2,a-value3,b-value1,b-value2,b-value3,c-value1,c-value2,c-value3
x,1,2,3,4,5,6,7,8,9
y,10,11,12,13,14,15,16,17,18

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by masgo
Comment options

You must be logged in to vote
4 replies
@masgo
Comment options

@masgo
Comment options

@aborruso
Comment options

@masgo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants