Hi there,
I am struggling with restructuring of the following matrix:
vec1 <- c("t1","t2","t1","t2","t1","t2")
vec2 <- c(15,61,44,15,35,11)
vec3 <- c("a", "a" , "b", "b", "c", "c")
vec1 vec2 vec3
t1 15 a
t2 61 a
t1 44 b
t2 15 b
t1 35 c
t2 11 c
I would like to create a new matrix, looks like the following:
a b c
t1 15 44 35
t2 61 15 11
In words:
- the entries in vec3 to be 3 distinct columns or column headers (but only the unique letters a, b & c).
- vec1 to be a column (again only unique values: t1 & t2)
- and vec 3 to become the entries
I would very much appreciate your help, as I am quite new to restructuring data.
Thx,
Felix