Reputation: 13
I am having trouble assigning columns to the strings above them. I believe the proper way to do this is use the attach()
function. I have a csv file loaded with columns of data on Flight
, O.ring
, and Temp
. I have tried to clear previously attached data by using the detach()
function, but have not had any luck.
### Files saved in the directory below
setwd("/Users/newUser/desktop/programming")
data <- read.table("Challenger.csv", header=TRUE)
attach(data)
O.ring
Error: object 'O.ring' not found
Flight
Error: object 'Flight' not found
Temp
Error: object 'Temp' not found
fit1 <- glm(O.ring ~ Temp + Pressure, family=binomial(logit))
Error in eval(expr, envir, enclos) : object 'O.ring' not found
fit1
Error: object 'fit1' not found
Edit: I also need help accessing the columns stored in data to use them to model. Any idea what the problem is with my fit1
?
Upvotes: 1
Views: 3926
Reputation: 99331
Don't use attach()
. Ever. Forget it exists.
glm()
has a data
argument. Using that proves much less stressful.
glm(O.ring ~ Temp + Pressure, family = binomial(logit), data = data)
If you want to know why attach()
is not advisable, see Why is it not advisable to use attach() in R and what should I use instead?
Upvotes: 9