我有一个数据框:
> head(APD.dataframe)
Serial_number Lot Wafer Irradiated Amplification Voltage Dark_current
1 912009913 9 912 0 1.00252 24.9681 0.000059
2 912009913 9 912 0 1.00452 29.9591 -0.002713
3 912009913 9 912 0 1.00537 34.9494 -0.018948
4 912009913 9 912 0 1.00560 44.9372 -0.023865
5 912009913 9 912 0 1.00683 49.9329 -0.032359
6 912009913 9 912 0 1.00690 54.9625 -0.039507
我想根据Serial_number
从其中减去一些数据点:
library(dplyr)
APDmin_irr<- APD.frame_irr %>% group_by(Serial_number, Threshold) %>% top_n(n, Amplification) %>% ungroup()
APDmin_irr<- APDmin_irr[!APDmin_irr$Threshold == "No", ]
APDmax_irr<- APD.frame_irr %>% group_by(Serial_number, Threshold) %>% top_n(-n, Amplification) %>% ungroup()
APDmax_irr<- APDmax_irr[!APDmax_irr$Threshold == "Yes", ]
APD_irr<- rbind(APDmin_irr, APDmax_irr)
APD_irr<- with(APD_irr, APD_irr[order(Serial_number, Amplification),])
APD_irr$Threshold<- NULL
然后我适合以下数据框:summary(fit3_irr<- lmer(log(log(Amplification)) ~ poly(Voltage, 3) + (poly(Voltage, 3) | Serial_number), REML = FALSE, data = APD_irr))
现在的问题是,我想通过使用ggeffects()
来利用ggpredict(fit3_irr)
,我收到以下错误:
ggeffect(fit3_irr)
Error: Unknown column `log(log(Amplification))`
In addition: Warning message:
'glue::collapse' is deprecated.
Use 'glue_collapse' instead.
See help("Deprecated") and help("glue-deprecated").
据我了解,这是由于group_by
开头的dplyr
造成的。但是我无法将其删除。想过使用ungroup()
,但是我不了解它是如何工作的,或者它通常无法工作:
APDmin_irr<- APD.frame_irr %>% group_by(Serial_number, Threshold) %>% top_n(n, Amplification) %>% ungroup()
APDmin_irr<- APDmin_irr[!APDmin_irr$Threshold == "No", ]
APDmax_irr<- APD.frame_irr %>% group_by(Serial_number, Threshold) %>% top_n(-n, Amplification) %>% ungroup()
APDmax_irr<- APDmax_irr[!APDmax_irr$Threshold == "Yes", ]
APD_irr<- rbind(APDmin_irr, APDmax_irr)
APD_irr<- with(APD_irr, APD_irr[order(Serial_number, Amplification),])
APD_irr$Threshold<- NULL
我使用R 3.4.4
编辑:数据框的一部分:
Serial_number Lot Wafer Irradiated Amplification Voltage Dark_current
1 608004648 6 608 1 111.997 379.980 0.386364
2 608004648 6 608 1 123.673 381.968 0.381323
3 608004648 6 608 1 137.701 383.979 0.411581
4 608004648 6 608 1 154.514 385.973 0.460648
5 608004648 6 608 1 175.331 387.980 0.506632
6 608004648 6 608 1 201.379 389.968 0.554607
7 608004649 6 608 1 118.753 378.080 0.960515
8 608004649 6 608 1 131.739 380.085 1.060070
9 608004649 6 608 1 147.294 382.082 1.195970
10 608004649 6 608 1 166.238 384.077 1.369470
11 608004649 6 608 1 189.841 386.074 1.576770
12 608004649 6 608 1 220.072 388.073 1.849820
...