I have a table like:
C1, C2, C3
1 1.1, 2.3, 5.5
2 3.3, 4.3, 2.5
Sample reproducible data:
df <- tribble(
~ C1, ~ C2, ~ C3,
1.1, 2.3, 5.5,
3.3, 4.3, 2.5
)
I am then using the following:
df %>%
mutate(Type = row_number()) %>%
pivot_longer(-Type, names_to = "name", values_to = "Time") %>%
select(-name)
To get it into a format like:
Type Time
1 1.1
1 2.3
1 5.5
2 3.3
2 4.3
2 2.5
How can I create a third column which has the numeric part of C1/C2/C3 to create eg:
Type Time Value
1 1.1 1
1 2.3 2
1 5.5 3
2 3.3 1
2 4.3 2
2 2.5 3