MY DATA
I have a data.frame Movement
that contains X and Y column with positional data that belongs to a subject (ID)
. There are 300+ subjects in my dataset, imported in R from a .csv file. The following is a (small) example of my data.
X1 <- c(10.83, 11.91, 12.32)
Y1 <- c(25.26, 27.81, 27.96)
ID1 <- c("John", "John", "John")
X2 <- c(14.73, 15.95, 15.97)
Y2 <- c(21.29, 22.83, 23.36)
ID2 <- c("Tom", "Tom", "Tom")
WHAT I WISH FOR IT TO LOOK LIKE
Merge all the columns into three and have Movement
be:
X <- c(10.83, 11.91, 12.32,14.73, 15.95, 15.97)
Y <- c(25.26, 27.81, 27.96, 21.29, 22.83, 23.36)
ID <- c("John", "John", "John", "Tom", "Tom", "Tom")
WHAT I HAVE TRIED
Merge and stack, although this combine my X
and Y
values into one Value
which I do not want. I feel it is a simple question but I am stuck, any assistance please?
Thank you.