Subset variables by significant P value
问题 I'm trying to subset variables by significant P-values, and I attempted with the following code, but it only selects all variables instead of selecting by condition. Could anyone help me to correct the problem? myvars <- names(summary(backward_lm)$coefficients[,4] < 0.05) happiness_reduced <- happiness_nomis[myvars] Thanks! 回答1: An alternative solution to Martin's great answer (in the comments section) using the broom package. Unfortunately, you haven't posted an data, so I'm using the mtcars