Suggestion [General Statistics]
❝ # remove subjects who has imcomplete periods. More elegant solution?
❝ library(dplyr)
Didn’t know this package. The syntax within some functions (i.e., the
%>%
-operator) is – well – unconventional.Code to keep only subjects completing all four periods:
summary(ema[2:4]) # show structure
per.4 <- summary(ema$subj) == 4 # subjs have 4 levels?
incomp <- per.4[per.4 == FALSE] # incomplete ones
print(sort(names(incomp)))
comp <- per.4[per.4 == TRUE] # complete ones
print(sort(names(comp)))
d <- subset(ema, subj %in% names(comp))
print(d)
summary(d[2:4])
seq1 <- as.numeric(summary(d[, 3])[names(summary(d[, 3]))[1]])
seq2 <- as.numeric(summary(d[, 3])[names(summary(d[, 3]))[2]])
if(seq1 == seq2) {
txt <- "Balanced: "
} else {
txt <- "Unbalanced: "
}
cat(paste0(txt, names(summary(d[, 3]))[1], "=", seq1, ", ",
names(summary(d[, 3]))[2], "=", seq2, "\n"))
Which subjects are incomplete?
print(sort(names(incomp)))
gives[1] "11" "20" "24" "31" "42" "67" "69" "71"
summary(d[2:4])
gives per seq treat
1:69 RTRT:144 R:138
2:69 TRTR:132 T:138
3:69
4:69
Unbalanced: RTRT=144, TRTR=132
ema$subj <- as.factor(paste0("Sub #", ema$subj))
levels(ema$seq)[levels(ema$seq)=="RTRT"] <- 1
levels(ema$seq)[levels(ema$seq)=="TRTR"] <- 2
levels(ema$treat)[levels(ema$treat)=="T"] <- "A"
levels(ema$treat)[levels(ema$treat)=="R"] <- "B"
print(sort(names(incomp)))
[1] "Sub #11" "Sub #20" "Sub #24" "Sub #31" "Sub #42" "Sub #67" "Sub #69"
[8] "Sub #71
summary(d[2:4])
per seq treat
1:69 1:144 B:138
2:69 2:132 A:138
3:69
4:69

Edit: Once I saw Detlew’s code below, I can only say about my snippet: Forget it!
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- SAS and R (?) for variability comparison (FDA NTID Guidance) Shuanghe 2015-09-25 18:48 [General Statistics]
- SAS and R (?) for variability comparison (FDA NTID Guidance) jag009 2015-09-25 22:42
- SAS and R (?) for variability comparison (FDA NTID Guidance) Shuanghe 2015-09-28 17:05
- LaTeX, MathML, PNGs Helmut 2015-09-27 14:23
- OT: LaTeX, MathML, PNGs Shuanghe 2015-09-28 17:32
- OT: LaTeX, MathML, PNGs Helmut 2015-09-28 17:46
- OT: LaTeX, MathML, PNGs Shuanghe 2015-09-28 17:32
- Quantiles of the F-distribution d_labes 2015-09-28 09:45
- Quantiles of the F-distribution Shuanghe 2015-09-28 17:39
- What's wrong with this picture? Shuanghe 2015-09-28 18:57
- SuggestionHelmut 2015-09-29 02:22
- Suggestion Shuanghe 2015-09-29 18:44
- OT: The Hadleyverse d_labes 2015-09-30 08:44
- Suggestion Shuanghe 2015-09-29 18:44
- Another suggestion for a R-solution d_labes 2015-09-29 14:26
- Wow – another gem from the master! Helmut 2015-09-29 16:31
- Another suggestion for a R-solution Shuanghe 2015-09-29 18:37
- Another R-solution d_labes 2015-09-29 21:55
- @Shuanghe: Outdated URL gvk 2019-05-21 11:36
- SuggestionHelmut 2015-09-29 02:22
- SAS and R (?) for variability comparison (FDA NTID Guidance) M.tareq 2017-04-14 15:04
- SAS and R (?) for variability comparison (FDA NTID Guidance) M.tareq 2017-04-15 01:01
- SAS and R (?) for variability comparison (FDA NTID Guidance) jag009 2015-09-25 22:42