variables.null.model <- paste('utalter', 'lcsex', 'utcigreg', 'utbmi', 'month', sep = '+')
variables.full.model <- paste('utalter', 'lcsex', 'utcigreg', 'utbmi', 'month', 'ltedyrs','occ_status', 'marital_status', 'social_cat','GC_linc125_07', 'GC_linc250_07', 'GC_linc500_07', 'GC_linc1000_07', 'GC_linc5000_07', 'GC_pop500_08','utalkkon', 'activity', 'utpyrs', 'cvd', 'utmstati', 'utmfibra', 'utantihy', 'utmeddia', 'utmadins','utwhrat','ul_choln', sep='+')
pollutants_3 <- c('GC_PM10_09', 'GC_PM25_09', 'GC_Coarse_09', 'GC_BS25_09', 'GC_NOX_09', '$GC_NO2_09')
null <- paste(variables.null.model, pollutants_3, sep='+')
full <- paste(variables.full.model, pollutants_3, sep='+')
fun.model.summary <- function(x) {
formula <- as.formula(paste("log_sfrp5 ~", x))
lm <- lm(formula, data = kalonji.na)
coef(summary(lm))
}
lm.summary <- lapply(full, fun.model.summary)
私はいくつかの大気汚染データに取り組んでおり、線形回帰関数を実行して係数を要約したいと考えています。上記のコードがありますが、このエラーが発生します:線形回帰関数の不具合
Error in parse(text = x, keep.source = FALSE) : :1:269: unexpected '$'
私はこれをどのように修正できますか?
「pollutants_3」とは何ですか? 'lapply(c(null、full)、...)'は動作するはずです –
あなたの 'full'変数は長さ1の文字ベクトルです。なぜそれに' lapply'を使いたいのですか? – Istrel
@Istrelもう一度見てください、それは長さ> 1を持っています。 –