I have two tables that I want to join with different number of rows and different column names(FzR/FzL):
a <- data.frame(FzR = c(130.8616, 130.9943, 131.1719, 131.3771, 131.6092, 131.8660, 132.1437, 132.4384, 132.7980, 133.2867), limb = c("L","L","L","L","L","L","L","L","L","L"), time = c(1.724178, 1.725178, 1.726178, 1.727178, 1.728178, 1.729178, 1.730178, 1.731178, 1.732179, 1.733179))
b <- data.frame(FzL = c(134.8616, 130.9943, 134.1719, 135.3771, 135.6092, 135.8660, 135.1437, 135.4384), limb = c("R","R","R","R","R","R","R","R"), time = c(2.724178, 2.725178, 2.726178, 2.727178, 2.728178, 2.729178, 2.730178, 2.731178))
I would like to join these two tables to look like this:
Fz limb time
130.8616 L 0
130.9943 L 0.01
131.1719 L 0.02
131.3771 L 0.03
131.6092 L 0.04
131.8660 L 0.05
132.1437 L 0.06
132.4384 L 0.07
132.7980 L 0.08
133.2867 L 0.09
134.8616 R 0.10
130.9943 R 0.11
134.1719 R 0.12
135.3771 R 0.13
135.6092 R NA
135.8660 R NA
135.1437 R NA
135.4384 R NA
My objective is to gather the FzR, FzL, and limb columns on top of each other, drop the "time" columns from the a and b dataframes and create a new time vector in the new dataframe, in order to graph Fz versus time according to limb.
Code I have tried:
rename_1 <- names(a)[names(a) == 'FzR'] <- 'Fz'
rename_2 <- names(b)[names(b) == 'FzL'] <- 'Fz'
rbind(rename_1,rename_2)
My thought process was to rename the FzR and FzL column names to a common name of Fz in order to perform an rbind, however this did not give me the correct output. Any help would be much appreciated, thank you.