I have a table like described below:
in_key | in_id | ro_id | data |
---|---|---|---|
42 | Text | 1 | 1 |
42 | Text | 2 | 1 |
43 | Text | 3 | 0 |
43 | Text | 4 | 0 |
44 | Text | 5 | 0 |
44 | Text | 6 | 0 |
I need to transform this table in format:
ro_1 | ro_2 | ro_3 | in_key | in_id |
---|---|---|---|---|
Value | Value | Value | 42 | Text |
Where values of ro_1, ro_2, etc are taken from corresponding values in data column and indexes in column names such as _1, _2, are taken from values in ro_id column. The in_key value should correspond same as table 1.
How to approach to this in R? In SPSS this transformation can be done easily but I would like to see an R solution for this.
Kinds