How do I extract just the number from a named number (without the name)?
问题 I am looking for just the value of the B1(newx) linear model coefficient, not the name. I just want the 0.5 value. I do not want the name \"newx\". newx <- c(0.5,1.5.2.5) newy <- c(2,3,4) out <- lm(newy ~ newx) out looks like: Call: lm(formula = newy ~ newx) Coefficients: (Intercept) newx 1.5 1.0 I arrived here. But now I am stuck. out$coefficients[\"newx\"] newx 1.0 回答1: For a single element like this, use [[ rather than [ . Compare: coefficients(out)["newx"] # newx # 1 coefficients(out)[[