0

I have a dataset with 2 columns specifying 'ID' and 3 individual 'Timepoints' that looks like this:

 ID Timepoint Var1 Var2 Var3 Var4 Var5
  1         1  5.7 1.70  4.8  6.8  6.4
  1         2  5.7 4.32  4.2  5.5  7.3
  1         3  5.6 3.16  4.7  5.6  6.3
  2         1  6.1 0.19  5.2  6.2  7.7
  2         2  4.9 4.60  2.4  5.1  7.6
  2         3  3.6 3.85  4.4  5.0  6.4
  3         1  3.7 2.26  3.3  6.2  6.8
  3         2  3.4 2.41  3.5  5.5  7.2
  3         3  5.6 3.20  4.3  5.6  4.7
  4         1  3.0 2.68  3.0  7.4  6.9
  4         2  5.7 1.70  4.8  6.8  6.4
  4         3  5.7 4.32  4.2  5.5  7.3
  5         1  5.6 3.16  4.7  5.6  6.3
  5         2  6.1 0.19  5.2  6.2  7.7
  5         3  4.9 4.60  2.4  5.1  7.6
  6         1  3.6 3.85  4.4  5.0  6.4
  6         2  3.7 2.26  3.3  6.2  6.8
  6         3  3.4 2.41  3.5  5.5  7.2
  7         1  5.6 3.20  4.3  5.6  4.7
  7         2  3.0 2.68  3.0  7.4  6.9
  7         3  5.7 1.70  4.8  6.8  6.4
  8         1  5.7 4.32  4.2  5.5  7.3
  8         2  5.6 3.16  4.7  5.6  6.3
  8         3  6.1 0.19  5.2  6.2  7.7
  9         1  4.9 4.60  2.4  5.1  7.6
  9         2  3.6 3.85  4.4  5.0  6.4
  9         3  3.7 2.26  3.3  6.2  6.8
 10         1  3.4 2.41  3.5  5.5  7.2
 10         2  5.6 3.20  4.3  5.6  4.7
 10         3  3.0 2.68  3.0  7.4  6.9

I have about 450 'Var' columns though, of different data types (not all are numberic), and some with NA values, and have tried a number of methods to get the data looking like this; with a variable created for each of the 3 'Timepoints':

  ID Var1.1 Var1.2 Var1.3 Var2.1 Var2.2 Var2.3 Var3.1 Var3.2 Var3.3
   1    6.4    4.5    4.8    4.0    1.2    2.9    4.4    4.0    4.7
   2    3.4    6.3    6.4    3.3    2.5    1.8    2.2    3.6    2.9
   3    4.8    5.1    4.9    2.9    3.3    2.8    4.1    4.0    4.2
   4    3.6    5.1    6.3    2.7    5.3    2.7    3.8    5.7    4.4
   5    5.5    3.2    5.3    3.2    1.7    3.3    3.5    4.3    3.7
   6    4.1    5.6    7.2    3.4    2.4    2.7    3.6    6.6    4.3
   7    5.2    4.1    5.1    2.5    2.7    2.8    3.8    3.8    3.3
   8    5.1    5.4    5.3    3.0    3.8    2.8    3.8    3.1    5.9
   9    3.0    4.7    5.3    1.5    3.4    1.5    3.1    4.5    3.5
  10    6.6    5.2    5.6    2.7    3.8    2.6    4.3    5.0    5.5

None of my solutions seem to be working, either giving me a dataset with 1 ID column and 1350 accompanying 'var' columns, or error messages.

Is there a solution to obtain this output without removing NA values and with non-numeric data types included (assuming that's part of the issue)?

0 Answers0