0

I want to make a wide table with the data from a long table which only has two columns, I´ve tried in many ways but I couldn't do it. What funtion do I need to use?

Long table:

Cepas Valor
B1 5.3
B1 4.25
B1 2.2
B1 2.5
B2 3.15
B2 2.5
B2 5.7

Wide table (expected output):

B1 B2 B3
5.3 3.15 17.8
4.25 2.5 2.6
2.2 5.7 3.1
2.5 2.5 31.1
Jan
  • 2,245
  • 1
  • 2
  • 16
  • please post the data as texts not as images/links – Onyambu Jul 14 '23 at 15:26
  • https://stackoverflow.com/a/57013551/646761 – margusl Jul 14 '23 at 15:30
  • If you only have these two columns, you can just do `unstack(df[2:1])` – Allan Cameron Jul 14 '23 at 15:36
  • Welcome to SO, Carlos Gonzalez! Please do not post (only) an image of code/data/errors: it breaks screen-readers and it cannot be copied or searched (ref: https://meta.stackoverflow.com/a/285557 and https://xkcd.com/2116/). Please include the code, console output, or data (e.g., `data.frame(...)` or the output from `dput(head(x))`) directly into a [code block]. – r2evans Jul 14 '23 at 16:41
  • This question is a duplicate of several others, so it'll be closed shortly. The reason it'll be closed has nothing to do with the quality of your question, the act of closing is meant to allow the answers in the _other_ links to percolate to the top of searches. Hope you stick around StackOverflow! – r2evans Jul 14 '23 at 16:43

0 Answers0