dmcglinn / quant_methods

Applied Quantitative Methods course at the College of Charleston
http://dmcglinn.github.io/quant_methods/
Other
18 stars 26 forks source link

changing variables #51

Closed Mckenziematt closed 5 years ago

Mckenziematt commented 5 years ago

HomelessClean$ConcernForSafety <- as.numeric(factor(HomelessClean$ConcernForSafety, levels = c('Never', 'Rarely', 'Sometimes', 'Always')))

I got help recoding my variable in class. It worked when Mcglinn ran it. But when I loaded R again it listed all my data for "ConcernForSafety" as NA instead of in numeric form in the HomelessClean data set

I was wondering if R is assigning things in alphabetical order and if that may be the reason

dmcglinn commented 5 years ago

Hey @Mckenziematt this is just a guess but I think what happened is that we set HomelessClean$ConcernForSafety to integers as the code above suggested. Then you accidentally reran that same line of code. That would cause that variable to become all NA's. When in doubt I always suggest a fresh import of the data.

Mckenziematt commented 5 years ago

Thanks for your help