This is the data frame I'm working with:
datal2<- structure(list(id = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), .Label = c("49180", "75725",
"88743", "172231"), class = "factor"), group = structure(c(1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("Control",
"Intervention"), class = "factor"), time = c(1L, 2L, 3L, 4L,
1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), v6 = c(0.2,
0.27, NA, NA, 0.36, 0.4, 0.35, 0.36, 0.44, 0.57, 0.65, 0.59,
0.67, 0.86, 0.86, 0.78)), reshapeLong = list(varying = structure(list(
v6 = c("v6_Ing", "v6_Alt", "v6_M1", "v6_M3")), v.names = "v6", times = 1:4),
v.names = "v6", idvar = "id", timevar = "time"), row.names = c("49180.1",
"49180.2", "49180.3", "49180.4", "75725.1", "75725.2", "75725.3",
"75725.4", "88743.1", "88743.2", "88743.3", "88743.4", "172231.1",
"172231.2", "172231.3", "172231.4"), class = "data.frame")
I want to order the individuals (id) by the group they belong to.
When I write:
library(lattice)
print(xyplot(v6 ~ time |id+group, groups=group, datal2, aspect = "xy",
type = c("g", "p", "r"),as.table=TRUE,auto.key=TRUE,
xlab = "Measurement times",
ylab = "Gait speed",
scales = list(cex = 1,
x = list(tick.number = 4))))
I got one row of scatter plots for each group, but each row has blank cells for individuals that do not pertain to that group. I would like to get rid of these blank cells.
Thank you for your time and attention.
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-38
loaded via a namespace (and not attached):
[1] compiler_3.5.2 tools_3.5.2 grid_3.5.2