In R, given a data frame df
with column names y,x1,x2,...,xn
, how can I plot xi
vs y
for all xi
in the data frame without manually typing
plot(df$y,df$xi,...)
for all $i$ so that I get n
different plots, with appropriate axis names (the column names) in one swoop?
Edit: My dataframe looks like this
Price SqFt Rooms Something Age
1 53.5 1008 5 2 35
2 49 1290 6 3 36
3 50.5 860 8 2 36
4 49.9 912 5 3 41
5 52 1204 6 3 40
6 55 1024 5 3 10
7 80.5 1764 8 4 64
8 86 1600 7 3 19
And I would like to obtain several separate graphics with Price
on the y-axis, each one having a different column on the x-value. For 4-5 columns one can do it by hand, but I've got dataframes with 200+ columns, so I would like to automatize the process.
I've been reading several similar questions on the site but I haven't had much luck getting the answers to work on my particular situation. I'm not used to handling data frames.
Thank you in advance.
Edit: Apparently I can't even plot SqFt
against Price
, the command
plot(df$SqFt,df$Price)
does not return a scatter plot, but instead this: