I'm running data through linear regression and discovered outliers. I've tried data=dataframe[-c("country1", "country2"),]
but the outliers still appear. Can I get some help here? Thank you
#Remove outliers
fit <- lm(Robbery ~ Unlawful.acts.involving.controlled.drugs.or.precursors,
data=NoNACountry[-c("Spain", "Luxembourg"),])
par(mfrow=c(2,2))
plot(fit)
I think I've somehow lost the row names, because I think the Robbery
and Unlawful.acts...
have become vectors? I used the Country names are row labels and the Robbery
and Unlawful.acts...
are columns. I have been able through guidance from here, to use drop = FALSE
in other code, but I have not been able to incorporate this approach here
Dataframe information is below
structure(list(Intentional.homicide = c(2.03, 0.84, 1.14), Attempted.intentional.homicide = c(3.25,
1.93, 0.54), Assault = c(5.52, 43.29, 39.54), Kidnapping = c(0.14,
0.07, 1.03), Sexual.violence = c(5.38, 50.9, 8.64), Robbery = c(3.42,
29.67, 16.9), Unlawful.acts.involving.controlled.drugs.or.precursors = c(70.26,
494.05, 78.14), Country.Totals.per.000s = c(90, 620.75, 145.93
)), row.names = c("Albania", "Austria", "Bulgaria"), class = "data.frame")