Scatterplot of many variables against a single variable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Scatterplot of many variables against a single variable

Temel İspanyolca
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?


Sincerely
Engin YILMAZ
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Jim Lemon-4
Hi Engin,
Sadly, your illustration was ambushed on the way to the list. Perhaps
you want something like this:

# proportion of useful answers to your request
pua<-sort(runif(20))
#legibility of your request
lor<-sort(runif(20))+runif(20,-0.5,0.5)
# is a data set provided?
dsp<-sort(runif(20))+runif(20,-0.5,0.5)
# generate a linear model for the above
pua.lm<-lm(pua~lor+dsp)
# get the coefficients
pua.lm

Call:
lm(formula = pua ~ lor + dsp)

Coefficients:
(Intercept)          lor          dsp
    0.1692       0.6132       0.3311

plot(pua~lor,col="red",main="Proportion of useful answers by request quality")
points(pua~dsp,col="blue",pch=2)
abline(0.1692,0.6132,col="red")
abline(0.1692,0.3311,col="blue")

So, the more readable your request and the quality of the data that
you provide, the more useful answers you are likely to receive.

Jim


On Mon, Nov 27, 2017 at 7:56 PM, Engin YILMAZ <[hidden email]> 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?
>
>
> Sincerely
> Engin YILMAZ
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Eric Berger
LOL. Great reply Jim.
(N.B. Jim's conclusion is "debatable" by a judicious choice of seed. e.g.
set.seed(79) suggests that making the request more readable will actually
lower the number of useful answers. :-))


On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon <[hidden email]> wrote:

> Hi Engin,
> Sadly, your illustration was ambushed on the way to the list. Perhaps
> you want something like this:
>
> # proportion of useful answers to your request
> pua<-sort(runif(20))
> #legibility of your request
> lor<-sort(runif(20))+runif(20,-0.5,0.5)
> # is a data set provided?
> dsp<-sort(runif(20))+runif(20,-0.5,0.5)
> # generate a linear model for the above
> pua.lm<-lm(pua~lor+dsp)
> # get the coefficients
> pua.lm
>
> Call:
> lm(formula = pua ~ lor + dsp)
>
> Coefficients:
> (Intercept)          lor          dsp
>     0.1692       0.6132       0.3311
>
> plot(pua~lor,col="red",main="Proportion of useful answers by request
> quality")
> points(pua~dsp,col="blue",pch=2)
> abline(0.1692,0.6132,col="red")
> abline(0.1692,0.3311,col="blue")
>
> So, the more readable your request and the quality of the data that
> you provide, the more useful answers you are likely to receive.
>
> Jim
>
>
> On Mon, Nov 27, 2017 at 7:56 PM, Engin YILMAZ <[hidden email]>
> 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?
> >
> >
> > Sincerely
> > Engin YILMAZ
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Temel İspanyolca
Dear Berger and Jim

Can you see my eviews example in the annex? (scattersample.jpg)

Sincerely
Engin

2017-11-27 13:27 GMT+03:00 Eric Berger <[hidden email]>:

> LOL. Great reply Jim.
> (N.B. Jim's conclusion is "debatable" by a judicious choice of seed. e.g.
> set.seed(79) suggests that making the request more readable will actually
> lower the number of useful answers. :-))
>
>
> On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon <[hidden email]> wrote:
>
>> Hi Engin,
>> Sadly, your illustration was ambushed on the way to the list. Perhaps
>> you want something like this:
>>
>> # proportion of useful answers to your request
>> pua<-sort(runif(20))
>> #legibility of your request
>> lor<-sort(runif(20))+runif(20,-0.5,0.5)
>> # is a data set provided?
>> dsp<-sort(runif(20))+runif(20,-0.5,0.5)
>> # generate a linear model for the above
>> pua.lm<-lm(pua~lor+dsp)
>> # get the coefficients
>> pua.lm
>>
>> Call:
>> lm(formula = pua ~ lor + dsp)
>>
>> Coefficients:
>> (Intercept)          lor          dsp
>>     0.1692       0.6132       0.3311
>>
>> plot(pua~lor,col="red",main="Proportion of useful answers by request
>> quality")
>> points(pua~dsp,col="blue",pch=2)
>> abline(0.1692,0.6132,col="red")
>> abline(0.1692,0.3311,col="blue")
>>
>> So, the more readable your request and the quality of the data that
>> you provide, the more useful answers you are likely to receive.
>>
>> Jim
>>
>>
>> On Mon, Nov 27, 2017 at 7:56 PM, Engin YILMAZ <[hidden email]>
>> 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?
>> >
>> >
>> > Sincerely
>> > Engin YILMAZ
>> > ______________________________________________
>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>


--
*Saygılarımla*
Engin YILMAZ
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Ismail SEZEN

> On 27 Nov 2017, at 13:59, Engin YILMAZ <[hidden email]> wrote:
>
> Dear Berger and Jim
>
> Can you see my eviews example in the annex? (scattersample.jpg)
>
> Sincerely
> Engin

Please, use an image hosting service (i.e. https://imgbb.com/) to share images in the list and share the link in the email.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Ulrik Stervbo-2
ggplot and facets might be useful.

Ulrik

Ismail SEZEN <[hidden email]> schrieb am Mo., 27. Nov. 2017, 14:06:

>
> > On 27 Nov 2017, at 13:59, Engin YILMAZ <[hidden email]> wrote:
> >
> > Dear Berger and Jim
> >
> > Can you see my eviews example in the annex? (scattersample.jpg)
> >
> > Sincerely
> > Engin
>
> Please, use an image hosting service (i.e. https://imgbb.com/) to share
> images in the list and share the link in the email.
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Jeff Newmiller
In reply to this post by Temel İspanyolca
You do not appear to have read the Posting Guide mentioned at the bottom if this and every posting on the mailing list.

Only a very few attachment types are allowed through the mailing list... and due to the way many email programs fail to identify them properly, even those few types may not make it through.

Also, this is a plain text email list... any time you send HTML-formatted email it gets converted to plain text with varying amounts of scrambling... you really need to tell your email program to send plain text format or we may see something very different than you saw when you sent it.

Luckily, R is a text based programing environment, so if you include a complete (with sample data), minimal (so we don't get lost looking at code you already have working), reproducible (so we can run it from scratch in our R environment) example of your problem in the main body of your plain text email, we should be able to help you efficiently. If you don't do that, we usually won't understand what your problem is and could either bounce useless emails back and forth or may just not reply at all.

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette)
--
Sent from my phone. Please excuse my brevity.

On November 27, 2017 2:59:10 AM PST, Engin YILMAZ <[hidden email]> wrote:

>Dear Berger and Jim
>
>Can you see my eviews example in the annex? (scattersample.jpg)
>
>Sincerely
>Engin
>
>2017-11-27 13:27 GMT+03:00 Eric Berger <[hidden email]>:
>
>> LOL. Great reply Jim.
>> (N.B. Jim's conclusion is "debatable" by a judicious choice of seed.
>e.g.
>> set.seed(79) suggests that making the request more readable will
>actually
>> lower the number of useful answers. :-))
>>
>>
>> On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon <[hidden email]>
>wrote:
>>
>>> Hi Engin,
>>> Sadly, your illustration was ambushed on the way to the list.
>Perhaps
>>> you want something like this:
>>>
>>> # proportion of useful answers to your request
>>> pua<-sort(runif(20))
>>> #legibility of your request
>>> lor<-sort(runif(20))+runif(20,-0.5,0.5)
>>> # is a data set provided?
>>> dsp<-sort(runif(20))+runif(20,-0.5,0.5)
>>> # generate a linear model for the above
>>> pua.lm<-lm(pua~lor+dsp)
>>> # get the coefficients
>>> pua.lm
>>>
>>> Call:
>>> lm(formula = pua ~ lor + dsp)
>>>
>>> Coefficients:
>>> (Intercept)          lor          dsp
>>>     0.1692       0.6132       0.3311
>>>
>>> plot(pua~lor,col="red",main="Proportion of useful answers by request
>>> quality")
>>> points(pua~dsp,col="blue",pch=2)
>>> abline(0.1692,0.6132,col="red")
>>> abline(0.1692,0.3311,col="blue")
>>>
>>> So, the more readable your request and the quality of the data that
>>> you provide, the more useful answers you are likely to receive.
>>>
>>> Jim
>>>
>>>
>>> On Mon, Nov 27, 2017 at 7:56 PM, Engin YILMAZ
><[hidden email]>
>>> 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?
>>> >
>>> >
>>> > Sincerely
>>> > Engin YILMAZ
>>> > ______________________________________________
>>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> > https://stat.ethz.ch/mailman/listinfo/r-help
>>> > PLEASE do read the posting guide http://www.R-project.org/posti
>>> ng-guide.html
>>> > and provide commented, minimal, self-contained, reproducible code.
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>
>
>--
>*Saygılarımla*
>Engin YILMAZ
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Temel İspanyolca
Dear Users

I embed my sample

https://ibb.co/dhc23R

or

<a href="https://ibb.co/dhc23R"><img src="
https://preview.ibb.co/eEDaOR/scattersample.jpg" alt="scattersample"
border="0"></a>

<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 17:52 GMT+03:00 Jeff Newmiller <[hidden email]>:

> You do not appear to have read the Posting Guide mentioned at the bottom
> if this and every posting on the mailing list.
>
> Only a very few attachment types are allowed through the mailing list...
> and due to the way many email programs fail to identify them properly, even
> those few types may not make it through.
>
> Also, this is a plain text email list... any time you send HTML-formatted
> email it gets converted to plain text with varying amounts of scrambling...
> you really need to tell your email program to send plain text format or we
> may see something very different than you saw when you sent it.
>
> Luckily, R is a text based programing environment, so if you include a
> complete (with sample data), minimal (so we don't get lost looking at code
> you already have working), reproducible (so we can run it from scratch in
> our R environment) example of your problem in the main body of your plain
> text email, we should be able to help you efficiently. If you don't do
> that, we usually won't understand what your problem is and could either
> bounce useless emails back and forth or may just not reply at all.
>
> [1] http://stackoverflow.com/questions/5963269/how-to-make-
> a-great-r-reproducible-example
>
> [2] http://adv-r.had.co.nz/Reproducibility.html
>
> [3] https://cran.r-project.org/web/packages/reprex/index.html (read the
> vignette)
> --
> Sent from my phone. Please excuse my brevity.
>
> On November 27, 2017 2:59:10 AM PST, Engin YILMAZ <[hidden email]>
> wrote:
> >Dear Berger and Jim
> >
> >Can you see my eviews example in the annex? (scattersample.jpg)
> >
> >Sincerely
> >Engin
> >
> >2017-11-27 13:27 GMT+03:00 Eric Berger <[hidden email]>:
> >
> >> LOL. Great reply Jim.
> >> (N.B. Jim's conclusion is "debatable" by a judicious choice of seed.
> >e.g.
> >> set.seed(79) suggests that making the request more readable will
> >actually
> >> lower the number of useful answers. :-))
> >>
> >>
> >> On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon <[hidden email]>
> >wrote:
> >>
> >>> Hi Engin,
> >>> Sadly, your illustration was ambushed on the way to the list.
> >Perhaps
> >>> you want something like this:
> >>>
> >>> # proportion of useful answers to your request
> >>> pua<-sort(runif(20))
> >>> #legibility of your request
> >>> lor<-sort(runif(20))+runif(20,-0.5,0.5)
> >>> # is a data set provided?
> >>> dsp<-sort(runif(20))+runif(20,-0.5,0.5)
> >>> # generate a linear model for the above
> >>> pua.lm<-lm(pua~lor+dsp)
> >>> # get the coefficients
> >>> pua.lm
> >>>
> >>> Call:
> >>> lm(formula = pua ~ lor + dsp)
> >>>
> >>> Coefficients:
> >>> (Intercept)          lor          dsp
> >>>     0.1692       0.6132       0.3311
> >>>
> >>> plot(pua~lor,col="red",main="Proportion of useful answers by request
> >>> quality")
> >>> points(pua~dsp,col="blue",pch=2)
> >>> abline(0.1692,0.6132,col="red")
> >>> abline(0.1692,0.3311,col="blue")
> >>>
> >>> So, the more readable your request and the quality of the data that
> >>> you provide, the more useful answers you are likely to receive.
> >>>
> >>> Jim
> >>>
> >>>
> >>> On Mon, Nov 27, 2017 at 7:56 PM, Engin YILMAZ
> ><[hidden email]>
> >>> 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?
> >>> >
> >>> >
> >>> > Sincerely
> >>> > Engin YILMAZ
> >>> > ______________________________________________
> >>> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >>> > https://stat.ethz.ch/mailman/listinfo/r-help
> >>> > PLEASE do read the posting guide http://www.R-project.org/posti
> >>> ng-guide.html
> >>> > and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>> ______________________________________________
> >>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide http://www.R-project.org/posti
> >>> ng-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>
> >>
> >
> >
> >--
> >*Saygılarımla*
> >Engin YILMAZ
> >______________________________________________
> >[hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>



--
*Saygılarımla*
Engin YILMAZ

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

MacQueen, Don
In reply to this post by Temel İspanyolca
Here's the quickest way I know of to get a scatterplot of many variables against a single variable. I create example data to illustrate.

x <- 1:10
ys <- matrix( runif(30), ncol=3)

matplot(x,ys)
## or, a little better,
matplot(x,ys, type='b')

To add regression lines:

for (iy in seq(ncol(ys))) abline(lsfit(x, ys[,iy]))

Coloring the regression lines to match the matplot will take a little more work (but not a lot more).

Don't ask me about putting the regression line formulas on the plot like in Excel. I don't do things that way...

There is probably something in ggplot2 or some other package.

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 11/27/17, 12:56 AM, "R-help on behalf of Engin YILMAZ" <[hidden email] on behalf of [hidden email]> 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?
   
   
    Sincerely
    Engin YILMAZ
    ______________________________________________
    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
   

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Ismail SEZEN
In reply to this post by Temel İspanyolca

> On 27 Nov 2017, at 11:56, Engin YILMAZ <[hidden email]> 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
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Scatterplot of many variables against a single variable

Temel İspanyolca
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 <[hidden email]>:

>
> > On 27 Nov 2017, at 11:56, Engin YILMAZ <[hidden email]> 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]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.