[R] Scatterplot of many variables against a single variable
ispanyolcom at gmail.com
Tue Nov 28 14:40:30 CET 2017
Thanks all users
2017-11-27 23:18 GMT+03:00 Ismail SEZEN <sezenismail at gmail.com>:
> > On 27 Nov 2017, at 11:56, Engin YILMAZ <ispanyolcom at gmail.com> wrote:
> > Dear
> > I try to realize one scatter matrix which draws *one single variable to
> > variables* with *regression line* . You can see my eviews version in the
> > annex .
> > How can I draw this graph with R studio?
> A tiny note; You do calculations in R not RSudio. RStudio is a tool (IDE)
> to use R in an easy way.
> The code below shows how to accomplish this task easily by ggplot. It’s
> adapted from .
> # This is your initial data.frame and you want scatterplots of all
> variables against x1.
> foo <- data.frame(x1 = runif(50, 0, 1),
> x2 = runif(50, 0, 1),
> x3 = runif(50, 0, 1),
> x4 = runif(50, 0, 1))
> # melt data. This is very handy function from reshape2 library.
> foo2 <- melt(foo, "x1”)
> # plot points and add lm lines.
> ggplot(foo2, aes(value, x1)) +
> geom_point() +
> geom_smooth(method=lm) +
> 1- https://stackoverflow.com/questions/24648729/plot-one-
[[alternative HTML version deleted]]
More information about the R-help