I have a dataframe filter
, which is a subset of dataframe df2
, which was made with dyplr's mutate()
function.
I want to loop through some columns and make scatterplots with them.
My loop:
colNames <- names(filter)[9:47]
for(i in colNames){
ggplot(filter, aes(x=i, y=CrimesPer10k)) +
geom_point(color="#B20000", size=4, alpha=0.5) +
geom_hline(yintercept=0, size=0.06, color="black") +
geom_smooth(method=lm, alpha=0.25, color="black", fill="black")
}
Yet I get no output, nor any errors.
What am I doing wrong?