# [R] Scatterplot of many variables against a single variable

Engin YILMAZ ispanyolcom at gmail.com
Tue Nov 28 14:40:30 CET 2017

```Thanks all users

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

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
> all
> > 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 [1].
>
> library(ggplot2)
> library(reshape2)
>
> # 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) +
>   facet_grid(.~variable)
>
>
> 1- https://stackoverflow.com/questions/24648729/plot-one-
> numeric-variable-against-n-numeric-variables-in-n-plots
>
> isezen

--
*Saygılarımla*
Engin YILMAZ

[[alternative HTML version deleted]]

```

More information about the R-help mailing list