[R] prop.test question

2023-07-11 Thread Thomas Subia via R-help
Colleagues
Consider:smokers  <- c( 83, 90, 129, 70 )
patients <- c( 86, 93, 136, 82 )
prop.test(smokers, patients)
    4-sample test for equality of proportions
    without continuity correction

data:  smokers out of patients
X-squared = 12.6, df = 3, p-value = 0.005585
alternative hypothesis: two.sided
sample estimates:
   prop 1    prop 2    prop 3    prop 4 
0.9651163 0.9677419 0.9485294 0.8536585 

Now:prop.trend.test(smokers, patients)    Chi-squared Test for Trend in 
Proportions

data:  smokers out of patients ,
 using scores: 1 2 3 4
X-squared = 8.2249, df = 1, p-value = 0.004132
How can one determine the direction of the trend?
Thomas Subia




[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] Plotting factors in graph panel

2023-07-11 Thread Anupam Tyagi
Wonderful! This is great news. Thanks, Deepayan.

On Wed, 12 Jul 2023 at 09:21, Deepayan Sarkar 
wrote:

>
>
> On Wed, 12 Jul 2023 at 08:57, Anupam Tyagi  wrote:
>
>> Thanks.
>> I made a graph in Stata that is close to what I want in R. Stata graph is
>> attached. The main differences between Stata and R graphs that I was able
>> to make, with ggplot or lattice, is that I have been able to scale y-axis
>> of each sub-graph independently in Stata, but not in R. Also, x-axis
>> labels
>> are also complete in Stata but not in R. Is there a way to do this in R
>> via
>> base-R, ggplot or lattice?
>
>
> Yes, of course. For lattice, add the argument
>
> scales = list(y = "free")
>
> For ggplot2, change
>
> facet_wrap(~Measure)
>
> to
>
> facet_wrap(~Measure, scale = "free")
>
> -Deepayan
>
> I had initially thought that these types of
>> panel graphs are common and should be easy to do, but that is not how this
>> is turning out to be. Any help is welcome.
>>
>
>> On Fri, 7 Jul 2023 at 17:57, PIKAL Petr  wrote:
>>
>> > Hallo Anupam
>> >
>> > With
>> >
>> > ggplot change axis label size into Google
>> >
>> > the first answer I got was
>> >
>> > axis.text theme
>> >
>> > r - Change size of axes title and labels in ggplot2 - Stack Overflow
>> > <
>> https://stackoverflow.com/questions/14942681/change-size-of-axes-title-and-labels-in-ggplot2
>> >
>> >
>> >
>> >
>> > so
>> >
>> >
>> >
>> > ggplot(TrialData4, aes(x=Income, y=Percent, group=Measure)) +
>> geom_point()
>> > +
>> >   geom_line() + facet_wrap(~Measure) +
>> > theme(axis.text=element_text(size=5))
>> >
>> >
>> >
>> > Should do the trick.
>> >
>> >
>> >
>> > S pozdravem | Best Regards
>> >
>> >
>> > *RNDr. Petr PIKAL*Vedoucí Výzkumu a vývoje | Research Manager
>> >
>> >
>> > *PRECHEZA a.s.*nábř. Dr. Edvarda Beneše 1170/24 | 750 02 Přerov | Czech
>> > Republic
>> > Tel: +420 581 252 256 | GSM: +420 724 008 364
>> > petr.pi...@precheza.cz | *www.precheza.cz *
>> >
>> > *Osobní údaje: *Informace o zpracování a ochraně osobních údajů
>> > obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: *
>> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/
>> > * | Information
>> > about processing and protection of business partner’s personal data are
>> > available on website: *
>> https://www.precheza.cz/en/personal-data-protection-principles/
>> > *
>> >
>> > *Důvěrnost: *Tento e-mail a jakékoliv k němu připojené dokumenty jsou
>> > důvěrné a podléhají tomuto právně závaznému prohlášení o vyloučení
>> > odpovědnosti: *https://www.precheza.cz/01-dovetek/
>> > * | This email and any documents
>> > attached to it may be confidential and are subject to the legally
>> binding
>> > disclaimer: *https://www.precheza.cz/en/01-disclaimer/
>> > *
>> >
>> >
>> >
>> > *From:* Anupam Tyagi 
>> > *Sent:* Friday, July 7, 2023 12:48 PM
>> > *To:* PIKAL Petr 
>> > *Cc:* r-help@r-project.org
>> > *Subject:* Re: [R] Plotting factors in graph panel
>> >
>> >
>> >
>> > Thanks! You are correct, the graphs look very similar, except ggplot is
>> > scaling the text font to make it more readable. Is there a way to scale
>> > down the x-axis labels, so they are readable?
>> >
>> >
>> >
>> > On Fri, 7 Jul 2023 at 12:02, PIKAL Petr  wrote:
>> >
>> > Hallo Anupam
>> >
>> > I do not see much difference in ggplot or lattice, they seems to me
>> > provide almost identical results when removing theme part from ggplot.
>> >
>> > library(ggplot2)
>> > library(lattice)
>> >
>> > ggplot(TrialData4, aes(x=Income, y=Percent, group=Measure)) +
>> geom_point()
>> > +
>> >   geom_line() + facet_wrap(~Measure)
>> >
>> > xyplot(Percent ~ Income | Measure, TrialData4,
>> >type = "o", pch = 16, as.table = TRUE, grid = TRUE)
>> >
>> > So it is probably only matter of your preference which one do you
>> choose.
>> >
>> > Cheers
>> > Petr
>> >
>> >
>> > > -Original Message-
>> > > From: R-help  On Behalf Of Deepayan
>> Sarkar
>> > > Sent: Thursday, July 6, 2023 3:06 PM
>> > > To: Anupam Tyagi 
>> > > Cc: r-help@r-project.org
>> > > Subject: Re: [R] Plotting factors in graph panel
>> > >
>> > > On Thu, 6 Jul 2023 at 15:21, Anupam Tyagi 
>> wrote:
>> > > >
>> > > > Btw, I think "lattice" graphics will provide a better solution than
>> > > > "ggplot", because it puts appropriate (space saving) markers on the
>> > > > axes and does axes labels well. However, I cannot figure out how to
>> do
>> > > > it in "lattice".
>> > >
>> > > You will need to convert Income to a factor first. Alternatively, use
>> > > dotplot() instead of xyplot(), but that will sort the levels wrongly,
>> so
>> > better to
>> > > make the factor first anyway.
>> > >
>> > > TrialData4 <- within(TrialData4,
>> > > {
>> > > Income <- factor(Income, levels = c("$10", "$25", "$40", "$75", ">
>> > $75"))
>> 

Re: [R] Plotting factors in graph panel

2023-07-11 Thread Deepayan Sarkar
On Wed, 12 Jul 2023 at 08:57, Anupam Tyagi  wrote:

> Thanks.
> I made a graph in Stata that is close to what I want in R. Stata graph is
> attached. The main differences between Stata and R graphs that I was able
> to make, with ggplot or lattice, is that I have been able to scale y-axis
> of each sub-graph independently in Stata, but not in R. Also, x-axis labels
> are also complete in Stata but not in R. Is there a way to do this in R via
> base-R, ggplot or lattice?


Yes, of course. For lattice, add the argument

scales = list(y = "free")

For ggplot2, change

facet_wrap(~Measure)

to

facet_wrap(~Measure, scale = "free")

-Deepayan

I had initially thought that these types of
> panel graphs are common and should be easy to do, but that is not how this
> is turning out to be. Any help is welcome.
>

> On Fri, 7 Jul 2023 at 17:57, PIKAL Petr  wrote:
>
> > Hallo Anupam
> >
> > With
> >
> > ggplot change axis label size into Google
> >
> > the first answer I got was
> >
> > axis.text theme
> >
> > r - Change size of axes title and labels in ggplot2 - Stack Overflow
> > <
> https://stackoverflow.com/questions/14942681/change-size-of-axes-title-and-labels-in-ggplot2
> >
> >
> >
> >
> > so
> >
> >
> >
> > ggplot(TrialData4, aes(x=Income, y=Percent, group=Measure)) +
> geom_point()
> > +
> >   geom_line() + facet_wrap(~Measure) +
> > theme(axis.text=element_text(size=5))
> >
> >
> >
> > Should do the trick.
> >
> >
> >
> > S pozdravem | Best Regards
> >
> >
> > *RNDr. Petr PIKAL*Vedoucí Výzkumu a vývoje | Research Manager
> >
> >
> > *PRECHEZA a.s.*nábř. Dr. Edvarda Beneše 1170/24 | 750 02 Přerov | Czech
> > Republic
> > Tel: +420 581 252 256 | GSM: +420 724 008 364
> > petr.pi...@precheza.cz | *www.precheza.cz *
> >
> > *Osobní údaje: *Informace o zpracování a ochraně osobních údajů
> > obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: *
> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/
> > * | Information
> > about processing and protection of business partner’s personal data are
> > available on website: *
> https://www.precheza.cz/en/personal-data-protection-principles/
> > *
> >
> > *Důvěrnost: *Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> > důvěrné a podléhají tomuto právně závaznému prohlášení o vyloučení
> > odpovědnosti: *https://www.precheza.cz/01-dovetek/
> > * | This email and any documents
> > attached to it may be confidential and are subject to the legally binding
> > disclaimer: *https://www.precheza.cz/en/01-disclaimer/
> > *
> >
> >
> >
> > *From:* Anupam Tyagi 
> > *Sent:* Friday, July 7, 2023 12:48 PM
> > *To:* PIKAL Petr 
> > *Cc:* r-help@r-project.org
> > *Subject:* Re: [R] Plotting factors in graph panel
> >
> >
> >
> > Thanks! You are correct, the graphs look very similar, except ggplot is
> > scaling the text font to make it more readable. Is there a way to scale
> > down the x-axis labels, so they are readable?
> >
> >
> >
> > On Fri, 7 Jul 2023 at 12:02, PIKAL Petr  wrote:
> >
> > Hallo Anupam
> >
> > I do not see much difference in ggplot or lattice, they seems to me
> > provide almost identical results when removing theme part from ggplot.
> >
> > library(ggplot2)
> > library(lattice)
> >
> > ggplot(TrialData4, aes(x=Income, y=Percent, group=Measure)) +
> geom_point()
> > +
> >   geom_line() + facet_wrap(~Measure)
> >
> > xyplot(Percent ~ Income | Measure, TrialData4,
> >type = "o", pch = 16, as.table = TRUE, grid = TRUE)
> >
> > So it is probably only matter of your preference which one do you choose.
> >
> > Cheers
> > Petr
> >
> >
> > > -Original Message-
> > > From: R-help  On Behalf Of Deepayan
> Sarkar
> > > Sent: Thursday, July 6, 2023 3:06 PM
> > > To: Anupam Tyagi 
> > > Cc: r-help@r-project.org
> > > Subject: Re: [R] Plotting factors in graph panel
> > >
> > > On Thu, 6 Jul 2023 at 15:21, Anupam Tyagi  wrote:
> > > >
> > > > Btw, I think "lattice" graphics will provide a better solution than
> > > > "ggplot", because it puts appropriate (space saving) markers on the
> > > > axes and does axes labels well. However, I cannot figure out how to
> do
> > > > it in "lattice".
> > >
> > > You will need to convert Income to a factor first. Alternatively, use
> > > dotplot() instead of xyplot(), but that will sort the levels wrongly,
> so
> > better to
> > > make the factor first anyway.
> > >
> > > TrialData4 <- within(TrialData4,
> > > {
> > > Income <- factor(Income, levels = c("$10", "$25", "$40", "$75", ">
> > $75"))
> > > })
> > >
> > > xyplot(Percent ~ Income | Measure, TrialData4,
> > >type = "o", pch = 16, as.table = TRUE, grid = TRUE)
> > >
> > > or
> > >
> > > dotplot(Percent ~ Income | Measure, TrialData4,
> > > type = "o", as.table = TRUE)
> > >
> > > This is not really any 

[R] Variable and value labels

2023-07-11 Thread Anupam Tyagi
Hello,

is there an easy way to do variable and value labels (for factor variables)
in base-R, without using a package. If not, what is an easy and good way to
do labels, using an add-on package.

-- 
Anupam.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] Alternative to rggobi

2023-07-11 Thread Anupam Tyagi
Hello,

since rggobi is not available, is there an alternative to rggobi?

-- 
Anupam.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] Plotting factors in graph panel

2023-07-11 Thread Anupam Tyagi
Thanks.
I made a graph in Stata that is close to what I want in R. Stata graph is
attached. The main differences between Stata and R graphs that I was able
to make, with ggplot or lattice, is that I have been able to scale y-axis
of each sub-graph independently in Stata, but not in R. Also, x-axis labels
are also complete in Stata but not in R. Is there a way to do this in R via
base-R, ggplot or lattice? I had initially thought that these types of
panel graphs are common and should be easy to do, but that is not how this
is turning out to be. Any help is welcome.

On Fri, 7 Jul 2023 at 17:57, PIKAL Petr  wrote:

> Hallo Anupam
>
> With
>
> ggplot change axis label size into Google
>
> the first answer I got was
>
> axis.text theme
>
> r - Change size of axes title and labels in ggplot2 - Stack Overflow
> 
>
>
>
> so
>
>
>
> ggplot(TrialData4, aes(x=Income, y=Percent, group=Measure)) + geom_point()
> +
>   geom_line() + facet_wrap(~Measure) +
> theme(axis.text=element_text(size=5))
>
>
>
> Should do the trick.
>
>
>
> S pozdravem | Best Regards
>
>
> *RNDr. Petr PIKAL*Vedoucí Výzkumu a vývoje | Research Manager
>
>
> *PRECHEZA a.s.*nábř. Dr. Edvarda Beneše 1170/24 | 750 02 Přerov | Czech
> Republic
> Tel: +420 581 252 256 | GSM: +420 724 008 364
> petr.pi...@precheza.cz | *www.precheza.cz *
>
> *Osobní údaje: *Informace o zpracování a ochraně osobních údajů
> obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: 
> *https://www.precheza.cz/zasady-ochrany-osobnich-udaju/
> * | Information
> about processing and protection of business partner’s personal data are
> available on website: 
> *https://www.precheza.cz/en/personal-data-protection-principles/
> *
>
> *Důvěrnost: *Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> důvěrné a podléhají tomuto právně závaznému prohlášení o vyloučení
> odpovědnosti: *https://www.precheza.cz/01-dovetek/
> * | This email and any documents
> attached to it may be confidential and are subject to the legally binding
> disclaimer: *https://www.precheza.cz/en/01-disclaimer/
> *
>
>
>
> *From:* Anupam Tyagi 
> *Sent:* Friday, July 7, 2023 12:48 PM
> *To:* PIKAL Petr 
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] Plotting factors in graph panel
>
>
>
> Thanks! You are correct, the graphs look very similar, except ggplot is
> scaling the text font to make it more readable. Is there a way to scale
> down the x-axis labels, so they are readable?
>
>
>
> On Fri, 7 Jul 2023 at 12:02, PIKAL Petr  wrote:
>
> Hallo Anupam
>
> I do not see much difference in ggplot or lattice, they seems to me
> provide almost identical results when removing theme part from ggplot.
>
> library(ggplot2)
> library(lattice)
>
> ggplot(TrialData4, aes(x=Income, y=Percent, group=Measure)) + geom_point()
> +
>   geom_line() + facet_wrap(~Measure)
>
> xyplot(Percent ~ Income | Measure, TrialData4,
>type = "o", pch = 16, as.table = TRUE, grid = TRUE)
>
> So it is probably only matter of your preference which one do you choose.
>
> Cheers
> Petr
>
>
> > -Original Message-
> > From: R-help  On Behalf Of Deepayan Sarkar
> > Sent: Thursday, July 6, 2023 3:06 PM
> > To: Anupam Tyagi 
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Plotting factors in graph panel
> >
> > On Thu, 6 Jul 2023 at 15:21, Anupam Tyagi  wrote:
> > >
> > > Btw, I think "lattice" graphics will provide a better solution than
> > > "ggplot", because it puts appropriate (space saving) markers on the
> > > axes and does axes labels well. However, I cannot figure out how to do
> > > it in "lattice".
> >
> > You will need to convert Income to a factor first. Alternatively, use
> > dotplot() instead of xyplot(), but that will sort the levels wrongly, so
> better to
> > make the factor first anyway.
> >
> > TrialData4 <- within(TrialData4,
> > {
> > Income <- factor(Income, levels = c("$10", "$25", "$40", "$75", ">
> $75"))
> > })
> >
> > xyplot(Percent ~ Income | Measure, TrialData4,
> >type = "o", pch = 16, as.table = TRUE, grid = TRUE)
> >
> > or
> >
> > dotplot(Percent ~ Income | Measure, TrialData4,
> > type = "o", as.table = TRUE)
> >
> > This is not really any different from the ggplot() version though.
> > Maybe you just don't like the effect of the '+ theme_classic()' part.
> >
> > Best,
> > -Deepayan
> >
> >
> > > On Thu, 6 Jul 2023 at 15:11, Anupam Tyagi  wrote:
> > >
> > > > Hi John:
> > > >
> > > > Thanks! Below is the data using your suggestion. I used "ggplot" to
> > > > make a graph. I am not too happy with it. I am looking for something
> > > > simpler and cleaner. Plot is attached.
> > > >
> > > > I also tried "lattice" package, but nothing got plotted with "xyplot"
> 

Re: [R] Base R Stats Package - quantile function

2023-07-11 Thread Bert Gunter
1. I highly doubt that anyone from the "R Core team" would respond to such
a request. That is emphatically **not** their job.

2. More to the point, this is *exactly* the sort of task that *you*, as a
student/practitioner of statistics and data analysis are expected to do for
yourself. Indeed, examples already are included in ?quantile, and
references are provided for you to follow up on on your own if you wish to
learn more.

3. Finally, your request is largely off topic here. Please read and follow
the posting guide linked below for learning about/posting on matters that
are on topic.

Cheers,
Bert

On Tue, Jul 11, 2023 at 12:19 PM a.chandh...@btinternet.com a.chandhial---
via R-help  wrote:

>
>
>
> Hi,
>
>
> In Base R Stats Package, the quantile function has 9 Type's:
>
> ?quantile
>
> I'd be very grateful if simple numerical examples (ideally from members
> of the R core team), for each of the 9 methods, both for EVEN and ODD
> numbered length's of series, be provided.
>
>
> thanks,
> Amarjit
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org 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]]

__
R-help@r-project.org 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.


[R] Base R Stats Package - quantile function

2023-07-11 Thread a.chandh...@btinternet.com a.chandhial--- via R-help




Hi,


In Base R Stats Package, the quantile function has 9 Type's:

?quantile

I'd be very grateful if simple numerical examples (ideally from members 
of the R core team), for each of the 9 methods, both for EVEN and ODD 
numbered length's of series, be provided.


thanks,
Amarjit


[[alternative HTML version deleted]]

__
R-help@r-project.org 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.