Re: [R] R-help Digest, Vol 255, Issue 17

2024-05-21 Thread Michael L Friendly
You might be interested in the `Rdatasets` package, 
https://vincentarelbundock.github.io/Rdatasets/ which lists over 2200 datasets 
from various packages.

What is the context of the `lottery` dataset. I seem to recall smth to do with 
the NJ Lottery

-Michael

   1. Availability of Sdatasets (Avro Alo)

--

Message: 1
Date: Sun, 19 May 2024 08:58:20 +
From: Avro Alo 
To: "r-help@r-project.org" 
Subject: [R] Availability of Sdatasets
Message-ID:

<8I3Bj0m1IzC35J4nEoROCf1yZD66oeLHFLtxsXKSty3vplcl5gKp-_XmdSvEbG0UYtxv8g0Jw0ihsR5x0MS0QdF7DOmooZ2C9BJVqUUlNSQ=@protonmail.com>

Content-Type: text/plain; charset="utf-8"

>From the mention in R-intro I went to look at The new S language
book. In chapter 1 it has a lottery dataset. So naturally I thought it is 
pre-supplied with R. But I didn't fount, made a google search and found the 
package that has the dataset, 
https://docs.tibco.com/pub/enterprise-runtime-for-R/6.1.1/doc/html/Language_Reference/Sdatasets/00Index.html
 

This package is very interesting on it's own. But how can I get it?

Also, shouldn't regular R installation have this too?

Thanks!

(first time posting here)




--

Subject: Digest Footer

_______
R-help@r-project.org mailing list
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.


------

End of R-help Digest, Vol 255, Issue 17

______
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] help - Package: stats - function ar.ols

2024-02-23 Thread Ebert,Timothy Aaron
The data came through fine, the program was a miss. Can you paste the program 
into a ".txt" document like a notepad file and send that? You could also paste 
it into your email IF your email is configured to send text and NOT html.

TIm

-Original Message-----
From: R-help  On Behalf Of Pedro Gavronski.
Sent: Friday, February 23, 2024 5:00 AM
To: Rui Barradas 
Cc: r-help@r-project.org; r-help-requ...@r-project.org
Subject: Re: [R] help - Package: stats - function ar.ols

[External Email]

Hello,

Thanks for the reply Rui and for pointing out that I forgot to attach my code. 
Please find attached in this email my code and data.

Thanks in advance.

Best regards, Pedro Gerhardt Gavronski.

On Fri, Feb 23, 2024 at 5:50 AM Rui Barradas  wrote:
>
> Às 16:34 de 22/02/2024, Pedro Gavronski. escreveu:
> > Hello,
> >
> > My name is Pedro and it is nice to meet you all. I am having trouble
> > understanding a message that I receive when use function ar.ols from
> > package stats, it says that "Warning message:
> > In ar.ols(x = dtb[2:6966, ], demean = FALSE, intercept = TRUE,
> > prewhite = TRUE) :
> >model order:  2 singularities in the computation of the
> > projection matrix results are only valid up to model order 1, which
> > I do not know what it means, if someone could clarify it, I would
> > really appreciate it.
> >
> > Attached to this email you will find my code and data I used to run
> > this formula.
> >
> > Thanks in advance.
> >
> > Best regards,  Pedro.
> >
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://st/
> > at.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C02%7Ctebert%40ufl
> > .edu%7C0afd65836d774adc099408dc349f53c7%7C0d4da0f84a314d76ace60a6233
> > 1e1b84%7C0%7C0%7C638443106144255449%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi
> > MC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C
> > %7C=12OGc13jk3Lejmcvx5WH8Bko8JSpRxbtW3mzL3OIjyk%3D=0
> > PLEASE do read the posting guide
> > http://www/
> > .r-project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%
> > 7C0afd65836d774adc099408dc349f53c7%7C0d4da0f84a314d76ace60a62331e1b8
> > 4%7C0%7C0%7C638443106144262387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL
> > jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C
> > data=fAVz0iQ0zS5pmrxrzNeazRrrv%2FyjFdWvwMfgjhibdEA%3D=0
> > and provide commented, minimal, self-contained, reproducible code.
> Hello,
>
> Thanks for the data but the code is missing from the attachment.
> Can you please post your code? In an attachment or directly in the
> e-mail body.
>
> Rui Barradas
>
>
> --
> Este e-mail foi analisado pelo software antivírus AVG para verificar a 
> presença de vírus.
> http://www.a/
> vg.com%2F=05%7C02%7Ctebert%40ufl.edu%7C0afd65836d774adc099408dc34
> 9f53c7%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638443106144266047
> %7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6I
> k1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=rdqEhXdZ5%2FThzbhuKgspNaBPyhf
> aC%2BWh7MFq4iq%2BxVE%3D=0
__
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] help - Package: stats - function ar.ols

2024-02-23 Thread Rui Barradas

Às 16:34 de 22/02/2024, Pedro Gavronski. escreveu:

Hello,

My name is Pedro and it is nice to meet you all. I am having trouble
understanding a message that I receive when use function ar.ols from
package stats, it says that "Warning message:
In ar.ols(x = dtb[2:6966, ], demean = FALSE, intercept = TRUE,
prewhite = TRUE) :
   model order:  2 singularities in the computation of the projection
matrix results are only valid up to model order 1, which I do not know
what it means, if someone could clarify it, I would really appreciate
it.

Attached to this email you will find my code and data I used to run
this formula.

Thanks in advance.

Best regards,  Pedro.


______
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.

Hello,

Thanks for the data but the code is missing from the attachment.
Can you please post your code? In an attachment or directly in the 
e-mail body.


Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
www.avg.com

______
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] Help

2024-02-22 Thread Ben Bolker

  I agree that the posting guide is due for updating.

  If the mailing list maintainers were willing I think r-consult might 
not be a terrible idea. I do think the center of gravity has moved to 
Cross Validated, and it might be minimally sufficient to point people 
there (or Math Overflow for probability/math questions) rather than 
starting a new group.


On 2024-02-21 12:53 p.m., Joakim Linde wrote:

Lisa, this seems to be fairly straight forward to do in R and I'm happy to help 
you get started. However, please be aware that you do have to have knowledge of 
statistics to do the analysis/modeling.

Rolf, Jeff, I do appreciate your view that this is not a R probelm. It's more a 'how to 
use R' / 'help me get started' problem. The posting guidelines point to "Usenet 
groups sci.stat.consult (applied statistics and consulting) and sci.stat.math 
(mathematical stat and probability)." Since Google announced [1] that Google groups 
will not support new usenet content starting tomorrow, would it make sense to have a 
r-consult mailing list or tag it [consult] on r-help?

Regards,
Joakim

[1]: https://support.google.com/groups/answer/11036538

On Wed, Feb 21, 2024, at 1:28 AM, Jeff Newmiller via R-help wrote:

Regarding 1 and 2, please read the Posting Guide mentioned at the
bottom of every R-help post. R does not equal statistics... and
education about statistics is way too ambitious to include in this
mailing list that is about a tool that happens to be useful for
statisticians.

There are forums online that do cater to statistical methods (e.g.
Cross Validated or many results from a search engine)... but such
conversations can be extensive so as Rolf suggests this is a good time
to learn what resources your educational institutions can provide...
online forums may be too limiting when your questions are so vague.

On February 20, 2024 2:14:58 PM PST, Rolf Turner  wrote:


On Mon, 19 Feb 2024 17:39:23 +0100
Lisa Hupfer via R-help  wrote:


I am writing my master thesis in which I compared two cultures . So
for my statistics I need to compare Age,Sex,Culture as well as have a
look at the tasks scores .

Anyone familiar with this ?
I’d love to share my script so you guide me where I did wrong .


(1) This post is far too vague to be appropriate for this list.

(2) You should learn some statistics; probably linear modelling.

(3) You should talk to your thesis advisor.

(4) Please see fortunes::fortune(285).

cheers,

Rolf Turner




--
Sent from my phone. Please excuse my brevity.

______
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-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-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] Help

2024-02-22 Thread Joakim Linde
Lisa, this seems to be fairly straight forward to do in R and I'm happy to help 
you get started. However, please be aware that you do have to have knowledge of 
statistics to do the analysis/modeling.  

Rolf, Jeff, I do appreciate your view that this is not a R probelm. It's more a 
'how to use R' / 'help me get started' problem. The posting guidelines point to 
"Usenet groups sci.stat.consult (applied statistics and consulting) and 
sci.stat.math (mathematical stat and probability)." Since Google announced [1] 
that Google groups will not support new usenet content starting tomorrow, would 
it make sense to have a r-consult mailing list or tag it [consult] on r-help?

Regards, 
Joakim

[1]: https://support.google.com/groups/answer/11036538

On Wed, Feb 21, 2024, at 1:28 AM, Jeff Newmiller via R-help wrote:
> Regarding 1 and 2, please read the Posting Guide mentioned at the 
> bottom of every R-help post. R does not equal statistics... and 
> education about statistics is way too ambitious to include in this 
> mailing list that is about a tool that happens to be useful for 
> statisticians.
>
> There are forums online that do cater to statistical methods (e.g. 
> Cross Validated or many results from a search engine)... but such 
> conversations can be extensive so as Rolf suggests this is a good time 
> to learn what resources your educational institutions can provide... 
> online forums may be too limiting when your questions are so vague.
>
> On February 20, 2024 2:14:58 PM PST, Rolf Turner  
> wrote:
>>
>>On Mon, 19 Feb 2024 17:39:23 +0100
>>Lisa Hupfer via R-help  wrote:
>>
>>> I am writing my master thesis in which I compared two cultures . So
>>> for my statistics I need to compare Age,Sex,Culture as well as have a
>>> look at the tasks scores .
>>> 
>>> Anyone familiar with this ?
>>> I’d love to share my script so you guide me where I did wrong .
>>
>>(1) This post is far too vague to be appropriate for this list.
>>
>>(2) You should learn some statistics; probably linear modelling.
>>
>>(3) You should talk to your thesis advisor.
>>
>>(4) Please see fortunes::fortune(285).
>>
>>cheers,
>>
>>Rolf Turner
>>
>>
>
> -- 
> Sent from my phone. Please excuse my brevity.
>
> __
> 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-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] Help

2024-02-20 Thread Jeff Newmiller via R-help
Regarding 1 and 2, please read the Posting Guide mentioned at the bottom of 
every R-help post. R does not equal statistics... and education about 
statistics is way too ambitious to include in this mailing list that is about a 
tool that happens to be useful for statisticians.

There are forums online that do cater to statistical methods (e.g. Cross 
Validated or many results from a search engine)... but such conversations can 
be extensive so as Rolf suggests this is a good time to learn what resources 
your educational institutions can provide... online forums may be too limiting 
when your questions are so vague.

On February 20, 2024 2:14:58 PM PST, Rolf Turner  wrote:
>
>On Mon, 19 Feb 2024 17:39:23 +0100
>Lisa Hupfer via R-help  wrote:
>
>> I am writing my master thesis in which I compared two cultures . So
>> for my statistics I need to compare Age,Sex,Culture as well as have a
>> look at the tasks scores .
>> 
>> Anyone familiar with this ?
>> I’d love to share my script so you guide me where I did wrong .
>
>(1) This post is far too vague to be appropriate for this list.
>
>(2) You should learn some statistics; probably linear modelling.
>
>(3) You should talk to your thesis advisor.
>
>(4) Please see fortunes::fortune(285).
>
>cheers,
>
>Rolf Turner
>
>

-- 
Sent from my phone. Please excuse my brevity.

__
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] Help

2024-02-20 Thread Rolf Turner


On Mon, 19 Feb 2024 17:39:23 +0100
Lisa Hupfer via R-help  wrote:

> I am writing my master thesis in which I compared two cultures . So
> for my statistics I need to compare Age,Sex,Culture as well as have a
> look at the tasks scores .
> 
> Anyone familiar with this ?
> I’d love to share my script so you guide me where I did wrong .

(1) This post is far too vague to be appropriate for this list.

(2) You should learn some statistics; probably linear modelling.

(3) You should talk to your thesis advisor.

(4) Please see fortunes::fortune(285).

cheers,

Rolf Turner


-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
 +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619

______
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] Help

2024-02-20 Thread Lisa Hupfer via R-help
I am writing my master thesis in which I compared two cultures . So for my 
statistics I need to compare Age,Sex,Culture as well as have a look at the 
tasks scores .

Anyone familiar with this ?
I’d love to share my script so you guide me where I did wrong . 

Regards 

__
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] Help

2024-02-04 Thread Jibrin Alhassan
Hi Kimmo,
The code you sent has worked for me. Thank you very much.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Mon, Feb 5, 2024 at 7:40 AM Kimmo Elo  wrote:

> Hi,
>
> the command line with 'text' should be:
>
> text(-8,-8, expression(R^2 * " = 0.62,  r = 0.79, N = 161"), cex = 2 )
>
> Best,
>
> Kimmo
>
> su, 2024-02-04 kello 17:16 +0100, Jibrin Alhassan kirjoitti:
> > Here is the script I used to plot the graph indicating the text I
> > wanted to
> > insert. The line in the script that I have issues with is: text(-8,-
> > 8,
> > "R^2=  0.62",  r = 0.79, N = 161", cex = 2
> > R^2=  0.62 is not producing R squared = 0.62.
> > Thanks.
> > Sys.setenv( TZ="GMT" )
> > dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt"))
> > FDcli=dt$FDcli
> > FDapt=dt$FDapt
> > setEPS()
> > postscript(file = "cliapt2.eps")
> > par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1))
> > plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4, cex.main
> > = 0.8,
> > font.lab = 1.7, font.axis = 1.7,  col = "red",main = "Simultaneous
> > Events
> > at CLMX and APTY",ylab="CLMX",xlab="APTY")
> > text(-8,-8, "R^2=  0.62",  r = 0.79, N = 161", cex = 2 )
> > abline(lm(FDcli ~ FDapt, col="black"))
> > dev.off()
> > *Jibrin Adejoh Alhassan (Ph.D)*
> > Department of Physics and Astronomy,
> > University of Nigeria, Nsukka
> >
> >
> > On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan
> > 
> > wrote:
> >
> > > Hi Elo,
> > > It gave this error message:
> > > CR_plot2.R:14:37: unexpected string constant
> > > 13: plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4,
> > > cex.main =
> > > 0.8, font.lab = 1.7, font.axis = 1.7,  col = "red",main =
> > > "Simultaneous
> > > Events at CLMX and APTY",ylab="CLMX",xlab="APTY")
> > > 14: text(-8,-8, "expression(R^2*"=  0.62"),  r = 0.79, N = 161"
> > > ^
> > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > Department of Physics and Astronomy,
> > > University of Nigeria, Nsukka
> > >
> > >
> > > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan
> > > 
> > > wrote:
> > >
> > > > Thank you Zhao for the code. When I replotted the graph after
> > > > inserting
> > > > the code in my script, it gave me this error message without
> > > > plotting the
> > > > graph:
> > > > Warning message:
> > > > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)
> > > > :
> > > >  extra argument ‘col’ will be disregarded.
> > > > My regards.
> > > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > > Department of Physics and Astronomy,
> > > > University of Nigeria, Nsukka
> > > >
> > > >
> > > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao 
> > > > wrote:
> > > >
> > > > > ?plotmath
> > > > >
> > > > > expression(R^2==0.62)
> > > > >
> > > > > On 2024/2/4 18:10, Jibrin Alhassan wrote:
> > > > > > I have done a scatter plot in R. I want to insert the
> > > > > > coefficient of
> > > > > > determination R^2 = 0.62 as a text in the plot. I have tried
> > > > > > to write
> > > > > R^2
> > > > > > but could not produce R2. I would appreciate it if someone
> > > > > > could help
> > > > > me
> > > > > > with the syntax. I have tried:  expression(paste("", R^2,"=",
> > > > > > 0.62)),
> > > > > but
> > > > > > it did not produce R squared, rather it gave me error
> > > > > > messages. Thanks.
> > > > > > Jibrin Alhassan
> > > > > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > > > > Department of Physics and Astronomy,
> > > > > > University of Nigeria, Nsukka
> > > > > >
> > > > > >   [[alternative HTML version deleted]]
> > > > > >
> > > > > > __
> > > > > > R-help@r-project.org mailing list -- To UN

Re: [R] Help

2024-02-04 Thread Kimmo Elo
Hi,

the command line with 'text' should be:

text(-8,-8, expression(R^2 * " = 0.62,  r = 0.79, N = 161"), cex = 2 )

Best,

Kimmo

su, 2024-02-04 kello 17:16 +0100, Jibrin Alhassan kirjoitti:
> Here is the script I used to plot the graph indicating the text I
> wanted to
> insert. The line in the script that I have issues with is: text(-8,-
> 8,
> "R^2=  0.62",  r = 0.79, N = 161", cex = 2
> R^2=  0.62 is not producing R squared = 0.62.
> Thanks.
> Sys.setenv( TZ="GMT" )
> dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt"))
> FDcli=dt$FDcli
> FDapt=dt$FDapt
> setEPS()
> postscript(file = "cliapt2.eps")
> par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1))
> plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4, cex.main
> = 0.8,
> font.lab = 1.7, font.axis = 1.7,  col = "red",main = "Simultaneous
> Events
> at CLMX and APTY",ylab="CLMX",xlab="APTY")
> text(-8,-8, "R^2=  0.62",  r = 0.79, N = 161", cex = 2 )
> abline(lm(FDcli ~ FDapt, col="black"))
> dev.off()
> *Jibrin Adejoh Alhassan (Ph.D)*
> Department of Physics and Astronomy,
> University of Nigeria, Nsukka
> 
> 
> On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan
> 
> wrote:
> 
> > Hi Elo,
> > It gave this error message:
> > CR_plot2.R:14:37: unexpected string constant
> > 13: plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4,
> > cex.main =
> > 0.8, font.lab = 1.7, font.axis = 1.7,  col = "red",main =
> > "Simultaneous
> > Events at CLMX and APTY",ylab="CLMX",xlab="APTY")
> > 14: text(-8,-8, "expression(R^2*"=  0.62"),  r = 0.79, N = 161"
> >     ^
> > *Jibrin Adejoh Alhassan (Ph.D)*
> > Department of Physics and Astronomy,
> > University of Nigeria, Nsukka
> > 
> > 
> > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan
> > 
> > wrote:
> > 
> > > Thank you Zhao for the code. When I replotted the graph after
> > > inserting
> > > the code in my script, it gave me this error message without
> > > plotting the
> > > graph:
> > > Warning message:
> > > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...)
> > > :
> > >  extra argument ‘col’ will be disregarded.
> > > My regards.
> > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > Department of Physics and Astronomy,
> > > University of Nigeria, Nsukka
> > > 
> > > 
> > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao 
> > > wrote:
> > > 
> > > > ?plotmath
> > > > 
> > > > expression(R^2==0.62)
> > > > 
> > > > On 2024/2/4 18:10, Jibrin Alhassan wrote:
> > > > > I have done a scatter plot in R. I want to insert the
> > > > > coefficient of
> > > > > determination R^2 = 0.62 as a text in the plot. I have tried
> > > > > to write
> > > > R^2
> > > > > but could not produce R2. I would appreciate it if someone
> > > > > could help
> > > > me
> > > > > with the syntax. I have tried:  expression(paste("", R^2,"=",
> > > > > 0.62)),
> > > > but
> > > > > it did not produce R squared, rather it gave me error
> > > > > messages. Thanks.
> > > > > Jibrin Alhassan
> > > > > *Jibrin Adejoh Alhassan (Ph.D)*
> > > > > Department of Physics and Astronomy,
> > > > > University of Nigeria, Nsukka
> > > > > 
> > > > >       [[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-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-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] Help

2024-02-04 Thread Jibrin Alhassan
Many thanks.

On Mon, Feb 5, 2024, 1:06 AM Rolf Turner  wrote:

>
> Please see fortunes::fortune(285).
>
> cheers,
>
> Rolf Turner
>
> --
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Stats. Dep't. (secretaries) phone:
>  +64-9-373-7599 ext. 89622
> Home phone: +64-9-480-4619
>

[[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] Help

2024-02-04 Thread Rolf Turner


Please see fortunes::fortune(285).

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
 +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619

__
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] Help

2024-02-04 Thread Martin Møller Skarbiniks Pedersen
On Sun, 4 Feb 2024 at 17:26, Jibrin Alhassan  wrote:
>
> Here is the script I used to plot the graph indicating the text I wanted to
> insert. The line in the script that I have issues with is: text(-8,-8,
> "R^2=  0.62",  r = 0.79, N = 161", cex = 2
> R^2=  0.62 is not producing R squared = 0.62.
> Thanks.

This works for me:

curve(dnorm, from=-3, to=3, main="Normal Distribution")
text(x=0, y=0.1, cex=1.5, expression(R^2 == 0.62))

if you are used to write expression using LaTeX math , then maybe you
like the latex2exp package:
curve(dnorm, from=-3, to=3, main="Normal Distribution")
text(0, 0.1, latex2exp::TeX("$R^2 = 0.62$"))

Regards
Martin

__
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] Help

2024-02-04 Thread Jibrin Alhassan
Here is the script I used to plot the graph indicating the text I wanted to
insert. The line in the script that I have issues with is: text(-8,-8,
"R^2=  0.62",  r = 0.79, N = 161", cex = 2
R^2=  0.62 is not producing R squared = 0.62.
Thanks.
Sys.setenv( TZ="GMT" )
dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt"))
FDcli=dt$FDcli
FDapt=dt$FDapt
setEPS()
postscript(file = "cliapt2.eps")
par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1))
plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4, cex.main = 0.8,
font.lab = 1.7, font.axis = 1.7,  col = "red",main = "Simultaneous Events
at CLMX and APTY",ylab="CLMX",xlab="APTY")
text(-8,-8, "R^2=  0.62",  r = 0.79, N = 161", cex = 2 )
abline(lm(FDcli ~ FDapt, col="black"))
dev.off()
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan 
wrote:

> Hi Elo,
> It gave this error message:
> CR_plot2.R:14:37: unexpected string constant
> 13: plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4, cex.main =
> 0.8, font.lab = 1.7, font.axis = 1.7,  col = "red",main = "Simultaneous
> Events at CLMX and APTY",ylab="CLMX",xlab="APTY")
> 14: text(-8,-8, "expression(R^2*"=  0.62"),  r = 0.79, N = 161"
> ^
> *Jibrin Adejoh Alhassan (Ph.D)*
> Department of Physics and Astronomy,
> University of Nigeria, Nsukka
>
>
> On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan 
> wrote:
>
>> Thank you Zhao for the code. When I replotted the graph after inserting
>> the code in my script, it gave me this error message without plotting the
>> graph:
>> Warning message:
>> In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
>>  extra argument ‘col’ will be disregarded.
>> My regards.
>> *Jibrin Adejoh Alhassan (Ph.D)*
>> Department of Physics and Astronomy,
>> University of Nigeria, Nsukka
>>
>>
>> On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao  wrote:
>>
>>> ?plotmath
>>>
>>> expression(R^2==0.62)
>>>
>>> On 2024/2/4 18:10, Jibrin Alhassan wrote:
>>> > I have done a scatter plot in R. I want to insert the coefficient of
>>> > determination R^2 = 0.62 as a text in the plot. I have tried to write
>>> R^2
>>> > but could not produce R2. I would appreciate it if someone could help
>>> me
>>> > with the syntax. I have tried:  expression(paste("", R^2,"=", 0.62)),
>>> but
>>> > it did not produce R squared, rather it gave me error messages. Thanks.
>>> > Jibrin Alhassan
>>> > *Jibrin Adejoh Alhassan (Ph.D)*
>>> > Department of Physics and Astronomy,
>>> > University of Nigeria, Nsukka
>>> >
>>> >   [[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-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.


Re: [R] Help

2024-02-04 Thread Jibrin Alhassan
Hi Elo,
It gave this error message:
CR_plot2.R:14:37: unexpected string constant
13: plot(FDapt,FDcli, pch = 16,  cex.lab = 1.6, cex.axis = 1.4, cex.main =
0.8, font.lab = 1.7, font.axis = 1.7,  col = "red",main = "Simultaneous
Events at CLMX and APTY",ylab="CLMX",xlab="APTY")
14: text(-8,-8, "expression(R^2*"=  0.62"),  r = 0.79, N = 161"
^
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan 
wrote:

> Thank you Zhao for the code. When I replotted the graph after inserting
> the code in my script, it gave me this error message without plotting the
> graph:
> Warning message:
> In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
>  extra argument ‘col’ will be disregarded.
> My regards.
> *Jibrin Adejoh Alhassan (Ph.D)*
> Department of Physics and Astronomy,
> University of Nigeria, Nsukka
>
>
> On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao  wrote:
>
>> ?plotmath
>>
>> expression(R^2==0.62)
>>
>> On 2024/2/4 18:10, Jibrin Alhassan wrote:
>> > I have done a scatter plot in R. I want to insert the coefficient of
>> > determination R^2 = 0.62 as a text in the plot. I have tried to write
>> R^2
>> > but could not produce R2. I would appreciate it if someone could help me
>> > with the syntax. I have tried:  expression(paste("", R^2,"=", 0.62)),
>> but
>> > it did not produce R squared, rather it gave me error messages. Thanks.
>> > Jibrin Alhassan
>> > *Jibrin Adejoh Alhassan (Ph.D)*
>> > Department of Physics and Astronomy,
>> > University of Nigeria, Nsukka
>> >
>> >   [[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-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.


Re: [R] Help

2024-02-04 Thread Kimmo Elo
Hi,

maybe this works:

expression(R^2 * "= 0.62")

HTH,

Kimmo

4. helmik. 2024, 16.11, Jibrin Alhassan 
mailto:jibrin.alhas...@unn.edu.ng>> kirjoitti:

I have done a scatter plot in R. I want to insert the coefficient of
determination R^2 = 0.62 as a text in the plot. I have tried to write R^2
but could not produce R2. I would appreciate it if someone could help me
with the syntax. I have tried:  expression(paste("", R^2,"=", 0.62)), but
it did not produce R squared, rather it gave me error messages. Thanks.
Jibrin Alhassan
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka

 [[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.


Re: [R] Help

2024-02-04 Thread Jibrin Alhassan
Thank you Zhao for the code. When I replotted the graph after inserting the
code in my script, it gave me this error message without plotting the graph:
Warning message:
In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
 extra argument ‘col’ will be disregarded.
My regards.
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka


On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao  wrote:

> ?plotmath
>
> expression(R^2==0.62)
>
> On 2024/2/4 18:10, Jibrin Alhassan wrote:
> > I have done a scatter plot in R. I want to insert the coefficient of
> > determination R^2 = 0.62 as a text in the plot. I have tried to write R^2
> > but could not produce R2. I would appreciate it if someone could help me
> > with the syntax. I have tried:  expression(paste("", R^2,"=", 0.62)), but
> > it did not produce R squared, rather it gave me error messages. Thanks.
> > Jibrin Alhassan
> > *Jibrin Adejoh Alhassan (Ph.D)*
> > Department of Physics and Astronomy,
> > University of Nigeria, Nsukka
> >
> >       [[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-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.


Re: [R] Help

2024-02-04 Thread Jinsong Zhao

?plotmath

expression(R^2==0.62)

On 2024/2/4 18:10, Jibrin Alhassan wrote:

I have done a scatter plot in R. I want to insert the coefficient of
determination R^2 = 0.62 as a text in the plot. I have tried to write R^2
but could not produce R2. I would appreciate it if someone could help me
with the syntax. I have tried:  expression(paste("", R^2,"=", 0.62)), but
it did not produce R squared, rather it gave me error messages. Thanks.
Jibrin Alhassan
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka

[[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-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] Help

2024-02-04 Thread Jibrin Alhassan
I have done a scatter plot in R. I want to insert the coefficient of
determination R^2 = 0.62 as a text in the plot. I have tried to write R^2
but could not produce R2. I would appreciate it if someone could help me
with the syntax. I have tried:  expression(paste("", R^2,"=", 0.62)), but
it did not produce R squared, rather it gave me error messages. Thanks.
Jibrin Alhassan
*Jibrin Adejoh Alhassan (Ph.D)*
Department of Physics and Astronomy,
University of Nigeria, Nsukka

[[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2024-01-06 Thread Andy

Hi Tim

This is brilliant - thank you!!

I've had to tweak the basePath line a bit (I am on a Linux machine), but 
having done that, the code works as intended. This is a truly helpful 
contribution that gives me ideas about how to work it through for the 
missing fields, which is one of the major sticking points I kept bumping 
up against.


Thank you so much for this.

All the best
Andy

On 05/01/2024 13:59, Howard, Tim G (DEC) wrote:

Here's a simplified version of how I would do it, using `textreadr` but 
otherwise base functions. I haven't done it
all, but have a few examples of finding the correct row then extracting the 
right data.
I made a duplicate of the file you provided, so this loops through the two 
identical files, extracts a few parts,
then sticks those parts in a data frame.

#
library(textreadr)

# recommend not using setwd(), but instead just include the
# path as follows
basePath <- file.path("C:","temp")
files <- list.files(path=basePath, pattern = "docx$")

length(files)
# 2

# initialize a list to put the data in
myList <- vector(mode = "list", length = length(files))

for(i in 1:length(files)){
   fileDat <- read_docx(file.path(basePath, files[[i]]))
   # get the data you want, here one line per item to make it clearer
   # assume consistency among articles
   ttl <- fileDat[[1]]
   src <- fileDat[[2]]
   dt <- fileDat[[3]]
   aut <- fileDat[grepl("Byline:",fileDat)]
   aut <- trimws(sub("Byline:","",aut), whitespace = "[\\h\\v]")
   pg <- fileDat[grepl("Pg.",fileDat)]
   pg <- as.integer(sub(".*Pg. ([[:digit:]]+)","\\1",pg))
   len <- fileDat[grepl("Length:", fileDat)]
   len <- as.integer(sub("Length:.{1}([[:digit:]]+) .*","\\1",len))
   myList[[i]] <- data.frame("title"=ttl,
"source"=src,
"date"=dt,
"author"=aut,
"page"=pg,
    "length"=len)
}

# roll up the list to a data frame. Many ways to do this.
myDF <- do.call("rbind",myList)

#

Hope that helps.
Tim




--

Date: Thu, 4 Jan 2024 12:59:59 +
From: Andy 
To: r-help@r-project.org
Subject: Re: [R]  Help request: Parsing docx files for key words and
 appending to a spreadsheet
Message-ID: 
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi folks

Thanks for your help and suggestions - very much appreciated.

I now have some working code, using this file I uploaded for public
access:
https://docs/.
google.com%2Fdocument%2Fd%2F1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVER
k%2Fedit%3Fusp%3Dsharing%26ouid%3D103065135255080058813%26rtpof%
3Dtrue%26sd%3Dtrue=05%7C02%7Ctim.howard%40dec.ny.gov%7C8f2
952a3ae474d4da14908dc0ddd95fd%7Cf46cb8ea79004d108ceb80e8c1c81ee7
%7C0%7C0%7C638400492578674983%7CUnknown%7CTWFpbGZsb3d8eyJWIj
oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3
000%7C%7C%7C=%2BpYrk6cJA%2BDUn9szLbd2Y7R%2F30UNY2TFSJN
HcwkHa9Y%3D=0


The small code segment that now works is as follows:

###

# Load libraries
library(textreadr)
library(tcltk)
library(tidyverse)
#library(officer)
#library(stringr) #for splitting and trimming raw data
#library(tidyr) #for converting to wide format

# I'd like to keep this as it enables more control over the selected directories
filepath <- setwd(tk_choose.dir())

# The following correctly lists the names of all 9 files in my test directory 
files
<- list.files(filepath, ".docx") files
length(files)

# Ideally, I'd like to skip this step by being able to automatically read in the
name of each file, but one step at a time:
filename <- "Now they want us to charge our electric cars from litter
bins.docx"

# This produces the file content as output when run, and identifies the fields
that I want to extract.
read_docx(filename) %>%
str_split(",") %>%
unlist() %>%
str_trim()

###

What I'd like to try and accomplish next is to extract the data from selected
fields and append to a spreadsheet (Calc or Excel) under specific columns, or
if it is easier to write a CSV which I can then use later.

The fields I want to extract are illustrated with reference to the above file,
viz.:

The title: "Now they want us to charge our electric cars from litter bins"
The name of the newspaper: "Mail on Sunday (London)"
The publication date: "September 24, 2023" (in date format, preferably
separated into month and year (day is not important)) The section: "NEWS"
The page number(s): "16" (as numeric)
The length: "515" (as numeric)
The author: "Anna Mikhailova"
The subject: from the Subject section, but this is to match a value e.g.
GREENWASHING

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2024-01-04 Thread Andy

Hi folks

Thanks for your help and suggestions - very much appreciated.

I now have some working code, using this file I uploaded for public 
access: 
https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing=103065135255080058813=true=true 



The small code segment that now works is as follows:

###

# Load libraries
library(textreadr)
library(tcltk)
library(tidyverse)
#library(officer)
#library(stringr) #for splitting and trimming raw data
#library(tidyr) #for converting to wide format

# I'd like to keep this as it enables more control over the selected 
directories

filepath <- setwd(tk_choose.dir())

# The following correctly lists the names of all 9 files in my test 
directory

files <- list.files(filepath, ".docx")
files
length(files)

# Ideally, I'd like to skip this step by being able to automatically 
read in the name of each file, but one step at a time:
filename <- "Now they want us to charge our electric cars from litter 
bins.docx"


# This produces the file content as output when run, and identifies the 
fields that I want to extract.

read_docx(filename) %>%
  str_split(",") %>%
  unlist() %>%
  str_trim()

###

What I'd like to try and accomplish next is to extract the data from 
selected fields and append to a spreadsheet (Calc or Excel) under 
specific columns, or if it is easier to write a CSV which I can then use 
later.


The fields I want to extract are illustrated with reference to the above 
file, viz.:


The title: "Now they want us to charge our electric cars from litter bins"
The name of the newspaper: "Mail on Sunday (London)"
The publication date: "September 24, 2023" (in date format, preferably 
separated into month and year (day is not important))

The section: "NEWS"
The page number(s): "16" (as numeric)
The length: "515" (as numeric)
The author: "Anna Mikhailova"
The subject: from the Subject section, but this is to match a value e.g. 
GREENWASHING >= 50% (here this value is 51% so would be included). A 
match moves onto select the highest value under the section "Industry" 
(here it is ELECTRIC MOBILITY (91%)) and appends this text and % value. 
If no match with 'Greenwashing', then appends 'Null' and moves onto the 
next file in the directory.


###

The theory I am working with is if I can figure out how to extract these 
fields and append correctly, then the rest should just be wrapping this 
up in a for loop.


However, I am struggling to get my head around the extraction and append 
part. If I can get it to work for one of these fields, I suspect that I 
can repeat the basic syntax to extract and append the remaining fields.


Therefore, if someone can either suggest a syntax or point me to a 
useful tutorial, that would be splendid.


Thank you in anticipation.

Best wishes
Andy



__
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] Help request: Parsing docx files for key words and appending to a spreadsheet

2024-01-03 Thread Dr Eberhard Lisse
If you do something like this

for i in  $(pandoc --list-output-formats);
do pandoc -f docx -t $i -o test.$i Now\ they\ want\ us\ to\ 
charge\
our\ electric\ cars\ from\ litter\ bins.docx;
done

you get approximately 65 formats, from which you can pick one which you can
write a little parser for. The dokuwiki one for example uses long lines
which
makes parsing easier.

el


On 2023-12-30 13:57 , Andy wrote:
> Good idea, El - thanks.
>
> The link is
> https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing=103065135255080058813=true=true
>
>  This is helpful.
>
> From the article, which is typical of Lexis+ output, I want to
> extract the following fields and append to a Calc/ Excel spreadsheet.
> Given the volume of articles I have to work through, if this can be
> iterative and semi-automatic, that would be a god send and I might be
> able to do some actual research on the articles before I reach my
> pensionable age. :-)
>
> Title Newspaper Date Section and page number Length Byline Subject
> (only if the threshold of coverage for a specific subject is
>> =50% is reached (e.g. Greenwashing (51%)) - if not, enter 'nil' and
>>
> move onto the next article in the folder
>
> This is the ambition. I am clearly a long way short of that though.
>
> Many thanks. Andy

__
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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Ivan Krylov
В Sat, 30 Dec 2023 12:18:52 +
Andy  пишет:

> filepath <- setwd(tk_choose.dir())

Since you're using tcltk, you can get a file path in one step using
tk_choose.files(). (Use multi = FALSE to choose only one file.)

> full_filename <- paste(filepath, filename, sep="/")

There's also file.path(), which results in slightly more compact,
self-documenting code.

Nowadays, using '/' as the directory separator can be considered
portable, one notable exception being some Windows cmd.exe built-ins
(where '/' is interpreted as flag specifier). Perl5 documentation
mentions Classic MacOS using ':' as the directory separator (and many
other operating systems supporting or emulating Unix-style '/'
separators), but that hasn't been relevant for a long while.

> Error in x$doc_obj : $ operator is invalid for atomic vectors

Which line of code produces the error? What is the argument of
docx_summary() at this point?

Since you're learning R, I can recommend a couple of free books: Visual
Statistics [1] to study the basics of R and The R Inferno [2] for when
you get stuck.

-- 
Best regards,
Ivan

[1]
http://web.archive.org/web/20230415001551/http://ashipunov.info/shipunov/school/biol_240/en/visual_statistics.pdf

[2]
https://www.burns-stat.com/documents/books/the-r-inferno/

______
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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
Sorry, I was being too quick.
You have to pay attention to the pipe operator

You were advised to do the following

content <- read_docx(full_filename) |>
docx_summary()

which should have worked but I think you left out the |> operator.

Alternatively

tmp <- read_docx(full_filename)
content <-  docx_summary(tmp)



On Sat, Dec 30, 2023 at 2:37 PM Andy  wrote:

> An update: Running this block of code:
>
> # Load libraries
> library(tcltk)
> library(tidyverse)
> library(officer)
>
> filepath <- setwd(tk_choose.dir())
>
> filename <- "Now they want us to charge our electric cars from litter
> bins.docx"
>
> #full_filename <- paste0(filepath, filename)
> full_filename <- paste(filepath, filename, sep="/")
>
> if (!file.exists(full_filename)) {
>message("File missing")
> } else {
>content <- read_docx(full_filename) |>
>  docx_summary()
># this reads docx for the full filename and
># passes it ( |> command) to the next line
># which summarises it.
># the result is saved in a data frame object
># called content which we shall show some
># heading into from
>
>head(content)
> }
>
>
> Results in this error now:Error in x$doc_obj : $ operator is invalid for
> atomic vectors
>
> Thank you.
>
>
>
> On 30/12/2023 12:12, Andy wrote:
> > Hi Eric
> >
> > Thanks for that. That seems to fix one problem (the lack of a
> > separator), but introduces a new one when I complete the function
> > Calum proposed:Error in docx_summary() : argument "x" is missing, with
> > no default
> >
> > The whole code so far looks like this:
> >
> >
> > # Load libraries
> > library(tcltk)
> > library(tidyverse)
> > library(officer)
> >
> > filepath <- setwd(tk_choose.dir())
> >
> > filename <- "Now they want us to charge our electric cars from litter
> > bins.docx"
> > #full_filename <- paste0(filepath, filename) # Calum's original
> suggestion
> >
> > full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix
> >
> > #lets double check the file does exist! # The rest here is Calum's
> > suggestion
> > if (!file.exists(full_filename)) {
> >   message("File missing")
> > } else {
> >   content <- read_docx(full_filename)
> >   docx_summary()
> >   # this reads docx for the full filename and
> >   # passes it ( |> command) to the next line
> >   # which summarises it.
> >   # the result is saved in a data frame object
> >   # called content which we shall show some
> >   # heading into from
> >
> >   head(content)
> > }
> >
> >
> > Running this, results in the error cited above.
> >
> > Thanks as always :-)
> >
> >
> >
> >
> > On 30/12/2023 11:58, Eric Berger wrote:
> >> full_filename <- paste(filepath, filename,sep="/")
> >
> >
>
> [[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.


Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Andy
An update: Running this block of code:

# Load libraries
library(tcltk)
library(tidyverse)
library(officer)

filepath <- setwd(tk_choose.dir())

filename <- "Now they want us to charge our electric cars from litter 
bins.docx"

#full_filename <- paste0(filepath, filename)
full_filename <- paste(filepath, filename, sep="/")

if (!file.exists(full_filename)) {
   message("File missing")
} else {
   content <- read_docx(full_filename) |>
     docx_summary()
   # this reads docx for the full filename and
   # passes it ( |> command) to the next line
   # which summarises it.
   # the result is saved in a data frame object
   # called content which we shall show some
   # heading into from

   head(content)
}


Results in this error now:Error in x$doc_obj : $ operator is invalid for 
atomic vectors

Thank you.



On 30/12/2023 12:12, Andy wrote:
> Hi Eric
>
> Thanks for that. That seems to fix one problem (the lack of a 
> separator), but introduces a new one when I complete the function 
> Calum proposed:Error in docx_summary() : argument "x" is missing, with 
> no default
>
> The whole code so far looks like this:
>
>
> # Load libraries
> library(tcltk)
> library(tidyverse)
> library(officer)
>
> filepath <- setwd(tk_choose.dir())
>
> filename <- "Now they want us to charge our electric cars from litter 
> bins.docx"
> #full_filename <- paste0(filepath, filename) # Calum's original suggestion
>
> full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix
>
> #lets double check the file does exist! # The rest here is Calum's 
> suggestion
> if (!file.exists(full_filename)) {
>   message("File missing")
> } else {
>   content <- read_docx(full_filename)
>   docx_summary()
>   # this reads docx for the full filename and
>   # passes it ( |> command) to the next line
>   # which summarises it.
>   # the result is saved in a data frame object
>   # called content which we shall show some
>   # heading into from
>
>   head(content)
> }
>
>
> Running this, results in the error cited above.
>
> Thanks as always :-)
>
>
>
>
> On 30/12/2023 11:58, Eric Berger wrote:
>> full_filename <- paste(filepath, filename,sep="/")
>
>

[[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
docx_summary(content)

You should read documentation e.g. ?docx_summary and check the examples
section

On Sat, Dec 30, 2023 at 2:12 PM Andy  wrote:

> Hi Eric
>
> Thanks for that. That seems to fix one problem (the lack of a separator),
> but introduces a new one when I complete the function Calum proposed:
> Error in docx_summary() : argument "x" is missing, with no default
>
> The whole code so far looks like this:
>
>
> # Load libraries
> library(tcltk)
> library(tidyverse)
> library(officer)
>
> filepath <- setwd(tk_choose.dir())
>
> filename <- "Now they want us to charge our electric cars from litter
> bins.docx"
> #full_filename <- paste0(filepath, filename) # Calum's original suggestion
>
> full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix
>
> #lets double check the file does exist! # The rest here is Calum's
> suggestion
> if (!file.exists(full_filename)) {
>   message("File missing")
> } else {
>   content <- read_docx(full_filename)
>   docx_summary()
>   # this reads docx for the full filename and
>   # passes it ( |> command) to the next line
>   # which summarises it.
>   # the result is saved in a data frame object
>   # called content which we shall show some
>   # heading into from
>
>   head(content)
> }
>
>
> Running this, results in the error cited above.
>
> Thanks as always :-)
>
>
>
>
> On 30/12/2023 11:58, Eric Berger wrote:
>
> full_filename <- paste(filepath, filename,sep="/")
>
>
>

[[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Andy
Hi Eric

Thanks for that. That seems to fix one problem (the lack of a 
separator), but introduces a new one when I complete the function Calum 
proposed:Error in docx_summary() : argument "x" is missing, with no default

The whole code so far looks like this:


# Load libraries
library(tcltk)
library(tidyverse)
library(officer)

filepath <- setwd(tk_choose.dir())

filename <- "Now they want us to charge our electric cars from litter 
bins.docx"
#full_filename <- paste0(filepath, filename) # Calum's original suggestion

full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix

#lets double check the file does exist! # The rest here is Calum's 
suggestion
if (!file.exists(full_filename)) {
   message("File missing")
} else {
   content <- read_docx(full_filename)
   docx_summary()
   # this reads docx for the full filename and
   # passes it ( |> command) to the next line
   # which summarises it.
   # the result is saved in a data frame object
   # called content which we shall show some
   # heading into from

   head(content)
}


Running this, results in the error cited above.

Thanks as always :-)




On 30/12/2023 11:58, Eric Berger wrote:
> full_filename <- paste(filepath, filename,sep="/")


[[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
full_filename <- paste(filepath, filename,sep="/")

On Sat, Dec 30, 2023 at 1:45 PM Andy  wrote:

> Thanks Ivan and Calum
>
> I continue to appreciate your support.
>
> Calum, I entered the code snippet you provided, and it returns 'file
> missing'. Looking at this, while the object 'full_filename' exists, what
> is happening is that the path from getwd() is being appended to the
> title of the article, but without the '/' between the end of the path
> name (here 'TEST' and the name of the article. In other words,
> full_filename is reading "~/TESTNow they want us to charge our electric
> cars from litter bins.docx", so logically, this file doesn't exist. To
> work, the '/' needs to be inserted to differentiate between the end of
> the path name and the start of the article name. I've tried both paste0,
> as you suggested, and paste but neither do the trick.
>
> Is this a result of me using the tkinter folder selection that you
> remarked on? I wanted to keep that so that the selection is interactive,
> but if there are better ways of doing this I am open to suggestions.
>
> Thanks again, both.
>
> Best wishes
> Andrew
>
>
> On 29/12/2023 22:25, CALUM POLWART wrote:
> >
> >
> > help(read_docx) says that the function only imports one docx file. In
> > order to read multiple files, use a for loop or the lapply function.
> >
> >
> > I told you people will suggest better ways to loop!!
> >
> >
> >
> > docx_summary(read_docx("Now they want us to charge our electric cars
> > from litter bins.docx")) should work.
> >
> >
> > Ivan thanks for spotting my fail! Since the OP is new to all this I'm
> > going to suggest a little tweak to this code which we can then build
> > into a for loop:
> >
> > filepath <- getwd() #you will want to change this later. You are doing
> > something with tcl to pick a directory which seems rather fancy! But
> > keep doing it for now or set the directory here ending in a /
> >
> > filename <- "Now they want us to charge our electric cars from litter
> > bins.docx"
> >
> > full_filename <- paste0(filepath, filename)
> >
> > #lets double check the file does exist!
> > if (!file.exists(full_filename)) {
> >   message("File missing")
> > } else {
> >   content <- read_docx(full_filename) |>
> > docx_summary()
> > # this reads docx for the full filename and
> > # passes it ( |> command) to the next line
> > # which summarises it.
> > # the result is saved in a data frame object
> > # called content which we shall show some
> > # heading into from
> >
> >head(content)
> > }
> >
> > Let's get this bit working before we try and loop
> >
>
> [[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.


Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Andy

Good idea, El - thanks.

The link is 
https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing=103065135255080058813=true=true


This is helpful.

From the article, which is typical of Lexis+ output, I want to extract 
the following fields and append to a Calc/ Excel spreadsheet. Given the 
volume of articles I have to work through, if this can be iterative and 
semi-automatic, that would be a god send and I might be able to do some 
actual research on the articles before I reach my pensionable age. :-)


Title
Newspaper
Date
Section and page number
Length
Byline
Subject (only if the threshold of coverage for a specific subject is 
>=50% is reached (e.g. Greenwashing (51%)) - if not, enter 'nil' and 
move onto the next article in the folder


This is the ambition. I am clearly a long way short of that though.

Many thanks.
Andy


On 30/12/2023 00:08, Dr Eberhard W Lisse wrote:

Andy,

you can always open a public Dropbox or Google folder and post the link.

el

On 29/12/2023 22:37, Andy wrote:

Thanks - I'll have a look at these options too.

I'm happy to send over a sample document, but wasn't aware if
attachments are allowed. The documents come Lexis+, so require user
  credentials to log in, but I could upload the file somewhere if
that would help? Any ideas for a good location to do so?

[...]

__
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-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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Andy
Thanks Ivan and Calum

I continue to appreciate your support.

Calum, I entered the code snippet you provided, and it returns 'file 
missing'. Looking at this, while the object 'full_filename' exists, what 
is happening is that the path from getwd() is being appended to the 
title of the article, but without the '/' between the end of the path 
name (here 'TEST' and the name of the article. In other words, 
full_filename is reading "~/TESTNow they want us to charge our electric 
cars from litter bins.docx", so logically, this file doesn't exist. To 
work, the '/' needs to be inserted to differentiate between the end of 
the path name and the start of the article name. I've tried both paste0, 
as you suggested, and paste but neither do the trick.

Is this a result of me using the tkinter folder selection that you 
remarked on? I wanted to keep that so that the selection is interactive, 
but if there are better ways of doing this I am open to suggestions.

Thanks again, both.

Best wishes
Andrew


On 29/12/2023 22:25, CALUM POLWART wrote:
>
>
> help(read_docx) says that the function only imports one docx file. In
> order to read multiple files, use a for loop or the lapply function.
>
>
> I told you people will suggest better ways to loop!!
>
>
>
> docx_summary(read_docx("Now they want us to charge our electric cars
> from litter bins.docx")) should work.
>
>
> Ivan thanks for spotting my fail! Since the OP is new to all this I'm 
> going to suggest a little tweak to this code which we can then build 
> into a for loop:
>
> filepath <- getwd() #you will want to change this later. You are doing 
> something with tcl to pick a directory which seems rather fancy! But 
> keep doing it for now or set the directory here ending in a /
>
> filename <- "Now they want us to charge our electric cars from litter 
> bins.docx"
>
> full_filename <- paste0(filepath, filename)
>
> #lets double check the file does exist!
> if (!file.exists(full_filename)) {
>   message("File missing")
> } else {
>   content <- read_docx(full_filename) |>
>     docx_summary()
>     # this reads docx for the full filename and
>     # passes it ( |> command) to the next line
>     # which summarises it.
>     # the result is saved in a data frame object
>     # called content which we shall show some
>     # heading into from
>
>    head(content)
> }
>
> Let's get this bit working before we try and loop
>

    [[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Dr Eberhard W Lisse
Andy,

you can always open a public Dropbox or Google folder and post the link.

el

On 29/12/2023 22:37, Andy wrote:
> Thanks - I'll have a look at these options too.
>
> I'm happy to send over a sample document, but wasn't aware if
> attachments are allowed. The documents come Lexis+, so require user
>  credentials to log in, but I could upload the file somewhere if
> that would help? Any ideas for a good location to do so?
[...]

______
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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread CALUM POLWART
help(read_docx) says that the function only imports one docx file. In
> order to read multiple files, use a for loop or the lapply function.
>

I told you people will suggest better ways to loop!!


>
> docx_summary(read_docx("Now they want us to charge our electric cars
> from litter bins.docx")) should work.
>

Ivan thanks for spotting my fail! Since the OP is new to all this I'm going
to suggest a little tweak to this code which we can then build into a for
loop:

filepath <- getwd() #you will want to change this later. You are doing
something with tcl to pick a directory which seems rather fancy! But keep
doing it for now or set the directory here ending in a /

filename <- "Now they want us to charge our electric cars from litter
bins.docx"

full_filename <- paste0(filepath, filename)

#lets double check the file does exist!
if (!file.exists(full_filename)) {
  message("File missing")
} else {
  content <- read_docx(full_filename) |>
docx_summary()
# this reads docx for the full filename and
# passes it ( |> command) to the next line
# which summarises it.
# the result is saved in a data frame object
# called content which we shall show some
# heading into from

   head(content)
}

Let's get this bit working before we try and loop

>

[[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Ivan Krylov
В Fri, 29 Dec 2023 20:17:41 +
Andy  пишет:

> doc_in <- read_docx(files)
> 
> Results in this error:Error in filetype %in% c("docx") && 
> grepl("^([fh]ttp)", file) :'length = 9' in coercion to 'logical(1)'

help(read_docx) says that the function only imports one docx file. In
order to read multiple files, use a for loop or the lapply function.

> content <- officer::docx_summary("Now they want us to charge our 
> electric cars from litter bins.docx") # A title of one of the articles
> 
> The error returned is:Error in x$doc_obj : $ operator is invalid for 
> atomic vectors

A similar problem here. help(docx_summary) says that the function
accepts "rdocx" objects returned by read_docx, not file paths. A string
in R is indeed an atomic vector of type character, length 1.

docx_summary(read_docx("Now they want us to charge our electric cars
from litter bins.docx")) should work.

-- 
Best regards,
Ivan

__
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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Andy

Thanks - I'll have a look at these options too.

I'm happy to send over a sample document, but wasn't aware if 
attachments are allowed. The documents come Lexis+, so require user 
credentials to log in, but I could upload the file somewhere if that 
would help? Any ideas for a good location to do so?



On 29/12/2023 20:25, Dr Eberhard W Lisse wrote:

I would also look at https://pandoc.org perhaps which can
export a number of formats...

And for spreadsheets https://github.com/jqnatividad/qsv is my
goto weapon.  Can also read and write XLSX and others.

A sample document or two would always be helpful...

el

On 29/12/2023 21:01, CALUM POLWART wrote:

It sounded like he looked at officeR but I would agree

content <- officer::docx_summary("filename.docx")

Would get the text content into an object called content.

That object is a data.frame so you can then manipulate it.
To be more specific, we might need an example of the DF

[...]

On Fri, Dec 29, 2023 at 10:14 AM Andy 
wrote:

[...]

I'd like to be able to accomplish the following:

(1) Append the title, the month, the author, the number of
words, and page number(s) to a spreadsheet

(2) Read each article and extract keywords (in the docs,
these are listed in 'Subject' section as a list of
keywords with a percentage showing the extent to which the
keyword features in the article (e.g., FAST FASHION (72%))
and to append the keyword and the % coverage to the same
row in the spreadsheet.  However, I want to ensure that
the keyword coverage meets the threshold of >= 50%; if
not, then pass onto the next article in the directory.
Rinse and repeat for the entire directory.

[...]

______
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-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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Dr Eberhard W Lisse
I would also look at https://pandoc.org perhaps which can
export a number of formats...

And for spreadsheets https://github.com/jqnatividad/qsv is my
goto weapon.  Can also read and write XLSX and others.

A sample document or two would always be helpful...

el

On 29/12/2023 21:01, CALUM POLWART wrote:
> It sounded like he looked at officeR but I would agree
> 
> content <- officer::docx_summary("filename.docx")
> 
> Would get the text content into an object called content.
> 
> That object is a data.frame so you can then manipulate it.
> To be more specific, we might need an example of the DF
[...]
>> On Fri, Dec 29, 2023 at 10:14 AM Andy 
>> wrote:
[...]
>>> I'd like to be able to accomplish the following:
>>>
>>> (1) Append the title, the month, the author, the number of
>>> words, and page number(s) to a spreadsheet
>>>
>>> (2) Read each article and extract keywords (in the docs,
>>> these are listed in 'Subject' section as a list of
>>> keywords with a percentage showing the extent to which the
>>> keyword features in the article (e.g., FAST FASHION (72%))
>>> and to append the keyword and the % coverage to the same
>>> row in the spreadsheet.  However, I want to ensure that
>>> the keyword coverage meets the threshold of >= 50%; if
>>> not, then pass onto the next article in the directory.
>>> Rinse and repeat for the entire directory.
[...]

__
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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Andy
However, these packages don't 
>> appear to do what I want the program to do, at least not in any of the 
>> examples I have found, nor in the vignettes and relevant package manuals 
>> I've looked at.
>>
>> The first point is, is what I am intending to do even possible using R? If 
>> it is, then where do I start with this? If these docx files were converted 
>> to UTF-8 plain text, would that make the task easier?
>>
>> I am not a confident coder, and am really only just getting my head around R 
>> so appreciate a steep learning curve ahead, but of course, I don't know what 
>> I don't know, so any pointers in the right direction would be a big help.
>>
>> Many thanks in anticipation
>>
>> Andy
>>
>> ______
>> 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 guidehttp://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.


Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread CALUM POLWART
It sounded like he looked at officeR but I would agree

content <- officer::docx_summary("filename.docx")

Would get the text content into an object called content.

That object is a data.frame so you can then manipulate it.  To be more
specific, we might need an example of the DF

You can loop this easily with a for statement although there are people who
prefer a non-for approach to iteration in R. For can be slow. But if you
don't need to do this very quickly I'd stick with for if you are used to
programming

On Fri, 29 Dec 2023, 18:35 jim holtman,  wrote:

> checkout the 'officer' package
>
> Thanks
>
> Jim Holtman
> *Data Munger Guru*
>
>
> *What is the problem that you are trying to solve?Tell me what you want to
> do, not how you want to do it.*
>
>
> On Fri, Dec 29, 2023 at 10:14 AM Andy  wrote:
>
> > Hello
> >
> > I am trying to work through a problem, but feel like I've gone down a
> > rabbit hole. I'd very much appreciate any help.
> >
> > The task: I have several directories of multiple (some directories, up
> > to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that
> > I want to iterate through to append to a spreadsheet only those articles
> > that satisfy a condition (i.e., a specific keyword is present for >= 50%
> > coverage of the subject matter). Lexis+ has a very specific structure
> > and keywords are given in the row "Subject".
> >
> > I'd like to be able to accomplish the following:
> >
> > (1) Append the title, the month, the author, the number of words, and
> > page number(s) to a spreadsheet
> >
> > (2) Read each article and extract keywords (in the docs, these are
> > listed in 'Subject' section as a list of keywords with a percentage
> > showing the extent to which the keyword features in the article (e.g.,
> > FAST FASHION (72%)) and to append the keyword and the % coverage to the
> > same row in the spreadsheet. However, I want to ensure that the keyword
> > coverage meets the threshold of >= 50%; if not, then pass onto the next
> > article in the directory. Rinse and repeat for the entire directory.
> >
> > So far, I've tried working through some Stack Overflow-based solutions,
> > but most seem to use the textreadr package, which is now deprecated;
> > others use either the officer or the officedown packages. However, these
> > packages don't appear to do what I want the program to do, at least not
> > in any of the examples I have found, nor in the vignettes and relevant
> > package manuals I've looked at.
> >
> > The first point is, is what I am intending to do even possible using R?
> > If it is, then where do I start with this? If these docx files were
> > converted to UTF-8 plain text, would that make the task easier?
> >
> > I am not a confident coder, and am really only just getting my head
> > around R so appreciate a steep learning curve ahead, but of course, I
> > don't know what I don't know, so any pointers in the right direction
> > would be a big help.
> >
> > Many thanks in anticipation
> >
> > Andy
> >
> > __
> > 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.
>

[[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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread CALUM POLWART
textreadr would be the obvious approach.

When you say it is depreciated do you mean it's not available on cran?
Sometimes maintaining a package on cran in just a pain in the ass.

devtools::install_github("trinker/textreadr")


Should let you install it.

In theory docx files are actually just zip files (you can unzip them) and
you may find there is then a specific file in the zip that is readable with
on of R's General text file readers.

Alternatively, read_docx from:
https://www.rdocumentation.org/packages/qdapTools

May be worth a look.

What platform are you on. Certainly options to command line convert files
to txt and do from there.


On Fri, 29 Dec 2023, 18:25 Roy Mendelssohn - NOAA Federal via R-help, <
r-help@r-project.org> wrote:

> Hi Andy:
>
> I don’t have an answer but I do have what I hope is some friendly advice.
> Generally the more information you can provide,  the more likely you will
> get help that is useful.  In your case you say that you tried several
> packages and they didn’t do what you wanted.  Providing that code,  as well
> as why they didn’t do what you wanted (be specific)  would greatly
> facilitate things.
>
> Happy new year,
>
> -Roy
>
>
> > On Dec 29, 2023, at 10:14 AM, Andy  wrote:
> >
> > Hello
> >
> > I am trying to work through a problem, but feel like I've gone down a
> rabbit hole. I'd very much appreciate any help.
> >
> > The task: I have several directories of multiple (some directories, up
> to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that I
> want to iterate through to append to a spreadsheet only those articles that
> satisfy a condition (i.e., a specific keyword is present for >= 50%
> coverage of the subject matter). Lexis+ has a very specific structure and
> keywords are given in the row "Subject".
> >
> > I'd like to be able to accomplish the following:
> >
> > (1) Append the title, the month, the author, the number of words, and
> page number(s) to a spreadsheet
> >
> > (2) Read each article and extract keywords (in the docs, these are
> listed in 'Subject' section as a list of keywords with a percentage showing
> the extent to which the keyword features in the article (e.g., FAST FASHION
> (72%)) and to append the keyword and the % coverage to the same row in the
> spreadsheet. However, I want to ensure that the keyword coverage meets the
> threshold of >= 50%; if not, then pass onto the next article in the
> directory. Rinse and repeat for the entire directory.
> >
> > So far, I've tried working through some Stack Overflow-based solutions,
> but most seem to use the textreadr package, which is now deprecated; others
> use either the officer or the officedown packages. However, these packages
> don't appear to do what I want the program to do, at least not in any of
> the examples I have found, nor in the vignettes and relevant package
> manuals I've looked at.
> >
> > The first point is, is what I am intending to do even possible using R?
> If it is, then where do I start with this? If these docx files were
> converted to UTF-8 plain text, would that make the task easier?
> >
> > I am not a confident coder, and am really only just getting my head
> around R so appreciate a steep learning curve ahead, but of course, I don't
> know what I don't know, so any pointers in the right direction would be a
> big help.
> >
> > Many thanks in anticipation
> >
> > Andy
> >
> > __
> > 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-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.


Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread jim holtman
checkout the 'officer' package

Thanks

Jim Holtman
*Data Munger Guru*


*What is the problem that you are trying to solve?Tell me what you want to
do, not how you want to do it.*


On Fri, Dec 29, 2023 at 10:14 AM Andy  wrote:

> Hello
>
> I am trying to work through a problem, but feel like I've gone down a
> rabbit hole. I'd very much appreciate any help.
>
> The task: I have several directories of multiple (some directories, up
> to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that
> I want to iterate through to append to a spreadsheet only those articles
> that satisfy a condition (i.e., a specific keyword is present for >= 50%
> coverage of the subject matter). Lexis+ has a very specific structure
> and keywords are given in the row "Subject".
>
> I'd like to be able to accomplish the following:
>
> (1) Append the title, the month, the author, the number of words, and
> page number(s) to a spreadsheet
>
> (2) Read each article and extract keywords (in the docs, these are
> listed in 'Subject' section as a list of keywords with a percentage
> showing the extent to which the keyword features in the article (e.g.,
> FAST FASHION (72%)) and to append the keyword and the % coverage to the
> same row in the spreadsheet. However, I want to ensure that the keyword
> coverage meets the threshold of >= 50%; if not, then pass onto the next
> article in the directory. Rinse and repeat for the entire directory.
>
> So far, I've tried working through some Stack Overflow-based solutions,
> but most seem to use the textreadr package, which is now deprecated;
> others use either the officer or the officedown packages. However, these
> packages don't appear to do what I want the program to do, at least not
> in any of the examples I have found, nor in the vignettes and relevant
> package manuals I've looked at.
>
> The first point is, is what I am intending to do even possible using R?
> If it is, then where do I start with this? If these docx files were
> converted to UTF-8 plain text, would that make the task easier?
>
> I am not a confident coder, and am really only just getting my head
> around R so appreciate a steep learning curve ahead, but of course, I
> don't know what I don't know, so any pointers in the right direction
> would be a big help.
>
> Many thanks in anticipation
>
> Andy
>
> ______
> 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.


Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Roy Mendelssohn - NOAA Federal via R-help
Hi Andy:

I don’t have an answer but I do have what I hope is some friendly advice.  
Generally the more information you can provide,  the more likely you will get 
help that is useful.  In your case you say that you tried several packages and 
they didn’t do what you wanted.  Providing that code,  as well as why they 
didn’t do what you wanted (be specific)  would greatly facilitate things.

Happy new year,

-Roy


> On Dec 29, 2023, at 10:14 AM, Andy  wrote:
> 
> Hello
> 
> I am trying to work through a problem, but feel like I've gone down a rabbit 
> hole. I'd very much appreciate any help.
> 
> The task: I have several directories of multiple (some directories, up to 
> 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that I want 
> to iterate through to append to a spreadsheet only those articles that 
> satisfy a condition (i.e., a specific keyword is present for >= 50% coverage 
> of the subject matter). Lexis+ has a very specific structure and keywords are 
> given in the row "Subject".
> 
> I'd like to be able to accomplish the following:
> 
> (1) Append the title, the month, the author, the number of words, and page 
> number(s) to a spreadsheet
> 
> (2) Read each article and extract keywords (in the docs, these are listed in 
> 'Subject' section as a list of keywords with a percentage showing the extent 
> to which the keyword features in the article (e.g., FAST FASHION (72%)) and 
> to append the keyword and the % coverage to the same row in the spreadsheet. 
> However, I want to ensure that the keyword coverage meets the threshold of >= 
> 50%; if not, then pass onto the next article in the directory. Rinse and 
> repeat for the entire directory.
> 
> So far, I've tried working through some Stack Overflow-based solutions, but 
> most seem to use the textreadr package, which is now deprecated; others use 
> either the officer or the officedown packages. However, these packages don't 
> appear to do what I want the program to do, at least not in any of the 
> examples I have found, nor in the vignettes and relevant package manuals I've 
> looked at.
> 
> The first point is, is what I am intending to do even possible using R? If it 
> is, then where do I start with this? If these docx files were converted to 
> UTF-8 plain text, would that make the task easier?
> 
> I am not a confident coder, and am really only just getting my head around R 
> so appreciate a steep learning curve ahead, but of course, I don't know what 
> I don't know, so any pointers in the right direction would be a big help.
> 
> Many thanks in anticipation
> 
> Andy
> 
> __
> 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-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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-29 Thread Andy

Hello

I am trying to work through a problem, but feel like I've gone down a 
rabbit hole. I'd very much appreciate any help.


The task: I have several directories of multiple (some directories, up 
to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that 
I want to iterate through to append to a spreadsheet only those articles 
that satisfy a condition (i.e., a specific keyword is present for >= 50% 
coverage of the subject matter). Lexis+ has a very specific structure 
and keywords are given in the row "Subject".


I'd like to be able to accomplish the following:

(1) Append the title, the month, the author, the number of words, and 
page number(s) to a spreadsheet


(2) Read each article and extract keywords (in the docs, these are 
listed in 'Subject' section as a list of keywords with a percentage 
showing the extent to which the keyword features in the article (e.g., 
FAST FASHION (72%)) and to append the keyword and the % coverage to the 
same row in the spreadsheet. However, I want to ensure that the keyword 
coverage meets the threshold of >= 50%; if not, then pass onto the next 
article in the directory. Rinse and repeat for the entire directory.


So far, I've tried working through some Stack Overflow-based solutions, 
but most seem to use the textreadr package, which is now deprecated; 
others use either the officer or the officedown packages. However, these 
packages don't appear to do what I want the program to do, at least not 
in any of the examples I have found, nor in the vignettes and relevant 
package manuals I've looked at.


The first point is, is what I am intending to do even possible using R? 
If it is, then where do I start with this? If these docx files were 
converted to UTF-8 plain text, would that make the task easier?


I am not a confident coder, and am really only just getting my head 
around R so appreciate a steep learning curve ahead, but of course, I 
don't know what I don't know, so any pointers in the right direction 
would be a big help.


Many thanks in anticipation

Andy

______
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] R-help Digest, Vol 250, Issue 13

2023-12-15 Thread Karl Ropkins
Kevin,
Maybe also look at what air quality monitoring is being done in area.
https://cran.r-project.org/web/packages/RAQSAPI/vignettes/RAQSAPIvignette.html
Depends what and how near, but might be something relevant there?

Karl

Dr Karl Ropkins
Transport Studies | Environment | University of Leeds

--

Message: 2
Date: Tue, 12 Dec 2023 07:52:59 -0800
From: Bert Gunter 
To: Kevin Zembower 
Cc: R-help email list 
Subject: Re: [R] Advice on starting to analyze smokestack emissions?
Message-ID:

Content-Type: text/plain; charset="utf-8"

You might also try the R-Sig-ecology list, though I would agree that it's
not clearly related. Still, air pollution effects...?

-- Bert

On Tue, Dec 12, 2023 at 3:15 AM Kevin Zembower via R-help <
r-help@r-project.org> wrote:

> Hello, all,
>
> [Originally sent to r-sig-geo list, with no response. Cross-posting
> here, in the hope of a wider audience. Anyone with any experience in
> this topic? Thanks.]
>
> I'm trying to get started analyzing the concentrations of smokestack
> emissions. I don't have any professional background or training for
> this; I'm just an old, retired guy who thinks playing with numbers is
> fun.
>
> A local funeral home in my neighborhood (less than 1200 ft from my
> home) is proposing to construct a crematorium for human remains. I have
> some experience with the tidycensus package and thought it might be
> interesting to construct a model for the changes in concentrations of
> the pollutants from the smokestack and, using recorded wind speeds and
> directions, see which US Census blocks would be affected.
>
> I have the US Government EPA SCREEN3 output on how concentration varies
> with distance from the smokestack.
> See
> https://www.epa.gov/scram/air-quality-dispersion-modeling-screening-models#screen3
> if curious. As a first task, I'd like to see if I can calculate similar
> results in R. I'm aware of the 'plume' steady-state Gaussian dispersion
> package
> (https://rdrr.io/github/holstius/plume/f/inst/doc/plume-intro.pdf), but
> am a little concerned that this package was last updated 11 years ago.
>
> Do you have any recommendations for me on how to get started analyzing
> this problem? Is 'plume' still the way to go? I'm aware that there are
> many atmospheric dispersion models from the US EPA, but I was hoping to
> keep my work within R, which I'm really enjoying using and learning
> about. Are SCREEN3 and 'plume' comparable? Is this the best R list to
> ask questions about this topic?
>
> Thanks for any advice or guidance you have for me.
>
> -Kevin
>
>
>
>
> ______
> 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]]




--

Message: 3
Date: Tue, 12 Dec 2023 21:19:12 + (UTC)
From: varin sacha 
To: "r-help@r-project.org" ,  Ben Bolker

Subject: Re: [R] ggplot2: Get the regression line with 95% confidence
bands
Message-ID: <68588390.888662.1702415952...@mail.yahoo.com>
Content-Type: text/plain; charset="utf-8"

Dear Ben,
Dear Daniel,
Dear Rui,
Dear Bert,

Here below my R code.
I really appreciate all your comments. My R code is perfectly working but there 
is still something I would like to improve. The X-axis is showing   2012.5 ;   
2015.0   ;   2017.5   ;  2020.0
I would like to see on X-axis only the year (2012 ; 2015 ; 2017 ; 2020). How to 
do?


#
library(ggplot2)

df=data.frame(year= c(2012,2015,2018,2022), score=c(495,493, 495, 474))

ggplot(df, aes(x = year, y = score)) + geom_point() + geom_smooth(method = 
"lm", formula = y ~ x) +
 labs(title = "Standard linear regression for France", x = "Year", y = "PISA 
score in mathematics") + 
scale_y_continuous(limits=c(470,500),oob=scales::squish)
#####









Le lundi 11 décembre 2023 à 23:38:06 UTC+1, Ben Bolker  a 
écrit :







On 2023-12-11 5:27 p.m., Daniel Nordlund wrote:
> On 12/10/2023 2:50 PM, Rui Barradas wrote:
>> Às 22:35 de 10/12/2023, varin sacha via R-help escreveu:
>>>
>>> Dear R-experts,
>>>
>>> Here below my R code, as my X-axis is "year", I must be missing one
>>> or more steps! I am trying to get the regression line with the 95%
>>> confidence bands around the regression line. Any help would be
>>> appreciated.
>>>
>>> Best,
>>> S.
>>>
>>>
>>> 

Re: [R] Virus alert because of an R-help e-mail

2023-10-31 Thread Bert Gunter
No attachments. Most are deleted by  ETH mailman ... because they might
contain viruses.

-- Bert

On Tue, Oct 31, 2023 at 8:59 AM David Croll  wrote:

> I just received a virus warning from my e-mail provider, GMX. See the
> attached image below.
>
> The virus detection can be spurious - but the e-mail was automatically
> deleted by GMX.
>
> With the best regards,
>
>
> David
> __
> 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] Virus alert because of an R-help e-mail

2023-10-31 Thread David Croll

I just received a virus warning from my e-mail provider, GMX. See the
attached image below.

The virus detection can be spurious - but the e-mail was automatically
deleted by GMX.

With the best regards,


David
__
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-es] Resumen de R-help-es, Vol 176, Envío 10

2023-10-17 Thread Andrés Hirigoyen
Gracias!

El mar, 17 oct 2023 a la(s) 07:06, 
escribió:

> Envíe los mensajes para la lista R-help-es a
>     r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
>
>
> Asuntos del día:
>
>1. Re: Gráfica en R (Marcelino de la Cruz Rot)
>
> --
>
> Message: 1
> Date: Mon, 16 Oct 2023 20:36:26 +0200
> From: Marcelino de la Cruz Rot 
> To: r-help-es@r-project.org
> Subject: Re: [R-es] Gráfica en R
> Message-ID: <357922dc-eda4-0663-51f8-c6a3cc638...@urjc.es>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> Buenas tardes:
>
> ggplot(data=data, aes(x = Peso1, y =Peso2))+
>geom_point()+
>geom_path()
>
> Saludos,
> Marcelino
>
>
> El 16/10/2023 a las 20:11, Andrés Hirigoyen escribió:
> > Buenas tardes. Necesito una mano para reproducir esta gráfica  en R
> > desde esta base:
> > Base:
> >
> > Dosis Nivel   Peso1   Peso2
> > 1 0   1,882,43
> > 1 40  1,862,84
> > 1 80  2,063,02
> > 1 120 2,084,12
> > 1 300 1,815,65
> > 1 600 1,775,96
> >
> > Gráfica Excel
> > image.png
> >
> > Si uso asi:
> > ggplot(data=data, aes(x = Peso1, y =Peso2, group=Nivel, color =Nivel))+
> >  geom_point()+
> >  geom_line()
> > Une los puntos por orden de magnitud y no por orden de Nivel:
> > image.png
> > Muchas gracias desde ya
> >
> >  *
> >
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
> --
> Marcelino de la Cruz Rot
> Coordinador funcional de Biología
> Depto. de Biología y Geología
> Física y Química Inorgánica
> Universidad Rey Juan Carlos
> Móstoles España
>
>
>
>
> --
>
> Subject: Pié de página del digest
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
> --
>
> Fin de Resumen de R-help-es, Vol 176, Envío 10
> **
>


-- 
 *Dr. **Andrés Hirigoyen*
*Ing. Agr. **(MSc)*
* Prof. Ciencias Biológicas*
Scholar Andrés
<https://scholar.google.com/citations?hl=es=ubpY7s4J_op=list_works=pubdate>
Researchgate Andrés <https://www.researchgate.net/profile/Andres-Hirigoyen>

   -

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 176, Envío 1

2023-10-07 Thread Amable Moreno
Me chas gracias!!
Ya lo pude instalar!!!

El El sáb, 7 de oct. de 2023 a la(s) 07:01, 
escribió:

> Envíe los mensajes para la lista R-help-es a
>     r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
>
>
> Asuntos del día:
>
>1. TeachingDemos (Amable Moreno)
>2. Re: TeachingDemos (Javier Marcuzzi)
>
> --
>
> Message: 1
> Date: Fri, 6 Oct 2023 17:26:43 -0300
> From: Amable Moreno 
> To: r-help-es@r-project.org
> Subject: [R-es] TeachingDemos
> Message-ID:
> <
> cadothbhp6s5_ulc5eitx0otc7e37kx6pp2c+rekfcioj9bf...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Estimados colegas
>
> Hasta el año pasado he usado el paquete "TeachingDemos"
> Pero ahora, este paque no lo tengo instalado y no lo puedo volver a
> instalar
> me marca error
> Agradecweria me constesten, por favor, si alguien sabe porque ocurre
>
> [[alternative HTML version deleted]]
>
>
>
>
> --
>
> Message: 2
> Date: Fri, 6 Oct 2023 19:54:10 -0300
> From: Javier Marcuzzi 
> To: Amable Moreno 
> Cc: "R-help-es@r-project.org" 
> Subject: Re: [R-es] TeachingDemos
> Message-ID: <32218d4b-5644-4ac8-8489-f7c01ecdd...@gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Estimada Amable Moreno
>
> En Mac, R actualizado, anda. Observe mi escritura y la respuesta.
>
> > install.packages("TeachingDemos")
> trying URL '
> https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.3/TeachingDemos_2.12.tgz
> '
> Content type 'application/x-gzip' length 1237702 bytes (1.2 MB)
> ==
> downloaded 1.2 MB
>
>
> Javier Rubén Marcuzzi
>
> > El 6 oct 2023, a las 17:26, Amable Moreno 
> escribió:
> >
> > TeachingDemos
>
>
> [[alternative HTML version deleted]]
>
>
>
>
> --
>
> Subject: Pié de página del digest
>
> ___________
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
> --
>
> Fin de Resumen de R-help-es, Vol 176, Envío 1
> *
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Help with plotting and date-times for climate data

2023-09-15 Thread Martin Møller Skarbiniks Pedersen
Change

 geom_point(aes(y = tmax_mean, color = "blue"))
to
 geom_point(aes(y = tmax_mean), color = "blue")
if you want blue points.

aes(color = ) does not set the color of the points.

aes(color = ) takes a column (best if it is a factor) and uses that for
different colors.


/Martin

On Tue, Sep 12, 2023, 22:50 Kevin Zembower via R-help 
wrote:

> Hello,
>
> I'm trying to calculate the mean temperature max from a file of climate
> date, and plot it over a range of days in the year. I've downloaded the
> data, and cleaned it up the way I think it should be. However, when I
> plot it, the geom_smooth line doesn't show up. I think that's because
> my x axis is characters or factors. Here's what I have so far:
> 
> library(tidyverse)
>
> data <- read_csv("Ely_MN_Weather.csv")
>
> start_day = yday(as_date("2023-09-22"))
> end_day = yday(as_date("2023-10-15"))
>
> d <- as_tibble(data) %>%
> select(DATE,TMAX,TMIN) %>%
> mutate(DATE = as_date(DATE),
>yday = yday(DATE),
>md = sprintf("%02d-%02d", month(DATE), mday(DATE))
>) %>%
> filter(yday >= start_day & yday <= end_day) %>%
> mutate(md = as.factor(md))
>
> d_sum <- d %>%
> group_by(md) %>%
> summarize(tmax_mean = mean(TMAX, na.rm=TRUE))
>
> ## Here's the filtered data:
> dput(d_sum)
>
> > structure(list(md = structure(1:25, levels = c("09-21", "09-22",
> "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
> "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06",
> "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13",
> "10-14", "10-15"), class = "factor"), tmax_mean = c(65,
> 62.2,
> 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9,
> 61.2, 63.7, 59.5, 59.6, 61.6,
> 59.4, 58.8, 55.9, 58.125,
> 58, 55.7, 57, 55.4, 49.8,
> 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame"
> ), row.names = c(NA, -25L))
> >
> ggplot(data = d_sum, aes(x = md)) +
> geom_point(aes(y = tmax_mean, color = "blue")) +
> geom_smooth(aes(y = tmax_mean, color = "blue"))
> =
> My questions are:
> 1. Why isn't my geom_smooth plotting? How can I fix it?
> 2. I don't think I'm handling the month and day combination correctly.
> Is there a way to encode month and day (but not year) as a date?
> 3. (Minor point) Why does my graph of tmax_mean come out red when I
> specify "blue"?
>
> Thanks for any advice or guidance you can offer. I really appreciate
> the expertise of this group.
>
> -Kevin
>
> __
> 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.


Re: [R] Help with plotting and date-times for climate data

2023-09-14 Thread Richard O'Keefe
ee day models (or
> > > some version of that). This is number of thermal units needed for
> > > the organism to develop to the next stage (e.g. instar for an
> > > insect, or fruit/flower formation for a plant). However, better
> > > accuracy is obtained if the model includes both min and max
> > > thresholds.
> > >
> > > All I have done is provide an example where min and max could have
> > > a real world use. I use max(temp) over some interval and then
> > > update an accumulated thermal units variable based on the outcome.
> > > That detail is not evident in the original request.
> > >
> > > Tim
> > >
> > > -Original Message-
> > > From: R-help  On Behalf Of Richard
> > > O'Keefe
> > > Sent: Wednesday, September 13, 2023 9:58 AM
> > > To: Kevin Zembower 
> > > Cc: r-help@r-project.org
> > > Subject: Re: [R] Help with plotting and date-times for climate data
> > >
> > > [External Email]
> > >
> > > Off-topic, but what is a "mean temperature max"
> > > and what good would it do you to know you if you did?
> > > I've been looking at a lot of weather station data and for no
> > > question I've ever had (except "would the newspapers get excited
> > > about this") was "max" (or min) the answer.  Considering the way
> > > that temperature can change by several degrees in a few minutes, or
> > > a few metres -- I meant horizontally when I wrote that, but as you
> > > know your head and feet don't experience the same temperature,
> > > again by more than one degree -- I am at something of a loss to
> > > ascribe much practical significance to TMAX.  Are you sure this is
> > > the analysis you want to do?  Is this the most informative data you
> > > can get?
> > >
> > > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help <
> > > r-help@r-project.org> wrote:
> > >
> > > > Hello,
> > > >
> > > > I'm trying to calculate the mean temperature max from a file of
> > > > climate date, and plot it over a range of days in the year. I've
> > > > downloaded the data, and cleaned it up the way I think it should
> > > > be.
> > > > However, when I plot it, the geom_smooth line doesn't show up. I
> > > > think
> > > > that's because my x axis is characters or factors. Here's what I
> > > > have so far:
> > > > 
> > > > library(tidyverse)
> > > >
> > > > data <- read_csv("Ely_MN_Weather.csv")
> > > >
> > > > start_day = yday(as_date("2023-09-22")) end_day =
> > > > yday(as_date("2023-10-15"))
> > > >
> > > > d <- as_tibble(data) %>%
> > > >  select(DATE,TMAX,TMIN) %>%
> > > >  mutate(DATE = as_date(DATE),
> > > > yday = yday(DATE),
> > > > md = sprintf("%02d-%02d", month(DATE), mday(DATE))
> > > > ) %>%
> > > >  filter(yday >= start_day & yday <= end_day) %>%
> > > >  mutate(md = as.factor(md))
> > > >
> > > > d_sum <- d %>%
> > > >  group_by(md) %>%
> > > >  summarize(tmax_mean = mean(TMAX, na.rm=TRUE))
> > > >
> > > > ## Here's the filtered data:
> > > > dput(d_sum)
> > > >
> > > > > structure(list(md = structure(1:25, levels = c("09-21", "09-
> > > > > 22",
> > > > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
> > > > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06",
> > > > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13",
> > > > "10-14", "10-15"), class = "factor"), tmax_mean = c(65,
> > > > 62.2, 61.3, 63.9, 64.3, 60.1,
> > > > 62.3, 60.5, 61.9, 61.2, 63.7, 59.5, 59.6,
> > > > 61.6, 59.4, 58.8,
> > > > 55.9, 58.125, 58, 55.7, 57,
> > > > 55.4,
> > > > 49.8, 48.75, 43.

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Ebert,Timothy Aaron
Dear Kevin,

You could try the National Weather Service. I can get "International Falls" and 
other locations, though Ely is not specifically listed. 

h**ps://www.weather.gov/wrh/climate?wfo=dlh
Replace the ** with tt and it should give the right link.

There is a menu.
Select your location,
Select a product (I selected temperature)
Select a year, and period of interest.
Select go.

If you scroll over the figure a popup with numbers appears.

The weather data in R is possible as well.
I would start by filtering the data to remove dates outside my range of 
interest. Then extract the date (say Day). Group_by the day and apply a max 
function to the grouped data. Then plot the result.

Tim

-Original Message-
From: Kevin Zembower  
Sent: Wednesday, September 13, 2023 3:26 PM
To: Ebert,Timothy Aaron ; Richard O'Keefe 
Cc: r-help@r-project.org
Subject: Re: [R] Help with plotting and date-times for climate data

[External Email]

Hi, Tim,

I actually did see this chart when I was doing some research, but rejected it 
because it was difficult to interpolate the graph for the three week period I 
was interested it. I didn't discover until just now that I could click on the 
labels on the x-axis to expand the graph.
Unfortunately, downloading the data from this site costs $95/month.

Also, I found the raw data (from the NWS, for free) and decided to exercise my 
R skills to see if I could produce the exact graph I wanted.

Thanks for taking the time to research this.

-Kevin

On Wed, 2023-09-13 at 18:21 +, Ebert,Timothy Aaron wrote:
> Hi Kevin,
>
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fweat
> herspark.com%2Fy%2F11610%2FAverage-Weather-in-Ely-Minnesota-United-Sta
> tes-Year-Round=05%7C01%7Ctebert%40ufl.edu%7C3c23bc8b4af14d747e2f0
> 8dbb48f37af%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C6383022994410
> 38779%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB
> TiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=CE%2FYdcJbtKhZZ6VeRlI
> 55gEfwy8m2i1yhO9iUgB%2BkUc%3D=0
> Just scroll down. I think what you are looking for is the first graph, 
> but there are about a dozen other graphs on various meteorological 
> metrics.
>
>Another option would be to use larger cities (Duluth, 
> International Falls, Thunder Bay) and take a metal average. There is a 
> lake effect for two of these more than the other.
>
>All good?
> Tim
>
> -Original Message-
> From: Kevin Zembower 
> Sent: Wednesday, September 13, 2023 2:05 PM
> To: Ebert,Timothy Aaron ; Richard O'Keefe 
> 
> Cc: r-help@r-project.org
> Subject: Re: [R] Help with plotting and date-times for climate data
>
> [External Email]
>
> Well, I looked for this, on both the NWS and WeatherUnderground, but 
> couldn't find what I was looking for. Didn't check Weather.com, but if 
> you can find a chart of the average high and low temperatures in Ely, 
> MN between about the middle of September to the middle of October, 
> I'll buy you a beer.
>
> -Kevin
>
> On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote:
> > I admire the dedication to R and data science, but the Weather 
> > Channel might be a simpler approach. Weather.com. I can search for 
> > (city
> > name)
> > and either weather (current values) or climate. It depends on how 
> > far away the trip will be.
> >
> > -Original Message-
> > From: Kevin Zembower 
> > Sent: Wednesday, September 13, 2023 1:22 PM
> > To: Richard O'Keefe ; Ebert,Timothy Aaron 
> > 
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Help with plotting and date-times for climate data
> >
> > [External Email]
> >
> > Tim, Richard, y'all are reading too much into this. I believe that 
> > TMAX is the high temperature of the day, and TMIN is the low. I'm 
> > trying to compute the average or median high and low temperatures 
> > for the data I have (2011 to present). I'm going on a trip to this 
> > area, and want to know how to pack.
> >
> > Thanks for your interest.
> >
> > -Kevin
> >
> > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote:
> > > I am well aware of the physiological implications of temperature, 
> > > and that is *why* I view recorded TMIN and TMAX at a single point 
> > > with an extremely jaundiced eye.  TMAX at shoulder height has very 
> > > little relevance to an insect living in grass, for example.  And 
> > > if TMAX is sustained for one second, that has very different 
> > > consequences from if TMAX is sustained for five minutes.  I can 
> > > see the usefulness of "proportion of day above Thi/below Tlo", but 
> > > that is quite different.
> > >
>

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Kevin Zembower via R-help
Hi, Tim,

I actually did see this chart when I was doing some research, but
rejected it because it was difficult to interpolate the graph for the
three week period I was interested it. I didn't discover until just now
that I could click on the labels on the x-axis to expand the graph.
Unfortunately, downloading the data from this site costs $95/month. 

Also, I found the raw data (from the NWS, for free) and decided to
exercise my R skills to see if I could produce the exact graph I
wanted.

Thanks for taking the time to research this.

-Kevin

On Wed, 2023-09-13 at 18:21 +, Ebert,Timothy Aaron wrote:
> Hi Kevin,
> 
> https://weatherspark.com/y/11610/Average-Weather-in-Ely-Minnesota-United-States-Year-Round
> Just scroll down. I think what you are looking for is the first
> graph, but there are about a dozen other graphs on various
> meteorological metrics. 
>    
>    Another option would be to use larger cities (Duluth,
> International Falls, Thunder Bay) and take a metal average. There is
> a lake effect for two of these more than the other. 
>    
>    All good?
> Tim
> 
> -Original Message-
> From: Kevin Zembower  
> Sent: Wednesday, September 13, 2023 2:05 PM
> To: Ebert,Timothy Aaron ; Richard O'Keefe
> 
> Cc: r-help@r-project.org
> Subject: Re: [R] Help with plotting and date-times for climate data
> 
> [External Email]
> 
> Well, I looked for this, on both the NWS and WeatherUnderground, but
> couldn't find what I was looking for. Didn't check Weather.com, but
> if you can find a chart of the average high and low temperatures in
> Ely, MN between about the middle of September to the middle of
> October, I'll buy you a beer.
> 
> -Kevin
> 
> On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote:
> > I admire the dedication to R and data science, but the Weather
> > Channel 
> > might be a simpler approach. Weather.com. I can search for (city
> > name) 
> > and either weather (current values) or climate. It depends on how
> > far 
> > away the trip will be.
> > 
> > -Original Message-
> > From: Kevin Zembower 
> > Sent: Wednesday, September 13, 2023 1:22 PM
> > To: Richard O'Keefe ; Ebert,Timothy Aaron 
> > 
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Help with plotting and date-times for climate data
> > 
> > [External Email]
> > 
> > Tim, Richard, y'all are reading too much into this. I believe that 
> > TMAX is the high temperature of the day, and TMIN is the low. I'm 
> > trying to compute the average or median high and low temperatures
> > for 
> > the data I have (2011 to present). I'm going on a trip to this
> > area, 
> > and want to know how to pack.
> > 
> > Thanks for your interest.
> > 
> > -Kevin
> > 
> > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote:
> > > I am well aware of the physiological implications of temperature,
> > > and that is *why* I view recorded TMIN and TMAX at a single point
> > > with an extremely jaundiced eye.  TMAX at shoulder height has
> > > very 
> > > little relevance to an insect living in grass, for example.  And
> > > if 
> > > TMAX is sustained for one second, that has very different 
> > > consequences from if TMAX is sustained for five minutes.  I can
> > > see 
> > > the usefulness of "proportion of day above Thi/below Tlo", but
> > > that 
> > > is quite different.
> > > 
> > > OK, so my interest in weather data was mainly based around water
> > > management: precipitation, evaporation, herd and crop water
> > > needs, 
> > > that kind of thing.  And the first thing you learn from that 
> > > experience is that ANY kind of single-point summary is seriously 
> > > misleading.
> > > 
> > > Let's end this digression.
> > > 
> > > 
> > > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron
> > > 
> > > wrote:
> > > > I had the same question.
> > > > However, I can partly answer the off-topic question. Min and
> > > > max 
> > > > can be important as lower and upper development thresholds.
> > > > Below 
> > > > the min no growth or development occur because reaction rates
> > > > are 
> > > > too slow to enable such. Above max, temperatures are too hot.
> > > > Protein function is impaired, and systems stop functioning.
> > > > There 
> > > > is a considerable range between where systems shut down (but
> > > > recover) and tissue deat

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Ebert,Timothy Aaron
Hi Kevin,

https://weatherspark.com/y/11610/Average-Weather-in-Ely-Minnesota-United-States-Year-Round
Just scroll down. I think what you are looking for is the first graph, but 
there are about a dozen other graphs on various meteorological metrics. 
   
   Another option would be to use larger cities (Duluth, International 
Falls, Thunder Bay) and take a metal average. There is a lake effect for two of 
these more than the other. 
   
   All good?
Tim

-Original Message-
From: Kevin Zembower  
Sent: Wednesday, September 13, 2023 2:05 PM
To: Ebert,Timothy Aaron ; Richard O'Keefe 
Cc: r-help@r-project.org
Subject: Re: [R] Help with plotting and date-times for climate data

[External Email]

Well, I looked for this, on both the NWS and WeatherUnderground, but couldn't 
find what I was looking for. Didn't check Weather.com, but if you can find a 
chart of the average high and low temperatures in Ely, MN between about the 
middle of September to the middle of October, I'll buy you a beer.

-Kevin

On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote:
> I admire the dedication to R and data science, but the Weather Channel 
> might be a simpler approach. Weather.com. I can search for (city name) 
> and either weather (current values) or climate. It depends on how far 
> away the trip will be.
>
> -Original Message-
> From: Kevin Zembower 
> Sent: Wednesday, September 13, 2023 1:22 PM
> To: Richard O'Keefe ; Ebert,Timothy Aaron 
> 
> Cc: r-help@r-project.org
> Subject: Re: [R] Help with plotting and date-times for climate data
>
> [External Email]
>
> Tim, Richard, y'all are reading too much into this. I believe that 
> TMAX is the high temperature of the day, and TMIN is the low. I'm 
> trying to compute the average or median high and low temperatures for 
> the data I have (2011 to present). I'm going on a trip to this area, 
> and want to know how to pack.
>
> Thanks for your interest.
>
> -Kevin
>
> On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote:
> > I am well aware of the physiological implications of temperature, 
> > and that is *why* I view recorded TMIN and TMAX at a single point 
> > with an extremely jaundiced eye.  TMAX at shoulder height has very 
> > little relevance to an insect living in grass, for example.  And if 
> > TMAX is sustained for one second, that has very different 
> > consequences from if TMAX is sustained for five minutes.  I can see 
> > the usefulness of "proportion of day above Thi/below Tlo", but that 
> > is quite different.
> >
> > OK, so my interest in weather data was mainly based around water
> > management: precipitation, evaporation, herd and crop water needs, 
> > that kind of thing.  And the first thing you learn from that 
> > experience is that ANY kind of single-point summary is seriously 
> > misleading.
> >
> > Let's end this digression.
> >
> >
> > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron 
> > wrote:
> > > I had the same question.
> > > However, I can partly answer the off-topic question. Min and max 
> > > can be important as lower and upper development thresholds. Below 
> > > the min no growth or development occur because reaction rates are 
> > > too slow to enable such. Above max, temperatures are too hot.
> > > Protein function is impaired, and systems stop functioning. There 
> > > is a considerable range between where systems shut down (but
> > > recover) and tissue death.
> > > In a simple form the growth and physiological stage of plants, 
> > > insects, and many others, can be modeled as a function of 
> > > temperature. These are often called growing degree day models (or 
> > > some version of that). This is number of thermal units needed for 
> > > the organism to develop to the next stage (e.g. instar for an 
> > > insect, or fruit/flower formation for a plant). However, better 
> > > accuracy is obtained if the model includes both min and max 
> > > thresholds.
> > >
> > > All I have done is provide an example where min and max could have 
> > > a real world use. I use max(temp) over some interval and then 
> > > update an accumulated thermal units variable based on the outcome.
> > > That detail is not evident in the original request.
> > >
> > > Tim
> > >
> > > -Original Message-
> > > From: R-help  On Behalf Of Richard
> > > O'Keefe
> > > Sent: Wednesday, September 13, 2023 9:58 AM
> > > To: Kevin Zembower 
> > > Cc: r-help@r-project.org
> > > Subject: Re: [R] Help with plotting and date-times for 

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Kevin Zembower via R-help
Well, I looked for this, on both the NWS and WeatherUnderground, but
couldn't find what I was looking for. Didn't check Weather.com, but if
you can find a chart of the average high and low temperatures in Ely,
MN between about the middle of September to the middle of October, I'll
buy you a beer.

-Kevin

On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote:
> I admire the dedication to R and data science, but the Weather
> Channel might be a simpler approach. Weather.com. I can search for
> (city name) and either weather (current values) or climate. It
> depends on how far away the trip will be.
> 
> -Original Message-
> From: Kevin Zembower  
> Sent: Wednesday, September 13, 2023 1:22 PM
> To: Richard O'Keefe ; Ebert,Timothy Aaron
> 
> Cc: r-help@r-project.org
> Subject: Re: [R] Help with plotting and date-times for climate data
> 
> [External Email]
> 
> Tim, Richard, y'all are reading too much into this. I believe that
> TMAX is the high temperature of the day, and TMIN is the low. I'm
> trying to compute the average or median high and low temperatures for
> the data I have (2011 to present). I'm going on a trip to this area,
> and want to know how to pack.
> 
> Thanks for your interest.
> 
> -Kevin
> 
> On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote:
> > I am well aware of the physiological implications of temperature,
> > and 
> > that is *why* I view recorded TMIN and TMAX at a single point with
> > an 
> > extremely jaundiced eye.  TMAX at shoulder height has very little 
> > relevance to an insect living in grass, for example.  And if TMAX
> > is 
> > sustained for one second, that has very different consequences from
> > if 
> > TMAX is sustained for five minutes.  I can see the usefulness of 
> > "proportion of day above Thi/below Tlo", but that is quite
> > different.
> > 
> > OK, so my interest in weather data was mainly based around water 
> > management: precipitation, evaporation, herd and crop water needs, 
> > that kind of thing.  And the first thing you learn from that 
> > experience is that ANY kind of single-point summary is seriously 
> > misleading.
> > 
> > Let's end this digression.
> > 
> > 
> > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron 
> > wrote:
> > > I had the same question.
> > > However, I can partly answer the off-topic question. Min and max
> > > can 
> > > be important as lower and upper development thresholds. Below the
> > > min no growth or development occur because reaction rates are too
> > > slow to enable such. Above max, temperatures are too hot.
> > > Protein function is impaired, and systems stop functioning. There
> > > is 
> > > a considerable range between where systems shut down (but
> > > recover) and tissue death.
> > > In a simple form the growth and physiological stage of plants, 
> > > insects, and many others, can be modeled as a function of 
> > > temperature. These are often called growing degree day models (or
> > > some version of that). This is number of thermal units needed for
> > > the organism to develop to the next stage (e.g. instar for an 
> > > insect, or fruit/flower formation for a plant). However, better 
> > > accuracy is obtained if the model includes both min and max 
> > > thresholds.
> > > 
> > > All I have done is provide an example where min and max could
> > > have a 
> > > real world use. I use max(temp) over some interval and then
> > > update 
> > > an accumulated thermal units variable based on the outcome.
> > > That detail is not evident in the original request.
> > > 
> > > Tim
> > > 
> > > -Original Message-
> > > From: R-help  On Behalf Of Richard 
> > > O'Keefe
> > > Sent: Wednesday, September 13, 2023 9:58 AM
> > > To: Kevin Zembower 
> > > Cc: r-help@r-project.org
> > > Subject: Re: [R] Help with plotting and date-times for climate
> > > data
> > > 
> > > [External Email]
> > > 
> > > Off-topic, but what is a "mean temperature max"
> > > and what good would it do you to know you if you did?
> > > I've been looking at a lot of weather station data and for no 
> > > question I've ever had (except "would the newspapers get excited 
> > > about this") was "max" (or min) the answer.  Considering the way 
> > > that temperature can change by several degrees in a few minutes,
> > > or 
> > > a few metres -- 

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Ebert,Timothy Aaron
I admire the dedication to R and data science, but the Weather Channel might be 
a simpler approach. Weather.com. I can search for (city name) and either 
weather (current values) or climate. It depends on how far away the trip will 
be.

-Original Message-
From: Kevin Zembower  
Sent: Wednesday, September 13, 2023 1:22 PM
To: Richard O'Keefe ; Ebert,Timothy Aaron 
Cc: r-help@r-project.org
Subject: Re: [R] Help with plotting and date-times for climate data

[External Email]

Tim, Richard, y'all are reading too much into this. I believe that TMAX is the 
high temperature of the day, and TMIN is the low. I'm trying to compute the 
average or median high and low temperatures for the data I have (2011 to 
present). I'm going on a trip to this area, and want to know how to pack.

Thanks for your interest.

-Kevin

On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote:
> I am well aware of the physiological implications of temperature, and 
> that is *why* I view recorded TMIN and TMAX at a single point with an 
> extremely jaundiced eye.  TMAX at shoulder height has very little 
> relevance to an insect living in grass, for example.  And if TMAX is 
> sustained for one second, that has very different consequences from if 
> TMAX is sustained for five minutes.  I can see the usefulness of 
> "proportion of day above Thi/below Tlo", but that is quite different.
>
> OK, so my interest in weather data was mainly based around water 
> management: precipitation, evaporation, herd and crop water needs, 
> that kind of thing.  And the first thing you learn from that 
> experience is that ANY kind of single-point summary is seriously 
> misleading.
>
> Let's end this digression.
>
>
> On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron 
> wrote:
> > I had the same question.
> > However, I can partly answer the off-topic question. Min and max can 
> > be important as lower and upper development thresholds. Below the 
> > min no growth or development occur because reaction rates are too 
> > slow to enable such. Above max, temperatures are too hot.
> > Protein function is impaired, and systems stop functioning. There is 
> > a considerable range between where systems shut down (but
> > recover) and tissue death.
> > In a simple form the growth and physiological stage of plants, 
> > insects, and many others, can be modeled as a function of 
> > temperature. These are often called growing degree day models (or 
> > some version of that). This is number of thermal units needed for 
> > the organism to develop to the next stage (e.g. instar for an 
> > insect, or fruit/flower formation for a plant). However, better 
> > accuracy is obtained if the model includes both min and max 
> > thresholds.
> >
> > All I have done is provide an example where min and max could have a 
> > real world use. I use max(temp) over some interval and then update 
> > an accumulated thermal units variable based on the outcome.
> > That detail is not evident in the original request.
> >
> > Tim
> >
> > -Original Message-
> > From: R-help  On Behalf Of Richard 
> > O'Keefe
> > Sent: Wednesday, September 13, 2023 9:58 AM
> > To: Kevin Zembower 
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Help with plotting and date-times for climate data
> >
> > [External Email]
> >
> > Off-topic, but what is a "mean temperature max"
> > and what good would it do you to know you if you did?
> > I've been looking at a lot of weather station data and for no 
> > question I've ever had (except "would the newspapers get excited 
> > about this") was "max" (or min) the answer.  Considering the way 
> > that temperature can change by several degrees in a few minutes, or 
> > a few metres -- I meant horizontally when I wrote that, but as you 
> > know your head and feet don't experience the same temperature, again 
> > by more than one degree -- I am at something of a loss to ascribe 
> > much practical significance to TMAX.  Are you sure this is the 
> > analysis you want to do?  Is this the most informative data you can 
> > get?
> >
> > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < 
> > r-help@r-project.org> wrote:
> >
> > > Hello,
> > >
> > > I'm trying to calculate the mean temperature max from a file of 
> > > climate date, and plot it over a range of days in the year. I've 
> > > downloaded the data, and cleaned it up the way I think it should 
> > > be.
> > > However, when I plot it, the geom_smooth line doesn't show up. I 
> > > think that's because my x ax

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Kevin Zembower via R-help
Rui, thanks so much for your clear explanation, solution to my problem,
and additional help with making the graph come out exactly as I was
hoping. I learned a lot from your solution. Thanks, again, for your
help.

-Kevin

On Tue, 2023-09-12 at 23:06 +0100, Rui Barradas wrote:
> Às 21:50 de 12/09/2023, Kevin Zembower via R-help escreveu:
> > Hello,
> > 
> > I'm trying to calculate the mean temperature max from a file of
> > climate
> > date, and plot it over a range of days in the year. I've downloaded
> > the
> > data, and cleaned it up the way I think it should be. However, when
> > I
> > plot it, the geom_smooth line doesn't show up. I think that's
> > because
> > my x axis is characters or factors. Here's what I have so far:
> > 
> > library(tidyverse)
> > 
> > data <- read_csv("Ely_MN_Weather.csv")
> > 
> > start_day = yday(as_date("2023-09-22"))
> > end_day = yday(as_date("2023-10-15"))
> >     
> > d <- as_tibble(data) %>%
> >  select(DATE,TMAX,TMIN) %>%
> >  mutate(DATE = as_date(DATE),
> >     yday = yday(DATE),
> >     md = sprintf("%02d-%02d", month(DATE), mday(DATE))
> >     ) %>%
> >  filter(yday >= start_day & yday <= end_day) %>%
> >  mutate(md = as.factor(md))
> > 
> > d_sum <- d %>%
> >  group_by(md) %>%
> >  summarize(tmax_mean = mean(TMAX, na.rm=TRUE))
> > 
> > ## Here's the filtered data:
> > dput(d_sum)
> > 
> > > structure(list(md = structure(1:25, levels = c("09-21", "09-22",
> > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
> > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06",
> > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13",
> > "10-14", "10-15"), class = "factor"), tmax_mean = c(65,
> > 62.2,
> > 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9,
> > 61.2, 63.7, 59.5, 59.6, 61.6,
> > 59.4, 58.8, 55.9, 58.125,
> > 58, 55.7, 57, 55.4, 49.8,
> > 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame"
> > ), row.names = c(NA, -25L))
> > > 
> > ggplot(data = d_sum, aes(x = md)) +
> >  geom_point(aes(y = tmax_mean, color = "blue")) +
> >  geom_smooth(aes(y = tmax_mean, color = "blue"))
> > =
> > My questions are:
> > 1. Why isn't my geom_smooth plotting? How can I fix it?
> > 2. I don't think I'm handling the month and day combination
> > correctly.
> > Is there a way to encode month and day (but not year) as a date?
> > 3. (Minor point) Why does my graph of tmax_mean come out red when I
> > specify "blue"?
> > 
> > Thanks for any advice or guidance you can offer. I really
> > appreciate
> > the expertise of this group.
> > 
> > -Kevin
> > 
> > __
> > 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.
> Hello,
> 
> The problem is that the dates are factors, not real dates. And 
> geom_smooth is not interpolating along a discrete axis (the x axis).
> 
> Paste a fake year with md, coerce to date and plot.
> I have simplified the aes() calls and added a date scale in order to 
> make the x axis more readable.
> 
> Without the formula and method arguments, geom_smooth will print a 
> message, they are now made explicit.
> 
> 
> 
> suppressPackageStartupMessages({
>    library(dplyr)
>    library(ggplot2)
> })
> 
> d_sum %>%
>    mutate(md = paste("2023", md, sep = "-"),
>   md = as.Date(md)) %>%
>    ggplot(aes(x = md, y = tmax_mean)) +
>    geom_point(color = "blue") +
>    geom_smooth(
>  formula = y ~ x,
>  method = loess,
>  color = "blue"
>    ) +
>    scale_x_date(date_breaks = "7 days", date_labels = "%m-%d")
> 
> 
> 
> Hope this helps,
> 
> Rui Barradas
> 



__
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] Help with plotting and date-times for climate data

2023-09-13 Thread Kevin Zembower via R-help
Tim, Richard, y'all are reading too much into this. I believe that TMAX
is the high temperature of the day, and TMIN is the low. I'm trying to
compute the average or median high and low temperatures for the data I
have (2011 to present). I'm going on a trip to this area, and want to
know how to pack.

Thanks for your interest.

-Kevin

On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote:
> I am well aware of the physiological implications
> of temperature, and that is *why* I view recorded
> TMIN and TMAX at a single point with an extremely
> jaundiced eye.  TMAX at shoulder height has very
> little relevance to an insect living in grass, for
> example.  And if TMAX is sustained for one second,
> that has very different consequences from if TMAX
> is sustained for five minutes.  I can see the usefulness
> of "proportion of day above Thi/below Tlo", but that
> is quite different.
> 
> OK, so my interest in weather data was mainly based
> around water management: precipitation, evaporation,
> herd and crop water needs, that kind of thing.  And
> the first thing you learn from that experience is
> that ANY kind of single-point summary is seriously
> misleading.
> 
> Let's end this digression.
> 
> 
> On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron 
> wrote:
> > I had the same question.
> > However, I can partly answer the off-topic question. Min and max
> > can be important as lower and upper development thresholds. Below
> > the min no growth or development occur because reaction rates are
> > too slow to enable such. Above max, temperatures are too hot.
> > Protein function is impaired, and systems stop functioning. There
> > is a considerable range between where systems shut down (but
> > recover) and tissue death.
> > In a simple form the growth and physiological stage of plants,
> > insects, and many others, can be modeled as a function of
> > temperature. These are often called growing degree day models (or
> > some version of that). This is number of thermal units needed for
> > the organism to develop to the next stage (e.g. instar for an
> > insect, or fruit/flower formation for a plant). However, better
> > accuracy is obtained if the model includes both min and max
> > thresholds.
> > 
> > All I have done is provide an example where min and max could have
> > a real world use. I use max(temp) over some interval and then
> > update an accumulated thermal units variable based on the outcome.
> > That detail is not evident in the original request.
> > 
> > Tim
> > 
> > -Original Message-
> > From: R-help  On Behalf Of Richard
> > O'Keefe
> > Sent: Wednesday, September 13, 2023 9:58 AM
> > To: Kevin Zembower 
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Help with plotting and date-times for climate data
> > 
> > [External Email]
> > 
> > Off-topic, but what is a "mean temperature max"
> > and what good would it do you to know you if you did?
> > I've been looking at a lot of weather station data and for no
> > question I've ever had (except "would the newspapers get excited
> > about this") was "max" (or min) the answer.  Considering the way
> > that temperature can change by several degrees in a few minutes, or
> > a few metres -- I meant horizontally when I wrote that, but as you
> > know your head and feet don't experience the same temperature,
> > again by more than one degree -- I am at something of a loss to
> > ascribe much practical significance to TMAX.  Are you sure this is
> > the analysis you want to do?  Is this the most informative data you
> > can get?
> > 
> > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help <
> > r-help@r-project.org> wrote:
> > 
> > > Hello,
> > > 
> > > I'm trying to calculate the mean temperature max from a file of
> > > climate date, and plot it over a range of days in the year. I've
> > > downloaded the data, and cleaned it up the way I think it should
> > > be.
> > > However, when I plot it, the geom_smooth line doesn't show up. I
> > > think
> > > that's because my x axis is characters or factors. Here's what I
> > > have so far:
> > > 
> > > library(tidyverse)
> > > 
> > > data <- read_csv("Ely_MN_Weather.csv")
> > > 
> > > start_day = yday(as_date("2023-09-22")) end_day =
> > > yday(as_date("2023-10-15"))
> > > 
> > > d <- as_tibble(data) %>%
> > >      select(DATE,

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Richard O'Keefe
I am well aware of the physiological implications
of temperature, and that is *why* I view recorded
TMIN and TMAX at a single point with an extremely
jaundiced eye.  TMAX at shoulder height has very
little relevance to an insect living in grass, for
example.  And if TMAX is sustained for one second,
that has very different consequences from if TMAX
is sustained for five minutes.  I can see the usefulness
of "proportion of day above Thi/below Tlo", but that
is quite different.

OK, so my interest in weather data was mainly based
around water management: precipitation, evaporation,
herd and crop water needs, that kind of thing.  And
the first thing you learn from that experience is
that ANY kind of single-point summary is seriously
misleading.

Let's end this digression.


On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron  wrote:

> I had the same question.
> However, I can partly answer the off-topic question. Min and max can be
> important as lower and upper development thresholds. Below the min no
> growth or development occur because reaction rates are too slow to enable
> such. Above max, temperatures are too hot. Protein function is impaired,
> and systems stop functioning. There is a considerable range between where
> systems shut down (but recover) and tissue death.
> In a simple form the growth and physiological stage of plants, insects,
> and many others, can be modeled as a function of temperature. These are
> often called growing degree day models (or some version of that). This is
> number of thermal units needed for the organism to develop to the next
> stage (e.g. instar for an insect, or fruit/flower formation for a plant).
> However, better accuracy is obtained if the model includes both min and max
> thresholds.
>
> All I have done is provide an example where min and max could have a real
> world use. I use max(temp) over some interval and then update an
> accumulated thermal units variable based on the outcome. That detail is not
> evident in the original request.
>
> Tim
>
> -Original Message-
> From: R-help  On Behalf Of Richard O'Keefe
> Sent: Wednesday, September 13, 2023 9:58 AM
> To: Kevin Zembower 
> Cc: r-help@r-project.org
> Subject: Re: [R] Help with plotting and date-times for climate data
>
> [External Email]
>
> Off-topic, but what is a "mean temperature max"
> and what good would it do you to know you if you did?
> I've been looking at a lot of weather station data and for no question
> I've ever had (except "would the newspapers get excited about this") was
> "max" (or min) the answer.  Considering the way that temperature can change
> by several degrees in a few minutes, or a few metres -- I meant
> horizontally when I wrote that, but as you know your head and feet don't
> experience the same temperature, again by more than one degree -- I am at
> something of a loss to ascribe much practical significance to TMAX.  Are
> you sure this is the analysis you want to do?  Is this the most informative
> data you can get?
>
> On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help <
> r-help@r-project.org> wrote:
>
> > Hello,
> >
> > I'm trying to calculate the mean temperature max from a file of
> > climate date, and plot it over a range of days in the year. I've
> > downloaded the data, and cleaned it up the way I think it should be.
> > However, when I plot it, the geom_smooth line doesn't show up. I think
> > that's because my x axis is characters or factors. Here's what I have so
> far:
> > 
> > library(tidyverse)
> >
> > data <- read_csv("Ely_MN_Weather.csv")
> >
> > start_day = yday(as_date("2023-09-22")) end_day =
> > yday(as_date("2023-10-15"))
> >
> > d <- as_tibble(data) %>%
> > select(DATE,TMAX,TMIN) %>%
> > mutate(DATE = as_date(DATE),
> >yday = yday(DATE),
> >md = sprintf("%02d-%02d", month(DATE), mday(DATE))
> >) %>%
> > filter(yday >= start_day & yday <= end_day) %>%
> > mutate(md = as.factor(md))
> >
> > d_sum <- d %>%
> > group_by(md) %>%
> > summarize(tmax_mean = mean(TMAX, na.rm=TRUE))
> >
> > ## Here's the filtered data:
> > dput(d_sum)
> >
> > > structure(list(md = structure(1:25, levels = c("09-21", "09-22",
> > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
> > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Ebert,Timothy Aaron
I had the same question.
However, I can partly answer the off-topic question. Min and max can be 
important as lower and upper development thresholds. Below the min no growth or 
development occur because reaction rates are too slow to enable such. Above 
max, temperatures are too hot. Protein function is impaired, and systems stop 
functioning. There is a considerable range between where systems shut down (but 
recover) and tissue death.
In a simple form the growth and physiological stage of plants, insects, and 
many others, can be modeled as a function of temperature. These are often 
called growing degree day models (or some version of that). This is number of 
thermal units needed for the organism to develop to the next stage (e.g. instar 
for an insect, or fruit/flower formation for a plant). However, better accuracy 
is obtained if the model includes both min and max thresholds.

All I have done is provide an example where min and max could have a real world 
use. I use max(temp) over some interval and then update an accumulated thermal 
units variable based on the outcome. That detail is not evident in the original 
request.

Tim

-Original Message-
From: R-help  On Behalf Of Richard O'Keefe
Sent: Wednesday, September 13, 2023 9:58 AM
To: Kevin Zembower 
Cc: r-help@r-project.org
Subject: Re: [R] Help with plotting and date-times for climate data

[External Email]

Off-topic, but what is a "mean temperature max"
and what good would it do you to know you if you did?
I've been looking at a lot of weather station data and for no question I've 
ever had (except "would the newspapers get excited about this") was "max" (or 
min) the answer.  Considering the way that temperature can change by several 
degrees in a few minutes, or a few metres -- I meant horizontally when I wrote 
that, but as you know your head and feet don't experience the same temperature, 
again by more than one degree -- I am at something of a loss to ascribe much 
practical significance to TMAX.  Are you sure this is the analysis you want to 
do?  Is this the most informative data you can get?

On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < 
r-help@r-project.org> wrote:

> Hello,
>
> I'm trying to calculate the mean temperature max from a file of
> climate date, and plot it over a range of days in the year. I've
> downloaded the data, and cleaned it up the way I think it should be.
> However, when I plot it, the geom_smooth line doesn't show up. I think
> that's because my x axis is characters or factors. Here's what I have so far:
> 
> library(tidyverse)
>
> data <- read_csv("Ely_MN_Weather.csv")
>
> start_day = yday(as_date("2023-09-22")) end_day =
> yday(as_date("2023-10-15"))
>
> d <- as_tibble(data) %>%
> select(DATE,TMAX,TMIN) %>%
> mutate(DATE = as_date(DATE),
>yday = yday(DATE),
>md = sprintf("%02d-%02d", month(DATE), mday(DATE))
>) %>%
> filter(yday >= start_day & yday <= end_day) %>%
> mutate(md = as.factor(md))
>
> d_sum <- d %>%
> group_by(md) %>%
> summarize(tmax_mean = mean(TMAX, na.rm=TRUE))
>
> ## Here's the filtered data:
> dput(d_sum)
>
> > structure(list(md = structure(1:25, levels = c("09-21", "09-22",
> "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
> "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06",
> "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13",
> "10-14", "10-15"), class = "factor"), tmax_mean = c(65,
> 62.2, 61.3, 63.9, 64.3, 60.1,
> 62.3, 60.5, 61.9, 61.2, 63.7, 59.5, 59.6,
> 61.6, 59.4, 58.8,
> 55.9, 58.125, 58, 55.7, 57, 55.4,
> 49.8, 48.75, 43.7)), class = c("tbl_df",
> "tbl", "data.frame"
> ), row.names = c(NA, -25L))
> >
> ggplot(data = d_sum, aes(x = md)) +
> geom_point(aes(y = tmax_mean, color = "blue")) +
> geom_smooth(aes(y = tmax_mean, color = "blue"))
> =
> My questions are:
> 1. Why isn't my geom_smooth plotting? How can I fix it?
> 2. I don't think I'm handling the month and day combination correctly.
> Is there a way to encode month and day (but not year) as a date?
> 3. (Minor point) Why does my graph of tmax_mean come out red when I
> specify "blu

Re: [R] Help with plotting and date-times for climate data

2023-09-13 Thread Richard O'Keefe
Off-topic, but what is a "mean temperature max"
and what good would it do you to know you if you did?
I've been looking at a lot of weather station data
and for no question I've ever had (except "would the
newspapers get excited about this") was "max" (or min)
the answer.  Considering the way that temperature can
change by several degrees in a few minutes, or a few
metres -- I meant horizontally when I wrote that, but
as you know your head and feet don't experience the
same temperature, again by more than one degree -- I am
at something of a loss to ascribe much practical
significance to TMAX.  Are you sure this is the analysis
you want to do?  Is this the most informative data you
can get?

On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help <
r-help@r-project.org> wrote:

> Hello,
>
> I'm trying to calculate the mean temperature max from a file of climate
> date, and plot it over a range of days in the year. I've downloaded the
> data, and cleaned it up the way I think it should be. However, when I
> plot it, the geom_smooth line doesn't show up. I think that's because
> my x axis is characters or factors. Here's what I have so far:
> 
> library(tidyverse)
>
> data <- read_csv("Ely_MN_Weather.csv")
>
> start_day = yday(as_date("2023-09-22"))
> end_day = yday(as_date("2023-10-15"))
>
> d <- as_tibble(data) %>%
> select(DATE,TMAX,TMIN) %>%
> mutate(DATE = as_date(DATE),
>yday = yday(DATE),
>md = sprintf("%02d-%02d", month(DATE), mday(DATE))
>) %>%
> filter(yday >= start_day & yday <= end_day) %>%
> mutate(md = as.factor(md))
>
> d_sum <- d %>%
> group_by(md) %>%
> summarize(tmax_mean = mean(TMAX, na.rm=TRUE))
>
> ## Here's the filtered data:
> dput(d_sum)
>
> > structure(list(md = structure(1:25, levels = c("09-21", "09-22",
> "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
> "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06",
> "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13",
> "10-14", "10-15"), class = "factor"), tmax_mean = c(65,
> 62.2,
> 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9,
> 61.2, 63.7, 59.5, 59.6, 61.6,
> 59.4, 58.8, 55.9, 58.125,
> 58, 55.7, 57, 55.4, 49.8,
> 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame"
> ), row.names = c(NA, -25L))
> >
> ggplot(data = d_sum, aes(x = md)) +
> geom_point(aes(y = tmax_mean, color = "blue")) +
> geom_smooth(aes(y = tmax_mean, color = "blue"))
> =
> My questions are:
> 1. Why isn't my geom_smooth plotting? How can I fix it?
> 2. I don't think I'm handling the month and day combination correctly.
> Is there a way to encode month and day (but not year) as a date?
> 3. (Minor point) Why does my graph of tmax_mean come out red when I
> specify "blue"?
>
> Thanks for any advice or guidance you can offer. I really appreciate
> the expertise of this group.
>
> -Kevin
>
> __
> 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.


Re: [R] Help with plotting and date-times for climate data

2023-09-12 Thread Rui Barradas

Às 21:50 de 12/09/2023, Kevin Zembower via R-help escreveu:

Hello,

I'm trying to calculate the mean temperature max from a file of climate
date, and plot it over a range of days in the year. I've downloaded the
data, and cleaned it up the way I think it should be. However, when I
plot it, the geom_smooth line doesn't show up. I think that's because
my x axis is characters or factors. Here's what I have so far:

library(tidyverse)

data <- read_csv("Ely_MN_Weather.csv")

start_day = yday(as_date("2023-09-22"))
end_day = yday(as_date("2023-10-15"))

d <- as_tibble(data) %>%

 select(DATE,TMAX,TMIN) %>%
 mutate(DATE = as_date(DATE),
yday = yday(DATE),
md = sprintf("%02d-%02d", month(DATE), mday(DATE))
) %>%
 filter(yday >= start_day & yday <= end_day) %>%
 mutate(md = as.factor(md))

d_sum <- d %>%
 group_by(md) %>%
 summarize(tmax_mean = mean(TMAX, na.rm=TRUE))

## Here's the filtered data:
dput(d_sum)


structure(list(md = structure(1:25, levels = c("09-21", "09-22",

"09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29",
"09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06",
"10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13",
"10-14", "10-15"), class = "factor"), tmax_mean = c(65,
62.2,
61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9,
61.2, 63.7, 59.5, 59.6, 61.6,
59.4, 58.8, 55.9, 58.125,
58, 55.7, 57, 55.4, 49.8,
48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -25L))



ggplot(data = d_sum, aes(x = md)) +
 geom_point(aes(y = tmax_mean, color = "blue")) +
 geom_smooth(aes(y = tmax_mean, color = "blue"))
=
My questions are:
1. Why isn't my geom_smooth plotting? How can I fix it?
2. I don't think I'm handling the month and day combination correctly.
Is there a way to encode month and day (but not year) as a date?
3. (Minor point) Why does my graph of tmax_mean come out red when I
specify "blue"?

Thanks for any advice or guidance you can offer. I really appreciate
the expertise of this group.

-Kevin

__
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.

Hello,

The problem is that the dates are factors, not real dates. And 
geom_smooth is not interpolating along a discrete axis (the x axis).


Paste a fake year with md, coerce to date and plot.
I have simplified the aes() calls and added a date scale in order to 
make the x axis more readable.


Without the formula and method arguments, geom_smooth will print a 
message, they are now made explicit.




suppressPackageStartupMessages({
  library(dplyr)
  library(ggplot2)
})

d_sum %>%
  mutate(md = paste("2023", md, sep = "-"),
 md = as.Date(md)) %>%
  ggplot(aes(x = md, y = tmax_mean)) +
  geom_point(color = "blue") +
  geom_smooth(
formula = y ~ x,
method = loess,
color = "blue"
  ) +
  scale_x_date(date_breaks = "7 days", date_labels = "%m-%d")



Hope this helps,

Rui Barradas

__
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] Help with plotting and date-times for climate data

2023-09-12 Thread Kevin Zembower via R-help
Hello,

I'm trying to calculate the mean temperature max from a file of climate
date, and plot it over a range of days in the year. I've downloaded the
data, and cleaned it up the way I think it should be. However, when I
plot it, the geom_smooth line doesn't show up. I think that's because
my x axis is characters or factors. Here's what I have so far:

library(tidyverse)

data <- read_csv("Ely_MN_Weather.csv")

start_day = yday(as_date("2023-09-22"))
end_day = yday(as_date("2023-10-15"))
   
d <- as_tibble(data) %>%
select(DATE,TMAX,TMIN) %>%
mutate(DATE = as_date(DATE),
   yday = yday(DATE),
   md = sprintf("%02d-%02d", month(DATE), mday(DATE))
   ) %>%
filter(yday >= start_day & yday <= end_day) %>%
mutate(md = as.factor(md))

d_sum <- d %>%
group_by(md) %>%
summarize(tmax_mean = mean(TMAX, na.rm=TRUE))

## Here's the filtered data:
dput(d_sum)

> structure(list(md = structure(1:25, levels = c("09-21", "09-22", 
"09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", 
"09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", 
"10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", 
"10-14", "10-15"), class = "factor"), tmax_mean = c(65,
62.2, 
61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9, 
61.2, 63.7, 59.5, 59.6, 61.6, 
59.4, 58.8, 55.9, 58.125, 
58, 55.7, 57, 55.4, 49.8, 
48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -25L))
> 
ggplot(data = d_sum, aes(x = md)) +
geom_point(aes(y = tmax_mean, color = "blue")) +
geom_smooth(aes(y = tmax_mean, color = "blue"))
=
My questions are:
1. Why isn't my geom_smooth plotting? How can I fix it?
2. I don't think I'm handling the month and day combination correctly.
Is there a way to encode month and day (but not year) as a date?
3. (Minor point) Why does my graph of tmax_mean come out red when I
specify "blue"?

Thanks for any advice or guidance you can offer. I really appreciate
the expertise of this group.

-Kevin

__
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] Help needed with olsrr package

2023-08-24 Thread Ivan Krylov
On Thu, 24 Aug 2023 10:56:00 +0530
Ashim Kapoor  wrote:

> When I  open a terminal, type R and run my code, it runs fine. When I
> start Emacs, start an inferior R process using ESS, the error comes
> back.

Thankfully, in both of these cases you get an interactive R session.

Compare sessionInfo() outputs.

Use traceback(), options(error = recover) and other tricks described in
help(browser) and the free book The R Inferno [*] to find out (1) which
function is trying to eval(); (2) what is being evaluated (what does
predvars contain?), and (3) what do the environments actually contain
(what is `data`? what is `env`? Use ls(env) if it's an environment)

-- 
Best regards,
Ivan

[*] https://www.burns-stat.com/documents/books/the-r-inferno/

______
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] Help needed with olsrr package

2023-08-22 Thread Eric Berger
I copied your data and ran your code.
It worked fine for me.

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;
 LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
LC_ADDRESS=C   LC_TELEPHONE=C
LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Asia/Jerusalem
tzcode source: system (glibc)

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] olsrr_0.5.3

loaded via a namespace (and not attached):
 [1] vctrs_0.6.3   cli_3.6.1 rlang_1.1.1   car_3.1-2
  generics_0.1.3data.table_1.14.8 glue_1.6.2
colorspace_2.1-0  gridExtra_2.3
[10] scales_1.2.1  fansi_1.0.4   grid_4.3.1
carData_3.0-5 munsell_0.5.0 tibble_3.2.1  abind_1.4-5
 lifecycle_1.0.3   compiler_4.3.1
[19] goftest_1.2-3 dplyr_1.1.2   Rcpp_1.0.11
pkgconfig_2.0.3   rstudioapi_0.15.0 nortest_1.0-4 R6_2.5.1
 tidyselect_1.2.0  utf8_1.2.3
[28] pillar_1.9.0  magrittr_2.0.3tools_4.3.1
gtable_0.3.3  ggplot2_3.4.2
>

HTH,
Eric


On Tue, Aug 22, 2023 at 7:47 PM Ivan Krylov  wrote:
>
> В Tue, 22 Aug 2023 16:06:22 +0530
> Ashim Kapoor  пишет:
>
> > Error in eval(predvars, data, env) : object 'Var.One' not found
>
> Use traceback() to find out in which function the error was raised.
> This looks like a bug in the olsrr package. Could be due to use of
> string manipulation in order to work with formula terms, could be
> some other assumption violated by I(10*Var2).
>
> Try asking at https://github.com/rsquaredacademy/olsrr/issues.
>
> --
> Best regards,
> Ivan
>
> __
> 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-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] Help needed with olsrr package

2023-08-22 Thread Ivan Krylov
В Tue, 22 Aug 2023 16:06:22 +0530
Ashim Kapoor  пишет:

> Error in eval(predvars, data, env) : object 'Var.One' not found

Use traceback() to find out in which function the error was raised.
This looks like a bug in the olsrr package. Could be due to use of
string manipulation in order to work with formula terms, could be
some other assumption violated by I(10*Var2).

Try asking at https://github.com/rsquaredacademy/olsrr/issues.

-- 
Best regards,
Ivan

__
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-es] Resumen de R-help-es, Vol 172, Envío 23

2023-07-08 Thread Amable Moreno
Buen dia
Tengo un problema con el paquete "semPlot", no puedo realizar un digrama de
senderos porque me da este error::
"package or namespace load failed for ‘semPlot’ in loadNamespace(i,
c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace ‘vctrs’ 0.4.1 is being loaded, but >= 0.5.0 is required"
Agradeceria que alguien me ayude

El vie, 16 jun 2023 a la(s) 17:16, 
escribió:

> Envíe los mensajes para la lista R-help-es a
> r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
>
>
> Asuntos del día:
>
>1. Re: Seleccionar valores consecutivos en un dataframe
>   (Juan Carlos Lopez Mesa)
>2. Supuestos de una ANOVA (Yesica Pallavicini Fernandez)
>3. Opciones de guardado - gráfico en png (David Camilo Gomez Medina)
>
> ------
>
> Message: 1
> Date: Fri, 16 Jun 2023 05:02:14 -0500
> From: Juan Carlos Lopez Mesa 
> To: jose luis 
> Cc: "r-help-es@r-project.org" , Jaume Tormo
> 
> Subject: Re: [R-es] Seleccionar valores consecutivos en un dataframe
> Message-ID:
> <
> cahuwr6oentz4dpwxyuop0k39txmyfv4nrdmrkxn4kayp1k5...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hola,
> Este código le puede servir para lo que necesita
> library(dplyr)
>
> ejemplo$dia <- as.Date(ejemplo$dia)
>
> ejemplo <- arrange(ejemplo, dia)
>
> ejemplo$suma <- NA
>
> ejemplo$suma[1] <- as.numeric(ejemplo$germ)
>
> for(i in 2:nrow(ejemplo)){
>
>   ejemplo$suma[i] <- ifelse(ejemplo$germ[i],
> ejemplo$suma[i-1] + ejemplo$p[i],
> 0)
> }
>
>
> Saludos
>
>
>
> El vie, 16 jun 2023 a las 3:21, jose luis via R-help-es (<
> r-help-es@r-project.org>) escribió:
>
> >  Hola Jaumecomo todos los valores de p son menores de 1he entendido
> > esto: por ejemplo en la fila 5 que sería el segundo TRUE, quieres que la
> > nueva variable sea la suma del valor de la fila 4 mas el de la fila 5 y
> asi
> > sucesivamente. ¿o me desvío mucho?
> > En viernes, 16 de junio de 2023, 09:28:18 CEST, Jaume Tormo via
> > R-help-es  escribió:
> >
> >  Estimados eRReros,
> > Tengo un df como el adjunto (en txt y como objeto de R)Como veréis hay
> una
> > columna T/F que se llama germ y cada fila corresponde a datos de un día.
> > Me gustaría que R fuera siguiendo la columna germ y en cada serie de días
> > con TRUE sumara el valor de la columna p. Se trata de saber si en esa
> serie
> > de días con valor T el total de p es mayor que 1 o no.
> > He hecho algo parecido con rle() que me cuenta la longitud de las series
> > de TRUE, pero este siguiente paso no se como darlo.Si uso apply o subset
> me
> > toma todas las filas del df con T en la columna germ. Lo que no se el
> como
> > decirle a R que empiece por el principio y vaya tomando grupo a grupo.Me
> > imagino que podría llegar a construir un bucle que lo hiciera, pero no
> > quiero pasarme tres horas dándole vueltas si hay una función o
> combinación
> > de funciones que lo hace ¿Alguna sugerencia o me pongo ya con el bucle?
> >
> > Muchas gracias.
> > Jaume.
> >
> >
> > --
> > Dr. Jaume Tormo.
> > Area of Ecology
> > Department of Agrarian and Environmental Sciences
> > Technological College. Agri-food and Environment
> > University of Zaragoza, Spain
> > 0034 974292678
> > https://flipboard.com/@jaumetormo/hallazgos-interesantes-bj8opmboy
> > https://acercad.wordpress.com/
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.c

Re: [R] Help/documentation on Rgui

2023-07-03 Thread Iago Giné Vázquez
Thank you Petr, great!

Best,
Iago


De: PIKAL Petr
Enviat: Dilluns, 3-juliol 3e000 2023 9:42
Per a: Iago Gin� V�zquez; r-help@r-project.org
Assumpte: RE: Help/documentation on Rgui

Hi

I am not sure about opening Rgui in terminal but for customising Rgui
appearance you can modify Rconsole and Rprofile or Rprofile.site which you
should find in etc folder of your R installation.

https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rconsole.html
https://rdrr.io/r/utils/Rconsole.html
and "Initialization at Start of an R Session" in R help
?Rprofile

Cheers
Petr

> -Original Message-----
> From: R-help  On Behalf Of Iago Gin�
> V�zquez
> Sent: Monday, July 3, 2023 8:36 AM
> To: r-help@r-project.org
> Subject: [R] Help/documentation on Rgui
>
> Hi all,
>
> Where can I find a detailed document(ation) on the use of Rgui.exe. The
most
> detailed I found is https://cran.r-project.org/doc/manuals/r-release/R-
> ints.html#GUI-consoles, where there is almost nothing.
>
> Actually I want to know how to open Rgui.exe (let's say, from a terminal
> [mainly in Windows], even better, through the ViM plugin NVim-R) with a
set
> of specific preferences, like a dark background or specific text colour
and size,
> which I see I can modify once it is open.
>
> Thank you for your help.
>
> Iago
>
>
>[[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.


Re: [R] Help/documentation on Rgui

2023-07-03 Thread PIKAL Petr
Hi

I am not sure about opening Rgui in terminal but for customising Rgui
appearance you can modify Rconsole and Rprofile or Rprofile.site which you
should find in etc folder of your R installation.

https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rconsole.html
https://rdrr.io/r/utils/Rconsole.html
and "Initialization at Start of an R Session" in R help
?Rprofile

Cheers
Petr

> -Original Message-----
> From: R-help  On Behalf Of Iago Giné
> Vázquez
> Sent: Monday, July 3, 2023 8:36 AM
> To: r-help@r-project.org
> Subject: [R] Help/documentation on Rgui
> 
> Hi all,
> 
> Where can I find a detailed document(ation) on the use of Rgui.exe. The
most
> detailed I found is https://cran.r-project.org/doc/manuals/r-release/R-
> ints.html#GUI-consoles, where there is almost nothing.
> 
> Actually I want to know how to open Rgui.exe (let's say, from a terminal
> [mainly in Windows], even better, through the ViM plugin NVim-R) with a
set
> of specific preferences, like a dark background or specific text colour
and size,
> which I see I can modify once it is open.
> 
> Thank you for your help.
> 
> Iago
> 
> 
>   [[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-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] Help/documentation on Rgui

2023-07-03 Thread Iago Giné Vázquez
Hi all,

Where can I find a detailed document(ation) on the use of Rgui.exe. The most 
detailed I found is 
https://cran.r-project.org/doc/manuals/r-release/R-ints.html#GUI-consoles, 
where there is almost nothing.

Actually I want to know how to open Rgui.exe (let's say, from a terminal 
[mainly in Windows], even better, through the ViM plugin NVim-R) with a set of 
specific preferences, like a dark background or specific text colour and size, 
which I see I can modify once it is open.

Thank you for your help.

Iago


[[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] Help with regex replacements

2023-06-27 Thread Chris Evans via R-help

Magic!

tmp %>%
  as_tibble() %>%
  rename(Text = value) %>%
  mutate(Text = str_replace_all(Text, fixed("."), "")) %>%
  # filter(row_number() < 4) %>%
  mutate(Text2 = gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", 
"", Text))


Which (as you have already shown!) gave me this:

# A tibble: 7 × 2
  Text Text2
   
1 "Я досяг того, чого хотів"  "Я досяг того, чого 
хотів"
2 "Мені вдалося зробити бажане"   "Мені вдалося зробити 
бажане"
3 "Я досяг (досягла) того, чого хотів (хотіла)"   "Я досяг того, чого 
хотів "
4 "Я досяг(-ла) речей, яких хотілося досягти" "Я досяг речей, яких 
хотілося досягти"
5 "Я досяг/ла того, чого хотів/ла"    "Я досяг того, чого 
хотів"
6 "Я досяг\\досягла того, чого прагнув\\прагнула" "Я досяг того, чого 
прагнув"
7 "Я досягнув(ла) того, чого хотів(ла)"   "Я досягнув того, чого 
хотів"


perfect and I will spend some time tomorrow unpacking that regex and 
trying to drive the learning points into my thick skull!


Deeply indebted, as so often here though generally only when I'm reading 
others questions and the answers!


Chris

On 27/06/2023 20:48, Bert Gunter wrote:
OK, so you want parentheses, not "brackets" + I think I misinterpreted 
your specification, which I think is actually incomplete. Based on 
what I think you meant, how does this work:


gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text)
[1] "Я досяг того, чого хотів"              "Мені вдалося\nзробити 
бажане"
[3] "Я досяг  того, чого хотів "            "Я\nдосяг речей, яких 
хотілося досягти"

[5] "Я досяг того, чого\nхотів"             "Я досяг того, чого прагнув"
[7] "Я\nдосягнув того, чого хотів"

If you want it without the \n's, cat the above to get:
cat(gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text))

Я досяг того, чого хотів Мені вдалося
зробити бажане Я досяг  того, чого хотів  Я
досяг речей, яких хотілося досягти Я досяг того, чого
хотів Я досяг того, чого прагнув Я
досягнув того, чого хотів

Cheers,
Bert

On Tue, Jun 27, 2023 at 11:09 AM Bert Gunter  
wrote:


Does this do it for you (or get you closer):

 gsub("\\[.*\\]|[] |/ ","",tmp$Text)
[1] "Я досяг того, чого хотів"
    [2] "Мені вдалося\nзробити бажане"
[3] "Я досяг (досягла) того, чого хотів (хотіла)"
[4] "Я\nдосяг(-ла) речей, яких хотілося досягти"
[5] "Я досяг/ла того, чого\nхотів/ла"
[6] "Я досяг\\досягла того, чого прагнув\\прагнула"
[7] "Я\nдосягнув(ла) того, чого хотів(ла)"

On Tue, Jun 27, 2023 at 10:16 AM Chris Evans via R-help
 wrote:

I am sure this is easy for people who are good at regexps but I'm
failing with it.  The situation is that I have hundreds of
lines of
Ukrainian translations of some English. They contain things
like this:

1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я
досяг
(досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких
хотілося
досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла
того, чого
прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)"

Using dput():

tmp <- structure(list(Text = c("Я досяг того, чого хотів",
"Мені вдалося
зробити бажане", "Я досяг (досягла) того, чого хотів
(хотіла)", "Я
досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого
хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я
досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L),
class =
c("tbl_df", "tbl", "data.frame" )) Those show four different ways
translators have handled gendered words: 1) Ignore them and (I'm
guessing) only give the masculine 2) Give the feminine form of
the word
(or just the feminine suffix) in brackets 3) Give the feminine
form/suffix prefixed by a forward slash 4) Give the feminine
form/suffix
prefixed by backslash (here a double backslash) I would like
just to
drop all these feminine gendered options. (Don't worry,
they'll get back
in later.) So I would like to replace 1) anything between
brackets with
nothing! 2) anything between a forward slash and the next
space with
nothing 3) anything between a backslash and the next space
w

Re: [R] Help with regex replacements

2023-06-27 Thread Bert Gunter
OK, so you want parentheses, not "brackets" + I think I misinterpreted your
specification, which I think is actually incomplete. Based on what I think
you meant, how does this work:

gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text)
[1] "Я досяг того, чого хотів"  "Мені вдалося\nзробити бажане"

[3] "Я досяг  того, чого хотів ""Я\nдосяг речей, яких хотілося
досягти"
[5] "Я досяг того, чого\nхотів" "Я досяг того, чого прагнув"

[7] "Я\nдосягнув того, чого хотів"

If you want it without the \n's, cat the above to get:
cat(gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text))

Я досяг того, чого хотів Мені вдалося
зробити бажане Я досяг  того, чого хотів  Я
досяг речей, яких хотілося досягти Я досяг того, чого
хотів Я досяг того, чого прагнув Я
досягнув того, чого хотів

Cheers,
Bert

On Tue, Jun 27, 2023 at 11:09 AM Bert Gunter  wrote:

> Does this do it for you (or get you closer):
>
>  gsub("\\[.*\\]|[] |/ ","",tmp$Text)
> [1] "Я досяг того, чого хотів"
> [2] "Мені вдалося\nзробити бажане"
> [3] "Я досяг (досягла) того, чого хотів (хотіла)"
> [4] "Я\nдосяг(-ла) речей, яких хотілося досягти"
> [5] "Я досяг/ла того, чого\nхотів/ла"
> [6] "Я досяг\\досягла того, чого прагнув\\прагнула"
> [7] "Я\nдосягнув(ла) того, чого хотів(ла)"
>
> On Tue, Jun 27, 2023 at 10:16 AM Chris Evans via R-help <
> r-help@r-project.org> wrote:
>
>> I am sure this is easy for people who are good at regexps but I'm
>> failing with it.  The situation is that I have hundreds of lines of
>> Ukrainian translations of some English. They contain things like this:
>>
>> 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг
>> (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося
>> досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого
>> прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)"
>>
>> Using dput():
>>
>> tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося
>> зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я
>> досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого
>> хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я
>> досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class =
>> c("tbl_df", "tbl", "data.frame" )) Those show four different ways
>> translators have handled gendered words: 1) Ignore them and (I'm
>> guessing) only give the masculine 2) Give the feminine form of the word
>> (or just the feminine suffix) in brackets 3) Give the feminine
>> form/suffix prefixed by a forward slash 4) Give the feminine form/suffix
>> prefixed by backslash (here a double backslash) I would like just to
>> drop all these feminine gendered options. (Don't worry, they'll get back
>> in later.) So I would like to replace 1) anything between brackets with
>> nothing! 2) anything between a forward slash and the next space with
>> nothing 3) anything between a backslash and the next space with nothing
>> but preserving the rest of the text. I have been trying to achieve this
>> using str_replace_all() but I am failing utterly. Here's a silly little
>> example of my failures. This was just trying to get the text I wanted to
>> replace (as I was trying to simplify the issues for my tired wetware): >
>> tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text =
>> str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4)
>> %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin
>> `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)",
>> "\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to
>> access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run
>> `rlang::last_trace()` to see where the error occurred. I have tried
>> gurgling around the internet but am striking out so throwing myself on
>> the list. Apologies if this is trivial but I'd hate to have to clean
>> these hundreds of lines by hand though it's starting to look as if I'd
>> achieve that faster by hand than I will by banging my ignorance of R
>> regexp syntax on the problem. TIA, Chris
>>
>> --
>> Chris Evans (he/him)
>> Visiting Professor, UDLA, Quit

Re: [R] Help with regex replacements

2023-06-27 Thread Bert Gunter
Does this do it for you (or get you closer):

 gsub("\\[.*\\]|[] |/ ","",tmp$Text)
[1] "Я досяг того, чого хотів"
[2] "Мені вдалося\nзробити бажане"
[3] "Я досяг (досягла) того, чого хотів (хотіла)"
[4] "Я\nдосяг(-ла) речей, яких хотілося досягти"
[5] "Я досяг/ла того, чого\nхотів/ла"
[6] "Я досяг\\досягла того, чого прагнув\\прагнула"
[7] "Я\nдосягнув(ла) того, чого хотів(ла)"

On Tue, Jun 27, 2023 at 10:16 AM Chris Evans via R-help <
r-help@r-project.org> wrote:

> I am sure this is easy for people who are good at regexps but I'm
> failing with it.  The situation is that I have hundreds of lines of
> Ukrainian translations of some English. They contain things like this:
>
> 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг
> (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося
> досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого
> прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)"
>
> Using dput():
>
> tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося
> зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я
> досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого
> хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я
> досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class =
> c("tbl_df", "tbl", "data.frame" )) Those show four different ways
> translators have handled gendered words: 1) Ignore them and (I'm
> guessing) only give the masculine 2) Give the feminine form of the word
> (or just the feminine suffix) in brackets 3) Give the feminine
> form/suffix prefixed by a forward slash 4) Give the feminine form/suffix
> prefixed by backslash (here a double backslash) I would like just to
> drop all these feminine gendered options. (Don't worry, they'll get back
> in later.) So I would like to replace 1) anything between brackets with
> nothing! 2) anything between a forward slash and the next space with
> nothing 3) anything between a backslash and the next space with nothing
> but preserving the rest of the text. I have been trying to achieve this
> using str_replace_all() but I am failing utterly. Here's a silly little
> example of my failures. This was just trying to get the text I wanted to
> replace (as I was trying to simplify the issues for my tired wetware): >
> tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text =
> str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4)
> %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin
> `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)",
> "\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to
> access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run
> `rlang::last_trace()` to see where the error occurred. I have tried
> gurgling around the internet but am striking out so throwing myself on
> the list. Apologies if this is trivial but I'd hate to have to clean
> these hundreds of lines by hand though it's starting to look as if I'd
> achieve that faster by hand than I will by banging my ignorance of R
> regexp syntax on the problem. TIA, Chris
>
> --
> Chris Evans (he/him)
> Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor,
> University of Roehampton, London, UK.
> Work web site: https://www.psyctc.org/psyctc/
> CORE site: http://www.coresystemtrust.org.uk/
> Personal site: https://www.psyctc.org/pelerinage2016/
>
> ______
> 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.


Re: [R] Help with regex replacements

2023-06-27 Thread Chris Evans via R-help

Thanks Avi (I am a keen follower or your, and other stalwart helpers here).

On 27/06/2023 18:27, avi.e.gr...@gmail.com wrote:

Chris,

Consider breaking up your task into multiple passes.


Sorry, I could have explained more of what I had tried.  I never know 
how long to make things here.


I had been doing that. My plan was to pick them off, one by one but I 
think I am banging my head on a fundamental incomprehension on my part.



And do them in whatever order preserves what you need.

Agree.

First, are you talking about brackets as in square brackets, or as in your 
example, parentheses?

Sorry, always get that wrong, parentheses. Mea culpa.

If you are sure you have no nested brackets, your requirement seems to be that 
anything matching [ stuff ] be replaced with nothing. Or if using parentheses, 
something similar.
> 99% sure there are no nested parentheses.  However, there are lines 
with none, one or sometimes (as in the little reprex) more than one set 
of parentheses.

Your issue here is both sets of symbols are special so you must escape them so 
they are seen as part of the pattern and not the instructions.
So, sorry to be stupid but I thought I was doing that using "\(.*\)"  
Could you reply showing me the correct escaping and the correct 
replacing?  I was using str_replace_all() but happy to use gsub() if 
that's easier/safer/better.

The idea would be to pass through the text once and match all instances on a 
line and then replace with nothing or whatever is needed.

Nothing.

  But there is no guarantee some of your constructs will be on the same line 
completely so be wary.


Totally agree.

I also see that my Emailer (Thunderbird) despite my exhorting it not to, 
mangled the Email.  Have tried to fix that.  The mess below should have 
said:


I am sure this is easy for people who are good at regexps but I'm
failing with it.  The situation is that I have hundreds of lines of
Ukrainian translations of some English. They contain things like this:

1"Я досяг того, чого хотів"
2"Мені вдалося зробити бажане"
3"Я досяг (досягла) того, чого хотів (хотіла)"
4"Я досяг(-ла) речей, яких хотілося досягти"
5"Я досяг/ла того, чого хотів/ла"
6"Я досяг\\досягла того, чогопрагнув\\прагнула."7"Я досягнув(ла) того, 
чого хотів(ла)"


Using dput():

tmp <- structure(list(Text = c("Я досяг того, чого хотів",
"Мені вдалося зробити бажане",
"Я досяг (досягла) того, чого хотів (хотіла)",
"Я досяг(-ла) речей, яких хотілося досягти",
"Я досяг/ла того, чого хотів/ла",
"Я досяг\\досягла того, чого прагнув\\прагнула",
"Я досягнув(ла) того, чого хотів(ла)" )),
row.names = c(NA, -7L), class = c("tbl_df", "tbl", "data.frame" ))

Those show four different ways translators have handled gendered words:

1) Ignore them and (I'm guessing) only give the masculine
2) Give the feminine form of the word (or just the feminine suffix) in 
brackets

3) Give the feminine form/suffix prefixed by a forward slash
4) Give the feminine form/suffix prefixed by backslash (here a double 
backslash)


I would like just to drop all these feminine gendered options. (Don't 
worry,

they'll get back in later.)

So I would like to replace
1) anything between brackets with nothing!
2) anything between a forward slash and the next space with nothing
3) anything between a backslash and the next space with nothing
but preserving the rest of the text. I have been trying to achieve this
using str_replace_all() but I am failing utterly.

Here's a silly little example of my failures.
This was just trying to get the text I wanted to
replace (as I was trying to simplify the issues for my tired wetware):

> tmp %>%
+ as_tibble() %>%
+ rename(Text = value) %>%
+ mutate(Text = str_replace_all(Text, fixed("."), "")) %>%
+ filter(row_number() < 4) %>%
+ mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1"))

Error in `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)",
"\\1")`.

Caused by error in `stri_replace_first_regex()`:!
Trying to access the index that is out of bounds. 
(U_INDEX_OUTOFBOUNDS_ERROR)

Run `rlang::last_trace()` to see where the error occurred.

I have tried gurgling around the internet but am striking out so 
throwing myself on

the list. Apologies if this is trivial but I'd hate to have to clean
these hundreds of lines by hand though it's starting to look as if I'd
achieve that faster by hand than I will by banging my ignorance of R
regexp syntax on the problem. TIA, Chris




  


-Original Message-
From: R-help  On Behalf Of Chris Evans via R-help
Sent: Tuesday, June 27, 2023 1:16 PM
To: r-help@r-project.org
Subject: [R] Help with regex replacements

I am sure this is easy for people who are good at regexps but I'm
failing with it.  The situation is th

Re: [R] Help with regex replacements

2023-06-27 Thread avi.e.gross
Chris,

Consider breaking up your task into multiple passes.

And do them in whatever order preserves what you need.

First, are you talking about brackets as in square brackets, or as in your 
example, parentheses?

If you are sure you have no nested brackets, your requirement seems to be that 
anything matching [ stuff ] be replaced with nothing. Or if using parentheses, 
something similar.

Your issue here is both sets of symbols are special so you must escape them so 
they are seen as part of the pattern and not the instructions.

The idea would be to pass through the text once and match all instances on a 
line and then replace with nothing or whatever is needed. But there is no 
guarantee some of your constructs will be on the same line completely so be 
wary.

 

-Original Message-
From: R-help  On Behalf Of Chris Evans via R-help
Sent: Tuesday, June 27, 2023 1:16 PM
To: r-help@r-project.org
Subject: [R] Help with regex replacements

I am sure this is easy for people who are good at regexps but I'm 
failing with it.  The situation is that I have hundreds of lines of 
Ukrainian translations of some English. They contain things like this:

1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг 
(досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося 
досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого 
прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)"

Using dput():

tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося 
зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я 
досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого 
хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я 
досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = 
c("tbl_df", "tbl", "data.frame" )) Those show four different ways 
translators have handled gendered words: 1) Ignore them and (I'm 
guessing) only give the masculine 2) Give the feminine form of the word 
(or just the feminine suffix) in brackets 3) Give the feminine 
form/suffix prefixed by a forward slash 4) Give the feminine form/suffix 
prefixed by backslash (here a double backslash) I would like just to 
drop all these feminine gendered options. (Don't worry, they'll get back 
in later.) So I would like to replace 1) anything between brackets with 
nothing! 2) anything between a forward slash and the next space with 
nothing 3) anything between a backslash and the next space with nothing 
but preserving the rest of the text. I have been trying to achieve this 
using str_replace_all() but I am failing utterly. Here's a silly little 
example of my failures. This was just trying to get the text I wanted to 
replace (as I was trying to simplify the issues for my tired wetware): > 
tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text = 
str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) 
%>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin 
`mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", 
"\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to 
access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run 
`rlang::last_trace()` to see where the error occurred. I have tried 
gurgling around the internet but am striking out so throwing myself on 
the list. Apologies if this is trivial but I'd hate to have to clean 
these hundreds of lines by hand though it's starting to look as if I'd 
achieve that faster by hand than I will by banging my ignorance of R 
regexp syntax on the problem. TIA, Chris

-- 
Chris Evans (he/him)
Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, 
University of Roehampton, London, UK.
Work web site: https://www.psyctc.org/psyctc/
CORE site: http://www.coresystemtrust.org.uk/
Personal site: https://www.psyctc.org/pelerinage2016/

__
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-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] Help with regex replacements

2023-06-27 Thread Chris Evans via R-help
I am sure this is easy for people who are good at regexps but I'm 
failing with it.  The situation is that I have hundreds of lines of 
Ukrainian translations of some English. They contain things like this:


1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг 
(досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося 
досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого 
прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)"


Using dput():

tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося 
зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я 
досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого 
хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я 
досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = 
c("tbl_df", "tbl", "data.frame" )) Those show four different ways 
translators have handled gendered words: 1) Ignore them and (I'm 
guessing) only give the masculine 2) Give the feminine form of the word 
(or just the feminine suffix) in brackets 3) Give the feminine 
form/suffix prefixed by a forward slash 4) Give the feminine form/suffix 
prefixed by backslash (here a double backslash) I would like just to 
drop all these feminine gendered options. (Don't worry, they'll get back 
in later.) So I would like to replace 1) anything between brackets with 
nothing! 2) anything between a forward slash and the next space with 
nothing 3) anything between a backslash and the next space with nothing 
but preserving the rest of the text. I have been trying to achieve this 
using str_replace_all() but I am failing utterly. Here's a silly little 
example of my failures. This was just trying to get the text I wanted to 
replace (as I was trying to simplify the issues for my tired wetware): > 
tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text = 
str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) 
%>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin 
`mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", 
"\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to 
access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run 
`rlang::last_trace()` to see where the error occurred. I have tried 
gurgling around the internet but am striking out so throwing myself on 
the list. Apologies if this is trivial but I'd hate to have to clean 
these hundreds of lines by hand though it's starting to look as if I'd 
achieve that faster by hand than I will by banging my ignorance of R 
regexp syntax on the problem. TIA, Chris


--
Chris Evans (he/him)
Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, 
University of Roehampton, London, UK.

Work web site: https://www.psyctc.org/psyctc/
CORE site: http://www.coresystemtrust.org.uk/
Personal site: https://www.psyctc.org/pelerinage2016/

__
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-es] Resumen de R-help-es, Vol 172, Envío 25

2023-06-19 Thread patricio fuenmayor
Que tal.
Entiendo que se debe a la nueva funcionalidad visual de preview de las
tablas ...
Una solución es deshabilitar esto
configura esto en el script o en las configuraciones de inicio de R

options(rstudio.help.showDataPreview=FALSE)


El dom, 18 jun 2023 a la(s) 05:00, 
escribió:

> Envíe los mensajes para la lista R-help-es a
>     r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
> Asuntos del día:
>
>1. Re: Supuestos de una ANOVA (Proyecto R-UCA)
>2. Error RStudio (Javier Gómez Gonzalez)
>
>
> -- Forwarded message --
> From: Proyecto R-UCA 
> To: r-help-es@r-project.org
> Cc:
> Bcc:
> Date: Sun, 18 Jun 2023 00:19:31 +0200
> Subject: Re: [R-es] Supuestos de una ANOVA
> Buenas,
>
> La instrucción plot admite un parámetro which, su valor por defecto es
> c(1, 2, 3, 5), que son los cuatro gráficos que salen por defecto.
> Usando which = 2 obtienes únicamente el qqplot.
>
> Las observaciones leverage son observaciones que tienen una gran
> influencia en los resultados del análisis, de forma que eliminarlas supone
> un cambio importante en las estimaciones. No hay que confundirlas con los
> outliers o atípicos, pues una observación puede ser atípica y no
> leverage, o ser leverage y no atípica.
>
> Un saludo
> --
> --
> http://knuth.uca.es/R
> --
> Proyecto R-UCA
> --
> Nombre: Manuel Muñoz Márquez
> Departamento: Departamento de Estadística e Investigación Operativa
> Institución: Escuela Superior de Ingeniería
> Organización: Universidad de Cádiz
> --
>
> El vie, 16-06-2023 a las 12:41 +0200, Yesica Pallavicini Fernandez
> escribió:
> > Buenos días y muchas gracias por adelantado
> > En cuando a probar gráficamente los supuestos de normalidad y
> > homocedasticidad de una ANOVA
> >
> > Lo estoy haciendo de forma gráfica de la siguiente manera:
> > Primero hago el nova con: aov()
> > luego hago la comprobación de los supuestos con: plot(modelo)
> > y me salen 4 gráficos;
> > 1 un scatter plot de los "residuals" vs " Fitted",
> > 2"standardizez residuals" vs " Fitted",
> > 3QQplot,
> > 4 Residuals vs leverage
> > Pero ¿Qué es el leverage?
> >  1)¿teneis algun script que reemplace a plot(modelo) y que solo contenga
> el
> > QQplot y los valores residuales frente a los fitted?
> >
> > 2) Shapiro.test () no funciona para observaciones mayores a 500 y mis
> datos
> > tienen más de 3 observaciones. ¿sabeis de algun otro test para este
> > caso?
> >
> > Muchísimas gracias y que acabéis fenomenal la semana
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> >
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help-es__;!!D9dNQwwGXtA!S2L6bI_NoCf_ox_hHI7PINlx5SKlSS1KpBOsabN8o1Z248Rp3TRh5axwIvBUT1g9XZtvU7qL25KUdwc$
> >
>
>
>
>
>
> -- Forwarded message --
> From: "Javier Gómez Gonzalez" 
> To: r-help-es 
> Cc:
> Bcc:
> Date: Sun, 18 Jun 2023 03:04:42 +0200
> Subject: [R-es] Error RStudio
> Hola a todos
>
> Desde que instalé la última versión de RStudio la 2023.06.0-421 para
> Windows me aparece el siguiente error :
>
> Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
>   invalid first argument
> Error in assign(cacheKey, frame, .rs.CachedDataEnv) :
>   attempt to use zero-length variable name
>
> La versión de R que tengo es la 4.3 y el sistema operativo es Windows 10.
>
> Un saludo
>
> Javier Gómez González
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 172, Envío 25

2023-06-19 Thread Juan Carlos Arronte
Javier,

Por lo visto, es un error de la nueva versi�n de RStudio. A m� me pasaba lo 
mismo usando Mac.

Seg�n he le�do en el github de Rstudio est�n trabajando en solucionarlo. Tienes 
dos opciones: o volver a la versi�n anterior o instalar el �ltimo daily build. 
Yo he hecho esto �ltimo, y aunque es una beta, el problema est� solucionado.

https://github.com/rstudio/rstudio/issues/13188

Un saludo

De: R-help-es  en nombre de 
r-help-es-requ...@r-project.org 
Enviado: domingo, 18 de junio de 2023 12:00
Para: r-help-es@r-project.org 
Asunto: Resumen de R-help-es, Vol 172, Env�o 25

Env�e los mensajes para la lista R-help-es a
r-help-es@r-project.org

Para subscribirse o anular su subscripci�n a trav�s de la WEB
https://stat.ethz.ch/mailman/listinfo/r-help-es

O por correo electr�nico, enviando un mensaje con el texto "help" en
el asunto (subject) o en el cuerpo a:
r-help-es-requ...@r-project.org

Puede contactar con el responsable de la lista escribiendo a:
r-help-es-ow...@r-project.org

Si responde a alg�n contenido de este mensaje, por favor, edite la
linea del asunto (subject) para que el texto sea mas especifico que:
"Re: Contents of R-help-es digest...". Adem�s, por favor, incluya en
la respuesta s�lo aquellas partes del mensaje a las que est�
respondiendo.


Asuntos del d�a:

   1. Re: Supuestos de una ANOVA (Proyecto R-UCA)
   2. Error RStudio (Javier G�mez Gonzalez)

--

Message: 1
Date: Sun, 18 Jun 2023 00:19:31 +0200
From: Proyecto R-UCA 
To: r-help-es@r-project.org
Subject: Re: [R-es] Supuestos de una ANOVA
Message-ID: 
Content-Type: text/plain; charset="utf-8"

Buenas,

La instrucci�n plot admite un par�metro which, su valor por defecto es c(1, 2, 
3, 5), que son los cuatro gr�ficos que salen por defecto.
Usando which = 2 obtienes �nicamente el qqplot.

Las observaciones leverage son observaciones que tienen una gran influencia en 
los resultados del an�lisis, de forma que eliminarlas supone
un cambio importante en las estimaciones. No hay que confundirlas con los 
outliers o at�picos, pues una observaci�n puede ser at�pica y no
leverage, o ser leverage y no at�pica.

Un saludo
--
--
http://knuth.uca.es/R
--
Proyecto R-UCA
--
Nombre: Manuel Mu�oz M�rquez
Departamento: Departamento de Estad�stica e Investigaci�n Operativa
Instituci�n: Escuela Superior de Ingenier�a
Organizaci�n: Universidad de C�diz
--

El vie, 16-06-2023 a las 12:41 +0200, Yesica Pallavicini Fernandez escribi�:
> Buenos d�as y muchas gracias por adelantado
> En cuando a probar gr�ficamente los supuestos de normalidad y
> homocedasticidad de una ANOVA
>
> Lo estoy haciendo de forma gr�fica de la siguiente manera:
> Primero hago el nova con: aov()
> luego hago la comprobaci�n de los supuestos con: plot(modelo)
> y me salen 4 gr�ficos;
> 1 un scatter plot de los "residuals" vs " Fitted",
> 2"standardizez residuals" vs " Fitted",
> 3QQplot,
> 4 Residuals vs leverage
> Pero �Qu� es el leverage?
>  1)�teneis algun script que reemplace a plot(modelo) y que solo contenga el
> QQplot y los valores residuales frente a los fitted?
>
> 2) Shapiro.test () no funciona para observaciones mayores a 500 y mis datos
> tienen m�s de 3 observaciones. �sabeis de algun otro test para este
> caso?
>
> Much�simas gracias y que acab�is fenomenal la semana
>
> [[alternative HTML version deleted]]
>
> _______
> R-help-es mailing list
> R-help-es@r-project.org
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help-es__;!!D9dNQwwGXtA!S2L6bI_NoCf_ox_hHI7PINlx5SKlSS1KpBOsabN8o1Z248Rp3TRh5axwIvBUT1g9XZtvU7qL25KUdwc$
>




--

Message: 2
Date: Sun, 18 Jun 2023 03:04:42 +0200
From: Javier G�mez Gonzalez 
To: r-help-es 
Subject: [R-es] Error RStudio
Message-ID:

Content-Type: text/plain; charset="utf-8"

Hola a todos

Desde que instal� la �ltima versi�n de RStudio la 2023.06.0-421 para


Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
  invalid first argument
Error in assign(cacheKey, frame, .rs.CachedDataEnv) :
  attempt to use zero-length variable name



Un saludo

Javier G�mez Gonz�lez

    [[alternative HTML version deleted]]




--

Subject: Pi� de p�gina del digest

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


--

Fin de Resumen de R-help-es, Vol 172, E

Re: [R-es] Resumen de R-help-es, Vol 172, Envío 16

2023-06-11 Thread Javier Gómez Gonzalez
Gracias a todos

El dom, 11 jun 2023 a las 13:20, Juan Carlos Arronte ()
escribió:

> Javier, no sé si es esto lo que buscas.
>
> Te copio una línea de uno de mis scripts. En el eje X, van los años desde
> 1990 a 2022, pero solo salen los años 90, 95, ... y el resto solo la marca
> secundaria sin el año
>
> scale_x_continuous(breaks = seq(1990, 2022, by = 1),
>   labels = c(1990, rep("", 4), 1995, rep("", 4), 2000,
> rep("", 4),
>  2005, rep("", 4), 2010, rep("", 4), 2015,
> rep("", 4),
>  2020, rep("", 2)))
>
>
> Espero que te sirva.
>
> Un saludo
>
> Juan Carlos
>
> ________
> De: R-help-es  en nombre de
> r-help-es-requ...@r-project.org 
> Enviado: domingo, 11 de junio de 2023 12:00
> Para: r-help-es@r-project.org 
> Asunto: Resumen de R-help-es, Vol 172, Envío 16
>
> Envíe los mensajes para la lista R-help-es a
> r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
>     r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
>
>
> Asuntos del día:
>
>1. Re: Marcas secundarias ejes ggplot2 (Javier Marcuzzi)
>2. Re: Marcas secundarias ejes ggplot2 (Javier Gómez Gonzalez)
>3. Re: Marcas secundarias ejes ggplot2 (David Camilo Gomez Medina)
>
> --
>
> Message: 1
> Date: Sat, 10 Jun 2023 17:43:26 -0300
> From: Javier Marcuzzi 
> To: Javier Gómez Gonzalez 
> Cc: "R-help-es@r-project.org" 
> Subject: Re: [R-es] Marcas secundarias ejes ggplot2
> Message-ID: <9d891275-1085-4bab-900c-f19660d04...@gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Estimado Javier Gómez Gonzalez
>
> Creo que es posible, pero: ¿podría usted mirar en este lugar, tomar un
> gráfico de ejemplo y dibujar lo que desea?
>
> Creo que esto traficaría el deseo de si gráfica.
>
> Javier Rubén Marcuzzi
>
> > El 10 jun. 2023, a las 00:31, Javier Gómez Gonzalez 
> escribió:
> >
> > Estimados amigos:
> > Quisiera saber si hay alguna forma en ggplot2 de establecer marcas
> > secundarias en los ejes y que estas marcas secundarias no muestren
> > etiquetas, pero sin que se dibuje las líneas minor grid.
> >
> > Javier Gómez González
> >
> >[[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
>
>
> --
>
> Message: 2
> Date: Sun, 11 Jun 2023 03:08:08 +0200
> From: Javier Gómez Gonzalez 
> To: Carlos Ortega 
> Cc: r-help-es 
> Subject: Re: [R-es] Marcas secundarias ejes ggplot2
> Message-ID:
>  s90z21luahy4caksxt2lva...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Muchas gracias Carlos por los enlaces.
>
> Estimado Javier Marcuzzi lo que yo quiero es poner las marcas secundarias a
> mis ejes sin etiquetas como se puede hacer en matplotlib. Un ejemplo se
> puede ver en el siguiente enlace
>
> https://interactivechaos.com/es/manual/tutorial-de-matplotlib/marcas-principales-y-secundarias
>
>
>
> El sáb, 10 jun 2023 a las 22:56, Carlos Ortega ( >)
> escribió:
>
> > Hola,
> >
> > Sí, puedes ver varias soluciones aquí:
> >
> >-
> >
> https://stackoverflow.com/questions/14490071/adding-minor-tick-marks-to-the-x-axis-in-ggplot2-with-no-labels
> >-
> >
> https://statisticsglobe.com/add-minor-tick-marks-without-labels-ggplot2-plot-r
> >
> > Gracias,
> > Carlos.
> > www.qualityexcellence.es<http://www.qualityexcellence.es>
> >
> > El sáb, 10 jun 2023 a las 5:29, Javier Gómez Gonzalez (<
> > zaraga...@gmail.com>) escribió:
> >
> >> Estimados amigos:
> &g

Re: [R-es] Resumen de R-help-es, Vol 172, Envío 16

2023-06-11 Thread Juan Carlos Arronte
Javier, no s� si es esto lo que buscas.

Te copio una l�nea de uno de mis scripts. En el eje X, van los a�os desde 1990 
a 2022, pero solo salen los a�os 90, 95, ... y el resto solo la marca 
secundaria sin el a�o

scale_x_continuous(breaks = seq(1990, 2022, by = 1),
  labels = c(1990, rep("", 4), 1995, rep("", 4), 2000, 
rep("", 4),
 2005, rep("", 4), 2010, rep("", 4), 2015, 
rep("", 4),
 2020, rep("", 2)))


Espero que te sirva.

Un saludo

Juan Carlos


De: R-help-es  en nombre de 
r-help-es-requ...@r-project.org 
Enviado: domingo, 11 de junio de 2023 12:00
Para: r-help-es@r-project.org 
Asunto: Resumen de R-help-es, Vol 172, Env�o 16

Env�e los mensajes para la lista R-help-es a
r-help-es@r-project.org

Para subscribirse o anular su subscripci�n a trav�s de la WEB
https://stat.ethz.ch/mailman/listinfo/r-help-es

O por correo electr�nico, enviando un mensaje con el texto "help" en
el asunto (subject) o en el cuerpo a:
r-help-es-requ...@r-project.org

Puede contactar con el responsable de la lista escribiendo a:
r-help-es-ow...@r-project.org

Si responde a alg�n contenido de este mensaje, por favor, edite la
linea del asunto (subject) para que el texto sea mas especifico que:
"Re: Contents of R-help-es digest...". Adem�s, por favor, incluya en
la respuesta s�lo aquellas partes del mensaje a las que est�
respondiendo.


Asuntos del d�a:

   1. Re: Marcas secundarias ejes ggplot2 (Javier Marcuzzi)
   2. Re: Marcas secundarias ejes ggplot2 (Javier G�mez Gonzalez)
   3. Re: Marcas secundarias ejes ggplot2 (David Camilo Gomez Medina)

--

Message: 1
Date: Sat, 10 Jun 2023 17:43:26 -0300
From: Javier Marcuzzi 
To: Javier G�mez Gonzalez 
Cc: "R-help-es@r-project.org" 
Subject: Re: [R-es] Marcas secundarias ejes ggplot2
Message-ID: <9d891275-1085-4bab-900c-f19660d04...@gmail.com>
Content-Type: text/plain; charset="utf-8"

Estimado Javier G�mez Gonzalez

Creo que es posible, pero: �podr�a usted mirar en este lugar, tomar un gr�fico 
de ejemplo y dibujar lo que desea?

Creo que esto traficar�a el deseo de si gr�fica.

Javier Rub�n Marcuzzi

> El 10 jun. 2023, a las 00:31, Javier G�mez Gonzalez  
> escribi�:
>
> Estimados amigos:
> Quisiera saber si hay alguna forma en ggplot2 de establecer marcas
> secundarias en los ejes y que estas marcas secundarias no muestren
> etiquetas, pero sin que se dibuje las l�neas minor grid.
>
>     Javier G�mez Gonz�lez
>
>[[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es




--

Message: 2
Date: Sun, 11 Jun 2023 03:08:08 +0200
From: Javier G�mez Gonzalez 
To: Carlos Ortega 
Cc: r-help-es 
Subject: Re: [R-es] Marcas secundarias ejes ggplot2
Message-ID:

Content-Type: text/plain; charset="utf-8"

Muchas gracias Carlos por los enlaces.

Estimado Javier Marcuzzi lo que yo quiero es poner las marcas secundarias a
mis ejes sin etiquetas como se puede hacer en matplotlib. Un ejemplo se
puede ver en el siguiente enlace
https://interactivechaos.com/es/manual/tutorial-de-matplotlib/marcas-principales-y-secundarias



El s�b, 10 jun 2023 a las 22:56, Carlos Ortega ()
escribi�:

> Hola,
>
> S�, puedes ver varias soluciones aqu�:
>
>-
>
> https://stackoverflow.com/questions/14490071/adding-minor-tick-marks-to-the-x-axis-in-ggplot2-with-no-labels
>-
>
> https://statisticsglobe.com/add-minor-tick-marks-without-labels-ggplot2-plot-r
>
> Gracias,
> Carlos.
> www.qualityexcellence.es<http://www.qualityexcellence.es>
>
> El s�b, 10 jun 2023 a las 5:29, Javier G�mez Gonzalez (<
> zaraga...@gmail.com>) escribi�:
>
>> Estimados amigos:
>> Quisiera saber si hay alguna forma en ggplot2 de establecer marcas
>> secundarias en los ejes y que estas marcas secundarias no muestren
>> etiquetas, pero sin que se dibuje las l�neas minor grid.
>>
>>  Javier G�mez Gonz�lez
>>
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es<http://www.qualityexcellence.es>
>

[[alternative HTML version deleted]]




--

Message: 3
Date: Sat, 10 Jun 2023 20:

Re: [R] Help sourcing datasets (.csv)

2023-06-02 Thread Ebert,Timothy Aaron
Another suggestion:
 The statistics does not care where the numbers come from. The values 1, 2, 
3 have a mean of 2 no matter if these are weights of a bird, plant heights, or 
concrete tensile strength. Your interpretation might change, but the mean is 
still 2.

Try synthetic data.
X<-rnorm(1000, mean=4, sd=2)
Y<-14+12*X
cor(X,Y)

That is too simple, but it is the start.
Y<- rnorm(1000, mean=14, sd=2) + 12*X
cor(X,Y)

look at the result in something like ggplot2
Dataf <- data.frame(X,Y)
ggplot(Dataf, aes(X, Y)) + geom.point() + stat_smooth(method=lm, se=FALSE)


This approach has a few advantages:
1) I know that X and Y are samples from the Gaussian (Normal) distribution.
2) I know that the data are homoscedastic.
3) I can change 1 and 2 in whatever way I want. Possibly useful if you want to 
understand how violations in model assumptions influence outcomes.
4) I can look closely at the influence of sample size when assumptions are met 
and when they are not.

Note that ANOVA and regression do not assume that the independent or dependent 
variables are normally distributed. The assumption of Normality is for the 
error term in the model. However, if both dependent and independent variables 
are normally distributed then it is likely that the error term will also be 
normally distributed.

What should I get here?
Y<- rnorm(1000, mean=14, sd=2) + X*rnorm(1000, mean=12, sd=27)



Tim
-Original Message-----
From: R-help  On Behalf Of Uwe Ligges
Sent: Friday, June 2, 2023 5:18 AM
To: james carrigan ; r-help@r-project.org
Subject: Re: [R] Help sourcing datasets (.csv)

[External Email]

See ?data


On 28.05.2023 10:53, james carrigan wrote:
> Dear Sir or Madam
> I'm trying to compile a collection of datasets that require use of the 
> following hypothesis tests.
> Are there datasets within the R library that I can get access to?
> Kind regards
> James Carrigan
>
> Hypothesis Testing
> t.test(X,Y)
> - performs a two sample t-test between X and Y
> t.test(X,Y,paired=TRUE)
> - performs a paired t-test between X and Y prop.test(x = c(a, b), n =
> c(n1, n2)) - performs a 2-sample test for equality of proportions with
> continuity correction
>
> Sent from my iPad Sent from my iPhone
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat/
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu
> %7C5f3292c3315b446b8b9008db634a37cb%7C0d4da0f84a314d76ace60a62331e1b84
> %7C0%7C0%7C638212942641271785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> ta=s5NqLzxYTlnA1BHldzka%2F2i%2FoefvsLmU%2FDuLJav5mMc%3D=0
> PLEASE do read the posting guide
> http://www.r/
> -project.org%2Fposting-guide.html=05%7C01%7Ctebert%40ufl.edu%7C5f
> 3292c3315b446b8b9008db634a37cb%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> 7C0%7C638212942641271785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=xG
> MQDNZksGydmnYDLAFjZ%2BEZp4ne%2Bf5JK%2BO9qrH7zeU%3D=0
> and provide commented, minimal, self-contained, reproducible code.

__
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-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] Help sourcing datasets (.csv)

2023-06-02 Thread Uwe Ligges

See ?data


On 28.05.2023 10:53, james carrigan wrote:

Dear Sir or Madam
I’m trying to compile a collection of datasets that require use of the 
following hypothesis tests.
Are there datasets within the R library that I can get access to?
Kind regards
James Carrigan

Hypothesis Testing
t.test(X,Y)
— performs a two sample t-test between X and Y
t.test(X,Y,paired=TRUE)
— performs a paired t-test between X and Y
prop.test(x = c(a, b), n = c(n1, n2))
— performs a 2-sample test for equality of proportions with continuity 
correction

Sent from my iPad Sent from my iPhone
__
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-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] Help sourcing datasets (.csv)

2023-05-31 Thread james carrigan
Dear Sir or Madam
I’m trying to compile a collection of datasets that require use of the 
following hypothesis tests.
Are there datasets within the R library that I can get access to?
Kind regards
James Carrigan 

Hypothesis Testing
t.test(X,Y) 
— performs a two sample t-test between X and Y 
t.test(X,Y,paired=TRUE) 
— performs a paired t-test between X and Y
prop.test(x = c(a, b), n = c(n1, n2)) 
— performs a 2-sample test for equality of proportions with continuity 
correction

Sent from my iPad Sent from my iPhone
__
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] Help with bootstrap sampling with rms package in R

2023-04-24 Thread Munveer Thind via R-help
Hi all,

I appreciate any help that can be offered and don’t mind sending a fee to 
anyone that can help. 

I am a physician and am writing a paper to be submitted to a medical journal 
and am performing bootstrap internal validation by the Harrell method using the 
R package called rms. It’s a multi variable logistic regression model. I have 
done the 1000 sample bootstrap and generated Dxy which I have converted to AUC. 
But I also want to illustrate with a histogram of all the 1000 AUC values 
generated from the training AUC from each bootstrap model. 

Reaching out for help with this, thanks in advance. 

Best,

Munveer

__
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-es] Resumen de R-help-es, Vol 168, Envío 4

2023-02-10 Thread Enrique Ramalle Gomara via R-help-es
Hola
Prueba esto:

names(dataframe)[c(xx)] <- c("Nueva")

Donde data frame es el nombre de tu data frame xx es el número de columna que 
ocupa la variable que quieres cambiar y “Nueva” es como quieres que se llame tu 
nueva variable

Saludos
Enrique Ramalle -Gómara

Enviado desde mi iPad

> El 9 feb 2023, a las 16:27, r-help-es-requ...@r-project.org escribió:
> 
> Envíe los mensajes para la lista R-help-es a
>r-help-es@r-project.org
> 
> Para subscribirse o anular su subscripción a través de la WEB
>https://stat.ethz.ch/mailman/listinfo/r-help-es
> 
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
>r-help-es-requ...@r-project.org
> 
> Puede contactar con el responsable de la lista escribiendo a:
>r-help-es-ow...@r-project.org
> 
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
> 
> 
> Asuntos del día:
> 
>   1. Cambiar nombre columnas de un dataframe
>  (David Camilo Gomez Medina)
> 
> --
> 
> Message: 1
> Date: Thu, 9 Feb 2023 10:27:07 -0500
> From: David Camilo Gomez Medina 
> To: Lista R 
> Subject: [R-es] Cambiar nombre columnas de un dataframe
> Message-ID:
>
> Content-Type: text/plain; charset="utf-8"
> 
> Buen día,
> 
> Es que al realizar diferentes operaciones con un dataframe, el nombre de
> las columnas aparece con una *X*. ¿Alguien sabe cómo podría solucionarlo?
> 
> Quedo atento a sus comentarios. Gracias.
> 
> [image: image.png]
> 
> -- 
> *Aviso legal:* El contenido de este mensaje y los archivos adjuntos son 
> confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. 
> Se encuentran dirigidos sólo para el uso del destinatario al cual van 
> enviados. La reproducción, lectura y/o copia se encuentran prohibidas a 
> cualquier persona diferente a este y puede ser ilegal. Si usted lo ha 
> recibido por error, infórmenos y elimínelo de su correo. Los Datos 
> Personales serán tratados conforme a la Ley 1581 de 2012 y a nuestra 
> Política de Datos Personales que podrá consultar en la página web 
> www.unal.edu.co <http://www.unal.edu.co/>.* *Las opiniones, informaciones, 
> conclusiones y cualquier otro tipo de dato contenido en este correo 
> electrónico, no relacionados con la actividad de la Universidad Nacional de 
> Colombia, se entenderá como personales y de ninguna manera son avaladas por 
> la Universidad.
> 
>  próxima parte 
> Se ha borrado un adjunto en formato HTML...
> URL: 
> <https://stat.ethz.ch/pipermail/r-help-es/attachments/20230209/cc59baf4/attachment.html>
> 
>  próxima parte 
> A non-text attachment was scrubbed...
> Name: image.png
> Type: image/png
> Size: 28750 bytes
> Desc: no disponible
> URL: 
> <https://stat.ethz.ch/pipermail/r-help-es/attachments/20230209/cc59baf4/attachment.png>
> 
> 
> --
> 
> Subject: Pié de página del digest
> 
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
> 
> 
> --
> 
> Fin de Resumen de R-help-es, Vol 168, Envío 4
> *

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 168, Envío 1

2023-02-04 Thread Enrique Ramalle Gomara via R-help-es
Muchas gracias, Marcelino

Saludos
Enrique

> El 4 feb 2023, a las 12:01, r-help-es-requ...@r-project.org escribió:
> 
> Envíe los mensajes para la lista R-help-es a
>r-help-es@r-project.org
> 
> Para subscribirse o anular su subscripción a través de la WEB
>https://stat.ethz.ch/mailman/listinfo/r-help-es
> 
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
>r-help-es-requ...@r-project.org
> 
> Puede contactar con el responsable de la lista escribiendo a:
>r-help-es-ow...@r-project.org
> 
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
> 
> 
> Asuntos del día:
> 
>   1. Comando similar a ELSE de spss (Enrique Ramalle Gomara)
>   2. Re: Comando similar a ELSE de spss (Marcelino de la Cruz Rot)
>   3. Re: Comando similar a ELSE de spss (José Trujillo)
> 
> ------
> 
> Message: 1
> Date: Fri, 3 Feb 2023 12:36:33 +
> From: Enrique Ramalle Gomara 
> To: "r-help-es@r-project.org" 
> Subject: [R-es] Comando similar a ELSE de spss
> Message-ID: <23c5fbc1bfde434b9e4e5a4da375d...@larioja.org>
> Content-Type: text/plain; charset="utf-8"
> 
> Hola
> Quiero recodificar los valores de una variable en otra, pero hay un 
> subconjunto de esos valores que me interesa agruparlos en una categor�a que 
> sea NA. Por ejemplo
> De la variable color:
> 1 ="verde"
> 2 ="azul"
> 3 ="rojo"
> Todos las dem�s  = NA (o que deje el campo vac�o)
> 
> �C�mo hacer para que todos los dem�s, los que no est�n en las categor�as de 
> recodificaci�n se les asigne un campo vacio o un campo NA?
> 
> 
> 
> Un saludo, muchas gracias
> 
> Enrique Ramalle
> 
> 
> ____
> 
> GOBIERNO DE LA RIOJA
> AVISO LEGAL: La informaci�n contenida en este mensaje ...{{dropped:10}}
> 
> 
> 
> 
> --
> 
> Message: 2
> Date: Fri, 3 Feb 2023 14:04:55 +0100
> From: Marcelino de la Cruz Rot 
> To: r-help-es@r-project.org
> Subject: Re: [R-es] Comando similar a ELSE de spss
> Message-ID: 
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
> 
> Hola, Enrique:
> Puedes hacerlo así de fácil:
> 
> variable <- factor(variable)
> 
> levels(variable)[!(levels(datos)%in% c("verde", "azul", "rojo"))] <- NA
> 
> Un saludo,
> Marcelino
> 
> 
>> El 03/02/2023 a las 13:36, Enrique Ramalle Gomara via R-help-es escribió:
>> Hola
>> Quiero recodificar los valores de una variable en otra, pero hay un 
>> subconjunto de esos valores que me interesa agruparlos en una categor�a que 
>> sea NA. Por ejemplo
>> De la variable color:
>> 1 ="verde"
>> 2 ="azul"
>> 3 ="rojo"
>> Todos las dem�s  = NA (o que deje el campo vac�o)
>> 
>> �C�mo hacer para que todos los dem�s, los que no est�n en las categor�as de 
>> recodificaci�n se les asigne un campo vacio o un campo NA?
>> 
>> 
>> 
>> Un saludo, muchas gracias
>> 
>> Enrique Ramalle
>> 
>> 
>> ____
>> 
>> GOBIERNO DE LA RIOJA
>> AVISO LEGAL: La informaci�n contenida en este mensaje ...{{dropped:10}}
>> 
>> 
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
> 
> 
> -- 
> Marcelino de la Cruz Rot
> 
> Depto. de Biología y Geología
> Física y Química Inorgánica
> Universidad Rey Juan Carlos
> Móstoles España
> 
> 
> 
> 
> --
> 
> Message: 3
> Date: Sat, 4 Feb 2023 09:30:08 +0100
> From: José Trujillo 
> To: r-help-es@r-project.org
> Subject: Re: [R-es] Comando similar a ELSE de spss
> Message-ID: <0a69ea9c-eedc-8fc7-fa3a-f1854d1b3...@unex.es>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
> 
> La respuesta está en la función recode del paquete car:
> 
> ?recode
> 
> example(recode)
> 
> Ahí tiene el uso de else justo como lo quieres.
> 
> Salud
> 
>> El 3/2/23 a las 13:36, Enrique Ramalle Gomara via R-help-es escribió:
>> Hola
>> Quiero recodificar los valores de una variable en otra, p

Re: [R-es] Resumen de R-help-es, Vol 167, Envío 10

2023-01-28 Thread Griera
Hola, Carlos:

Gracias, funciona también a la perfección y muy ingeniosa la solución.

Disculpa si no te he respondido antes, pero hasta ahora no he podido privarlo.

Gracias por la ayuda y saludos.

On Fri, 27 Jan 2023 01:40:48 +0100
Carlos Ortega  wrote:

> Hola,
> 
> Otra alternativa...
> 
> #
> > library(data.table)
> > library(tidytable)
> > library(stringi)
> >
> > df <- data.frame(   V1a = sample(c("1","0"), 10, TRUE)
> +   , V1b = sample(c("1","0"), 10, TRUE)
> +   , V2a = sample(c("1","0"), 10, TRUE)
> +   , V2b = sample(c("1","0"), 10, TRUE))
> > df
>V1a V1b V2a V2b
> 11   0   1   1
> 21   1   0   1
> 30   0   0   0
> 41   0   1   0
> 50   1   0   0
> 60   0   1   0
> 71   0   0   0
> 81   1   1   0
> 90   0   0   0
> 10   0   1   1   1
> > > #--- Función compara parejas de columnas comienzan por mismas 2 letras.
> > *colcompare <- function(df)* {
> +
> +nam_val <- names(df) %>% stri_sub(from = 1, to = 2) %>% unique()
> +res_df  <- data.table()
> +for (i in 1:length(nam_val)) {
> +  cols_tmp <- nam_val[i]
> +  df_tmp <- df %>% select.(starts_with(cols_tmp)) %>%
> +rename.( a = 1) %>%
> +rename.( b = 2) %>%
> +mutate.( c = if_else.( a == 1 | b == 1, 1, 0)) %>%
> +select.(c) %>%
> +as.data.table()
> +names(df_tmp) <- paste0(cols_tmp, "c")
> +res_df <- cbind(res_df, df_tmp)
> +}
> +return(res_df)
> + }
> >
> > #--- Sobre df creado
> > *resultado <- colcompare(df)*
> > resultado
>   V1c   V2c
>  
>  1: 0 1
>  2: 1 0
>  3: 1 1
>  4: 1 1
>  5: 1 1
>  6: 1 1
>  7: 1 1
>  8: 0 0
>  9: 1 1
> 10: 0 1
> #
> 
> 
> Gracias,
> Carlos Ortega
> www.qualityexcellence.es
> 
> El jue, 26 ene 2023 a las 19:55, Griera-yandex ()
> escribió:
> 
> > Hola:
> >
> > Funciona a la perfección. Y los nombres de las nuevas variables tipo "V1c"
> > "V2c"... ya me está bien.
> >
> > Gracias por habertelo currado tanto! Me has ahorrado copiar, pegar y
> > modificar un monton de linias. Y no
> > tenia conciencia de que podia ser tan complicado.
> >
> > Gracias por la ayuda. Saludos.
> >
> > On Thu, 26 Jan 2023 09:33:31 -0500
> > patricio fuenmayor  wrote:
> >
> > > Hola esta es una solución
> > >
> > > library(data.table)
> > > library(stringr)
> > >
> > >
> > > dt <- data.table( V1a = sample(c("1","0"), 10, TRUE)
> > > , V1b = sample(c("1","0"), 10, TRUE)
> > > , V2a = sample(c("1","0"), 10, TRUE)
> > > , V2b = sample(c("1","0"), 10, TRUE)
> > > , V3a = sample(c("1","0"), 10, TRUE)
> > > , V3b = sample(c("1","0"), 10, TRUE)
> > > , V4a = sample(c("1","0"), 10, TRUE)
> > > , V4b = sample(c("1","0"), 10, TRUE))
> > > dt[,":="(seq=.I)]
> > > setcolorder(dt,"seq")
> > >
> > > dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> > > value.name="vl")
> > > dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> > > dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
> > > paste0(x,collapse="|"),value.var="vl")
> > > dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
> > > dt3 <-dcast(dt2,seq~vrb_nm,fun.aggregate=\(x)
> > > paste0(x,collapse="|"),value.var="c")
> > > setnames(dt3,paste0(colnames(dt3),"c"))
> > > dt <- dt[dt3,on=.(seq=seqc)]
> > >
> > > Te crea un grupo de variables tipo c que es la lógica que necesitas ..
> > pero
> > > le puedes reemplazar por el nombre de "a", qué es lo que muestras en el
> > > ejemplo
> > >
> > >
> > > Saludos
> > >
> > >
> > >
> > >
> > > El jue, 26 ene 2023 a la(s) 06:02, 
> > > escribió:
> >

Re: [R] Bug in R-Help Archives?

2023-01-27 Thread Sorkin, John
My apologies,
I did not mean to be part of the discussion. If there is such a thing as a 
pocket email (similar to a pocket dial) the email would be classified as a 
pocket email.
John


From: R-help  on behalf of Rui Barradas 

Sent: Friday, January 27, 2023 10:15 AM
To: Ivan Krylov
Cc: R-help Mailing List
Subject: Re: [R] Bug in R-Help Archives?

Às 07:36 de 27/01/2023, Ivan Krylov escreveu:
> On Fri, 27 Jan 2023 13:01:39 +0530
> Deepayan Sarkar  wrote:
>
>>  From looking at the headers in John Sorkin's mail, my guess is that he
>> just replied to the other thread rather than starting a fresh email,
>> and in his attempts to hide that, was outsmarted by Outlook.
>
> That's 100% correct. The starting "Pipe operator" e-mail has
> In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the
> message with this Message-ID is the one from Mukesh Ghanshyamdas
> Lekhrajani with the subject "Re: [R] R Certification" that's
> immediately above the message by John Sorkin.
>
Thanks, I was searching the archives for something else, stumbled on
that and forgot to look at the heders.
Good news there's nothing wrong with R-Help.

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7CJSorkin%40som.umaryland.edu%7Ca90bca3f346f470c472808db007a65cd%7C717009a620de461a88940312a395cac9%7C0%7C0%7C638104297929279937%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=8CGlDg%2Fdkx28raPOalXjZ7NqN%2BP%2BoWo9UFL%2Boc6NBRU%3D=0
PLEASE do read the posting guide 
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=05%7C01%7CJSorkin%40som.umaryland.edu%7Ca90bca3f346f470c472808db007a65cd%7C717009a620de461a88940312a395cac9%7C0%7C0%7C638104297929279937%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=mira%2F3jlC1V3jAJvBiqw53EpaCJknQ1W77NY7jTzfyA%3D=0
and provide commented, minimal, self-contained, reproducible code.

__
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] Bug in R-Help Archives?

2023-01-27 Thread Rui Barradas

Às 07:36 de 27/01/2023, Ivan Krylov escreveu:

On Fri, 27 Jan 2023 13:01:39 +0530
Deepayan Sarkar  wrote:


 From looking at the headers in John Sorkin's mail, my guess is that he
just replied to the other thread rather than starting a fresh email,
and in his attempts to hide that, was outsmarted by Outlook.


That's 100% correct. The starting "Pipe operator" e-mail has
In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the
message with this Message-ID is the one from Mukesh Ghanshyamdas
Lekhrajani with the subject "Re: [R] R Certification" that's
immediately above the message by John Sorkin.

Thanks, I was searching the archives for something else, stumbled on 
that and forgot to look at the heders.

Good news there's nothing wrong with R-Help.

Rui Barradas

______
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] Bug in R-Help Archives?

2023-01-27 Thread Rui Barradas

Às 07:31 de 27/01/2023, Deepayan Sarkar escreveu:

 From looking at the headers in John Sorkin's mail, my guess is that he
just replied to the other thread rather than starting a fresh email,
and in his attempts to hide that, was outsmarted by Outlook.

This is based on references to domains such as yahoo.com,
dcn.davis.ca.us, and precheza.cz in the header, which were all
involved in the certification thread.

-Deepayan

On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas  wrote:


Às 06:39 de 27/01/2023, Rui Barradas escreveu:

Hello,

When consulting the R-Help Archives today I've noticed that the thread

Pipe operator

started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another
thread,

R Certification

started by Mukesh Ghanshyamdas Lekhrajani.

Isn't this a bug in the filing system?

Thanks to the list maintainer  Martin Maechler and ETH Zurich for
organizing and hosting the list for all of us. It's an invaluable tool
that has served so many R users along the years and that surely gives a
lot of work organizing and eventual headaches. I hope this is not one of
them.

Rui Barradas

__
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.


Maybe the attached screen capture makes it more clear.

Rui Barradas


__
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.


Thanks, I had missed that.

Rui Barradas

__
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-es] Resumen de R-help-es, Vol 167, Envío 10

2023-01-27 Thread Griera-yandex
Hola:

Muchas gracias por responder. Lo pruebo.

Saludos.


On Fri, 27 Jan 2023 01:40:48 +0100
Carlos Ortega  wrote:

> Hola,
> 
> Otra alternativa...
> 
> #
> > library(data.table)
> > library(tidytable)
> > library(stringi)
> >
> > df <- data.frame(   V1a = sample(c("1","0"), 10, TRUE)
> +   , V1b = sample(c("1","0"), 10, TRUE)
> +   , V2a = sample(c("1","0"), 10, TRUE)
> +   , V2b = sample(c("1","0"), 10, TRUE))
> > df
>V1a V1b V2a V2b
> 11   0   1   1
> 21   1   0   1
> 30   0   0   0
> 41   0   1   0
> 50   1   0   0
> 60   0   1   0
> 71   0   0   0
> 81   1   1   0
> 90   0   0   0
> 10   0   1   1   1
> > > #--- Función compara parejas de columnas comienzan por mismas 2 letras.
> > *colcompare <- function(df)* {
> +
> +nam_val <- names(df) %>% stri_sub(from = 1, to = 2) %>% unique()
> +res_df  <- data.table()
> +for (i in 1:length(nam_val)) {
> +  cols_tmp <- nam_val[i]
> +  df_tmp <- df %>% select.(starts_with(cols_tmp)) %>%
> +rename.( a = 1) %>%
> +rename.( b = 2) %>%
> +mutate.( c = if_else.( a == 1 | b == 1, 1, 0)) %>%
> +select.(c) %>%
> +as.data.table()
> +names(df_tmp) <- paste0(cols_tmp, "c")
> +res_df <- cbind(res_df, df_tmp)
> +}
> +return(res_df)
> + }
> >
> > #--- Sobre df creado
> > *resultado <- colcompare(df)*
> > resultado
>   V1c   V2c
>  
>  1: 0 1
>  2: 1 0
>  3: 1 1
>  4: 1 1
>  5: 1 1
>  6: 1 1
>  7: 1 1
>  8: 0 0
>  9: 1 1
> 10: 0 1
> #
> 
> 
> Gracias,
> Carlos Ortega
> www.qualityexcellence.es
> 
> El jue, 26 ene 2023 a las 19:55, Griera-yandex ()
> escribió:
> 
> > Hola:
> >
> > Funciona a la perfección. Y los nombres de las nuevas variables tipo "V1c"
> > "V2c"... ya me está bien.
> >
> > Gracias por habertelo currado tanto! Me has ahorrado copiar, pegar y
> > modificar un monton de linias. Y no
> > tenia conciencia de que podia ser tan complicado.
> >
> > Gracias por la ayuda. Saludos.
> >
> > On Thu, 26 Jan 2023 09:33:31 -0500
> > patricio fuenmayor  wrote:
> >
> > > Hola esta es una solución
> > >
> > > library(data.table)
> > > library(stringr)
> > >
> > >
> > > dt <- data.table( V1a = sample(c("1","0"), 10, TRUE)
> > > , V1b = sample(c("1","0"), 10, TRUE)
> > > , V2a = sample(c("1","0"), 10, TRUE)
> > > , V2b = sample(c("1","0"), 10, TRUE)
> > > , V3a = sample(c("1","0"), 10, TRUE)
> > > , V3b = sample(c("1","0"), 10, TRUE)
> > > , V4a = sample(c("1","0"), 10, TRUE)
> > > , V4b = sample(c("1","0"), 10, TRUE))
> > > dt[,":="(seq=.I)]
> > > setcolorder(dt,"seq")
> > >
> > > dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> > > value.name="vl")
> > > dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> > > dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
> > > paste0(x,collapse="|"),value.var="vl")
> > > dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
> > > dt3 <-dcast(dt2,seq~vrb_nm,fun.aggregate=\(x)
> > > paste0(x,collapse="|"),value.var="c")
> > > setnames(dt3,paste0(colnames(dt3),"c"))
> > > dt <- dt[dt3,on=.(seq=seqc)]
> > >
> > > Te crea un grupo de variables tipo c que es la lógica que necesitas ..
> > pero
> > > le puedes reemplazar por el nombre de "a", qué es lo que muestras en el
> > > ejemplo
> > >
> > >
> > > Saludos
> > >
> > >
> > >
> > >
> > > El jue, 26 ene 2023 a la(s) 06:02, 
> > > escribió:
> > >
> > > > Envíe los mensajes para la lista R-help-es a
> > > > r-help-es@r-project.org
> &g

Re: [R] Bug in R-Help Archives?

2023-01-26 Thread Jeff Newmiller
Every email thread (mailing list or not) gets a hidden identifier that is used 
to identify that thread. It is not that Outlook outsmarted John... any email 
program would have done the same.

John... please don't reply to existing posts with a new subject... many mailing 
list users may be using the threaded view in their email program and never see 
your question at all if they were not interested in the original thread.

On January 26, 2023 11:31:39 PM PST, Deepayan Sarkar 
 wrote:
>From looking at the headers in John Sorkin's mail, my guess is that he
>just replied to the other thread rather than starting a fresh email,
>and in his attempts to hide that, was outsmarted by Outlook.
>
>This is based on references to domains such as yahoo.com,
>dcn.davis.ca.us, and precheza.cz in the header, which were all
>involved in the certification thread.
>
>-Deepayan
>
>On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas  wrote:
>>
>> Às 06:39 de 27/01/2023, Rui Barradas escreveu:
>> > Hello,
>> >
>> > When consulting the R-Help Archives today I've noticed that the thread
>> >
>> > Pipe operator
>> >
>> > started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another
>> > thread,
>> >
>> > R Certification
>> >
>> > started by Mukesh Ghanshyamdas Lekhrajani.
>> >
>> > Isn't this a bug in the filing system?
>> >
>> > Thanks to the list maintainer  Martin Maechler and ETH Zurich for
>> > organizing and hosting the list for all of us. It's an invaluable tool
>> > that has served so many R users along the years and that surely gives a
>> > lot of work organizing and eventual headaches. I hope this is not one of
>> > them.
>> >
>> > Rui Barradas
>> >
>> > __
>> > 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.
>>
>> Maybe the attached screen capture makes it more clear.
>>
>> Rui Barradas
>>
>>
>> ______
>> 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-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.

-- 
Sent from my phone. Please excuse my brevity.

__
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] Bug in R-Help Archives?

2023-01-26 Thread Ivan Krylov
On Fri, 27 Jan 2023 13:01:39 +0530
Deepayan Sarkar  wrote:

> From looking at the headers in John Sorkin's mail, my guess is that he
> just replied to the other thread rather than starting a fresh email,
> and in his attempts to hide that, was outsmarted by Outlook.

That's 100% correct. The starting "Pipe operator" e-mail has
In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the
message with this Message-ID is the one from Mukesh Ghanshyamdas
Lekhrajani with the subject "Re: [R] R Certification" that's
immediately above the message by John Sorkin.

-- 
Best regards,
Ivan

__
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] Bug in R-Help Archives?

2023-01-26 Thread Deepayan Sarkar
>From looking at the headers in John Sorkin's mail, my guess is that he
just replied to the other thread rather than starting a fresh email,
and in his attempts to hide that, was outsmarted by Outlook.

This is based on references to domains such as yahoo.com,
dcn.davis.ca.us, and precheza.cz in the header, which were all
involved in the certification thread.

-Deepayan

On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas  wrote:
>
> Às 06:39 de 27/01/2023, Rui Barradas escreveu:
> > Hello,
> >
> > When consulting the R-Help Archives today I've noticed that the thread
> >
> > Pipe operator
> >
> > started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another
> > thread,
> >
> > R Certification
> >
> > started by Mukesh Ghanshyamdas Lekhrajani.
> >
> > Isn't this a bug in the filing system?
> >
> > Thanks to the list maintainer  Martin Maechler and ETH Zurich for
> > organizing and hosting the list for all of us. It's an invaluable tool
> > that has served so many R users along the years and that surely gives a
> > lot of work organizing and eventual headaches. I hope this is not one of
> > them.
> >
> > Rui Barradas
> >
> > ______
> > 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.
>
> Maybe the attached screen capture makes it more clear.
>
> Rui Barradas
>
>
> __
> 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-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] Bug in R-Help Archives?

2023-01-26 Thread Rui Barradas

Às 06:39 de 27/01/2023, Rui Barradas escreveu:

Hello,

When consulting the R-Help Archives today I've noticed that the thread

Pipe operator

started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another 
thread,


R Certification

started by Mukesh Ghanshyamdas Lekhrajani.

Isn't this a bug in the filing system?

Thanks to the list maintainer  Martin Maechler and ETH Zurich for 
organizing and hosting the list for all of us. It's an invaluable tool 
that has served so many R users along the years and that surely gives a 
lot of work organizing and eventual headaches. I hope this is not one of 
them.


Rui Barradas

__
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.


Maybe the attached screen capture makes it more clear.

Rui Barradas


__
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] Bug in R-Help Archives?

2023-01-26 Thread Rui Barradas

Hello,

When consulting the R-Help Archives today I've noticed that the thread

Pipe operator

started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another thread,

R Certification

started by Mukesh Ghanshyamdas Lekhrajani.

Isn't this a bug in the filing system?

Thanks to the list maintainer  Martin Maechler and ETH Zurich for 
organizing and hosting the list for all of us. It's an invaluable tool 
that has served so many R users along the years and that surely gives a 
lot of work organizing and eventual headaches. I hope this is not one of 
them.


Rui Barradas

__
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-es] Resumen de R-help-es, Vol 167, Envío 10

2023-01-26 Thread Griera-yandex
Hola:

Funciona a la perfección. Y los nombres de las nuevas variables tipo "V1c" 
"V2c"... ya me está bien.

Gracias por habertelo currado tanto! Me has ahorrado copiar, pegar y modificar 
un monton de linias. Y no
tenia conciencia de que podia ser tan complicado.

Gracias por la ayuda. Saludos.

On Thu, 26 Jan 2023 09:33:31 -0500
patricio fuenmayor  wrote:

> Hola esta es una solución
> 
> library(data.table)
> library(stringr)
> 
> 
> dt <- data.table( V1a = sample(c("1","0"), 10, TRUE)
> , V1b = sample(c("1","0"), 10, TRUE)
> , V2a = sample(c("1","0"), 10, TRUE)
> , V2b = sample(c("1","0"), 10, TRUE)
> , V3a = sample(c("1","0"), 10, TRUE)
> , V3b = sample(c("1","0"), 10, TRUE)
> , V4a = sample(c("1","0"), 10, TRUE)
> , V4b = sample(c("1","0"), 10, TRUE))
> dt[,":="(seq=.I)]
> setcolorder(dt,"seq")
> 
> dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> value.name="vl")
> dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
> paste0(x,collapse="|"),value.var="vl")
> dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
> dt3 <-dcast(dt2,seq~vrb_nm,fun.aggregate=\(x)
> paste0(x,collapse="|"),value.var="c")
> setnames(dt3,paste0(colnames(dt3),"c"))
> dt <- dt[dt3,on=.(seq=seqc)]
> 
> Te crea un grupo de variables tipo c que es la lógica que necesitas .. pero
> le puedes reemplazar por el nombre de "a", qué es lo que muestras en el
> ejemplo
> 
> 
> Saludos
> 
> 
> 
> 
> El jue, 26 ene 2023 a la(s) 06:02, 
> escribió:
> 
> > Envíe los mensajes para la lista R-help-es a
> > r-help-es@r-project.org
> >
> > Para subscribirse o anular su subscripción a través de la WEB
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
> > O por correo electrónico, enviando un mensaje con el texto "help" en
> > el asunto (subject) o en el cuerpo a:
> > r-help-es-requ...@r-project.org
> >
> > Puede contactar con el responsable de la lista escribiendo a:
> > r-help-es-ow...@r-project.org
> >
> > Si responde a algún contenido de este mensaje, por favor, edite la
> > linea del asunto (subject) para que el texto sea mas especifico que:
> > "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> > la respuesta sólo aquellas partes del mensaje a las que está
> > respondiendo.
> > Asuntos del día:
> >
> >1. Modificar una serie columnas de un dataframe (Griera)
> >
> >
> > -- Forwarded message --
> > From: Griera 
> > To: r-help-es@r-project.org, gri...@yandex.com
> > Cc:
> > Bcc:
> > Date: Thu, 26 Jan 2023 09:46:57 +0100
> > Subject: [R-es] Modificar una serie columnas de un dataframe
> > Hola:
> >
> > Lo vuelvo a enviar para ver si tengo más suerte:
> >
> > Tengo una tabla con pares de variables (V1a, V1b, V2a, V2b, ...) similar a
> > esta:
> >
> > df <- data.frame( V1a = sample(c("1","0"), 10, TRUE)
> > , V1b = sample(c("1","0"), 10, TRUE)
> > , V2a = sample(c("1","0"), 10, TRUE)
> > , V2b = sample(c("1","0"), 10, TRUE))
> >
> >V1a V1b V2a V2b
> > 1    0   1   0   0
> > 20   0   1   0
> > 30   1   0   0
> > ...
> >
> > y quiero que V1a valga "1" si V1a o V1b valen 1, V2a valga "1" si V2a o
> > V2b valen 1 y así sucesivamente. Lo hago mediante un transform con una
> > línia para cada pareja de variables:
> >
> > df <- transform (df
> > , V1a = ifelse (V1a == "1" | V1b == "1", "1, "0")
> > , V2a = ifelse (V2a == "1" | V2b == "1", "1, "0"))
> >
> >   )
> > ¿Habria forma de hacerlo (¿con un función?) de manera que no tenga que
> > escribir una línia para cada par de variables?
> >
> > Muchas gracias a todos y saludos.
> >
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 167, Envío 10

2023-01-26 Thread Griera-yandex
Muchas gracias por responder!

Después lo hago.

Saludos.

On Thu, 26 Jan 2023 09:33:31 -0500
patricio fuenmayor  wrote:

> Hola esta es una solución
> 
> library(data.table)
> library(stringr)
> 
> 
> dt <- data.table( V1a = sample(c("1","0"), 10, TRUE)
> , V1b = sample(c("1","0"), 10, TRUE)
> , V2a = sample(c("1","0"), 10, TRUE)
> , V2b = sample(c("1","0"), 10, TRUE)
> , V3a = sample(c("1","0"), 10, TRUE)
> , V3b = sample(c("1","0"), 10, TRUE)
> , V4a = sample(c("1","0"), 10, TRUE)
> , V4b = sample(c("1","0"), 10, TRUE))
> dt[,":="(seq=.I)]
> setcolorder(dt,"seq")
> 
> dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
> value.name="vl")
> dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
> dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
> paste0(x,collapse="|"),value.var="vl")
> dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
> dt3 <-dcast(dt2,seq~vrb_nm,fun.aggregate=\(x)
> paste0(x,collapse="|"),value.var="c")
> setnames(dt3,paste0(colnames(dt3),"c"))
> dt <- dt[dt3,on=.(seq=seqc)]
> 
> Te crea un grupo de variables tipo c que es la lógica que necesitas .. pero
> le puedes reemplazar por el nombre de "a", qué es lo que muestras en el
> ejemplo
> 
> 
> Saludos
> 
> 
> 
> 
> El jue, 26 ene 2023 a la(s) 06:02, 
> escribió:
> 
> > Envíe los mensajes para la lista R-help-es a
> > r-help-es@r-project.org
> >
> > Para subscribirse o anular su subscripción a través de la WEB
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
> > O por correo electrónico, enviando un mensaje con el texto "help" en
> > el asunto (subject) o en el cuerpo a:
> > r-help-es-requ...@r-project.org
> >
> > Puede contactar con el responsable de la lista escribiendo a:
> > r-help-es-ow...@r-project.org
> >
> > Si responde a algún contenido de este mensaje, por favor, edite la
> > linea del asunto (subject) para que el texto sea mas especifico que:
> > "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> > la respuesta sólo aquellas partes del mensaje a las que está
> > respondiendo.
> > Asuntos del día:
> >
> >1. Modificar una serie columnas de un dataframe (Griera)
> >
> >
> > -- Forwarded message --
> > From: Griera 
> > To: r-help-es@r-project.org, gri...@yandex.com
> > Cc:
> > Bcc:
> > Date: Thu, 26 Jan 2023 09:46:57 +0100
> > Subject: [R-es] Modificar una serie columnas de un dataframe
> > Hola:
> >
> > Lo vuelvo a enviar para ver si tengo más suerte:
> >
> > Tengo una tabla con pares de variables (V1a, V1b, V2a, V2b, ...) similar a
> > esta:
> >
> > df <- data.frame( V1a = sample(c("1","0"), 10, TRUE)
> > , V1b = sample(c("1","0"), 10, TRUE)
> > , V2a = sample(c("1","0"), 10, TRUE)
> >     , V2b = sample(c("1","0"), 10, TRUE))
> >
> >V1a V1b V2a V2b
> > 1    0   1   0   0
> > 20   0   1   0
> > 30   1   0   0
> > ...
> >
> > y quiero que V1a valga "1" si V1a o V1b valen 1, V2a valga "1" si V2a o
> > V2b valen 1 y así sucesivamente. Lo hago mediante un transform con una
> > línia para cada pareja de variables:
> >
> > df <- transform (df
> > , V1a = ifelse (V1a == "1" | V1b == "1", "1, "0")
> > , V2a = ifelse (V2a == "1" | V2b == "1", "1, "0"))
> >
> >   )
> > ¿Habria forma de hacerlo (¿con un función?) de manera que no tenga que
> > escribir una línia para cada par de variables?
> >
> > Muchas gracias a todos y saludos.
> >
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 167, Envío 10

2023-01-26 Thread patricio fuenmayor
Hola esta es una solución

library(data.table)
library(stringr)


dt <- data.table( V1a = sample(c("1","0"), 10, TRUE)
, V1b = sample(c("1","0"), 10, TRUE)
, V2a = sample(c("1","0"), 10, TRUE)
, V2b = sample(c("1","0"), 10, TRUE)
, V3a = sample(c("1","0"), 10, TRUE)
, V3b = sample(c("1","0"), 10, TRUE)
, V4a = sample(c("1","0"), 10, TRUE)
, V4b = sample(c("1","0"), 10, TRUE))
dt[,":="(seq=.I)]
setcolorder(dt,"seq")

dt1 <- melt(dt,id.vars=1,measure.vars=2:ncol(dt),variable.name="vrb",
value.name="vl")
dt1[,":="(vrb_nm=str_sub(vrb,end=2),vrb_tp=str_sub(vrb,start=-1))]
dt2 <- dcast(dt1,seq+vrb_nm~vrb_tp,fun.aggregate=\(x)
paste0(x,collapse="|"),value.var="vl")
dt2[,":="(c=fifelse(a=="1"|b=="1","1","0"))]
dt3 <-dcast(dt2,seq~vrb_nm,fun.aggregate=\(x)
paste0(x,collapse="|"),value.var="c")
setnames(dt3,paste0(colnames(dt3),"c"))
dt <- dt[dt3,on=.(seq=seqc)]

Te crea un grupo de variables tipo c que es la lógica que necesitas .. pero
le puedes reemplazar por el nombre de "a", qué es lo que muestras en el
ejemplo


Saludos




El jue, 26 ene 2023 a la(s) 06:02, 
escribió:

> Envíe los mensajes para la lista R-help-es a
> r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
> Asuntos del día:
>
>1. Modificar una serie columnas de un dataframe (Griera)
>
>
> -- Forwarded message --
> From: Griera 
> To: r-help-es@r-project.org, gri...@yandex.com
> Cc:
> Bcc:
> Date: Thu, 26 Jan 2023 09:46:57 +0100
> Subject: [R-es] Modificar una serie columnas de un dataframe
> Hola:
>
> Lo vuelvo a enviar para ver si tengo más suerte:
>
> Tengo una tabla con pares de variables (V1a, V1b, V2a, V2b, ...) similar a
> esta:
>
> df <- data.frame( V1a = sample(c("1","0"), 10, TRUE)
> , V1b = sample(c("1","0"), 10, TRUE)
> , V2a = sample(c("1","0"), 10, TRUE)
> , V2b = sample(c("1","0"), 10, TRUE))
>
>V1a V1b V2a V2b
> 10   1   0   0
> 20   0   1   0
> 30   1   0   0
> ...
>
> y quiero que V1a valga "1" si V1a o V1b valen 1, V2a valga "1" si V2a o
> V2b valen 1 y así sucesivamente. Lo hago mediante un transform con una
> línia para cada pareja de variables:
>
> df <- transform (df
>     , V1a = ifelse (V1a == "1" | V1b == "1", "1, "0")
> , V2a = ifelse (V2a == "1" | V2b == "1", "1, "0"))
>
>   )
> ¿Habria forma de hacerlo (¿con un función?) de manera que no tenga que
> escribir una línia para cada par de variables?
>
> Muchas gracias a todos y saludos.
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R-es] Resumen de R-help-es, Vol 166, Envío 1

2022-12-04 Thread patricio fuenmayor
Hola, adjunto proceso con lo que hago identificación y exclusión de outliers

# analiza y filtra atípicos
# ingresos disponibles
ing_dsp_out1 <- dlookr::imputate_outlier(eda1,ing_dsp_vl,method="capping")
ing_dsp_out2 <-
data.table(out_pos=attr(ing_dsp_out1,"outlier_pos"),out_vl=attr(ing_dsp_out1,"outliers"))[order(out_vl)]
# estadísticas de atípicos
out_sta1 <- data.table(smbinning.eda(ing_dsp_out2,rounding=3,pbar=0)$eda) #
Table with basic statistics
# filtra valores menores al Q50 de los atípicos
eda2 <- eda1[ing_dsp_vl<=out_sta1[Field=="out_vl",Q50]]

dlookr::plot_outlier(eda2[,.(ing_dsp_vl)])

El sáb, 3 dic 2022 a la(s) 06:00, 
escribió:

> Envíe los mensajes para la lista R-help-es a
> r-help-es@r-project.org
>
> Para subscribirse o anular su subscripción a través de la WEB
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> O por correo electrónico, enviando un mensaje con el texto "help" en
> el asunto (subject) o en el cuerpo a:
> r-help-es-requ...@r-project.org
>
> Puede contactar con el responsable de la lista escribiendo a:
> r-help-es-ow...@r-project.org
>
> Si responde a algún contenido de este mensaje, por favor, edite la
> linea del asunto (subject) para que el texto sea mas especifico que:
> "Re: Contents of R-help-es digest...". Además, por favor, incluya en
> la respuesta sólo aquellas partes del mensaje a las que está
> respondiendo.
> Asuntos del día:
>
>1. eliminar outliers en un tapply (Manuel Mendoza)
>
>
> -- Forwarded message --
> From: Manuel Mendoza 
> To: Lista R 
> Cc:
> Bcc:
> Date: Sat, 3 Dec 2022 09:14:11 +0100
> Subject: [R-es] eliminar outliers en un tapply
> Buenos días, utilizo:
>
> max <- tapply (Data$varnum, Data$varcat, max)
>
> para obtener el máximo de varnum en cada una de las categorías de varcat
>
> ¿cómo podría obtener los máximos, pero sin los outliers (Q75 + 1.5*IQR)?
>
> Es fácil quitar los outliers superiores de varnum, pero no es eso lo que
> necesito quitar, sino los outliers dentro ya de cada categoría de varcat.
>
> Gracias, como siempre,
> Manuel
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Help with function and survey data

2022-10-31 Thread Edjabou Vincent
Dear Bert

Thank you for your suggestion. I have tried it but it did not work.


For record, I am reposting the post with the plain text.
library(tidyverse)
library(plyr)
library(survey)

dat <- structure(list(
   r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L,
2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_2 = structure(c(3L, 3L,3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_3 = structure(c(3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L),
.Label = c("Don't Know","No", "Yes"), class = "factor"),
  r3a_4 = structure(c(3L,2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L,
2L, 3L, 2L, 2L,3L, 3L, 3L, 1L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_5 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L,2L, 3L,
2L, 3L, 3L, 2L, 3L, 2L, 3L, 1L),
.Label = c("Don't Know","No", "Yes"), class = "factor"),
  r3a_6 = structure(c(3L,3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L,
2L, 2L, 2L, 3L,2L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_7 = structure(c(1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L,3L, 3L,
2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_8 = structure(c(3L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L,
2L, 3L, 3L, 2L,  2L, 2L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_9 = structure(c(1L, 3L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 3L,3L, 3L,
2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L),
.Label = c("Don't Know","No", "Yes"), class = "factor"),
  weight = c(0.34, 0.34, 0.34,0.34, 0.34, 0.34, 0.34, 0.34, 0.34,
0.34, 0.34, 0.34, 0.43, 0.43, 0.43, 0.34, 0.34, 0.34, 0.34, 0.34),
  seg_2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 1L,1L, 1L, 1L, 1L),
.Label = c("1", "2"), class = "factor"),
  seg_3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L,
2L, 1L, 1L, 1L,1L, 2L, 2L, 2L),
.Label = c("1", "2"), class = "factor"),
  seg_4 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 1L,1L, 1L, 1L, 1L),
.Label = c("1", "2"), class = "factor")),
  .Names = c("r3a_1", "r3a_2", "r3a_3", "r3a_4", "r3a_5", "r3a_6",
"r3a_7", "r3a_8", "r3a_9", "weight", "seg_2","seg_3","seg_4"),
row.names = c(NA, 20L), class = "data.frame")

 dat_weight <- svydesign(ids = ~1, weights = ~weight, data = dat)

my_funca <- function(mk,y){
   my_re <-   ldply( mk, function(x)
  svytable(bquote(~ y + .(as.name(x))), dat_weight) %>%
as_tibble() %>%
dplyr::group_by({{y}}) %>%
transmute(!!(as.name(x)), Procent = round(n/sum(n,na.rm = T)*100,2)) %>%
pivot_wider(names_from = (as.name(x)),
values_from = Procent)
   )
   return(my_re)
}

my_funca(mk =names(dat)[1:9], y = dat$seg_2)
Regards,

Vincent Edjabou
Mobile: +45 31 95 99 33
linkedin.com/vincent

Orcid: -0003-2849-6151

Regards,

Vincent Edjabou
Mobile: +45 31 95 99 33
linkedin.com/vincent

Orcid: -0003-2849-6151




On Mon, Oct 31, 2022 at 5:21 PM Bert Gunter  wrote:
>
> 1. This is a plain text list. Set your email to post in plain text, not html, 
> which often gets mangled (see below).
>
> 2. I did not run your example, but try:
> my_funca(mk =names(dat)[1:9], y = dat$seg_2)
>
> ## seg_2 is a component of dat and is not in the environment of the call. I 
> did not see any data argument that would tell it to look elsewhere, but I am 
> not familiar with tidy_whatever's nonstandard evaluation conventions.
>
> -- Bert
>
> On Mon, Oct 31, 2022 at 8:39 AM Edjabou Vincent  wrote:
>>
>> Dear R-Help
>> I am working with complex survey data using the survey package.
>> I would like to create a function for the generate multi crosstable. The
>> problem is that I am getting error with the following message:
>> "Error in eval(predvars, data, env) : object 'y' not found"
>>
>> Here is the example:
>> library(tidyverse)
>> library(plyr)
>> library(survey)
>&g

Re: [R] Help with function and survey data

2022-10-31 Thread Bert Gunter
1. This is a plain text list. Set your email to post in plain text, not
html, which often gets mangled (see below).

2. I did not run your example, but try:
my_funca(mk =names(dat)[1:9], y = dat$seg_2)

## seg_2 is a component of dat and is not in the environment of the call. I
did not see any data argument that would tell it to look elsewhere, but I
am not familiar with tidy_whatever's nonstandard evaluation conventions.

-- Bert

On Mon, Oct 31, 2022 at 8:39 AM Edjabou Vincent  wrote:

> Dear R-Help
> I am working with complex survey data using the survey package.
> I would like to create a function for the generate multi crosstable. The
> problem is that I am getting error with the following message:
> "Error in eval(predvars, data, env) : object 'y' not found"
>
> Here is the example:
> library(tidyverse)
> library(plyr)
> library(survey)
>
> dat <- structure(list(
>r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L, 2L,
> 3L, 3L, 3L, 3L, 3L, 3L, 3L),
> .Label = c("Don't Know", "No", "Yes"), class = "factor"),
>   r3a_2 = structure(c(3L, 3L,3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
> 3L, 3L, 3L, 3L, 3L, 3L, 3L),
> .Label = c("Don't Know", "No", "Yes"), class =
> "factor"),
>   r3a_3 = structure(c(3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 3L, 3L),
> .Label = c("Don't Know","No", "Yes"), class =
> "factor"),
>   r3a_4 = structure(c(3L,2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 2L,
> 3L, 2L, 2L,3L, 3L, 3L, 1L),
> .Label = c("Don't Know", "No", "Yes"), class =
> "factor"),
>   r3a_5 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L,2L, 3L, 2L,
> 3L, 3L, 2L, 3L, 2L, 3L, 1L),
> .Label = c("Don't Know","No", "Yes"), class =
> "factor"),
>   r3a_6 = structure(c(3L,3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L,
> 2L, 2L, 3L,2L, 3L, 3L, 3L),
> .Label = c("Don't Know", "No", "Yes"), class =
> "factor"),
>   r3a_7 = structure(c(1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L,3L, 3L, 2L,
> 2L, 2L, 2L, 2L, 3L, 3L, 3L),
> .Label = c("Don't Know", "No", "Yes"), class =
> "factor"),
>   r3a_8 = structure(c(3L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L,
> 3L, 3L, 2L,  2L, 2L, 3L, 3L),
> .Label = c("Don't Know", "No", "Yes"), class =
> "factor"),
>   r3a_9 = structure(c(1L, 3L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 3L,3L, 3L, 2L,
> 2L, 2L, 3L, 2L, 2L, 3L, 3L),
> .Label = c("Don't Know","No", "Yes"), class =
> "factor"),
>   weight = c(0.34, 0.34, 0.34,0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34,
> 0.34, 0.34, 0.43, 0.43, 0.43, 0.34, 0.34, 0.34, 0.34, 0.34),
>   seg_2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
> 1L, 1L, 1L,1L, 1L, 1L, 1L),
> .Label = c("1", "2"), class = "factor"),
>   seg_3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L,
> 1L, 1L, 1L,1L, 2L, 2L, 2L),
> .Label = c("1", "2"), class = "factor"),
>   seg_4 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L,
> 1L, 1L, 1L,1L, 1L, 1L, 1L),
> .Label = c("1", "2"), class = "factor")),
>   .Names = c("r3a_1", "r3a_2", "r3a_3", "r3a_4", "r3a_5", "r3a_6", "r3a_7",
> "r3a_8", "r3a_9", "weight", "seg_2","seg_3","seg_4"), row.names = c(NA,
> 20L), class = "data.frame")
>
>  dat_weight <- svydesign(ids = ~1, weights = ~weight, data = dat)
>
> my_funca <- function(mk,y){
>my_re <-   ldply( mk, function(x)
>       svytable(bquote(~ y + .(as.name(x))), dat_weight) %>%
> as_tibble() %>%
> dplyr::group_by({{y}}) %>%
> transmute(!!(as.name(x)), Procent = round(n/sum(n,na.rm =
> T)*100,2)) %>%
> pivot_wider(names_from = (as.name(x)),
> values_from = Procent)
>)
>return(my_re)
> }
>
> my_funca(mk =names(dat)[1:9], y = seg_2)
>
>
> I will appreciate any help you will provide.
>
>
>
>
> Regards,
>
> Vincent Edjabou
> Mobile: +45 31 95 99 33
> linkedin.com/vincent
> <http://linkedin.com/in/vincent-maklawe-edjabou-9742a41b>
>
> Orcid: -0003-2849-6151
>
> [[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] Help with function and survey data

2022-10-31 Thread Edjabou Vincent
Dear R-Help
I am working with complex survey data using the survey package.
I would like to create a function for the generate multi crosstable. The
problem is that I am getting error with the following message:
"Error in eval(predvars, data, env) : object 'y' not found"

Here is the example:
library(tidyverse)
library(plyr)
library(survey)

dat <- structure(list(
   r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L, 2L,
3L, 3L, 3L, 3L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class = "factor"),
  r3a_2 = structure(c(3L, 3L,3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class =
"factor"),
  r3a_3 = structure(c(3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 3L, 3L),
.Label = c("Don't Know","No", "Yes"), class =
"factor"),
  r3a_4 = structure(c(3L,2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 2L,
3L, 2L, 2L,3L, 3L, 3L, 1L),
.Label = c("Don't Know", "No", "Yes"), class =
"factor"),
  r3a_5 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L,2L, 3L, 2L,
3L, 3L, 2L, 3L, 2L, 3L, 1L),
.Label = c("Don't Know","No", "Yes"), class =
"factor"),
  r3a_6 = structure(c(3L,3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L,
2L, 2L, 3L,2L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class =
"factor"),
  r3a_7 = structure(c(1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L,3L, 3L, 2L,
2L, 2L, 2L, 2L, 3L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class =
"factor"),
  r3a_8 = structure(c(3L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L,
3L, 3L, 2L,  2L, 2L, 3L, 3L),
.Label = c("Don't Know", "No", "Yes"), class =
"factor"),
  r3a_9 = structure(c(1L, 3L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 3L,3L, 3L, 2L,
2L, 2L, 3L, 2L, 2L, 3L, 3L),
.Label = c("Don't Know","No", "Yes"), class =
"factor"),
  weight = c(0.34, 0.34, 0.34,0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34,
0.34, 0.34, 0.43, 0.43, 0.43, 0.34, 0.34, 0.34, 0.34, 0.34),
  seg_2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
1L, 1L, 1L,1L, 1L, 1L, 1L),
.Label = c("1", "2"), class = "factor"),
  seg_3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L,
1L, 1L, 1L,1L, 2L, 2L, 2L),
.Label = c("1", "2"), class = "factor"),
  seg_4 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L,
1L, 1L, 1L,1L, 1L, 1L, 1L),
.Label = c("1", "2"), class = "factor")),
  .Names = c("r3a_1", "r3a_2", "r3a_3", "r3a_4", "r3a_5", "r3a_6", "r3a_7",
"r3a_8", "r3a_9", "weight", "seg_2","seg_3","seg_4"), row.names = c(NA,
20L), class = "data.frame")

 dat_weight <- svydesign(ids = ~1, weights = ~weight, data = dat)

my_funca <- function(mk,y){
   my_re <-   ldply( mk, function(x)
  svytable(bquote(~ y + .(as.name(x))), dat_weight) %>%
as_tibble() %>%
dplyr::group_by({{y}}) %>%
transmute(!!(as.name(x)), Procent = round(n/sum(n,na.rm =
T)*100,2)) %>%
pivot_wider(names_from = (as.name(x)),
values_from = Procent)
   )
   return(my_re)
}

my_funca(mk =names(dat)[1:9], y = seg_2)


I will appreciate any help you will provide.




Regards,

Vincent Edjabou
Mobile: +45 31 95 99 33
linkedin.com/vincent
<http://linkedin.com/in/vincent-maklawe-edjabou-9742a41b>

Orcid: -0003-2849-6151

[[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.


  1   2   3   4   5   6   7   8   9   10   >