Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Rui Barradas

Às 20:44 de 12/06/2024, Yuan Chun Ding escreveu:

Hi Rui,

Thank you very much!


Yes, I verified using real data, it worked correctly as expected after adding 
tidyr:: to the pivot_longer function and dplyr:: to the group_by and summarize
Function.

I did not know how to assign the tidyr and dplyr to the three functions because 
I do not really understand well the three functions and just got the code from 
a google search.

I also tried your simplified code, but got the following error
Error in `dplyr::summarize()`:
! Can't supply both `.by` and `.groups`.
Run `rlang::last_trace()` to see where the error occurred.

Ding

From: Rui Barradas 
Sent: Wednesday, June 12, 2024 11:29 AM
To: Yuan Chun Ding ; CALUM POLWART 
Cc: r-help@r-project.org
Subject: Re: [R] my R code worked well when running the first 1000 lines of R 
code

Hello, Inline. Às 19: 03 de 12/06/2024, Yuan Chun Ding via R-help escreveu: > I am sorry 
that I know I should provide a dataset that allows to replicate my problem. > > It is 
a research dataset and quite large, so I can not share. >


Hello,



Inline.



Às 19:03 de 12/06/2024, Yuan Chun Ding via R-help escreveu:


I am sorry that I know I should provide a dataset that allows to replicate my 
problem.







It is a research dataset and quite large, so I can not share.







Both Bert and Tim guessed my problem correctly.  I also thought about the 
conflicting issue between different packages and function masking.



I just hope to that someone has similar experience, so providing me suggestion.







For conflicting issue,







What I tried  was to add dplyr::pivot_longer or tidyr:: pivot_longer,






Do that to all functions comming from contributed packages. At least to

those.





summary_anno1148ft <- anno1148ft %>%

tidyr::pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to =

"measure") %>%

dplyr::group_by(dat, measure) %>%

dplyr::summarize(minimum = min(value,na.rm=T),

 q25 = quantile(value, probs = 0.25,na.rm=T),

 med = median(value,na.rm=T),

 q75 = quantile(value, probs = 0.75,na.rm=T),

 maximum = max(value,na.rm=T),

 average = mean(value,na.rm=T),

 #standard_deviation = sd(value),

 .groups = "drop"

)





Or, simpler, no need to group_by anymore. It can be done in summarise.





summary_anno1148ft <- anno1148ft %>%

tidyr::pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to =

"measure") %>%

dplyr::summarize(minimum = min(value,na.rm=T),

 q25 = quantile(value, probs = 0.25,na.rm=T),

 med = median(value,na.rm=T),

 q75 = quantile(value, probs = 0.75,na.rm=T),

 maximum = max(value,na.rm=T),

 average = mean(value,na.rm=T),

 #standard_deviation = sd(value),

 .by = c(dat, measure),

 .groups = "drop"

)







This is only a guess, the question cannot really be answered.





Hope this helps,



Rui Barradas



but still not resolved the problem.














I will restart from the first line my code, it will work again and then I will 
track down.















Thank you,







Ding











From: CALUM POLWART mailto:polc1...@gmail.com>>



Sent: Wednesday, June 12, 2024 10:52 AM



To: Yuan Chun Ding mailto:ycd...@coh.org>>



Cc: r-help@r-project.org



Subject: Re: [R] my R code worked well when running the first 1000 lines of R 
code







I sometimes think people on this list are quite rude to posters. I'm afraid I'm likely to 
join in with some rudeness? 1. "Here is some code that works but also doesn't" 
is probably not going to get you an answer 2. I provide











I sometimes think people on this list are quite rude to posters.







I'm afraid I'm likely to join in with some rudeness?







1. "Here is some code that works but also doesn't" is probably not going to get 
you an answer



2. I provide no information about the data it works on or doesn't



3. I tell you I'm using a load of dependencies, but don't tell you what



4. I refer to 2000 lines of code but probably means 2000 lines of data?







So. Please post a question someone can actually answer.







If the question is "why might code fail on a 2000 line dataset when it works on 1000 
line dataset" then here are some thoughts:







* Is the 1000 lines being run as dataset[1:1000,] or is it dataset1 and 
dataset2 ?



* Is there a structural difference in the datasets - i.e. numbers, characters 
or factors as columns. Often import functions guess a column type by reading 
the first 500/1000 lines. If the data has numbers in column 1 for 1-1000 but on 
line 1999 has a letter... The data type may vary.







On Wed, 12 Jun 2024, 17:28 Yuan Chun Ding via R-help, 

Re: [R-es] Congreso R Sevilla 2024: envío de comunicaciones hasta el próximo sábado 15 de junio

2024-06-12 Thread Francisco Rodríguez


De: R-help-es  en nombre de Francisco 
Rodríguez 
Enviado: miércoles, 12 de junio de 2024 22:22
Para: Francisco Rodriguez Sanchez ; 
r-help-es@r-project.org 
Asunto: Re: [R-es] Congreso R Sevilla 2024: envío de comunicaciones hasta el 
próximo sábado 15 de junio

Hola buenas tardes,

En mi caso solicit� para dar un taller, supongo que todo est� en orden.

Un saludo y gracias

De: R-help-es  en nombre de Francisco 
Rodriguez Sanchez 
Enviado: mi�rcoles, 12 de junio de 2024 12:04
Para: r-help-es@r-project.org 
Asunto: [R-es] Congreso R Sevilla 2024: env�o de comunicaciones hasta el 
pr�ximo s�bado 15 de junio

Buenos d�as

Este s�bado (15 de junio) se cierra el plazo para enviar comunicaciones
para el pr�ximo congreso de R en Sevilla (noviembre de 2024). Gran
oportunidad para presentar nuestro trabajo y aprender, con charlas y
talleres sobre datos, estad�stica, programaci�n, docencia, tidymodels,
rspatial... Animamos a todos a asistir y presentar su trabajo

Toda la informaci�n del congreso est� disponible en la web:
https://www.imus.us.es/congresos/IIIRqueR/

Saludos

--
Dr Francisco Rodr�guez-S�nchez
https://frodriguezsanchez.net

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

[[alternative HTML version deleted]]


[[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] Congreso R Sevilla 2024: envío de comunicaciones hasta el próximo sábado 15 de junio

2024-06-12 Thread Francisco Rodríguez
Hola buenas tardes,

En mi caso solicit� para dar un taller, supongo que todo est� en orden.

Un saludo y gracias

De: R-help-es  en nombre de Francisco 
Rodriguez Sanchez 
Enviado: mi�rcoles, 12 de junio de 2024 12:04
Para: r-help-es@r-project.org 
Asunto: [R-es] Congreso R Sevilla 2024: env�o de comunicaciones hasta el 
pr�ximo s�bado 15 de junio

Buenos d�as

Este s�bado (15 de junio) se cierra el plazo para enviar comunicaciones
para el pr�ximo congreso de R en Sevilla (noviembre de 2024). Gran
oportunidad para presentar nuestro trabajo y aprender, con charlas y
talleres sobre datos, estad�stica, programaci�n, docencia, tidymodels,
rspatial... Animamos a todos a asistir y presentar su trabajo

Toda la informaci�n del congreso est� disponible en la web:
https://www.imus.us.es/congresos/IIIRqueR/

Saludos

--
Dr Francisco Rodr�guez-S�nchez
https://frodriguezsanchez.net

___
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] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Yuan Chun Ding via R-help
Hi Rui,

Thank you very much!


Yes, I verified using real data, it worked correctly as expected after adding 
tidyr:: to the pivot_longer function and dplyr:: to the group_by and summarize
Function.

I did not know how to assign the tidyr and dplyr to the three functions because 
I do not really understand well the three functions and just got the code from 
a google search.

I also tried your simplified code, but got the following error
Error in `dplyr::summarize()`:
! Can't supply both `.by` and `.groups`.
Run `rlang::last_trace()` to see where the error occurred.

Ding

From: Rui Barradas 
Sent: Wednesday, June 12, 2024 11:29 AM
To: Yuan Chun Ding ; CALUM POLWART 
Cc: r-help@r-project.org
Subject: Re: [R] my R code worked well when running the first 1000 lines of R 
code

Hello, Inline. Às 19: 03 de 12/06/2024, Yuan Chun Ding via R-help escreveu: > I 
am sorry that I know I should provide a dataset that allows to replicate my 
problem. > > It is a research dataset and quite large, so I can not share. >


Hello,



Inline.



Às 19:03 de 12/06/2024, Yuan Chun Ding via R-help escreveu:

> I am sorry that I know I should provide a dataset that allows to replicate my 
> problem.

>

> It is a research dataset and quite large, so I can not share.

>

> Both Bert and Tim guessed my problem correctly.  I also thought about the 
> conflicting issue between different packages and function masking.

> I just hope to that someone has similar experience, so providing me 
> suggestion.

>

> For conflicting issue,

>

> What I tried  was to add dplyr::pivot_longer or tidyr:: pivot_longer,





Do that to all functions comming from contributed packages. At least to

those.





summary_anno1148ft <- anno1148ft %>%

   tidyr::pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to =

"measure") %>%

   dplyr::group_by(dat, measure) %>%

   dplyr::summarize(minimum = min(value,na.rm=T),

q25 = quantile(value, probs = 0.25,na.rm=T),

med = median(value,na.rm=T),

q75 = quantile(value, probs = 0.75,na.rm=T),

maximum = max(value,na.rm=T),

average = mean(value,na.rm=T),

#standard_deviation = sd(value),

.groups = "drop"

   )





Or, simpler, no need to group_by anymore. It can be done in summarise.





summary_anno1148ft <- anno1148ft %>%

   tidyr::pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to =

"measure") %>%

   dplyr::summarize(minimum = min(value,na.rm=T),

q25 = quantile(value, probs = 0.25,na.rm=T),

med = median(value,na.rm=T),

q75 = quantile(value, probs = 0.75,na.rm=T),

maximum = max(value,na.rm=T),

average = mean(value,na.rm=T),

#standard_deviation = sd(value),

.by = c(dat, measure),

.groups = "drop"

   )







This is only a guess, the question cannot really be answered.





Hope this helps,



Rui Barradas



but still not resolved the problem.

>

>

>

> I will restart from the first line my code, it will work again and then I 
> will track down.

>

>

>

> Thank you,

>

> Ding

>

>

> From: CALUM POLWART mailto:polc1...@gmail.com>>

> Sent: Wednesday, June 12, 2024 10:52 AM

> To: Yuan Chun Ding mailto:ycd...@coh.org>>

> Cc: r-help@r-project.org

> Subject: Re: [R] my R code worked well when running the first 1000 lines of R 
> code

>

> I sometimes think people on this list are quite rude to posters. I'm afraid 
> I'm likely to join in with some rudeness? 1. "Here is some code that works 
> but also doesn't" is probably not going to get you an answer 2. I provide

>

>

> I sometimes think people on this list are quite rude to posters.

>

> I'm afraid I'm likely to join in with some rudeness?

>

> 1. "Here is some code that works but also doesn't" is probably not going to 
> get you an answer

> 2. I provide no information about the data it works on or doesn't

> 3. I tell you I'm using a load of dependencies, but don't tell you what

> 4. I refer to 2000 lines of code but probably means 2000 lines of data?

>

> So. Please post a question someone can actually answer.

>

> If the question is "why might code fail on a 2000 line dataset when it works 
> on 1000 line dataset" then here are some thoughts:

>

> * Is the 1000 lines being run as dataset[1:1000,] or is it dataset1 and 
> dataset2 ?

> * Is there a structural difference in the datasets - i.e. numbers, characters 
> or factors as columns. Often import functions guess a column type by reading 
> the first 500/1000 lines. If the data has numbers in column 1 for 1-1000 but 
> on line 1999 has a letter... The data type may vary.

>

> On Wed, 12 Jun 2024, 17:28 Yuan Chun Ding via R-help, 
> mailto:r-help@r-project.org>>
>  

Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Rui Barradas

Hello,

Inline.

Às 19:03 de 12/06/2024, Yuan Chun Ding via R-help escreveu:

I am sorry that I know I should provide a dataset that allows to replicate my 
problem.

It is a research dataset and quite large, so I can not share.

Both Bert and Tim guessed my problem correctly.  I also thought about the 
conflicting issue between different packages and function masking.
I just hope to that someone has similar experience, so providing me suggestion.

For conflicting issue,

What I tried  was to add dplyr::pivot_longer or tidyr:: pivot_longer, 



Do that to all functions comming from contributed packages. At least to 
those.



summary_anno1148ft <- anno1148ft %>%
  tidyr::pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = 
"measure") %>%

  dplyr::group_by(dat, measure) %>%
  dplyr::summarize(minimum = min(value,na.rm=T),
   q25 = quantile(value, probs = 0.25,na.rm=T),
   med = median(value,na.rm=T),
   q75 = quantile(value, probs = 0.75,na.rm=T),
   maximum = max(value,na.rm=T),
   average = mean(value,na.rm=T),
   #standard_deviation = sd(value),
   .groups = "drop"
  )


Or, simpler, no need to group_by anymore. It can be done in summarise.


summary_anno1148ft <- anno1148ft %>%
  tidyr::pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = 
"measure") %>%

  dplyr::summarize(minimum = min(value,na.rm=T),
   q25 = quantile(value, probs = 0.25,na.rm=T),
   med = median(value,na.rm=T),
   q75 = quantile(value, probs = 0.75,na.rm=T),
   maximum = max(value,na.rm=T),
   average = mean(value,na.rm=T),
   #standard_deviation = sd(value),
   .by = c(dat, measure),
   .groups = "drop"
  )



This is only a guess, the question cannot really be answered.


Hope this helps,

Rui Barradas

but still not resolved the problem.




I will restart from the first line my code, it will work again and then I will 
track down.



Thank you,

Ding


From: CALUM POLWART 
Sent: Wednesday, June 12, 2024 10:52 AM
To: Yuan Chun Ding 
Cc: r-help@r-project.org
Subject: Re: [R] my R code worked well when running the first 1000 lines of R 
code

I sometimes think people on this list are quite rude to posters. I'm afraid I'm likely to 
join in with some rudeness? 1. "Here is some code that works but also doesn't" 
is probably not going to get you an answer 2. I provide


I sometimes think people on this list are quite rude to posters.

I'm afraid I'm likely to join in with some rudeness?

1. "Here is some code that works but also doesn't" is probably not going to get 
you an answer
2. I provide no information about the data it works on or doesn't
3. I tell you I'm using a load of dependencies, but don't tell you what
4. I refer to 2000 lines of code but probably means 2000 lines of data?

So. Please post a question someone can actually answer.

If the question is "why might code fail on a 2000 line dataset when it works on 1000 
line dataset" then here are some thoughts:

* Is the 1000 lines being run as dataset[1:1000,] or is it dataset1 and 
dataset2 ?
* Is there a structural difference in the datasets - i.e. numbers, characters 
or factors as columns. Often import functions guess a column type by reading 
the first 500/1000 lines. If the data has numbers in column 1 for 1-1000 but on 
line 1999 has a letter... The data type may vary.

On Wed, 12 Jun 2024, 17:28 Yuan Chun Ding via R-help, 
mailto:r-help@r-project.org>> wrote:
Hi R users,

The following code worked well to summarize four data groups in a dataframe for 
three variables (t_depth, t_alt_count, t_alt_ratio), 12 columns of summary, see 
attached.
However, after running another 2000 lines of R codes using functions from more 
than 10 other R  libraries, then it only generated one column of summary.
Do you know why?

Thank you,

Yuan Chun Ding

summary_anno1148ft <- anno1148ft %>%
   pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure") %>%
   group_by(dat, measure) %>%
   summarize(minimum = min(value,na.rm=T),
 q25 = quantile(value, probs = 0.25,na.rm=T),
 med = median(value,na.rm=T),
 q75 = quantile(value, probs = 0.75,na.rm=T),
 maximum = max(value,na.rm=T),
 average = mean(value,na.rm=T),
 #standard_deviation = sd(value),
 .groups = "drop"
   )
summary_anno1148ft <-t(summary_anno1148ft)



--

-SECURITY/CONFIDENTIALITY WARNING-

This message and any attachments are intended solely for the individual or 
entity to which they are addressed. This communication may contain information 
that is privileged, confidential, or exempt from disclosure under applicable 
law (e.g., personal health 

Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Yuan Chun Ding via R-help
I am sorry that I know I should provide a dataset that allows to replicate my 
problem.

It is a research dataset and quite large, so I can not share.

Both Bert and Tim guessed my problem correctly.  I also thought about the 
conflicting issue between different packages and function masking.
I just hope to that someone has similar experience, so providing me suggestion.

For conflicting issue,

What I tried  was to add dplyr::pivot_longer or tidyr:: pivot_longer, but still 
not resolved the problem.



I will restart from the first line my code, it will work again and then I will 
track down.



Thank you,

Ding


From: CALUM POLWART 
Sent: Wednesday, June 12, 2024 10:52 AM
To: Yuan Chun Ding 
Cc: r-help@r-project.org
Subject: Re: [R] my R code worked well when running the first 1000 lines of R 
code

I sometimes think people on this list are quite rude to posters. I'm afraid I'm 
likely to join in with some rudeness? 1. "Here is some code that works but also 
doesn't" is probably not going to get you an answer 2. I provide


I sometimes think people on this list are quite rude to posters.

I'm afraid I'm likely to join in with some rudeness?

1. "Here is some code that works but also doesn't" is probably not going to get 
you an answer
2. I provide no information about the data it works on or doesn't
3. I tell you I'm using a load of dependencies, but don't tell you what
4. I refer to 2000 lines of code but probably means 2000 lines of data?

So. Please post a question someone can actually answer.

If the question is "why might code fail on a 2000 line dataset when it works on 
1000 line dataset" then here are some thoughts:

* Is the 1000 lines being run as dataset[1:1000,] or is it dataset1 and 
dataset2 ?
* Is there a structural difference in the datasets - i.e. numbers, characters 
or factors as columns. Often import functions guess a column type by reading 
the first 500/1000 lines. If the data has numbers in column 1 for 1-1000 but on 
line 1999 has a letter... The data type may vary.

On Wed, 12 Jun 2024, 17:28 Yuan Chun Ding via R-help, 
mailto:r-help@r-project.org>> wrote:
Hi R users,

The following code worked well to summarize four data groups in a dataframe for 
three variables (t_depth, t_alt_count, t_alt_ratio), 12 columns of summary, see 
attached.
However, after running another 2000 lines of R codes using functions from more 
than 10 other R  libraries, then it only generated one column of summary.
Do you know why?

Thank you,

Yuan Chun Ding

summary_anno1148ft <- anno1148ft %>%
  pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure") %>%
  group_by(dat, measure) %>%
  summarize(minimum = min(value,na.rm=T),
q25 = quantile(value, probs = 0.25,na.rm=T),
med = median(value,na.rm=T),
q75 = quantile(value, probs = 0.75,na.rm=T),
maximum = max(value,na.rm=T),
average = mean(value,na.rm=T),
#standard_deviation = sd(value),
.groups = "drop"
  )
summary_anno1148ft <-t(summary_anno1148ft)



--

-SECURITY/CONFIDENTIALITY WARNING-

This message and any attachments are intended solely for the individual or 
entity to which they are addressed. This communication may contain information 
that is privileged, confidential, or exempt from disclosure under applicable 
law (e.g., personal health information, research data, financial information). 
Because this e-mail has been sent without encryption, individuals other than 
the intended recipient may be able to view the information, forward it to 
others or tamper with the information without the knowledge or consent of the 
sender. If you are not the intended recipient, or the employee or person 
responsible for delivering the message to the intended recipient, any 
dissemination, distribution or copying of the communication is strictly 
prohibited. If you received the communication in error, please notify the 
sender immediately by replying to this message and deleting the message and any 
accompanying files from your system. If, due to the security risks, you do not 
wish to rec
 eive further communications via e-mail, please reply to this message and 
inform the sender that you do not wish to receive further e-mail from the 
sender. (LCP301)

__
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 

Re: [R] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread CALUM POLWART
I sometimes think people on this list are quite rude to posters.

I'm afraid I'm likely to join in with some rudeness?

1. "Here is some code that works but also doesn't" is probably not going to
get you an answer
2. I provide no information about the data it works on or doesn't
3. I tell you I'm using a load of dependencies, but don't tell you what
4. I refer to 2000 lines of code but probably means 2000 lines of data?

So. Please post a question someone can actually answer.

If the question is "why might code fail on a 2000 line dataset when it
works on 1000 line dataset" then here are some thoughts:

* Is the 1000 lines being run as dataset[1:1000,] or is it dataset1 and
dataset2 ?
* Is there a structural difference in the datasets - i.e. numbers,
characters or factors as columns. Often import functions guess a column
type by reading the first 500/1000 lines. If the data has numbers in column
1 for 1-1000 but on line 1999 has a letter... The data type may vary.

On Wed, 12 Jun 2024, 17:28 Yuan Chun Ding via R-help, 
wrote:

> Hi R users,
>
> The following code worked well to summarize four data groups in a
> dataframe for three variables (t_depth, t_alt_count, t_alt_ratio), 12
> columns of summary, see attached.
> However, after running another 2000 lines of R codes using functions from
> more than 10 other R  libraries, then it only generated one column of
> summary.
> Do you know why?
>
> Thank you,
>
> Yuan Chun Ding
>
> summary_anno1148ft <- anno1148ft %>%
>   pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure")
> %>%
>   group_by(dat, measure) %>%
>   summarize(minimum = min(value,na.rm=T),
> q25 = quantile(value, probs = 0.25,na.rm=T),
> med = median(value,na.rm=T),
> q75 = quantile(value, probs = 0.75,na.rm=T),
> maximum = max(value,na.rm=T),
> average = mean(value,na.rm=T),
> #standard_deviation = sd(value),
> .groups = "drop"
>   )
> summary_anno1148ft <-t(summary_anno1148ft)
>
>
>
> --
> 
> -SECURITY/CONFIDENTIALITY WARNING-
>
> This message and any attachments are intended solely for the individual or
> entity to which they are addressed. This communication may contain
> information that is privileged, confidential, or exempt from disclosure
> under applicable law (e.g., personal health information, research data,
> financial information). Because this e-mail has been sent without
> encryption, individuals other than the intended recipient may be able to
> view the information, forward it to others or tamper with the information
> without the knowledge or consent of the sender. If you are not the intended
> recipient, or the employee or person responsible for delivering the message
> to the intended recipient, any dissemination, distribution or copying of
> the communication is strictly prohibited. If you received the communication
> in error, please notify the sender immediately by replying to this message
> and deleting the message and any accompanying files from your system. If,
> due to the security risks, you do not wish to receive further
> communications via e-mail, please reply to this message and inform the
> sender that you do not wish to receive further e-mail from the sender.
> (LCP301)
> 
> __
> 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] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Ebert,Timothy Aaron
Hi Yuan,
   When you load some packages do you get messages saying that some function is 
being masked? What can happen is that one package has a function with the same 
name as another package. The conflict is resolved by having one package mask 
the other. However, this can cause conflicts if your code uses the function in 
a way that is only supported in the masked package.

Tim

-Original Message-
From: R-help  On Behalf Of Yuan Chun Ding via 
R-help
Sent: Wednesday, June 12, 2024 12:28 PM
To: r-help@R-project.org (r-help@r-project.org) 
Subject: [R] my R code worked well when running the first 1000 lines of R code

[External Email]

Hi R users,

The following code worked well to summarize four data groups in a dataframe for 
three variables (t_depth, t_alt_count, t_alt_ratio), 12 columns of summary, see 
attached.
However, after running another 2000 lines of R codes using functions from more 
than 10 other R  libraries, then it only generated one column of summary.
Do you know why?

Thank you,

Yuan Chun Ding

summary_anno1148ft <- anno1148ft %>%
  pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure") %>%
  group_by(dat, measure) %>%
  summarize(minimum = min(value,na.rm=T),
q25 = quantile(value, probs = 0.25,na.rm=T),
med = median(value,na.rm=T),
q75 = quantile(value, probs = 0.75,na.rm=T),
maximum = max(value,na.rm=T),
average = mean(value,na.rm=T),
#standard_deviation = sd(value),
.groups = "drop"
  )
summary_anno1148ft <-t(summary_anno1148ft)



--

-SECURITY/CONFIDENTIALITY WARNING-

This message and any attachments are intended solely for the individual or 
entity to which they are addressed. This communication may contain information 
that is privileged, confidential, or exempt from disclosure under applicable 
law (e.g., personal health information, research data, financial information). 
Because this e-mail has been sent without encryption, individuals other than 
the intended recipient may be able to view the information, forward it to 
others or tamper with the information without the knowledge or consent of the 
sender. If you are not the intended recipient, or the employee or person 
responsible for delivering the message to the intended recipient, any 
dissemination, distribution or copying of the communication is strictly 
prohibited. If you received the communication in error, please notify the 
sender immediately by replying to this message and deleting the message and any 
accompanying files from your system. If, due to the security risks, you do not 
wish to receive further communications via e-mail, please reply to this message 
and inform the sender that you do not wish to receive further e-mail from the 
sender. (LCP301)

__
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] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Bert Gunter
I am assuming from your message that *exactly* the same code you show was
rerun and yielded different results. If that be so, I doubt that this can
be answered without knowing what that other R code did -- and perhaps not
even then -- and/or whether any of that code changed your data frame.
Another guess is that one of those other R packages may have replaced the
summarize method you used with another (customized) method.

Hopefully, someone else may have more insight than I, though.

-- Bert

On Wed, Jun 12, 2024 at 9:28 AM Yuan Chun Ding via R-help <
r-help@r-project.org> wrote:

> Hi R users,
>
> The following code worked well to summarize four data groups in a
> dataframe for three variables (t_depth, t_alt_count, t_alt_ratio), 12
> columns of summary, see attached.
> However, after running another 2000 lines of R codes using functions from
> more than 10 other R  libraries, then it only generated one column of
> summary.
> Do you know why?
>
> Thank you,
>
> Yuan Chun Ding
>
> summary_anno1148ft <- anno1148ft %>%
>   pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure")
> %>%
>   group_by(dat, measure) %>%
>   summarize(minimum = min(value,na.rm=T),
> q25 = quantile(value, probs = 0.25,na.rm=T),
> med = median(value,na.rm=T),
> q75 = quantile(value, probs = 0.75,na.rm=T),
> maximum = max(value,na.rm=T),
> average = mean(value,na.rm=T),
> #standard_deviation = sd(value),
> .groups = "drop"
>   )
> summary_anno1148ft <-t(summary_anno1148ft)
>
>
>
> --
> 
> -SECURITY/CONFIDENTIALITY WARNING-
>
> This message and any attachments are intended solely for the individual or
> entity to which they are addressed. This communication may contain
> information that is privileged, confidential, or exempt from disclosure
> under applicable law (e.g., personal health information, research data,
> financial information). Because this e-mail has been sent without
> encryption, individuals other than the intended recipient may be able to
> view the information, forward it to others or tamper with the information
> without the knowledge or consent of the sender. If you are not the intended
> recipient, or the employee or person responsible for delivering the message
> to the intended recipient, any dissemination, distribution or copying of
> the communication is strictly prohibited. If you received the communication
> in error, please notify the sender immediately by replying to this message
> and deleting the message and any accompanying files from your system. If,
> due to the security risks, you do not wish to receive further
> communications via e-mail, please reply to this message and inform the
> sender that you do not wish to receive further e-mail from the sender.
> (LCP301)
> 
> __
> 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] my R code worked well when running the first 1000 lines of R code

2024-06-12 Thread Yuan Chun Ding via R-help
Hi R users,

The following code worked well to summarize four data groups in a dataframe for 
three variables (t_depth, t_alt_count, t_alt_ratio), 12 columns of summary, see 
attached.
However, after running another 2000 lines of R codes using functions from more 
than 10 other R  libraries, then it only generated one column of summary.
Do you know why?

Thank you,

Yuan Chun Ding

summary_anno1148ft <- anno1148ft %>%
  pivot_longer(c(t_depth, t_alt_count, t_alt_ratio), names_to = "measure") %>%
  group_by(dat, measure) %>%
  summarize(minimum = min(value,na.rm=T),
q25 = quantile(value, probs = 0.25,na.rm=T),
med = median(value,na.rm=T),
q75 = quantile(value, probs = 0.75,na.rm=T),
maximum = max(value,na.rm=T),
average = mean(value,na.rm=T),
#standard_deviation = sd(value),
.groups = "drop"
  )
summary_anno1148ft <-t(summary_anno1148ft)



--

-SECURITY/CONFIDENTIALITY WARNING-  

This message and any attachments are intended solely for the individual or 
entity to which they are addressed. This communication may contain information 
that is privileged, confidential, or exempt from disclosure under applicable 
law (e.g., personal health information, research data, financial information). 
Because this e-mail has been sent without encryption, individuals other than 
the intended recipient may be able to view the information, forward it to 
others or tamper with the information without the knowledge or consent of the 
sender. If you are not the intended recipient, or the employee or person 
responsible for delivering the message to the intended recipient, any 
dissemination, distribution or copying of the communication is strictly 
prohibited. If you received the communication in error, please notify the 
sender immediately by replying to this message and deleting the message and any 
accompanying files from your system. If, due to the security risks, you do not 
wish to receive further communications via e-mail, please reply to this message 
and inform the sender that you do not wish to receive further e-mail from the 
sender. (LCP301)

__
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] Integration of functions with a vector argument

2024-06-12 Thread Ivan Krylov via R-help
В Tue, 11 Jun 2024 18:44:08 +
"Levine, Michael"  пишет:

> Let us say we have a function
> 
> F <- function(x){ body of the function}
> 
> Where x is, in general, a d by 1 vector with d>1.  Now I want to
> integrate out some of the coordinates of x, e.g. x[1] or x[2] or both
> of them etc. I'm well aware of how to integrate out e.g. y if a
> function is defined as f <- function (x,y) {body of the function}
> where y is a scalar.

The reason integrate() wants a separate function argument for the
integration coordinate is so that it could give the function a vector
of different values of the variable and receive a vector of the same
length containing the corresponding values of the function.

If the problem is small enough to make performance considerations
irrelevant, you can use Vectorize to make a function compatible with
integrate() from your function F:

x <- x0
z <- z0
Fiy <- Vectorize(function(y) F(c(x, y, z)))
integrate(Fiy, ymin, ymax)

The resulting function Fiy will accept a vector of values for y and
translate it into multiple calls to F with a three-element vector
argument as it expects.

Achieving better performance will require rewriting the function F to
be "vectorised", i.e. to accept vectors for arguments and return a
vector of the same length.

-- 
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-es] Congreso R Sevilla 2024: envío de comunicaciones hasta el próximo sábado 15 de junio

2024-06-12 Thread Francisco Rodriguez Sanchez

Buenos días

Este sábado (15 de junio) se cierra el plazo para enviar comunicaciones 
para el próximo congreso de R en Sevilla (noviembre de 2024). Gran 
oportunidad para presentar nuestro trabajo y aprender, con charlas y 
talleres sobre datos, estadística, programación, docencia, tidymodels, 
rspatial... Animamos a todos a asistir y presentar su trabajo


Toda la información del congreso está disponible en la web: 
https://www.imus.us.es/congresos/IIIRqueR/


Saludos

--
Dr Francisco Rodríguez-Sánchez
https://frodriguezsanchez.net

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


[R] Integration of functions with a vector argument

2024-06-12 Thread Levine, Michael
Hello all,

I have a question concerning integration of a function of a multivariate 
argument with respect to one or more variables in r.  Let us say we have a 
function

F <- function(x){ body of the function}

Where x is, in general, a d by 1 vector with d>1.  Now I want to integrate out 
some of the coordinates of x, e.g. x[1] or x[2] or both of them etc. I'm well 
aware of how to integrate out e.g. y if a function is defined as f <- function 
(x,y) {body of the function} where y is a scalar.
However, it seems to be quite difficult to do the same if the function is 
defined with a vector argument x. At the very least, I haven't seen any good 
examples of this being done.
Any suggestions?

Yours sincerely,
Michael

Michael Levine
Associate Professor, Statistics

Department of Statistics
Purdue University
250 North University Street
West Lafayette, IN 47907 USA

email: mlev...@purdue.edu
Phone: +1-765-496-7571
Fax:   +1-765-494-0558
URL:   www.stat.purdue.edu/~mlevins

[[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] Fwd: Webinar: How to access ERDDAP data using R

2024-06-11 Thread Roy Mendelssohn - NOAA Federal via R-help



> 
>   
>  
>  
> 
>  
> Note   |  June 2024
>  
>  
>   
>   
> Webinar announcement
>  
> How to access ERDDAP data using R
>  
>  
> 
>  
>   20 June 2024 | 18:00 CEST
>   See what time it is for you 
> 
>   Online
>  
> This seminar will demonstrating the use of ERDDAP™ in R. Demonstrating the 
> use of multiple ERDDAP™ servers to pull together collocated datasets, 
> extracting detailed metadata, and accessing ERDDAP™ hosted data using R.
> 
> This webinar is a follow up from the webinar “How to ERDDAP™” using python.
> 
> Future Seminars:
> July - Using ERDDAP to track usage metrics
> August - Abstracting across ERDDAP
> September - Writing Data into ERDDAP
> 
> Webinar registration 
> 
> Flyer 
> 
> Access previous ERDDAP webinars here 
> .
>   
>  
> Register
>  
> 
>  
>  
>  
>  
>  
>   
> 
>   
> 
>   
> 
>   
> 
>  
> The Global Ocean Observing System is sponsored by
> the Intergovernmental Oceanographic Commission of UNESCO,
> the World Meteorological Organization, the United Nations Environment 
> Programme, and the International Science Council.
> 
> Global Ocean Observing System 
> Intergovernmental Oceanographic Commission
> UNESCO
> 7 place de Fontenoy
> 75352 Paris 07-SP
> France
> 
> g...@unesco.org 
> 
> For inquiries about the GOOS mailing list please contact 
> Laura Stukonytė l.stukon...@unesco.org 
>  
>  
> You are receiving this email because you are a member of the 
> Global Ocean Observing Community.
> 
> Unsubscribe 
> 
>  ann-christine.zink...@noaa.gov  from 
> this list 
> Update subscription preferences 
> 
> View email in browser 
> 
> 
> © 2024 Global Ocean Observing System. All rights reserved.
>  
>  
> 
> 
> 
> -- 
> 
> 
> 
> 
> Ann-Christine Zinkann, PhD (she/her)
> Program Manager
> National Oceanic and Atmospheric Administration 
> Global Ocean Monitoring & Observing Program 
> and Cooperative Programs for the Advancement of Earth System Science 
> , University Corporation for Atmospheric Research
> 803.904.8291 | ann-christine.zink...@noaa.gov 
**
"The contents of this message do not reflect any position of the U.S. 
Government or NOAA."
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new street address***
110 McAllister Way
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: roy.mendelss...@noaa.gov www: https://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.


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

2024-06-10 Thread Eric Berger
Since you are loading lubridate it is enough to do

Atest$ddate1 <- dmy(Atest$ddate)



On Sun, Jun 9, 2024 at 11:59 PM Duncan Murdoch  wrote:
>
> On 2024-06-09 4:39 p.m., Val wrote:
> > HI all,
> >
> > My
> > I am trying to convert character date (mm/dd/yy)  to -mm-dd date
> > format in one of the columns of my data file.
> >
> > The first few lines of the data file looks like as follow
> >
> >   head(Atest,10);dim(Atest)
> >ddate
> > 1  19/08/21
> > 2  30/04/18
>
> Those aren't legal months in the first entry.  Your format looks like it
> should be "%d/%m/%y".
>
> Duncan Murdoch
>
> __
> 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] Format

2024-06-09 Thread Duncan Murdoch

On 2024-06-09 4:39 p.m., Val wrote:

HI all,

My
I am trying to convert character date (mm/dd/yy)  to -mm-dd date
format in one of the columns of my data file.

The first few lines of the data file looks like as follow

  head(Atest,10);dim(Atest)
   ddate
1  19/08/21
2  30/04/18


Those aren't legal months in the first entry.  Your format looks like it 
should be "%d/%m/%y".


Duncan Murdoch

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

2024-06-09 Thread Rui Barradas

Às 21:39 de 09/06/2024, Val escreveu:

HI all,

My
I am trying to convert character date (mm/dd/yy)  to -mm-dd date
format in one of the columns of my data file.

The first few lines of the data file looks like as follow

  head(Atest,10);dim(Atest)
   ddate
1  19/08/21
2  30/04/18
3  28/08/21
4  11/10/21
5  07/09/21
6  15/08/21
7  03/09/21
8  23/07/18
9  17/08/20
10 23/09/20
[1] 1270076   1

I am using the following different scenarios but none of them resulted
the desired result.

library(data.table)
library(stringr)
library(lubridate)
 Atest$ddate1 <- as.Date((Atest$ddate), format = "%m/%d/%y")
 Atest$ddate2 <- mdy((Atest$ddate))
 Atest$ddate3 <= as.Date(as.character(Atest$ddate),format="%m/%d/%y")
 Atest$ddate4 <- as.Date(as.character(Atest$ddate),"%m/%d/%y")
 Atest$ddate5 <- lubridate::mdy(Atest$ddate)


head(Atest,3)

  ddate ddate1 ddate2 ddate4 ddate5
1 19/08/21
2 30/04/18
3 28/08/21


Any help why I am not getting the desired result.
Thank you,

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

Day is clearly first, format "%m/%d/%y" assumes a month 19 in 19/08/21.
Try

as.Date(Atest$ddate, format = "%d/%m/%y")


Hope this helps,

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.


[R] Format

2024-06-09 Thread Val
HI all,

My
I am trying to convert character date (mm/dd/yy)  to -mm-dd date
format in one of the columns of my data file.

The first few lines of the data file looks like as follow

 head(Atest,10);dim(Atest)
  ddate
1  19/08/21
2  30/04/18
3  28/08/21
4  11/10/21
5  07/09/21
6  15/08/21
7  03/09/21
8  23/07/18
9  17/08/20
10 23/09/20
[1] 1270076   1

I am using the following different scenarios but none of them resulted
the desired result.

library(data.table)
library(stringr)
library(lubridate)
Atest$ddate1 <- as.Date((Atest$ddate), format = "%m/%d/%y")
Atest$ddate2 <- mdy((Atest$ddate))
Atest$ddate3 <= as.Date(as.character(Atest$ddate),format="%m/%d/%y")
Atest$ddate4 <- as.Date(as.character(Atest$ddate),"%m/%d/%y")
Atest$ddate5 <- lubridate::mdy(Atest$ddate)

> head(Atest,3)
 ddate ddate1 ddate2 ddate4 ddate5
1 19/08/21
2 30/04/18
3 28/08/21


Any help why I am not getting the desired result.
Thank you,

__
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] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Ebert,Timothy Aaron
Would this work?

xxxz$Average20 <- (xxxz$Low20 + xxxz$High20)/2

I tried this earlier but it does not appear to have gone through.

Tim

-Original Message-
From: R-help  On Behalf Of avi.e.gr...@gmail.com
Sent: Saturday, June 8, 2024 2:16 PM
To: 'Sorkin, John' ; r-help@r-project.org
Subject: Re: [R] Can't compute row means of two columns of a dataframe.

[External Email]

John,

Maybe you can clarify what you want the output to look like. It took me a while 
to realize what you may want as it is NOT properly described as wanting rowsums.

There is a standard function called rowMeans() that probably does what you want 
if you want the mean of all rows as in:

> rowMeans(xxxz)
 [1]  84.3  87.0  89.7  92.3  95.0  97.7 100.3
103.7 106.3 109.0 112.3 115.0 [13] 118.0 121.3 
124.0 127.3 130.7 134.0 137.0

It does not add the means to the original data.frame if you wanted it there but 
that is easy enough to do.

> xxxz$Average20 <-rowMeans(xxxz)
> head(xxxz)
  TotalInches Low20 High20 Average20
1  5884111  84.3
2  5987115  87.0
3  6090119  89.7
4  6193123  92.3
5  6296127  95.0
6  6399131  97.7

Your construct is more complex and it looks like you want to do this to a 
subset of two columns. Again, straightforward:

xxxz$Average20 <-rowMeans(xxxz[, c("Low20", "High20")])

And I probably would do this using a dplyr mutate but that is outside the scope.

This does not help explain your error, so let me look at what you are trying to 
do.


What  did you expect to use by() for in the second argument? You seem to be 
giving it INDICES of the first column entries. What is that for?

by(xxxz[,c("Low20","High20")],
   xxxz[,"TotalInches"],
   mean)

The documentation suggest this is for splitting by factors. I do not  see there 
are multiple instances of some TotalInches so why is this needed for some kind 
of grouping?

My guess is you are using the wrong function or the wrong way for your needs. 
The warnings may relate to that.


-Original Message-
From: R-help  On Behalf Of Sorkin, John
Sent: Saturday, June 8, 2024 1:38 PM
To: r-help@r-project.org (r-help@r-project.org) 
Subject: [R] Can't compute row means of two columns of a dataframe.

I have a data frame with three columns, TotalInches, Low20, High20. For each 
row of the dataset, I am trying to compute the mean of Low20 and High20.

xxxz <- structure(list(TotalInches =
 c(58, 59, 60, 61, 62, 63, 64, 65,
   66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 = c(84, 
87,
   90, 93, 96, 99, 102, 106, 109, 112, 116, 119, 122, 126, 129,
   133, 137, 141, 144), High20 = c(111, 115, 119, 123, 127, 131,
   135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181, 186, 
191
   )), class = "data.frame", row.names = c(NA, -19L)) xxxz
str(xxxz)
xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
warnings()

When I run the code above, I don't get the means by row. I get the following 
warning messages, one for each row of the dataframe.

Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA

 Can someone tell my what I am doing wrong, and how I can compute the row means?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine; Associate 
Director for Biostatistics and Informatics, Baltimore VA Medical Center 
Geriatrics Research, Education, and Clinical Center; PI Biostatistics and 
Informatics Core, University of Maryland School of Medicine Claude D. Pepper 
Older Americans Independence Center; Senior Statistician University of Maryland 
Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382



__
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

Re: [R] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Ebert,Timothy Aaron
Can this problem be made more direct?

xxxz$Average.20 <- (xxxz$Low20 + xxxz$High20)/2

That is literally the mean of two columns. Functions can be useful if there 
will be more columns, but with just two this seems easier.

I will point out that the average daily temperature based on the midpoint 
between minimum and maximum contains a fair bit of error because that is only 
roughly how heating and cooling respond. I admit that sometimes there are no 
other choices and we work with available data.

Tim


-Original Message-
From: R-help  On Behalf Of Sorkin, John
Sent: Saturday, June 8, 2024 1:38 PM
To: r-help@r-project.org (r-help@r-project.org) 
Subject: [R] Can't compute row means of two columns of a dataframe.

[External Email]

I have a data frame with three columns, TotalInches, Low20, High20. For each 
row of the dataset, I am trying to compute the mean of Low20 and High20.

xxxz <- structure(list(TotalInches =
 c(58, 59, 60, 61, 62, 63, 64, 65,
   66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 = c(84, 
87,
   90, 93, 96, 99, 102, 106, 109, 112, 116, 119, 122, 126, 129,
   133, 137, 141, 144), High20 = c(111, 115, 119, 123, 127, 131,
   135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181, 186, 
191
   )), class = "data.frame", row.names = c(NA, -19L)) xxxz
str(xxxz)
xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
warnings()

When I run the code above, I don't get the means by row. I get the following 
warning messages, one for each row of the dataframe.

Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA

 Can someone tell my what I am doing wrong, and how I can compute the row means?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine; Associate 
Director for Biostatistics and Informatics, Baltimore VA Medical Center 
Geriatrics Research, Education, and Clinical Center; PI Biostatistics and 
Informatics Core, University of Maryland School of Medicine Claude D. Pepper 
Older Americans Independence Center; Senior Statistician University of Maryland 
Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382



__
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] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread avi.e.gross
John,

Maybe you can clarify what you want the output to look like. It took me a
while to realize what you may want as it is NOT properly described as
wanting rowsums.

There is a standard function called rowMeans() that probably does what you
want if you want the mean of all rows as in:

> rowMeans(xxxz)
 [1]  84.3  87.0  89.7  92.3  95.0  97.7 100.3
103.7 106.3 109.0 112.3 115.0
[13] 118.0 121.3 124.0 127.3 130.7 134.0 137.0

It does not add the means to the original data.frame if you wanted it there
but that is easy enough to do.

> xxxz$Average20 <-rowMeans(xxxz)
> head(xxxz)
  TotalInches Low20 High20 Average20
1  5884111  84.3
2  5987115  87.0
3  6090119  89.7
4  6193123  92.3
5  6296127  95.0
6  6399131  97.7

Your construct is more complex and it looks like you want to do this to a
subset of two columns. Again, straightforward:

xxxz$Average20 <-rowMeans(xxxz[, c("Low20", "High20")])

And I probably would do this using a dplyr mutate but that is outside the
scope.

This does not help explain your error, so let me look at what you are trying
to do.


What  did you expect to use by() for in the second argument? You seem to be
giving it INDICES of the first column entries. What is that for?

by(xxxz[,c("Low20","High20")],
   xxxz[,"TotalInches"],
   mean)

The documentation suggest this is for splitting by factors. I do not  see
there are multiple instances of some TotalInches so why is this needed for
some kind of grouping?

My guess is you are using the wrong function or the wrong way for your
needs. The warnings may relate to that.


-Original Message-
From: R-help  On Behalf Of Sorkin, John
Sent: Saturday, June 8, 2024 1:38 PM
To: r-help@r-project.org (r-help@r-project.org) 
Subject: [R] Can't compute row means of two columns of a dataframe.

I have a data frame with three columns, TotalInches, Low20, High20. For each
row of the dataset, I am trying to compute the mean of Low20 and High20. 

xxxz <- structure(list(TotalInches = 
 c(58, 59, 60, 61, 62, 63, 64, 65, 
   66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 =
c(84, 87, 
   90, 93, 96, 99, 102, 106, 109, 112, 116, 119, 122, 126,
129, 
   133, 137, 141, 144), High20 = c(111, 115, 119, 123, 127,
131, 
   135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181,
186, 191
   )), class = "data.frame", row.names = c(NA, -19L))
xxxz
str(xxxz)
xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
warnings()

When I run the code above, I don't get the means by row. I get the following
warning messages, one for each row of the dataframe.

Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA

 Can someone tell my what I am doing wrong, and how I can compute the row
means?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical
Center Geriatrics Research, Education, and Clinical Center; 
PI Biostatistics and Informatics Core, University of Maryland School of
Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382



__
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] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Bert Gunter
Incidentally, FWIW, for means, rowMeans() is a lot faster:

xxxz$av20 <- rowMeans(xxxz[,c("Low20","High20")])

Bert



On Sat, Jun 8, 2024 at 10:47 AM Bert Gunter  wrote:

> Use apply(), not by().
>
> xxxz$av20 <- apply(xxxz[,c("Low20","High20")],1, mean)
>
> -- Bert
>
> On Sat, Jun 8, 2024 at 10:38 AM Sorkin, John 
> wrote:
>
>> I have a data frame with three columns, TotalInches, Low20, High20. For
>> each row of the dataset, I am trying to compute the mean of Low20 and
>> High20.
>>
>> xxxz <- structure(list(TotalInches =
>>  c(58, 59, 60, 61, 62, 63, 64, 65,
>>66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 =
>> c(84, 87,
>>90, 93, 96, 99, 102, 106, 109, 112, 116, 119, 122,
>> 126, 129,
>>133, 137, 141, 144), High20 = c(111, 115, 119, 123,
>> 127, 131,
>>135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181,
>> 186, 191
>>)), class = "data.frame", row.names = c(NA, -19L))
>> xxxz
>> str(xxxz)
>> xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
>> warnings()
>>
>> When I run the code above, I don't get the means by row. I get the
>> following warning messages, one for each row of the dataframe.
>>
>> Warning messages:
>> 1: In mean.default(data[x, , drop = FALSE], ...) :
>>   argument is not numeric or logical: returning NA
>> 2: In mean.default(data[x, , drop = FALSE], ...) :
>>   argument is not numeric or logical: returning NA
>>
>>  Can someone tell my what I am doing wrong, and how I can compute the row
>> means?
>>
>> Thank you,
>> John
>>
>> John David Sorkin M.D., Ph.D.
>> Professor of Medicine, University of Maryland School of Medicine;
>> Associate Director for Biostatistics and Informatics, Baltimore VA
>> Medical Center Geriatrics Research, Education, and Clinical Center;
>> PI Biostatistics and Informatics Core, University of Maryland School of
>> Medicine Claude D. Pepper Older Americans Independence Center;
>> Senior Statistician University of Maryland Center for Vascular Research;
>>
>> Division of Gerontology and Paliative Care,
>> 10 North Greene Street
>> GRECC (BT/18/GR)
>> Baltimore, MD 21201-1524
>> Cell phone 443-418-5382
>>
>>
>>
>> __
>> 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] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Bert Gunter
Use apply(), not by().

xxxz$av20 <- apply(xxxz[,c("Low20","High20")],1, mean)

-- Bert

On Sat, Jun 8, 2024 at 10:38 AM Sorkin, John 
wrote:

> I have a data frame with three columns, TotalInches, Low20, High20. For
> each row of the dataset, I am trying to compute the mean of Low20 and
> High20.
>
> xxxz <- structure(list(TotalInches =
>  c(58, 59, 60, 61, 62, 63, 64, 65,
>66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 =
> c(84, 87,
>90, 93, 96, 99, 102, 106, 109, 112, 116, 119, 122, 126,
> 129,
>133, 137, 141, 144), High20 = c(111, 115, 119, 123,
> 127, 131,
>135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181,
> 186, 191
>)), class = "data.frame", row.names = c(NA, -19L))
> xxxz
> str(xxxz)
> xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
> warnings()
>
> When I run the code above, I don't get the means by row. I get the
> following warning messages, one for each row of the dataframe.
>
> Warning messages:
> 1: In mean.default(data[x, , drop = FALSE], ...) :
>   argument is not numeric or logical: returning NA
> 2: In mean.default(data[x, , drop = FALSE], ...) :
>   argument is not numeric or logical: returning NA
>
>  Can someone tell my what I am doing wrong, and how I can compute the row
> means?
>
> Thank you,
> John
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine, University of Maryland School of Medicine;
> Associate Director for Biostatistics and Informatics, Baltimore VA Medical
> Center Geriatrics Research, Education, and Clinical Center;
> PI Biostatistics and Informatics Core, University of Maryland School of
> Medicine Claude D. Pepper Older Americans Independence Center;
> Senior Statistician University of Maryland Center for Vascular Research;
>
> Division of Gerontology and Paliative Care,
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> Cell phone 443-418-5382
>
>
>
> __
> 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] Can't compute row means of two columns of a dataframe.

2024-06-08 Thread Sorkin, John
I have a data frame with three columns, TotalInches, Low20, High20. For each 
row of the dataset, I am trying to compute the mean of Low20 and High20. 

xxxz <- structure(list(TotalInches = 
 c(58, 59, 60, 61, 62, 63, 64, 65, 
   66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76), Low20 = c(84, 
87, 
   90, 93, 96, 99, 102, 106, 109, 112, 116, 119, 122, 126, 129, 
   133, 137, 141, 144), High20 = c(111, 115, 119, 123, 127, 
131, 
   135, 140, 144, 148, 153, 157, 162, 167, 171, 176, 181, 186, 
191
   )), class = "data.frame", row.names = c(NA, -19L))
xxxz
str(xxxz)
xxxz$Average20 <- by(xxxz[,c("Low20","High20")],xxxz[,"TotalInches"],mean)
warnings()

When I run the code above, I don't get the means by row. I get the following 
warning messages, one for each row of the dataframe.

Warning messages:
1: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA
2: In mean.default(data[x, , drop = FALSE], ...) :
  argument is not numeric or logical: returning NA

 Can someone tell my what I am doing wrong, and how I can compute the row means?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine, University of Maryland School of Medicine;
Associate Director for Biostatistics and Informatics, Baltimore VA Medical 
Center Geriatrics Research, Education, and Clinical Center; 
PI Biostatistics and Informatics Core, University of Maryland School of 
Medicine Claude D. Pepper Older Americans Independence Center;
Senior Statistician University of Maryland Center for Vascular Research;

Division of Gerontology and Paliative Care,
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
Cell phone 443-418-5382



__
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] What is the HEX code for "transparent" color?

2024-06-07 Thread Roland Rau via R-help

On 6/6/24 18:41, Duncan Murdoch wrote:

On 2024-06-06 4:37 a.m., Yosu Yurramendi wrote:

What is the HEX code for "transparent" color?
I've tried "" "FF00" "", but they don't work.


If the other answers don't solve your problem, you should give us some 
context.  Not all graphics functions in R can handle transparency, so 
please show us some reproducible code for what you are trying.


Duncan Murdoch



I usually use the alpha argument of the rgb() function for transparency.
Does this code snippet help to give you an idea how it works.

plot(1, 1, type="n", xlim=c(0,10), ylim=c(0,10))
rect(xleft=0, xright=7.5, ybottom=0, ytop=7.5,
 col=rgb(0, 0, 1, alpha=0.5))
rect(xleft=2.5, xright=10, ybottom=2.5, ytop=10,
 col=rgb(1, 0, 0, alpha=0.5))

Please check
?rgb
Especially the "Details" section should be helpful where you will find a 
list of devices which are supported or not supported.


I hope this helps a bit.

All the best,
Roland


--
This mail has been sent through the MPI for Demographic ...{{dropped:2}}

__
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] What is the HEX code for "transparent" color?

2024-06-06 Thread Robert Knight via R-help
You would set the alpha of an existing color and give it a new name and then 
refer to it by name rather than using HEX codes. 

On June 6, 2024 11:08:06 AM EDT, Greg Snow <538...@gmail.com> wrote:
>You need a "#" at the beginning of the string to specify that it is a
>hex code for the color.  Try "#".
>
>On Thu, Jun 6, 2024 at 9:07 AM Yosu Yurramendi
> wrote:
>>
>> What is the HEX code for "transparent" color?
>> I've tried "" "FF00" "", but they don't work.
>> Thanks
>>
>> [[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.
>
>
>
>-- 
>Gregory (Greg) L. Snow Ph.D.
>538...@gmail.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.

-- 
Robert Knight
tel 270-306-1658
fax (270) 288-0474
r...@rk.fyi
[[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] What is the HEX code for "transparent" color?

2024-06-06 Thread Duncan Murdoch

On 2024-06-06 4:37 a.m., Yosu Yurramendi wrote:

What is the HEX code for "transparent" color?
I've tried "" "FF00" "", but they don't work.


If the other answers don't solve your problem, you should give us some 
context.  Not all graphics functions in R can handle transparency, so 
please show us some reproducible code for what you are trying.


Duncan Murdoch

__
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] What is the HEX code for "transparent" color?

2024-06-06 Thread Robert Knight
You would give an existing color a new name and modify the new name's
alpha.  Then refer to the color by the new name instead of using HEX.

On Thu, Jun 6, 2024, 11:07 AM Yosu Yurramendi 
wrote:

> What is the HEX code for "transparent" color?
> I've tried "" "FF00" "", but they don't work.
> Thanks
>
> [[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] What is the HEX code for "transparent" color?

2024-06-06 Thread Greg Snow
You need a "#" at the beginning of the string to specify that it is a
hex code for the color.  Try "#".

On Thu, Jun 6, 2024 at 9:07 AM Yosu Yurramendi
 wrote:
>
> What is the HEX code for "transparent" color?
> I've tried "" "FF00" "", but they don't work.
> Thanks
>
> [[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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.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.


[R] What is the HEX code for "transparent" color?

2024-06-06 Thread Yosu Yurramendi
What is the HEX code for "transparent" color?
I've tried "" "FF00" "", but they don't work.
Thanks

[[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] R Shiny Help - Trouble passing user input columns to emmeans after ANOVA analysis

2024-06-06 Thread Ivan Krylov via R-help
В Wed, 5 Jun 2024 19:07:19 -0500
I B  пишет:

> However, I am getting the following error: *"Argument is of length
> zero."*

> if (selected_graph() == cols$column2 | selected_model() == "Main
> effects model") {

The error must be coming from here.

At least one of selected_graph(), cols$column2, selected_model() is a
zero-length object (maybe NULL) at this point, which makes the result
of the whole expression zero-length too. if (...) only accepts logical
scalars, hence the error.

-- 
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] R Shiny Help - Trouble passing user input columns to emmeans after ANOVA analysis

2024-06-06 Thread Bert Gunter
Wrong list. Shiny is software from an external provider, POSIT (formerly
RStudio) and not part of R, itself. They have a community support site at:

https://forum.posit.co/?_gl=1*bh848i*_ga*MTY2NjcwNzQ4LjE3MTYyMzkzODQ.*_ga_2C0WZ1JHG0*MTcxNzY4NTExNi4yLjAuMTcxNzY4NTExNi4wLjAuMA
..

Cheers,
Bert

On Thu, Jun 6, 2024 at 12:09 AM I B  wrote:

> Hello everybody,
>
> I have experience coding with R, but am brand new to R Shiny. I am trying
> to produce an application that will allow users to upload their own
> dataset, select columns they want an ANOVA analysis run on, and generate
> graphs that will allow users to view their results. However, I am getting
> the following error: *"Argument is of length zero."*
>
> Being new to Shiny, I am having trouble passing the user input column to an
> emmeans argument in order to do a post hoc analysis, and using that
> information to produce a graph. Can somebody help me with this? *The code
> for my dataset and application are provided below; copying and pasting
> directly into R should generate the reproducible example.*
>
> In my application, the following columns should be selected after uploading
> the dataset:
>
>- Select response variable: "ndvi"
>- Select first independent variable: "genotype"
>- Select second independent variable: "rate"
>- Select random variable: "rep"
>
> For this example, the final two drop-down selections should be:
>
>- "Which variable would you like to graph? "genotype"
>- "Which ANOVA model do you want to graph? "Main effects model"
>
> Any help would be great. Thank you so much!
>
> Sincerely,
> Isaac Barnhart, PhD
>
>
> *Here is my dataset:*
>
> data <- data.frame(rep =
> c(1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3),
>genotype =
>
> c('a','a','a','a','b','b','b','b','c','c','c','c','a','a','a','a','b','b','b','b','c','c','c','c','a','a','a','a','b','b','b','b','c','c','c','c'),
>rate =
>
> c('1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x'),
>ndvi =
>
> c(0.584947811,0.642112121,0.654116902,0.785068313,0.79665163,0.674549249,0.958911611,0.547077528,0.613315552,0.768646411,0.97107949,0.680942649,0.520576242,0.723920266,0.868779972,0.834257732,0.554506685,0.520458208,0.617282262,0.80128067,0.875192693,0.572153151,0.850305042,0.500760522,0.796305833,0.643719779,0.590512435,0.522884966,0.905197544,0.663792758,0.690415735,0.975449466,0.621379163,0.734904647,0.812023395,0.928144532))
>
>
> *Here is my code:*
>
> library(shiny)
> library(ggplot2)
> library(tidyverse)
> library(emmeans)
> library(DHARMa)
> library(lme4)
>
> ui <- fluidPage(
>   fileInput("file1", "Choose .csv or .xlsx file",
> accept = c("text/csv",
>"text/comma-separated-values",
>".csv",
>".xlsx")),
>   textOutput("data_info"),
>   verbatimTextOutput("data_head"),
>   uiOutput("column_selector_1"),
>   uiOutput("column_selector_2"),
>   uiOutput("column_selector_3"),
>   uiOutput("column_selector_4"),
>   textOutput("dist_info"),
>   plotOutput("dist"),
>   textOutput("str_info"),
>   verbatimTextOutput("selected_columns"),
>   textOutput("two_way_anova"),
>   verbatimTextOutput("model_summary"),
>   textOutput("main_effects"),
>   verbatimTextOutput("model_summary_ME"),
>   textOutput("mod_diagnostic"),
>   plotOutput("diagnostic_plot"),
>   uiOutput("graph"),
>   uiOutput("model_selection"),
>   plotOutput("graph_plot")
> )
>
> server <- function(input, output, session) {
>   # Open file
>   req(data <- reactive({
> infile <- input$file1
> if (is.null(infile)) {
>   return(NULL)
> }
> read.csv(infile$datapath, header = TRUE)
>   }))
>
>   # Preview data
>   output$data_info <- renderText({
> req(data())
> "Preview of the data uploaded:"
>   })
>
>   output$data_head <- renderPrint({
> req(data())
> head(data(), 20)
>   })
>
>   # Select response variable
>   output$column_selector_1 <- renderUI({
> req(data())
> selectInput("column1","Select response variable", choices =
> names(data()))
> })
>
>   # Select first independent variable
>   output$column_selector_2 <- renderUI({
> req(data())
> selectInput("column2", "Select first independent variable", choices =
> names(data()))
>   })
>
>   # Select second independent variable
>   output$column_selector_3 <- renderUI({
> req(data())
> selectInput("column3", "Select second independent variable", choices =
> names(data()))
>   })
>
>   # Select random variable
>   output$column_selector_4 <- renderUI({
> req(data())
> selectInput("column4", "Select random variable", choices =
> names(data()))
>   })
>
>   # Assigning user inputs to correct variables
>   selected_columns <- reactive({
> req(data(), input$column1, input$column2, 

Re: [R] Bug report for package foreign anf functon write.foreign

2024-06-06 Thread Kevin Thorpe
I haven’t used this function in a long time, but it sounds like the issue is 
the format names for the formats catalog, not the variable names.

You might try the haven package as it can create SAS datasets directly, 
although there are limitations (I think).

> On Jun 6, 2024, at 4:45 AM, Julien JOLY  wrote:
> 
> [Vous ne recevez pas souvent de courriers de julien.j...@inserm.fr. D?couvrez 
> pourquoi ceci est important ? https://aka.ms/LearnAboutSenderIdentification ]
> 
> Dear all,
> 
> First of all, I thank you for the creation of the package.
> 
> I write this message concerning the write.foreign() function from the foreign 
> package and a bug that I discovered.
> When we want to save our dataset as a .sas file, the limit of variable names 
> character is 8 by default. In SAS this limit is 32 character and an argument 
> in the function, validvarname, can theorically switch the default from 8 to 
> 32 by selecting validvarname = "V7".
> 
> However, it did not work and show the error "Cannot uniquely abbreviate 
> format names to conform to eight-character limit and not ending in a digit" 
> that show the limit is still 8 characters.
> 
> By looking at the script at 
> https://github.com/cran/foreign/blob/master/R/writeForeignSAS.R , I realized 
> that the line 39, in the function make.SAS.formats, can be the reason of the 
> nonfunctioning argument :
> "if(any(nchar(x) > 8L) || any(duplicated(x)))" which is correct if the length 
> of the variable has a limit of 8, but it does not take in consideration when 
> the limit is at 32 defined by validvarnames = "V7".
> 
> A solution can be to add the argument validvarname in the definition of the 
> function and add these few lines :
>  validvarname <- match.arg(validvarname)
>  nmax <- if(validvarname == "V7") 32L else 8L
>  if(any(nchar(x) > nmax) || any(duplicated(x)))
> 
> 
> I hope I send the message to the good place and that it will help you improve 
> the package.
> 
> Kind regards,
> 
> 
> 
> Julien Joly
> 
> Biostatisticien et Data manager
> 
> 
> 
> 
> 
>[[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.


-- 
Kevin E. Thorpe
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416-946-8083


__
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 report for package foreign anf functon write.foreign

2024-06-06 Thread Julien JOLY
Dear all,

First of all, I thank you for the creation of the package.

I write this message concerning the write.foreign() function from the foreign 
package and a bug that I discovered.
When we want to save our dataset as a .sas file, the limit of variable names 
character is 8 by default. In SAS this limit is 32 character and an argument in 
the function, validvarname, can theorically switch the default from 8 to 32 by 
selecting validvarname = "V7".

However, it did not work and show the error "Cannot uniquely abbreviate format 
names to conform to eight-character limit and not ending in a digit" that show 
the limit is still 8 characters.

By looking at the script at 
https://github.com/cran/foreign/blob/master/R/writeForeignSAS.R , I realized 
that the line 39, in the function make.SAS.formats, can be the reason of the 
nonfunctioning argument :
"if(any(nchar(x) > 8L) || any(duplicated(x)))" which is correct if the length 
of the variable has a limit of 8, but it does not take in consideration when 
the limit is at 32 defined by validvarnames = "V7".

A solution can be to add the argument validvarname in the definition of the 
function and add these few lines :
  validvarname <- match.arg(validvarname)
  nmax <- if(validvarname == "V7") 32L else 8L
  if(any(nchar(x) > nmax) || any(duplicated(x)))


I hope I send the message to the good place and that it will help you improve 
the package.

Kind regards,



Julien Joly

Biostatisticien et Data manager





[[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] R Shiny Help - Trouble passing user input columns to emmeans after ANOVA analysis

2024-06-06 Thread I B
Hello everybody,

I have experience coding with R, but am brand new to R Shiny. I am trying
to produce an application that will allow users to upload their own
dataset, select columns they want an ANOVA analysis run on, and generate
graphs that will allow users to view their results. However, I am getting
the following error: *"Argument is of length zero."*

Being new to Shiny, I am having trouble passing the user input column to an
emmeans argument in order to do a post hoc analysis, and using that
information to produce a graph. Can somebody help me with this? *The code
for my dataset and application are provided below; copying and pasting
directly into R should generate the reproducible example.*

In my application, the following columns should be selected after uploading
the dataset:

   - Select response variable: "ndvi"
   - Select first independent variable: "genotype"
   - Select second independent variable: "rate"
   - Select random variable: "rep"

For this example, the final two drop-down selections should be:

   - "Which variable would you like to graph? "genotype"
   - "Which ANOVA model do you want to graph? "Main effects model"

Any help would be great. Thank you so much!

Sincerely,
Isaac Barnhart, PhD


*Here is my dataset:*

data <- data.frame(rep =
c(1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3),
   genotype =
c('a','a','a','a','b','b','b','b','c','c','c','c','a','a','a','a','b','b','b','b','c','c','c','c','a','a','a','a','b','b','b','b','c','c','c','c'),
   rate =
c('1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x','1x','2x','4x','8x'),
   ndvi =
c(0.584947811,0.642112121,0.654116902,0.785068313,0.79665163,0.674549249,0.958911611,0.547077528,0.613315552,0.768646411,0.97107949,0.680942649,0.520576242,0.723920266,0.868779972,0.834257732,0.554506685,0.520458208,0.617282262,0.80128067,0.875192693,0.572153151,0.850305042,0.500760522,0.796305833,0.643719779,0.590512435,0.522884966,0.905197544,0.663792758,0.690415735,0.975449466,0.621379163,0.734904647,0.812023395,0.928144532))


*Here is my code:*

library(shiny)
library(ggplot2)
library(tidyverse)
library(emmeans)
library(DHARMa)
library(lme4)

ui <- fluidPage(
  fileInput("file1", "Choose .csv or .xlsx file",
accept = c("text/csv",
   "text/comma-separated-values",
   ".csv",
   ".xlsx")),
  textOutput("data_info"),
  verbatimTextOutput("data_head"),
  uiOutput("column_selector_1"),
  uiOutput("column_selector_2"),
  uiOutput("column_selector_3"),
  uiOutput("column_selector_4"),
  textOutput("dist_info"),
  plotOutput("dist"),
  textOutput("str_info"),
  verbatimTextOutput("selected_columns"),
  textOutput("two_way_anova"),
  verbatimTextOutput("model_summary"),
  textOutput("main_effects"),
  verbatimTextOutput("model_summary_ME"),
  textOutput("mod_diagnostic"),
  plotOutput("diagnostic_plot"),
  uiOutput("graph"),
  uiOutput("model_selection"),
  plotOutput("graph_plot")
)

server <- function(input, output, session) {
  # Open file
  req(data <- reactive({
infile <- input$file1
if (is.null(infile)) {
  return(NULL)
}
read.csv(infile$datapath, header = TRUE)
  }))

  # Preview data
  output$data_info <- renderText({
req(data())
"Preview of the data uploaded:"
  })

  output$data_head <- renderPrint({
req(data())
head(data(), 20)
  })

  # Select response variable
  output$column_selector_1 <- renderUI({
req(data())
selectInput("column1","Select response variable", choices =
names(data()))
})

  # Select first independent variable
  output$column_selector_2 <- renderUI({
req(data())
selectInput("column2", "Select first independent variable", choices =
names(data()))
  })

  # Select second independent variable
  output$column_selector_3 <- renderUI({
req(data())
selectInput("column3", "Select second independent variable", choices =
names(data()))
  })

  # Select random variable
  output$column_selector_4 <- renderUI({
req(data())
selectInput("column4", "Select random variable", choices =
names(data()))
  })

  # Assigning user inputs to correct variables
  selected_columns <- reactive({
req(data(), input$column1, input$column2, input$column3, input$column4)
list(
  dependent = data()[[input$column1]],
  independent1 = as.factor(data()[[input$column2]]),
  independent2 = as.factor(data()[[input$column3]]),
  random = as.factor(data()[[input$column4]]),

  # Define column names for later use
  column1 <- input$column1,
  column2 <- input$column2,
  column3 <- input$column3,
  column4 <- input$column4
)
  })

  # Instructional text
  output$dist_info <- renderText({
req(data())
"The graph below shows the shape of response variable distribution"
  })


  # 

Re: [R] nc file

2024-06-05 Thread Roger Bivand
The link suggested by Ben is over 7 years old, so using the CRAN Task View: 
https://cran.r-project.org/web/views/Spatial.html, which is up-to-date, and 
https://rspatial.org/index.html, because the terra package has largely replaced 
the raster package. Please consider following up on the R-sig-geo mailing list: 
https://stat.ethz.ch/mailman/listinfo/r-sig-geo.

Hope this helps,

Roger

--
Roger Bivand
Emeritus Professor
Norwegian School of Economics
Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway
roger.biv...@nhh.no
__
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: [ESS] viewing data - how do you do it?

2024-06-04 Thread Greg Minshall via ESS-help
Sven,

my "suggestion" (barely) here is way outside the "ecosystem" of
ess/emacs/R, and not a valid answer to your query.  but ...

recently, i've fallen in love with vd(1):

https://www.visidata.org/


cheers, Greg

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[ESS] viewing data - how do you do it?

2024-06-04 Thread Sven Hartenstein via ESS-help

Dear ess-helpers,

I lived with using View(data) for ages now (as I don't need it much) but
would like to find a more elegant and feature-rich way of looking into a
dataframe or tibble.

Question 1: How do you do it? What way would you recommend?

Today I realised that I might like DT::datatable() (showing data as a
HTML table in a browser) and defined a function v() to call
DT::datatable() with some nice options. Now, I would like to call my
function from my R code buffer by "M-x"ing an emacs function, that asks
for an object (the dataframe) (with autocompletion) and sends
"v(CHOOSENOBJECT)" to the R process.

Question 2: How can I achieve this? Is there an ESS function, that helps
me to run a specified R function on an existing R object (which I would
like to choose interactively)?


The emacs packages ess-view-data also looks promising to me. (It might
however irritate my colleagues who are used to GUI elements when looking
at data together.)

Question 3: Do you recommend ess-view-data?


You might think "Try things out and use whatever feels best to you", but
I would appreciate any related recommendations and tips based on your
experience.

Thank you,

Sven

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] nc file

2024-06-04 Thread Ben Bolker
   This question is unfortunately too vague for us to help you.  A 
little bit of web-searching turned up this tutorial: maybe that will help?


https://rpubs.com/boyerag/297592

On 2024-06-04 6:49 a.m., Farzad Ghooshi wrote:

Hello
I am a PhD student in ecology.
The subject of my thesis is climate change and agricultural systems
modeling. One of the software used in this research is R.
As you know, nc files show climate variables by year in general for the
whole world.
With what command line can I isolate an nc file climate variable for a
specific location?

[[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] nc file

2024-06-04 Thread Farzad Ghooshi
Hello
I am a PhD student in ecology.
The subject of my thesis is climate change and agricultural systems
modeling. One of the software used in this research is R.
As you know, nc files show climate variables by year in general for the
whole world.
With what command line can I isolate an nc file climate variable for a
specific location?

[[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] Tools to modify highlighted areas in pdf documents?

2024-06-03 Thread Leo Mada via R-help
Dear Ivan,

Thank you very much for the hint. I have started to test it.

- it offers more colours and types of highlighting than MS Edge;
- it seems to have better word-boundary detection than MS Edge (but I haven't 
tested all the cases yet);


There are some nit-picks:
- I wish it had a better default color-pallet;
- the vertical positioning continues to be sometimes sub-optimal: editing 
manually the coordinates may be still useful;

Returning to R:
1. Some of the pdf-packages could implement some of the 
annotation-functionality as well.

2. It would be useful to be able to export the annotations and import/merge 
them in another document. I have spotted errors in various articles; such a 
functionality would be handy, if a new version of those articles gets published.

Sincerely,

Leonard

From: Ivan Krylov 
Sent: Sunday, June 2, 2024 8:02 PM
To: Leo Mada via R-help 
Cc: Leo Mada 
Subject: Re: [R] Tools to modify highlighted areas in pdf documents?

� Sat, 1 Jun 2024 16:16:23 +
Leo Mada via R-help  �:

> When highlighting pdf-documents with Microsoft Edge, the bounding box
> is sometimes misplaced, and quite ugly so. It also lacks the ability
> to draw lines or arrows.
>
> On the other hand, I did not get used to Acrobat Reader: it usually
> involves much more effort to add specific highlights. Lines can be
> drawn, but are NOT straight!

Sorry for answering a different question, but have you considered using
a different PDF viewer + annotation application? Okular
 is free and available on Windows (including
from outside Microsoft store). Its annotation features include all
kinds of highlights, arrows and lines, both straight and
arbitrarily-shaped, quickly available from the "annotations" panel.

--
Best regards,
Ivan

[[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] [R-pkgs] QGA 1.0 is released

2024-06-03 Thread Giulio Barcaroli
Dear R users,

I am pleased to announce that QGA 1.0 is now available on CRAN.

QGA implements the Quantum Genetic Algorithm, as proposed by Han and Kim 
in 2000, and is an R implementation derived from the Python one by 
Lahoz-Beltra in 2016.

Under this approach, each solution is represented as a sequence of 
(qu)bits. Simulating the quantum paradigm, these qubits are in a 
superposition state: when measuring them, they collapse in a 0 or 1 
state. After measurement, the solution's fitness is calculated as in 
usual genetic algorithms.

The evolution at each iteration is oriented by the application of two 
quantum gates to the amplitudes of the qubits: (1) a rotation gate 
(always); (2) a Pauli-X gate (optionally). The rotation is based on the 
theta angle values: higher values allow a quicker evolution, and lower 
values avoid local maxima. The Pauli-X gate is equivalent to the 
classical mutation operator and determines the swap between alfa and 
beta amplitudes of a given qubit.

The package has been developed in such a way as to permit a complete 
separation between the 'engine', and the particular problem subject to 
combinatorial optimization. This is evident in the available examples, 
that come with the package, illustrating the application of QGA to 
different problems: knapsack, traveler salesman, and clustering.

Thank you, kind regards,

Giulio Barcaroli

[[alternative HTML version deleted]]

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

__
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 code for overlapping variables -- count

2024-06-03 Thread Ebert,Timothy Aaron
One could make dummy variables if the existing variables are otherwise. If 
Female is a variable that includes other options (no-response, non-binary, ...) 
then recode it using dummy.female and the others would be similarly named.

-Original Message-
From: R-help  On Behalf Of peter dalgaard
Sent: Monday, June 3, 2024 5:02 AM
To: Shadee Ashtari 
Cc: r-help@r-project.org
Subject: Re: [R] R code for overlapping variables -- count

[External Email]

If they are binary (0/1 dummies), can't you just "&" them as in

table(Female & USA & MidIncome)

(or sum() if you don't care about the number of 0s)

-pd

> On 2 Jun 2024, at 00:31 , Shadee Ashtari  wrote:
>
> Hi!
>
> I am trying to find the code for how to get counts for intersectional
> variables. For example, I have three unique categorical variables --
> "Female," "USA," and "MidIncome" -- and I'm trying to see how many
> people I have at the intersection of the three.
>
> Thank you so much,
> Shadee
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat/
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C02%7Ctebert%40ufl.edu
> %7C66abf8af810348ed21b408dc83abdfd6%7C0d4da0f84a314d76ace60a62331e1b84
> %7C0%7C0%7C638530021430818928%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=
> a2oUZzOdXDHnzPA3Oo98DIp%2BFIqpg5o1fT0fcE%2BvkQI%3D=0
> PLEASE do read the posting guide
> http://www.r/
> -project.org%2Fposting-guide.html=05%7C02%7Ctebert%40ufl.edu%7C66
> abf8af810348ed21b408dc83abdfd6%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> 7C0%7C638530021430825783%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=L2I%2
> BxXV3kHZUwflUx0%2BGrakGbbOV6AWV7dul7%2FyuIBU%3D=0
> and provide commented, minimal, self-contained, reproducible code.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 
Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.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.

__
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 code for overlapping variables -- count

2024-06-03 Thread peter dalgaard
If they are binary (0/1 dummies), can't you just "&" them as in 

table(Female & USA & MidIncome)

(or sum() if you don't care about the number of 0s)

-pd

> On 2 Jun 2024, at 00:31 , Shadee Ashtari  wrote:
> 
> Hi!
> 
> I am trying to find the code for how to get counts for intersectional
> variables. For example, I have three unique categorical variables --
> "Female," "USA," and "MidIncome" -- and I'm trying to see how many people I
> have at the intersection of the three.
> 
> Thank you so much,
> Shadee
> 
>   [[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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.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] R code for overlapping variables -- count

2024-06-02 Thread Rui Barradas

Às 18:40 de 02/06/2024, Rui Barradas escreveu:

Às 18:34 de 02/06/2024, Leo Mada via R-help escreveu:

Dear Shadee,

If you have a data.frame with the following columns:

n = 100; # population size
x = data.frame(
  Sex = sample(c("M","F"), n, T),
  Country = sample(c("AA", "BB", "US"), n, T),
  Income  = as.factor(sample(1:3, n, T))
)

# Dummy variable
ONE = rep(1, nrow(x))

r = aggregate(ONE ~ Sex + Income + Country, length, data = x)
r = r[, c("Country", "Income", "Sex")]
print(r)

It is possible to write more simple code, if you need only the 
particular combination of variables (which you specified in your 
mail). But this is the more general approach.


Note: you may want to use "sum" instead of "length", e.g. if you have 
a column specifying the number of individuals in that category.



Hope this helps,

Leonard


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

Hello,

The following is simpler.


r2 <- xtabs(~ ., x) |> as.data.frame()
r2[-4L] # or r2[names(r2) != "Freq"]


Hope this helps,

Rui Barradas



Hello,

This is the same solution but the code to keep only the columns in the 
original data set is better. And it's a MRE.



n <- 100; # population size
x <- data.frame(
  Sex = sample(c("M","F"), n, T),
  Country = sample(c("AA", "BB", "US"), n, T),
  Income  = as.factor(sample(1:3, n, T))
)

r2 <- xtabs(~ ., x) |> as.data.frame()
# no need for constants, find the columns
# to keep from the data
r2[names(r2) %in% names(x)]


Hope this helps,

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] R code for overlapping variables -- count

2024-06-02 Thread Leo Mada via R-help
Correcting a small glitch - see new code.


From: Leo Mada 
Sent: Sunday, June 2, 2024 8:34 PM
To: Shadee Ashtari 
Cc: r-help@r-project.org 
Subject: [R] R code for overlapping variables -- count

Dear Shadee,

If you have a data.frame with the following columns:

n = 100; # population size
x = data.frame(
  Sex = sample(c("M","F"), n, T),
  Country = sample(c("AA", "BB", "US"), n, T),
  Income  = as.factor(sample(1:3, n, T))
)

# Dummy variable
ONE = rep(1, nrow(x))

# corrected
r = aggregate(ONE ~ Sex + Income + Country, length, data = x)
r = r[, c("Country", "Income", "Sex", "ONE")]
names(r)[4] = "Count"
print(r)

It is possible to write more simple code, if you need only the particular 
combination of variables (which you specified in your mail). But this is the 
more general approach.

Note: you may want to use "sum" instead of "length", e.g. if you have a column 
specifying the number of individuals in that category.


Hope this helps,

Leonard


[[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] R code for overlapping variables -- count

2024-06-02 Thread Rui Barradas

Às 18:34 de 02/06/2024, Leo Mada via R-help escreveu:

Dear Shadee,

If you have a data.frame with the following columns:

n = 100; # population size
x = data.frame(
  Sex = sample(c("M","F"), n, T),
  Country = sample(c("AA", "BB", "US"), n, T),
  Income  = as.factor(sample(1:3, n, T))
)

# Dummy variable
ONE = rep(1, nrow(x))

r = aggregate(ONE ~ Sex + Income + Country, length, data = x)
r = r[, c("Country", "Income", "Sex")]
print(r)

It is possible to write more simple code, if you need only the particular 
combination of variables (which you specified in your mail). But this is the 
more general approach.

Note: you may want to use "sum" instead of "length", e.g. if you have a column 
specifying the number of individuals in that category.


Hope this helps,

Leonard


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

Hello,

The following is simpler.


r2 <- xtabs(~ ., x) |> as.data.frame()
r2[-4L] # or r2[names(r2) != "Freq"]


Hope this helps,

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.


[R] R code for overlapping variables -- count

2024-06-02 Thread Leo Mada via R-help
Dear Shadee,

If you have a data.frame with the following columns:

n = 100; # population size
x = data.frame(
  Sex = sample(c("M","F"), n, T),
  Country = sample(c("AA", "BB", "US"), n, T),
  Income  = as.factor(sample(1:3, n, T))
)

# Dummy variable
ONE = rep(1, nrow(x))

r = aggregate(ONE ~ Sex + Income + Country, length, data = x)
r = r[, c("Country", "Income", "Sex")]
print(r)

It is possible to write more simple code, if you need only the particular 
combination of variables (which you specified in your mail). But this is the 
more general approach.

Note: you may want to use "sum" instead of "length", e.g. if you have a column 
specifying the number of individuals in that category.


Hope this helps,

Leonard


[[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] Tools to modify highlighted areas in pdf documents?

2024-06-02 Thread Ivan Krylov via R-help
В Sat, 1 Jun 2024 16:16:23 +
Leo Mada via R-help  пишет:

> When highlighting pdf-documents with Microsoft Edge, the bounding box
> is sometimes misplaced, and quite ugly so. It also lacks the ability
> to draw lines or arrows.
> 
> On the other hand, I did not get used to Acrobat Reader: it usually
> involves much more effort to add specific highlights. Lines can be
> drawn, but are NOT straight!

Sorry for answering a different question, but have you considered using
a different PDF viewer + annotation application? Okular
 is free and available on Windows (including
from outside Microsoft store). Its annotation features include all
kinds of highlights, arrows and lines, both straight and
arbitrarily-shaped, quickly available from the "annotations" panel.

-- 
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] R code for overlapping variables -- count

2024-06-02 Thread Duncan Murdoch

On 2024-06-01 6:31 p.m., Shadee Ashtari wrote:

Hi!

I am trying to find the code for how to get counts for intersectional
variables. For example, I have three unique categorical variables --
"Female," "USA," and "MidIncome" -- and I'm trying to see how many people I
have at the intersection of the three.


It depends on how those are stored.  Could you put together a little 
dataframe containing sample data, run `dput()` on it, and post the 
result here?


Duncan Murdoch

__
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] R code for overlapping variables -- count

2024-06-02 Thread Shadee Ashtari
Hi!

I am trying to find the code for how to get counts for intersectional
variables. For example, I have three unique categorical variables --
"Female," "USA," and "MidIncome" -- and I'm trying to see how many people I
have at the intersection of the three.

Thank you so much,
Shadee

[[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] Tools to modify highlighted areas in pdf documents?

2024-06-01 Thread Leo Mada via R-help
Dear Bert,

Thank you very much for the response.

I was aware of pdftools - but did not recall any such functionality. I have 
checked again (both pdftools, qpdf and the 3rd one): unfortunately, they do not 
implement such functionality. There might be other packages, which I missed.

However, the functionality is feasible. I will add a few more details - maybe 
someone picks up the task.

It is possible to edit manually the pdf-file, though it is quite cumbersome to 
find the right annotation.

1. One needs to edit the values both in the \QuadPoints and the \Rect in the 
\AP object.

2. Modifying the color is trickier:
\C() encodes the color and \CA the alpha channel (= 1): but neither Acrobat, 
nor MIcrosoft Edge update the color. The value of the color encoded in the 
stream is used instead.

It is possible to "trick" Edge: modify the \C color and set "\ca 1" (in the 
stream block) to a lower value (e.g. "\ca 0.99"). MS Edge will then accept the 
modified color (but Acrobat ignores it). Changing the value in the stream is 
the actual solution.

Note: non-rectangular shapes can be specified as well.

I hope that some of the referenced packages pick up this task.

Sincerely,

Leonard


From: Bert Gunter 
Sent: Saturday, June 1, 2024 9:23 PM
To: Leo Mada 
Cc: r-help@r-project.org 
Subject: Re: [R] Tools to modify highlighted areas in pdf documents?

Search!

on rseek.org, the query "modify pdf documents in R" brought 
up the staplr package. A quick web search with the same query brought up the 
pdftools package.

These were cursory efforts, so you may well find more. You will have to 
determine whether and to what degree any meet your needs.

-- Bert

On Sat, Jun 1, 2024 at 9:16 AM Leo Mada via R-help 
mailto:r-help@r-project.org>> wrote:
Dear R-Users,

Are there any packages that enable the modifications of highlighted areas / 
annotations in pdf documents?

It seems feasible - I have explored some R code (see below). However, I would 
rather avoid to reinvent the wheel.

The problem:
When highlighting pdf-documents with Microsoft Edge, the bounding box is 
sometimes misplaced, and quite ugly so. It also lacks the ability to draw lines 
or arrows.

On the other hand, I did not get used to Acrobat Reader: it usually involves 
much more effort to add specific highlights. Lines can be drawn, but are NOT 
straight!

Are there tools to change the size/position of highlights?
Or to add highlights and underline words?
 Changing position/size manually by editing the data in the pdf-document is 
possible. Changing the color is more trickier (somehow possible in Microsoft 
Edger; though the direct approach to rewrite the actual stream is better). 
Maybe there are some tools to do it?

Some R code is below.

Sincerely,

Leonard
#

library(zip)

con = file("_some_pdf_.pdf", "rb")

NL = 0
# - very dirty hack;
# - assumes Annotations are in the last fragment/chunk;
while(TRUE) {
tmp = readBin(con, "raw", 1024*128 + 515);
if(length(tmp) == 0) break;
x = tmp;
# isNL = (x == 10) | (x == 13);
isNL = (x == 13);
isNL = isNL & (x[which(isNL) + 1] == 10);
NL = NL + sum(isNL);
}

close(con)

idP = which(isNL)

idS = 935; # will vary with pdf and Annotations and ...;
nLast = 4; # usually 2 chunks
idx = idP[seq(idS, length.out = nLast)]

# Check: Right position?
# tmp = x[seq(idx[1] + 2, idx[1 + 2] - 1)]
# intToUtf8(tmp)

tmp = inflate(x[seq(idx[1] + 2, idx[nLast] - 1)])
intToUtf8(tmp$output)

# Output of inflate: an Example
# "/GS gs .56078434 .87058824 .97647059 rg\n
# 337.298 183.836 m 364.322 183.836 l 364.322 171.83 l 337.298 171.83 l h f\n"

# Note: /BBox[ 337.298 171.83 364.322 183.836]

The raw pdf data:

1948 0 obj
<>/C[ 0.560784 0.870588 0.976471]/CA 1/F 
4/PDFIUM_HasGeneratedAP true/QuadPoints[ 337.298 186 364.322 186 337.298 174.6 
364.322 174.6]/Rect[ 337.298 174.6 364.322 186]/Subtype/Highlight/Type/Annot>>
endobj
1949 0 obj
<>/Subtype/Form/Type/XObject>>stream
xœE˱
€0  Àž)~ “ä Û™€ Ø P@ ûKˆ"Оtó²¢ß jÉC© ðT#ŠBš›zª
WŸH—Ò 9(AÃ  š
Kùäøų _ iÀŽmz dR ²
endstream
endobj


[[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] Tools to modify highlighted areas in pdf documents?

2024-06-01 Thread Bert Gunter
Search!

on rseek.org, the query "modify pdf documents in R" brought up the staplr
package. A quick web search with the same query brought up the pdftools
package.

These were cursory efforts, so you may well find more. You will have to
determine whether and to what degree any meet your needs.

-- Bert

On Sat, Jun 1, 2024 at 9:16 AM Leo Mada via R-help 
wrote:

> Dear R-Users,
>
> Are there any packages that enable the modifications of highlighted areas
> / annotations in pdf documents?
>
> It seems feasible - I have explored some R code (see below). However, I
> would rather avoid to reinvent the wheel.
>
> The problem:
> When highlighting pdf-documents with Microsoft Edge, the bounding box is
> sometimes misplaced, and quite ugly so. It also lacks the ability to draw
> lines or arrows.
>
> On the other hand, I did not get used to Acrobat Reader: it usually
> involves much more effort to add specific highlights. Lines can be drawn,
> but are NOT straight!
>
> Are there tools to change the size/position of highlights?
> Or to add highlights and underline words?
>  Changing position/size manually by editing the data in the pdf-document
> is possible. Changing the color is more trickier (somehow possible in
> Microsoft Edger; though the direct approach to rewrite the actual stream is
> better). Maybe there are some tools to do it?
>
> Some R code is below.
>
> Sincerely,
>
> Leonard
> #
>
> library(zip)
>
> con = file("_some_pdf_.pdf", "rb")
>
> NL = 0
> # - very dirty hack;
> # - assumes Annotations are in the last fragment/chunk;
> while(TRUE) {
> tmp = readBin(con, "raw", 1024*128 + 515);
> if(length(tmp) == 0) break;
> x = tmp;
> # isNL = (x == 10) | (x == 13);
> isNL = (x == 13);
> isNL = isNL & (x[which(isNL) + 1] == 10);
> NL = NL + sum(isNL);
> }
>
> close(con)
>
> idP = which(isNL)
>
> idS = 935; # will vary with pdf and Annotations and ...;
> nLast = 4; # usually 2 chunks
> idx = idP[seq(idS, length.out = nLast)]
>
> # Check: Right position?
> # tmp = x[seq(idx[1] + 2, idx[1 + 2] - 1)]
> # intToUtf8(tmp)
>
> tmp = inflate(x[seq(idx[1] + 2, idx[nLast] - 1)])
> intToUtf8(tmp$output)
>
> # Output of inflate: an Example
> # "/GS gs .56078434 .87058824 .97647059 rg\n
> # 337.298 183.836 m 364.322 183.836 l 364.322 171.83 l 337.298 171.83 l h
> f\n"
>
> # Note: /BBox[ 337.298 171.83 364.322 183.836]
>
> The raw pdf data:
>
> 1948 0 obj
> <>/C[ 0.560784 0.870588 0.976471]/CA 1/F
> 4/PDFIUM_HasGeneratedAP true/QuadPoints[ 337.298 186 364.322 186 337.298
> 174.6 364.322 174.6]/Rect[ 337.298 174.6 364.322
> 186]/Subtype/Highlight/Type/Annot>>
> endobj
> 1949 0 obj
> < 1/Length 86/Matrix[ 1 0 0 1 0 0]/Resources< false/BM/Multiply/CA 1/Type/ExtGState/ca
> 1>>/Subtype/Form/Type/XObject>>stream
> xœE˱
> €0  Àž)~ “ä Û™€ Ø P@ ûKˆ"Оtó²¢ß jÉC© ðT#ŠBš›zª
> WŸH—Ò 9(AÃ š
> Kùäøų _ iÀŽmz dR ²
> endstream
> endobj
>
>
> [[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] Tools to modify highlighted areas in pdf documents?

2024-06-01 Thread Leo Mada via R-help
Dear R-Users,

Are there any packages that enable the modifications of highlighted areas / 
annotations in pdf documents?

It seems feasible - I have explored some R code (see below). However, I would 
rather avoid to reinvent the wheel.

The problem:
When highlighting pdf-documents with Microsoft Edge, the bounding box is 
sometimes misplaced, and quite ugly so. It also lacks the ability to draw lines 
or arrows.

On the other hand, I did not get used to Acrobat Reader: it usually involves 
much more effort to add specific highlights. Lines can be drawn, but are NOT 
straight!

Are there tools to change the size/position of highlights?
Or to add highlights and underline words?
 Changing position/size manually by editing the data in the pdf-document is 
possible. Changing the color is more trickier (somehow possible in Microsoft 
Edger; though the direct approach to rewrite the actual stream is better). 
Maybe there are some tools to do it?

Some R code is below.

Sincerely,

Leonard
#

library(zip)

con = file("_some_pdf_.pdf", "rb")

NL = 0
# - very dirty hack;
# - assumes Annotations are in the last fragment/chunk;
while(TRUE) {
tmp = readBin(con, "raw", 1024*128 + 515);
  if(length(tmp) == 0) break;
  x = tmp;
  # isNL = (x == 10) | (x == 13);
  isNL = (x == 13);
  isNL = isNL & (x[which(isNL) + 1] == 10);
NL = NL + sum(isNL);
}

close(con)

idP = which(isNL)

idS = 935; # will vary with pdf and Annotations and ...;
nLast = 4; # usually 2 chunks
idx = idP[seq(idS, length.out = nLast)]

# Check: Right position?
# tmp = x[seq(idx[1] + 2, idx[1 + 2] - 1)]
# intToUtf8(tmp)

tmp = inflate(x[seq(idx[1] + 2, idx[nLast] - 1)])
intToUtf8(tmp$output)

# Output of inflate: an Example
# "/GS gs .56078434 .87058824 .97647059 rg\n
# 337.298 183.836 m 364.322 183.836 l 364.322 171.83 l 337.298 171.83 l h f\n"

# Note: /BBox[ 337.298 171.83 364.322 183.836]

The raw pdf data:

1948 0 obj
<>/C[ 0.560784 0.870588 0.976471]/CA 1/F 
4/PDFIUM_HasGeneratedAP true/QuadPoints[ 337.298 186 364.322 186 337.298 174.6 
364.322 174.6]/Rect[ 337.298 174.6 364.322 186]/Subtype/Highlight/Type/Annot>>
endobj
1949 0 obj
<>/Subtype/Form/Type/XObject>>stream
xœE˱
€0 Àž)~“äÛ™€؁P@ûKˆ"Оtó²¢ßjÉC©ðT#ŠBš›zª
WŸH—Ò9(AÃ  š
Kùäøų_iÀŽmz dR²
endstream
endobj


[[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] [Rd] R 4.4.1 scheduled for June 14

2024-05-31 Thread peter dalgaard
Full schedule is available on developer.r-project.org (pending update from SVN).

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
r-de...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

___
r-annou...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] add only the 1st of May with POSIXct

2024-05-29 Thread Rui Barradas

Às 07:01 de 29/05/2024, Stefano Sofia escreveu:

Thank you Rui for your code.

I basically understood all your suggestions.

I am using an old version of R (version 3.6.3, installed in a server I am not 
allowed to control), and the new pipe operator does not work.

I tried to run your code without the "|>" operator, but I get an error when I 
use apply.

Could you please expand your code without the pipe operator?


Thank you again for your help

Stefano



  (oo)
--oOO--( )--OOo--
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo-oO



Da: Rui Barradas 
Inviato: martedì 28 maggio 2024 18:19
A: Stefano Sofia; r-help@R-project.org
Oggetto: Re: [R] add only the 1st of May with POSIXct

[Non ricevi spesso messaggi di posta elettronica da ruipbarra...@sapo.pt. Per 
informazioni sull'importanza di questo fatto, visita 
https://aka.ms/LearnAboutSenderIdentification.]

Às 16:23 de 28/05/2024, Stefano Sofia escreveu:

Dear R-list users,

  From an initial and a final date I create a sequence of days using POSIXct.

If this interval covers all or only in part the months from May to October, I 
need to get rid of the days from the 2nd of May to the 31st of October:


a <- as.POSIXct("2002-11-01", format = "%Y-%m-%d", tz="Etc/GMT-1")

b <- as.POSIXct("2004-06-01", format = "%Y-%m-%d", tz="Etc/GMT-1")

mydf <- data.frame(data_POSIX=seq(as.POSIXct(paste(format(a, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), 
as.POSIXct(paste(format(b, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), by="1 day"))


If I execute

as.data.frame(mydf[format(mydf$data_POSIX,"%m") %in% c("11", "12", "01", "02", "03", 
"04"), ])

the interval will be

from 2002-11-01 09:00:00 to 2003-04-30 09:00:00

and from 2003-11-01 09:00:00 to 2004-04-30 09:00:00


but I need also 2003-05-01 09:00:00 and 2004-05-01 09:00:00


How can I solve this problem?


Thank you for your attention and your help

Stefano



   (oo)
--oOO--( )--OOo--
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo-oO



AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere 
informazioni confidenziali, pertanto � destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
� il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed 
urgenza, la risposta al presente messaggio di posta elettronica pu� essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

   [[alternative HTML version deleted]]


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C02%7Cstefano.sofia%40regione.marche.it%7C0d812d3223344a1508d408dc7f31f657%7C295eaa1431a14b09bfe65a338b679f60%7C0%7C0%7C638525100275684754%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C6%7C%7C%7C=ac0Hx9auMSeXgsllDaaimZDFBpSLZ%2B3OeOGQoVvcjxQ%3D=0
PLEASE do read the posting guide 
https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=05%7C02%7Cstefano.sofia%40regione.marche.it%7C0d812d3223344a1508d408dc7f31f657%7C295eaa1431a14b09bfe65a338b679f60%7C0%7C0%7C638525100275684754%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C6%7C%7C%7C=NaHBMLopjjkqygAFPtT8oPv7A0UnYY%2BZGN%2Bp9EGCIqs%3D=0
and provide commented, minimal, self-contained, reproducible code.

Hello,

First of all, 'a' and 'b' are already objects of 

Re: [R] add only the 1st of May with POSIXct

2024-05-29 Thread Enrico Schumann
On Tue, 28 May 2024, Stefano Sofia writes:

> Dear R-list users,
>
> From an initial and a final date I create a sequence of days using POSIXct.
>
> If this interval covers all or only in part the months from May to October, I 
> need to get rid of the days from the 2nd of May to the 31st of October:
>
>
> a <- as.POSIXct("2002-11-01", format = "%Y-%m-%d", tz="Etc/GMT-1")
>
> b <- as.POSIXct("2004-06-01", format = "%Y-%m-%d", tz="Etc/GMT-1")
>
> mydf <- data.frame(data_POSIX=seq(as.POSIXct(paste(format(a, "%Y-%m-%d"), 
> "09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), 
> as.POSIXct(paste(format(b, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d 
> %H:%M:%S", tz="Etc/GMT-1"), by="1 day"))
>
>
> If I execute
>
> as.data.frame(mydf[format(mydf$data_POSIX,"%m") %in% c("11", "12", "01", 
> "02", "03", "04"), ])
>
> the interval will be
>
> from 2002-11-01 09:00:00 to 2003-04-30 09:00:00
>
> and from 2003-11-01 09:00:00 to 2004-04-30 09:00:00
>
>
> but I need also 2003-05-01 09:00:00 and 2004-05-01 09:00:00
>
>
> How can I solve this problem?
>
>
> Thank you for your attention and your help
>
> Stefano
>

I think this could be simplified a bit:

a <- as.POSIXct("2002-11-01 09", format = "%Y-%m-%d %H", tz="Etc/GMT-1")
b <- as.POSIXct("2004-06-01 09", format = "%Y-%m-%d %H", tz="Etc/GMT-1")

Create your sequence:

S <- seq(a, b , by = "1 day")
month.day <- format(S, "%m-%d")

Now subset S for those days that you want:

S[month.day <= "05-01" | month.day > "10-31"]


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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] add only the 1st of May with POSIXct

2024-05-29 Thread Stefano Sofia
Thank you Rui for your code.

I basically understood all your suggestions.

I am using an old version of R (version 3.6.3, installed in a server I am not 
allowed to control), and the new pipe operator does not work.

I tried to run your code without the "|>" operator, but I get an error when I 
use apply.

Could you please expand your code without the pipe operator?


Thank you again for your help

Stefano



 (oo)
--oOO--( )--OOo--
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo-oO



Da: Rui Barradas 
Inviato: martedì 28 maggio 2024 18:19
A: Stefano Sofia; r-help@R-project.org
Oggetto: Re: [R] add only the 1st of May with POSIXct

[Non ricevi spesso messaggi di posta elettronica da ruipbarra...@sapo.pt. Per 
informazioni sull'importanza di questo fatto, visita 
https://aka.ms/LearnAboutSenderIdentification.]

Às 16:23 de 28/05/2024, Stefano Sofia escreveu:
> Dear R-list users,
>
>  From an initial and a final date I create a sequence of days using POSIXct.
>
> If this interval covers all or only in part the months from May to October, I 
> need to get rid of the days from the 2nd of May to the 31st of October:
>
>
> a <- as.POSIXct("2002-11-01", format = "%Y-%m-%d", tz="Etc/GMT-1")
>
> b <- as.POSIXct("2004-06-01", format = "%Y-%m-%d", tz="Etc/GMT-1")
>
> mydf <- data.frame(data_POSIX=seq(as.POSIXct(paste(format(a, "%Y-%m-%d"), 
> "09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), 
> as.POSIXct(paste(format(b, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d 
> %H:%M:%S", tz="Etc/GMT-1"), by="1 day"))
>
>
> If I execute
>
> as.data.frame(mydf[format(mydf$data_POSIX,"%m") %in% c("11", "12", "01", 
> "02", "03", "04"), ])
>
> the interval will be
>
> from 2002-11-01 09:00:00 to 2003-04-30 09:00:00
>
> and from 2003-11-01 09:00:00 to 2004-04-30 09:00:00
>
>
> but I need also 2003-05-01 09:00:00 and 2004-05-01 09:00:00
>
>
> How can I solve this problem?
>
>
> Thank you for your attention and your help
>
> Stefano
>
>
>
>   (oo)
> --oOO--( )--OOo--
> Stefano Sofia PhD
> Civil Protection - Marche Region - Italy
> Meteo Section
> Snow Section
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona (AN)
> Uff: +39 071 806 7743
> E-mail: stefano.so...@regione.marche.it
> ---Oo-oO
>
> 
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere 
> informazioni confidenziali, pertanto � destinato solo a persone autorizzate 
> alla ricezione. I messaggi di posta elettronica per i client di Regione 
> Marche possono contenere informazioni confidenziali e con privilegi legali. 
> Se non si � il destinatario specificato, non leggere, copiare, inoltrare o 
> archiviare questo messaggio. Se si � ricevuto questo messaggio per errore, 
> inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio 
> computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso 
> di necessit� ed urgenza, la risposta al presente messaggio di posta 
> elettronica pu� essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by 
> persons entitled to receive the confidential information it may contain. 
> E-mail messages to clients of Regione Marche may contain information that is 
> confidential and legally privileged. Please do not read, copy, forward, or 
> store this message unless you are an intended recipient of it. If you have 
> received this message in error, please forward it to the sender and delete it 
> completely from your computer system.
>
>   [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C02%7Cstefano.sofia%40regione.marche.it%7C0d812d3223344a1508d408dc7f31f657%7C295eaa1431a14b09bfe65a338b679f60%7C0%7C0%7C638525100275684754%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C6%7C%7C%7C=ac0Hx9auMSeXgsllDaaimZDFBpSLZ%2B3OeOGQoVvcjxQ%3D=0
> PLEASE do read the posting guide 
> https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=05%7C02%7Cstefano.sofia%40regione.marche.it%7C0d812d3223344a1508d408dc7f31f657%7C295eaa1431a14b09bfe65a338b679f60%7C0%7C0%7C638525100275684754%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C6%7C%7C%7C=NaHBMLopjjkqygAFPtT8oPv7A0UnYY%2BZGN%2Bp9EGCIqs%3D=0
> and provide commented, minimal, 

Re: [R] add only the 1st of May with POSIXct

2024-05-28 Thread Rui Barradas

Às 16:23 de 28/05/2024, Stefano Sofia escreveu:

Dear R-list users,

 From an initial and a final date I create a sequence of days using POSIXct.

If this interval covers all or only in part the months from May to October, I 
need to get rid of the days from the 2nd of May to the 31st of October:


a <- as.POSIXct("2002-11-01", format = "%Y-%m-%d", tz="Etc/GMT-1")

b <- as.POSIXct("2004-06-01", format = "%Y-%m-%d", tz="Etc/GMT-1")

mydf <- data.frame(data_POSIX=seq(as.POSIXct(paste(format(a, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), 
as.POSIXct(paste(format(b, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), by="1 day"))


If I execute

as.data.frame(mydf[format(mydf$data_POSIX,"%m") %in% c("11", "12", "01", "02", "03", 
"04"), ])

the interval will be

from 2002-11-01 09:00:00 to 2003-04-30 09:00:00

and from 2003-11-01 09:00:00 to 2004-04-30 09:00:00


but I need also 2003-05-01 09:00:00 and 2004-05-01 09:00:00


How can I solve this problem?


Thank you for your attention and your help

Stefano



  (oo)
--oOO--( )--OOo--
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo-oO



AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere 
informazioni confidenziali, pertanto � destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
� il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed 
urgenza, la risposta al presente messaggio di posta elettronica pu� essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

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

Hello,

First of all, 'a' and 'b' are already objects of class "POSIXct", you 
don't need to repeat the code creating them when creating mydf.


As for the question, see the code below.


a <- as.POSIXct("2002-11-01", format = "%Y-%m-%d", tz="Etc/GMT-1")
b <- as.POSIXct("2004-06-01", format = "%Y-%m-%d", tz="Etc/GMT-1")
mydf <- data.frame(data_POSIX = seq(a, b, by = "1 day"))

# get the years from the data
years <- format(c(a, b), "%Y") |> as.integer()
# this creates a sequence with all the years
years <- Reduce(`:`, years)

# coerce to "Date"
from <- ISOdate(years, 5L, 2L, tz = "Etc/GMT-1")
to <- ISOdate(years, 10L, 30L, tz = "Etc/GMT-1")

# this logical index keeps only the dates between May, 2nd and Nov 1st.
keep <- data.frame(from, to) |>
  apply(1L, \(x) x[1L] <= mydf$data_POSIX & mydf$data_POSIX <= x[2L]) |>
  rowSums() > 0L

mydf[keep, , drop = FALSE]



Hope this helps,

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.


[R] add only the 1st of May with POSIXct

2024-05-28 Thread Stefano Sofia
Dear R-list users,

>From an initial and a final date I create a sequence of days using POSIXct.

If this interval covers all or only in part the months from May to October, I 
need to get rid of the days from the 2nd of May to the 31st of October:


a <- as.POSIXct("2002-11-01", format = "%Y-%m-%d", tz="Etc/GMT-1")

b <- as.POSIXct("2004-06-01", format = "%Y-%m-%d", tz="Etc/GMT-1")

mydf <- data.frame(data_POSIX=seq(as.POSIXct(paste(format(a, "%Y-%m-%d"), 
"09:00:00", sep=""), format="%Y-%m-%d %H:%M:%S", tz="Etc/GMT-1"), 
as.POSIXct(paste(format(b, "%Y-%m-%d"), "09:00:00", sep=""), format="%Y-%m-%d 
%H:%M:%S", tz="Etc/GMT-1"), by="1 day"))


If I execute

as.data.frame(mydf[format(mydf$data_POSIX,"%m") %in% c("11", "12", "01", "02", 
"03", "04"), ])

the interval will be

from 2002-11-01 09:00:00 to 2003-04-30 09:00:00

and from 2003-11-01 09:00:00 to 2004-04-30 09:00:00


but I need also 2003-05-01 09:00:00 and 2004-05-01 09:00:00


How can I solve this problem?


Thank you for your attention and your help

Stefano



 (oo)
--oOO--( )--OOo--
Stefano Sofia PhD
Civil Protection - Marche Region - Italy
Meteo Section
Snow Section
Via del Colle Ameno 5
60126 Torrette di Ancona, Ancona (AN)
Uff: +39 071 806 7743
E-mail: stefano.so...@regione.marche.it
---Oo-oO



AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere 
informazioni confidenziali, pertanto � destinato solo a persone autorizzate 
alla ricezione. I messaggi di posta elettronica per i client di Regione Marche 
possono contenere informazioni confidenziali e con privilegi legali. Se non si 
� il destinatario specificato, non leggere, copiare, inoltrare o archiviare 
questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al 
mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi 
dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed 
urgenza, la risposta al presente messaggio di posta elettronica pu� essere 
visionata da persone estranee al destinatario.
IMPORTANT NOTICE: This e-mail message is intended to be received only by 
persons entitled to receive the confidential information it may contain. E-mail 
messages to clients of Regione Marche may contain information that is 
confidential and legally privileged. Please do not read, copy, forward, or 
store this message unless you are an intended recipient of it. If you have 
received this message in error, please forward it to the sender and delete it 
completely from your computer system.

[[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] Can someone please have a look at my query on stackoverflow ?

2024-05-28 Thread Ashim Kapoor
Dear Uwe and others,

Here is my query:

I am looking for a function which can:-

take a seasonal ARMA model

and return :-

the spectrum of the seasonal ARMA model.

I have seen:

library(astsa)
?arma.spec

However it's a bit clumsy to use arma.spec when my model has seasonal
ar / ma terms.

For example (from the help page of arma.spec) we have that, we may
compute the spectrum of a seasonal AR model like this:

Notice: How we have a seasonal AR term of order one,
which is being fed to arma.spec by converting the seasonal lag to a
non-seasonal lag:

arma.spec(ar=c(rep(0,11),.4), ma=.5, col=5, lwd=3, frequency=12)

I will illustrate my difficulty as follows:

> plot(AirPassengers)
> auto.arima(log(AirPassengers))
Series: log(AirPassengers)
ARIMA(0,1,1)(0,1,1)[12]

Coefficients:
  ma1 sma1
  -0.4018  -0.5569
s.e.   0.0896   0.0731

sigma^2 = 0.001371:  log likelihood = 244.7
AIC=-483.4   AICc=-483.21   BIC=-474.77

I do not know how to programmatically feed the above model to arma.spec.

I have tried:

auto.arima(log(AirPassengers))$coef
arma.spec(auto.arima(log(AirPassengers))$coef,frequency=12)

I manually convert the seasonal MA to non-seasonal MA model and give
it to arma.spec and I get a different picture.

arma.spec(ma=c(-.4,rep(0,10),-.55))

Hence I conclude that arma.spec does not understand seasonal models.

Query : How can I conveniently plot the spectrum of a seasonal ARMA process ?

Note : I wonder if there is a library which converts seasonal model to
non-seasonal model which perhaps can then be used with arma.spec.

Many thanks,
Ashim

On Tue, May 28, 2024 at 12:28 PM Uwe Ligges
 wrote:
>
>
>
> On 28.05.2024 06:41, Ashim Kapoor wrote:
> > Dear Sir,
> >
> > OK. I will migrate this query to stats.stackexchange.com.
>
> In any case, if you ask on the list, the question should be on the list.
> Personally, I do read mails, but rather not websites.
>
> Best,
> Uwe Ligges
>
>
>
>
>
>
> > Best,
> > Ashim
> >
> >
> > On Mon, May 27, 2024 at 8:28 PM David Winsemius  
> > wrote:
> >>
> >> If I had seen that post before it got a bounty, I would have voted to 
> >> migrate it to https://stats.stackexchange.com since it is a request for 
> >> advice on methods as well as an implicit request for a package 
> >> recommendation.
> >>
> >> —
> >> David
> >> Sent from my iPhone
> >>
> >>> On May 27, 2024, at 5:40 AM, Ashim Kapoor  wrote:
> >>>
> >>> Dear experts,
> >>>
> >>> I am having difficulty with computing spectrum of seasonal ARMA models.
> >>>
> >>> My query is posted here :
> >>>
> >>> https://stackoverflow.com/questions/78526800/computing-the-spectrum-of-a-seasonal-model-in-r
> >>>
> >>> Will be grateful if someone has a look at it and responds.
> >>>
> >>> Many thanks,
> >>> Ashim.
> >>>
> >>> [[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@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] Can someone please have a look at my query on stackoverflow ?

2024-05-28 Thread Uwe Ligges



On 28.05.2024 06:41, Ashim Kapoor wrote:

Dear Sir,

OK. I will migrate this query to stats.stackexchange.com.


In any case, if you ask on the list, the question should be on the list.
Personally, I do read mails, but rather not websites.

Best,
Uwe Ligges







Best,
Ashim


On Mon, May 27, 2024 at 8:28 PM David Winsemius  wrote:


If I had seen that post before it got a bounty, I would have voted to migrate 
it to https://stats.stackexchange.com since it is a request for advice on 
methods as well as an implicit request for a package recommendation.

—
David
Sent from my iPhone


On May 27, 2024, at 5:40 AM, Ashim Kapoor  wrote:

Dear experts,

I am having difficulty with computing spectrum of seasonal ARMA models.

My query is posted here :

https://stackoverflow.com/questions/78526800/computing-the-spectrum-of-a-seasonal-model-in-r

Will be grateful if someone has a look at it and responds.

Many thanks,
Ashim.

[[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@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] Can someone please have a look at my query on stackoverflow ?

2024-05-27 Thread Ashim Kapoor
Dear Sir,

OK. I will migrate this query to stats.stackexchange.com.

Best,
Ashim


On Mon, May 27, 2024 at 8:28 PM David Winsemius  wrote:
>
> If I had seen that post before it got a bounty, I would have voted to migrate 
> it to https://stats.stackexchange.com since it is a request for advice on 
> methods as well as an implicit request for a package recommendation.
>
> —
> David
> Sent from my iPhone
>
> > On May 27, 2024, at 5:40 AM, Ashim Kapoor  wrote:
> >
> > Dear experts,
> >
> > I am having difficulty with computing spectrum of seasonal ARMA models.
> >
> > My query is posted here :
> >
> > https://stackoverflow.com/questions/78526800/computing-the-spectrum-of-a-seasonal-model-in-r
> >
> > Will be grateful if someone has a look at it and responds.
> >
> > Many thanks,
> > Ashim.
> >
> >[[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] Issues with R's forecast function

2024-05-27 Thread Paul Bernal
Dear Sarah,

I installed the latest R version available (4.4.0), installed the forecast
package and related packages from scratch and the issue was resolved.

Kind regards,
Paul

El lun, 27 may 2024 a las 13:51, Sarah Goslee ()
escribió:

> Hi Paul,
>
> Looking at this, you aren't running the most recent version of forecast.
>
> If I were having a problem of this sort, I'd update R (if you can),
> run update.packages() and then try again with a minimal set of
> packages. As one of the other responses suggested, you probably have
> mismatched versions of packages with dependencies.
>
> Sarah
>
> On Mon, May 27, 2024 at 2:48 PM Paul Bernal 
> wrote:
> >
> > Dear Sarah,
> >
> > Here is the sessionInfo() output, I forgot to include it in my reply.
> >
> > sessionInfo()
> > R version 4.3.2 (2023-10-31 ucrt)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 11 x64 (build 22631)
> >
> > Matrix products: default
> >
> >
> > locale:
> > [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United
> States.utf8
> > [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
> > [5] LC_TIME=English_United States.utf8
> >
> > time zone: America/Bogota
> > tzcode source: internal
> >
> > attached base packages:
> >  [1] parallel  grid  stats4stats graphics  grDevices utils
>datasets  methods   base
> >
> > other attached packages:
> >  [1] mvgam_1.1.1insight_0.19.7
>  marginaleffects_0.20.1 brms_2.21.0
> >  [5] mgcv_1.9-0 nlme_3.1-163   gbm_2.1.9
>   yardstick_1.3.1
> >  [9] workflowsets_1.1.0 workflows_1.1.4tune_1.2.1
>  rsample_1.2.1
> > [13] recipes_1.0.10 parsnip_1.2.1  modeldata_1.3.0
>   infer_1.0.7
> > [17] dials_1.2.1scales_1.3.0   broom_1.0.5
>   tidymodels_1.2.0
> > [21] ggthemes_5.1.0 janitor_2.2.0  tictoc_1.2.1
>  Ckmeans.1d.dp_4.3.5
> > [25] magrittr_2.0.3 data.table_1.14.10 reticulate_1.34.0
>   tensorflow_2.15.0
> > [29] keras_2.13.0   matlabr_1.5.2  R.matlab_3.7.0
>  distrMod_2.9.1
> > [33] RandVar_1.2.3  distrEx_2.9.2  distr_2.9.3
>   sfsmisc_1.1-17
> > [37] startupmsg_0.9.6.1 qcc_2.7pdp_0.8.1
>   doParallel_1.0.17
> > [41] iterators_1.0.14   foreach_1.5.2  tsintermittent_1.10
>   ivreg_0.6-2
> > [45] vars_1.6-0 urca_1.3-3 strucchange_1.5-3
>   Amelia_1.8.1
> > [49] Rcpp_1.0.12VIM_6.2.2  colorspace_2.1-0
>  mi_1.1
> > [53] Hmisc_5.1-1missForest_1.5 mice_3.16.0
>   gghighlight_0.4.1
> > [57] caret_6.0-94   lattice_0.21-9 xgboost_1.7.7.1
>   smooth_4.0.0
> > [61] e1071_1.7-14   greybox_2.0.0  rio_1.0.1
>   fitdistrplus_1.1-11
> > [65] AER_1.2-12 survival_3.5-7 sandwich_3.1-0
>  lmtest_0.9-40
> > [69] zoo_1.8-12 car_3.1-2  carData_3.0-5
>   forcats_1.0.0
> > [73] stringr_1.5.1  purrr_1.0.2readr_2.1.5
>   tidyr_1.3.1
> > [77] tibble_3.2.1   tidyverse_2.0.0dplyr_1.1.4
>   Metrics_0.1.4
> > [81] corrgram_1.14  corrplot_0.92  readxl_1.4.3
>  glmnet_4.1-8
> > [85] Matrix_1.6-1.1 MASS_7.3-60.0.1actuar_3.3-4
>  neuralnet_1.44.2
> > [89] nnfor_0.9.9generics_0.1.3 ggplot2_3.5.1
>   lubridate_1.9.3
> > [93] tseries_0.10-55forecast_8.21.1
> >
> > loaded via a namespace (and not attached):
> >   [1] matrixStats_1.3.0DiceDesign_1.10  httr_1.4.7
>  RColorBrewer_1.1-3   tools_4.3.2
> >   [6] doRNG_1.8.6  backports_1.4.1  utf8_1.2.4
>  R6_2.5.1 jomo_2.7-6
> >  [11] withr_3.0.0  sp_2.1-3 Brobdingnag_1.2-9
> gridExtra_2.3cli_3.6.2
> >  [16] labeling_0.4.3   tsutils_0.9.4mvtnorm_1.2-4
> robustbase_0.99-2randomForest_4.7-1.1
> >  [21] proxy_0.4-27 QuickJSR_1.1.3   StanHeaders_2.32.7
>  foreign_0.8-85   R.utils_2.12.3
> >  [26] parallelly_1.36.0scoringRules_1.1.1   itertools_0.1-3
> TTR_0.24.4   rstudioapi_0.16.0
> >  [31] shape_1.4.6  distributional_0.4.0 inline_0.3.19
> loo_2.7.0fansi_1.0.6
> >  [36] abind_1.4-5  R.methodsS3_1.8.2lifecycle_1.0.4
> multcomp_1.4-25  whisker_0.4.1
> >  [41] snakecase_0.11.1 crayon_1.5.2 mitml_0.4-5
> zeallot_0.1.0pillar_1.9.0
> >  [46] knitr_1.45   boot_1.3-28.1estimability_1.4.1
>  future.apply_1.11.1  codetools_0.2-19
> >  [51] pan_1.9  glue_1.7.0   vcd_1.4-12
>  vctrs_0.6.5  png_0.1-8
> >  [56] Rdpack_2.6   cellranger_1.1.0 gtable_0.3.4
>  gower_1.0.1  xfun_0.41
> >  [61] rbibutils_2.2.16 prodlim_2023.08.28   MAPA_2.0.6
>  pracma_2.4.4 uroot_2.1-3
> >  [66] coda_0.19-4.1timeDate_4032.109hardhat_1.3.1
> lava_1.7.3   statmod_1.5.0
> >  [71] TH.data_1.1-2ipred_0.9-14 xts_0.13.1
>  

Re: [R] Issues with R's forecast function

2024-05-27 Thread Paul Bernal
Hi Sarah,

I ran update.packages, reloaded the forecast package, but kept on getting
the same errors. I am going to install the latest R version (4.4.0), as I
was using version 4.3.2 and reinstall the package.


Cheers,
Paul

El lun, 27 may 2024 a las 13:51, Sarah Goslee ()
escribió:

> Hi Paul,
>
> Looking at this, you aren't running the most recent version of forecast.
>
> If I were having a problem of this sort, I'd update R (if you can),
> run update.packages() and then try again with a minimal set of
> packages. As one of the other responses suggested, you probably have
> mismatched versions of packages with dependencies.
>
> Sarah
>
> On Mon, May 27, 2024 at 2:48 PM Paul Bernal 
> wrote:
> >
> > Dear Sarah,
> >
> > Here is the sessionInfo() output, I forgot to include it in my reply.
> >
> > sessionInfo()
> > R version 4.3.2 (2023-10-31 ucrt)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 11 x64 (build 22631)
> >
> > Matrix products: default
> >
> >
> > locale:
> > [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United
> States.utf8
> > [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
> > [5] LC_TIME=English_United States.utf8
> >
> > time zone: America/Bogota
> > tzcode source: internal
> >
> > attached base packages:
> >  [1] parallel  grid  stats4stats graphics  grDevices utils
>datasets  methods   base
> >
> > other attached packages:
> >  [1] mvgam_1.1.1insight_0.19.7
>  marginaleffects_0.20.1 brms_2.21.0
> >  [5] mgcv_1.9-0 nlme_3.1-163   gbm_2.1.9
>   yardstick_1.3.1
> >  [9] workflowsets_1.1.0 workflows_1.1.4tune_1.2.1
>  rsample_1.2.1
> > [13] recipes_1.0.10 parsnip_1.2.1  modeldata_1.3.0
>   infer_1.0.7
> > [17] dials_1.2.1scales_1.3.0   broom_1.0.5
>   tidymodels_1.2.0
> > [21] ggthemes_5.1.0 janitor_2.2.0  tictoc_1.2.1
>  Ckmeans.1d.dp_4.3.5
> > [25] magrittr_2.0.3 data.table_1.14.10 reticulate_1.34.0
>   tensorflow_2.15.0
> > [29] keras_2.13.0   matlabr_1.5.2  R.matlab_3.7.0
>  distrMod_2.9.1
> > [33] RandVar_1.2.3  distrEx_2.9.2  distr_2.9.3
>   sfsmisc_1.1-17
> > [37] startupmsg_0.9.6.1 qcc_2.7pdp_0.8.1
>   doParallel_1.0.17
> > [41] iterators_1.0.14   foreach_1.5.2  tsintermittent_1.10
>   ivreg_0.6-2
> > [45] vars_1.6-0 urca_1.3-3 strucchange_1.5-3
>   Amelia_1.8.1
> > [49] Rcpp_1.0.12VIM_6.2.2  colorspace_2.1-0
>  mi_1.1
> > [53] Hmisc_5.1-1missForest_1.5 mice_3.16.0
>   gghighlight_0.4.1
> > [57] caret_6.0-94   lattice_0.21-9 xgboost_1.7.7.1
>   smooth_4.0.0
> > [61] e1071_1.7-14   greybox_2.0.0  rio_1.0.1
>   fitdistrplus_1.1-11
> > [65] AER_1.2-12 survival_3.5-7 sandwich_3.1-0
>  lmtest_0.9-40
> > [69] zoo_1.8-12 car_3.1-2  carData_3.0-5
>   forcats_1.0.0
> > [73] stringr_1.5.1  purrr_1.0.2readr_2.1.5
>   tidyr_1.3.1
> > [77] tibble_3.2.1   tidyverse_2.0.0dplyr_1.1.4
>   Metrics_0.1.4
> > [81] corrgram_1.14  corrplot_0.92  readxl_1.4.3
>  glmnet_4.1-8
> > [85] Matrix_1.6-1.1 MASS_7.3-60.0.1actuar_3.3-4
>  neuralnet_1.44.2
> > [89] nnfor_0.9.9generics_0.1.3 ggplot2_3.5.1
>   lubridate_1.9.3
> > [93] tseries_0.10-55forecast_8.21.1
> >
> > loaded via a namespace (and not attached):
> >   [1] matrixStats_1.3.0DiceDesign_1.10  httr_1.4.7
>  RColorBrewer_1.1-3   tools_4.3.2
> >   [6] doRNG_1.8.6  backports_1.4.1  utf8_1.2.4
>  R6_2.5.1 jomo_2.7-6
> >  [11] withr_3.0.0  sp_2.1-3 Brobdingnag_1.2-9
> gridExtra_2.3cli_3.6.2
> >  [16] labeling_0.4.3   tsutils_0.9.4mvtnorm_1.2-4
> robustbase_0.99-2randomForest_4.7-1.1
> >  [21] proxy_0.4-27 QuickJSR_1.1.3   StanHeaders_2.32.7
>  foreign_0.8-85   R.utils_2.12.3
> >  [26] parallelly_1.36.0scoringRules_1.1.1   itertools_0.1-3
> TTR_0.24.4   rstudioapi_0.16.0
> >  [31] shape_1.4.6  distributional_0.4.0 inline_0.3.19
> loo_2.7.0fansi_1.0.6
> >  [36] abind_1.4-5  R.methodsS3_1.8.2lifecycle_1.0.4
> multcomp_1.4-25  whisker_0.4.1
> >  [41] snakecase_0.11.1 crayon_1.5.2 mitml_0.4-5
> zeallot_0.1.0pillar_1.9.0
> >  [46] knitr_1.45   boot_1.3-28.1estimability_1.4.1
>  future.apply_1.11.1  codetools_0.2-19
> >  [51] pan_1.9  glue_1.7.0   vcd_1.4-12
>  vctrs_0.6.5  png_0.1-8
> >  [56] Rdpack_2.6   cellranger_1.1.0 gtable_0.3.4
>  gower_1.0.1  xfun_0.41
> >  [61] rbibutils_2.2.16 prodlim_2023.08.28   MAPA_2.0.6
>  pracma_2.4.4 uroot_2.1-3
> >  [66] coda_0.19-4.1timeDate_4032.109hardhat_1.3.1
> lava_1.7.3   statmod_1.5.0
> >  [71] 

Re: [R] Issues with R's forecast function

2024-05-27 Thread Sarah Goslee
Hi Paul,

Looking at this, you aren't running the most recent version of forecast.

If I were having a problem of this sort, I'd update R (if you can),
run update.packages() and then try again with a minimal set of
packages. As one of the other responses suggested, you probably have
mismatched versions of packages with dependencies.

Sarah

On Mon, May 27, 2024 at 2:48 PM Paul Bernal  wrote:
>
> Dear Sarah,
>
> Here is the sessionInfo() output, I forgot to include it in my reply.
>
> sessionInfo()
> R version 4.3.2 (2023-10-31 ucrt)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 11 x64 (build 22631)
>
> Matrix products: default
>
>
> locale:
> [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8
> [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
> [5] LC_TIME=English_United States.utf8
>
> time zone: America/Bogota
> tzcode source: internal
>
> attached base packages:
>  [1] parallel  grid  stats4stats graphics  grDevices utils 
> datasets  methods   base
>
> other attached packages:
>  [1] mvgam_1.1.1insight_0.19.7 marginaleffects_0.20.1 
> brms_2.21.0
>  [5] mgcv_1.9-0 nlme_3.1-163   gbm_2.1.9  
> yardstick_1.3.1
>  [9] workflowsets_1.1.0 workflows_1.1.4tune_1.2.1 
> rsample_1.2.1
> [13] recipes_1.0.10 parsnip_1.2.1  modeldata_1.3.0
> infer_1.0.7
> [17] dials_1.2.1scales_1.3.0   broom_1.0.5
> tidymodels_1.2.0
> [21] ggthemes_5.1.0 janitor_2.2.0  tictoc_1.2.1   
> Ckmeans.1d.dp_4.3.5
> [25] magrittr_2.0.3 data.table_1.14.10 reticulate_1.34.0  
> tensorflow_2.15.0
> [29] keras_2.13.0   matlabr_1.5.2  R.matlab_3.7.0 
> distrMod_2.9.1
> [33] RandVar_1.2.3  distrEx_2.9.2  distr_2.9.3
> sfsmisc_1.1-17
> [37] startupmsg_0.9.6.1 qcc_2.7pdp_0.8.1  
> doParallel_1.0.17
> [41] iterators_1.0.14   foreach_1.5.2  tsintermittent_1.10
> ivreg_0.6-2
> [45] vars_1.6-0 urca_1.3-3 strucchange_1.5-3  
> Amelia_1.8.1
> [49] Rcpp_1.0.12VIM_6.2.2  colorspace_2.1-0   
> mi_1.1
> [53] Hmisc_5.1-1missForest_1.5 mice_3.16.0
> gghighlight_0.4.1
> [57] caret_6.0-94   lattice_0.21-9 xgboost_1.7.7.1
> smooth_4.0.0
> [61] e1071_1.7-14   greybox_2.0.0  rio_1.0.1  
> fitdistrplus_1.1-11
> [65] AER_1.2-12 survival_3.5-7 sandwich_3.1-0 
> lmtest_0.9-40
> [69] zoo_1.8-12 car_3.1-2  carData_3.0-5  
> forcats_1.0.0
> [73] stringr_1.5.1  purrr_1.0.2readr_2.1.5
> tidyr_1.3.1
> [77] tibble_3.2.1   tidyverse_2.0.0dplyr_1.1.4
> Metrics_0.1.4
> [81] corrgram_1.14  corrplot_0.92  readxl_1.4.3   
> glmnet_4.1-8
> [85] Matrix_1.6-1.1 MASS_7.3-60.0.1actuar_3.3-4   
> neuralnet_1.44.2
> [89] nnfor_0.9.9generics_0.1.3 ggplot2_3.5.1  
> lubridate_1.9.3
> [93] tseries_0.10-55forecast_8.21.1
>
> loaded via a namespace (and not attached):
>   [1] matrixStats_1.3.0DiceDesign_1.10  httr_1.4.7   
> RColorBrewer_1.1-3   tools_4.3.2
>   [6] doRNG_1.8.6  backports_1.4.1  utf8_1.2.4   R6_2.5.1 
> jomo_2.7-6
>  [11] withr_3.0.0  sp_2.1-3 Brobdingnag_1.2-9
> gridExtra_2.3cli_3.6.2
>  [16] labeling_0.4.3   tsutils_0.9.4mvtnorm_1.2-4
> robustbase_0.99-2randomForest_4.7-1.1
>  [21] proxy_0.4-27 QuickJSR_1.1.3   StanHeaders_2.32.7   
> foreign_0.8-85   R.utils_2.12.3
>  [26] parallelly_1.36.0scoringRules_1.1.1   itertools_0.1-3  
> TTR_0.24.4   rstudioapi_0.16.0
>  [31] shape_1.4.6  distributional_0.4.0 inline_0.3.19
> loo_2.7.0fansi_1.0.6
>  [36] abind_1.4-5  R.methodsS3_1.8.2lifecycle_1.0.4  
> multcomp_1.4-25  whisker_0.4.1
>  [41] snakecase_0.11.1 crayon_1.5.2 mitml_0.4-5  
> zeallot_0.1.0pillar_1.9.0
>  [46] knitr_1.45   boot_1.3-28.1estimability_1.4.1   
> future.apply_1.11.1  codetools_0.2-19
>  [51] pan_1.9  glue_1.7.0   vcd_1.4-12   
> vctrs_0.6.5  png_0.1-8
>  [56] Rdpack_2.6   cellranger_1.1.0 gtable_0.3.4 
> gower_1.0.1  xfun_0.41
>  [61] rbibutils_2.2.16 prodlim_2023.08.28   MAPA_2.0.6   
> pracma_2.4.4 uroot_2.1-3
>  [66] coda_0.19-4.1timeDate_4032.109hardhat_1.3.1
> lava_1.7.3   statmod_1.5.0
>  [71] TH.data_1.1-2ipred_0.9-14 xts_0.13.1   
> rstan_2.32.6 tensorA_0.36.2.1
>  [76] rpart_4.1.21 nnet_7.3-19

Re: [R] Issues with R's forecast function

2024-05-27 Thread Paul Bernal
Dear Sarah,

Here is the sessionInfo() output, I forgot to include it in my reply.

sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United
States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C

[5] LC_TIME=English_United States.utf8

time zone: America/Bogota
tzcode source: internal

attached base packages:
 [1] parallel  grid  stats4stats graphics  grDevices utils
datasets  methods   base

other attached packages:
 [1] mvgam_1.1.1insight_0.19.7 marginaleffects_0.20.1
brms_2.21.0
 [5] mgcv_1.9-0 nlme_3.1-163   gbm_2.1.9
 yardstick_1.3.1
 [9] workflowsets_1.1.0 workflows_1.1.4tune_1.2.1
rsample_1.2.1
[13] recipes_1.0.10 parsnip_1.2.1  modeldata_1.3.0
 infer_1.0.7
[17] dials_1.2.1scales_1.3.0   broom_1.0.5
 tidymodels_1.2.0
[21] ggthemes_5.1.0 janitor_2.2.0  tictoc_1.2.1
Ckmeans.1d.dp_4.3.5
[25] magrittr_2.0.3 data.table_1.14.10 reticulate_1.34.0
 tensorflow_2.15.0
[29] keras_2.13.0   matlabr_1.5.2  R.matlab_3.7.0
distrMod_2.9.1
[33] RandVar_1.2.3  distrEx_2.9.2  distr_2.9.3
 sfsmisc_1.1-17
[37] startupmsg_0.9.6.1 qcc_2.7pdp_0.8.1
 doParallel_1.0.17
[41] iterators_1.0.14   foreach_1.5.2  tsintermittent_1.10
 ivreg_0.6-2
[45] vars_1.6-0 urca_1.3-3 strucchange_1.5-3
 Amelia_1.8.1
[49] Rcpp_1.0.12VIM_6.2.2  colorspace_2.1-0
mi_1.1
[53] Hmisc_5.1-1missForest_1.5 mice_3.16.0
 gghighlight_0.4.1
[57] caret_6.0-94   lattice_0.21-9 xgboost_1.7.7.1
 smooth_4.0.0
[61] e1071_1.7-14   greybox_2.0.0  rio_1.0.1
 fitdistrplus_1.1-11
[65] AER_1.2-12 survival_3.5-7 sandwich_3.1-0
lmtest_0.9-40
[69] zoo_1.8-12 car_3.1-2  carData_3.0-5
 forcats_1.0.0
[73] stringr_1.5.1  purrr_1.0.2readr_2.1.5
 tidyr_1.3.1
[77] tibble_3.2.1   tidyverse_2.0.0dplyr_1.1.4
 Metrics_0.1.4
[81] corrgram_1.14  corrplot_0.92  readxl_1.4.3
glmnet_4.1-8
[85] Matrix_1.6-1.1 MASS_7.3-60.0.1actuar_3.3-4
neuralnet_1.44.2
[89] nnfor_0.9.9generics_0.1.3 ggplot2_3.5.1
 lubridate_1.9.3
[93] tseries_0.10-55forecast_8.21.1

loaded via a namespace (and not attached):
  [1] matrixStats_1.3.0DiceDesign_1.10  httr_1.4.7
RColorBrewer_1.1-3   tools_4.3.2
  [6] doRNG_1.8.6  backports_1.4.1  utf8_1.2.4
R6_2.5.1 jomo_2.7-6
 [11] withr_3.0.0  sp_2.1-3 Brobdingnag_1.2-9
 gridExtra_2.3cli_3.6.2
 [16] labeling_0.4.3   tsutils_0.9.4mvtnorm_1.2-4
 robustbase_0.99-2randomForest_4.7-1.1
 [21] proxy_0.4-27 QuickJSR_1.1.3   StanHeaders_2.32.7
foreign_0.8-85   R.utils_2.12.3
 [26] parallelly_1.36.0scoringRules_1.1.1   itertools_0.1-3
 TTR_0.24.4   rstudioapi_0.16.0
 [31] shape_1.4.6  distributional_0.4.0 inline_0.3.19
 loo_2.7.0fansi_1.0.6
 [36] abind_1.4-5  R.methodsS3_1.8.2lifecycle_1.0.4
 multcomp_1.4-25  whisker_0.4.1
 [41] snakecase_0.11.1 crayon_1.5.2 mitml_0.4-5
 zeallot_0.1.0pillar_1.9.0
 [46] knitr_1.45   boot_1.3-28.1estimability_1.4.1
future.apply_1.11.1  codetools_0.2-19
 [51] pan_1.9  glue_1.7.0   vcd_1.4-12
vctrs_0.6.5  png_0.1-8
 [56] Rdpack_2.6   cellranger_1.1.0 gtable_0.3.4
gower_1.0.1  xfun_0.41
 [61] rbibutils_2.2.16 prodlim_2023.08.28   MAPA_2.0.6
pracma_2.4.4 uroot_2.1-3
 [66] coda_0.19-4.1timeDate_4032.109hardhat_1.3.1
 lava_1.7.3   statmod_1.5.0
 [71] TH.data_1.1-2ipred_0.9-14 xts_0.13.1
rstan_2.32.6 tensorA_0.36.2.1
 [76] rpart_4.1.21 nnet_7.3-19  tidyselect_1.2.0
emmeans_1.10.0   compiler_4.3.2
 [81] curl_5.2.0   ahead_0.10.0 htmlTable_2.4.2
 posterior_1.5.0  checkmate_2.3.1
 [86] DEoptimR_1.1-3   fracdiff_1.5-2   quadprog_1.5-8
tfruns_1.5.1 digest_0.6.34
 [91] minqa_1.2.6  rmarkdown_2.25   htmltools_0.5.7
 pkgconfig_2.0.3  base64enc_0.1-3
 [96] lme4_1.1-35.1lhs_1.1.6fastmap_1.1.1
 rlang_1.1.3  htmlwidgets_1.6.4
[101] quantmod_0.4.26  farver_2.1.1 jsonlite_1.8.8
ModelMetrics_1.2.2.2 R.oo_1.26.0
[106] Formula_1.2-5bayesplot_1.11.1 texreg_1.39.3
 GPfit_1.0-8  munsell_0.5.0
[111] furrr_0.3.1  stringi_1.8.3pROC_1.18.5
 pkgbuild_1.4.3   plyr_1.8.9
[116] expint_0.1-8 listenv_0.9.1splines_4.3.2
 hms_1.1.3ranger_0.16.0
[121] rngtools_1.5.2   reshape2_1.4.4   rstantools_2.4.0
evaluate_0.23

Re: [R] Issues with R's forecast function

2024-05-27 Thread Paul Bernal
Thanks for the kind feedback. I will go ahead and update the packages and
see what happens. I will keep you posted.

Cheers,

Paul

El lun, 27 may 2024 a las 13:51, Sarah Goslee ()
escribió:

> Hi Paul,
>
> Looking at this, you aren't running the most recent version of forecast.
>
> If I were having a problem of this sort, I'd update R (if you can),
> run update.packages() and then try again with a minimal set of
> packages. As one of the other responses suggested, you probably have
> mismatched versions of packages with dependencies.
>
> Sarah
>
> On Mon, May 27, 2024 at 2:48 PM Paul Bernal 
> wrote:
> >
> > Dear Sarah,
> >
> > Here is the sessionInfo() output, I forgot to include it in my reply.
> >
> > sessionInfo()
> > R version 4.3.2 (2023-10-31 ucrt)
> > Platform: x86_64-w64-mingw32/x64 (64-bit)
> > Running under: Windows 11 x64 (build 22631)
> >
> > Matrix products: default
> >
> >
> > locale:
> > [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United
> States.utf8
> > [3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
> > [5] LC_TIME=English_United States.utf8
> >
> > time zone: America/Bogota
> > tzcode source: internal
> >
> > attached base packages:
> >  [1] parallel  grid  stats4stats graphics  grDevices utils
>datasets  methods   base
> >
> > other attached packages:
> >  [1] mvgam_1.1.1insight_0.19.7
>  marginaleffects_0.20.1 brms_2.21.0
> >  [5] mgcv_1.9-0 nlme_3.1-163   gbm_2.1.9
>   yardstick_1.3.1
> >  [9] workflowsets_1.1.0 workflows_1.1.4tune_1.2.1
>  rsample_1.2.1
> > [13] recipes_1.0.10 parsnip_1.2.1  modeldata_1.3.0
>   infer_1.0.7
> > [17] dials_1.2.1scales_1.3.0   broom_1.0.5
>   tidymodels_1.2.0
> > [21] ggthemes_5.1.0 janitor_2.2.0  tictoc_1.2.1
>  Ckmeans.1d.dp_4.3.5
> > [25] magrittr_2.0.3 data.table_1.14.10 reticulate_1.34.0
>   tensorflow_2.15.0
> > [29] keras_2.13.0   matlabr_1.5.2  R.matlab_3.7.0
>  distrMod_2.9.1
> > [33] RandVar_1.2.3  distrEx_2.9.2  distr_2.9.3
>   sfsmisc_1.1-17
> > [37] startupmsg_0.9.6.1 qcc_2.7pdp_0.8.1
>   doParallel_1.0.17
> > [41] iterators_1.0.14   foreach_1.5.2  tsintermittent_1.10
>   ivreg_0.6-2
> > [45] vars_1.6-0 urca_1.3-3 strucchange_1.5-3
>   Amelia_1.8.1
> > [49] Rcpp_1.0.12VIM_6.2.2  colorspace_2.1-0
>  mi_1.1
> > [53] Hmisc_5.1-1missForest_1.5 mice_3.16.0
>   gghighlight_0.4.1
> > [57] caret_6.0-94   lattice_0.21-9 xgboost_1.7.7.1
>   smooth_4.0.0
> > [61] e1071_1.7-14   greybox_2.0.0  rio_1.0.1
>   fitdistrplus_1.1-11
> > [65] AER_1.2-12 survival_3.5-7 sandwich_3.1-0
>  lmtest_0.9-40
> > [69] zoo_1.8-12 car_3.1-2  carData_3.0-5
>   forcats_1.0.0
> > [73] stringr_1.5.1  purrr_1.0.2readr_2.1.5
>   tidyr_1.3.1
> > [77] tibble_3.2.1   tidyverse_2.0.0dplyr_1.1.4
>   Metrics_0.1.4
> > [81] corrgram_1.14  corrplot_0.92  readxl_1.4.3
>  glmnet_4.1-8
> > [85] Matrix_1.6-1.1 MASS_7.3-60.0.1actuar_3.3-4
>  neuralnet_1.44.2
> > [89] nnfor_0.9.9generics_0.1.3 ggplot2_3.5.1
>   lubridate_1.9.3
> > [93] tseries_0.10-55forecast_8.21.1
> >
> > loaded via a namespace (and not attached):
> >   [1] matrixStats_1.3.0DiceDesign_1.10  httr_1.4.7
>  RColorBrewer_1.1-3   tools_4.3.2
> >   [6] doRNG_1.8.6  backports_1.4.1  utf8_1.2.4
>  R6_2.5.1 jomo_2.7-6
> >  [11] withr_3.0.0  sp_2.1-3 Brobdingnag_1.2-9
> gridExtra_2.3cli_3.6.2
> >  [16] labeling_0.4.3   tsutils_0.9.4mvtnorm_1.2-4
> robustbase_0.99-2randomForest_4.7-1.1
> >  [21] proxy_0.4-27 QuickJSR_1.1.3   StanHeaders_2.32.7
>  foreign_0.8-85   R.utils_2.12.3
> >  [26] parallelly_1.36.0scoringRules_1.1.1   itertools_0.1-3
> TTR_0.24.4   rstudioapi_0.16.0
> >  [31] shape_1.4.6  distributional_0.4.0 inline_0.3.19
> loo_2.7.0fansi_1.0.6
> >  [36] abind_1.4-5  R.methodsS3_1.8.2lifecycle_1.0.4
> multcomp_1.4-25  whisker_0.4.1
> >  [41] snakecase_0.11.1 crayon_1.5.2 mitml_0.4-5
> zeallot_0.1.0pillar_1.9.0
> >  [46] knitr_1.45   boot_1.3-28.1estimability_1.4.1
>  future.apply_1.11.1  codetools_0.2-19
> >  [51] pan_1.9  glue_1.7.0   vcd_1.4-12
>  vctrs_0.6.5  png_0.1-8
> >  [56] Rdpack_2.6   cellranger_1.1.0 gtable_0.3.4
>  gower_1.0.1  xfun_0.41
> >  [61] rbibutils_2.2.16 prodlim_2023.08.28   MAPA_2.0.6
>  pracma_2.4.4 uroot_2.1-3
> >  [66] coda_0.19-4.1timeDate_4032.109hardhat_1.3.1
> lava_1.7.3   statmod_1.5.0
> >  [71] TH.data_1.1-2ipred_0.9-14 xts_0.13.1
>  rstan_2.32.6 tensorA_0.36.2.1
> >  [76] 

Re: [R] Issues with R's forecast function

2024-05-27 Thread Paul Bernal
Dear Sarah,

Thank you for kindly reaching back. I did load the package, which makes
this issue really odd. I ran the same model about a week ago and everything
was working to perfection.

Best regards,

Paul

El lun, 27 may 2024 a las 12:15, Sarah Goslee ()
escribió:

> Hi Paul,
>
> It looks like you're using the forecast package, right? Have you loaded it?
>
> What is the output of sessionInfo() ?
>
> It looks to me like you either haven't loaded the needed packages, or
> there's some kind of conflict. Your examples don't give me errors when
> I run them, so we need more information.
>
> Sarah
>
>
>
> On Mon, May 27, 2024 at 12:25 PM Paul Bernal 
> wrote:
> >
> > Dear all,
> >
> > I am currently using R 4.3.2 and the data I am working with is the
> > following:
> >
> > ts_ingresos_reservas= ts(ingresos_reservaciones$RESERVACIONES, start
> =
> > c(1996,11), end = c(2024,4), frequency = 12)
> >
> > structure(c(11421.54, 388965.46, 254774.78, 228066.02, 254330.44,
> > 272561.38, 377802.1, 322810.02, 490996.48, 581998.3, 557009.96,
> > 619568.56, 578893.9, 938765.36, 566374.38, 582678.46, 931035.04,
> > 855661.3, 839760.22, 745521.4, 816424.96, 899616.64, 921462.88,
> > 942825, 1145845.74, 1260554.36, 1003983.5, 855516.22, 1273913.68,
> > 1204626.54, 1034135.18, 904641.14, 1003094.3, 1073084.74, 928515.64,
> > 854864.4, 928927.48, 1076922.34, 1031265.04, 1043755.7, 1238565.12,
> > 1343609.54, 1405817.92, 1243192.86, 1235505.44, 1280514.56, 1314029.08,
> > 1562841.28, 1405662.96, 1315083.12, 1363980.02, 1126195.72, 1542338.98,
> > 1577437.94, 1474855.98, 1287170.56, 1404118.3, 1528979.66, 1286690.34,
> > 1544495.16, 1527018.22, 1462908.72, 1682739.76, 1439027.72, 1531060.44,
> > 1793606.88, 1835054.26, 1616743.96, 1779745.24, 1772628, 1736200.18,
> > 1736792.72, 1835714.4, 2031238.04, 1937816.14, 1942473.52, 2131666.68,
> > 2099279.26, 1939093.78, 2135231.54, 2187614.52, 2150766.28, 2179862.62,
> > 2467330.32, 2421603.34, 2585889.54, 4489381.11, 4915745.55, 5313521.43,
> > 5185438.48, 5346116.46, 4507418.33, 5028489.81, 4931266.16, 5529189.46,
> > 5470279.34, 5354912.01, 5937028.11, 6422819.13, 5989941.72, 6549070.26,
> > 6710738.34, 6745949.78, 6345832.78, 6656868.36, 6836903.51, 6456545.14,
> > 7039815.42, 7288665.89, 7372047.96, 8116822.48, 7318300.42, 8742429.72,
> > 8780764.44, 8984081.22, 8221966.77, 8594896.69, 8319125.91, 8027227.8,
> > 9241082.48, 8765799.78, 9360643.68, 9384937.59, 8237007.99, 9251122.07,
> > 8703017.5, 9004464.9, 8099029.39, 8883214.99, 8360815.05, 8408082.51,
> > 9126756.64, 8610501.05, 9109139.05, 8904803.6, 12766215.9, 14055014.03,
> > 12789865.86, 13251587.21, 13731917.7, 14925330.72, 14295954.4,
> > 13346681.84, 14233732.03, 12743141.34, 13742979.78, 11770238.46,
> > 11655300, 12327000, 10096000, 8712000, 6742500, 7199000, 5459000,
> > 4442000, 7448500, 6322500, 6030500, 5521000, 4752000, 6248500,
> > 5233000, 7440500, 5604500, 6516500, 6001500, 9364500, 14528500,
> > 14076000, 11671500, 11778500, 13902500, 13073000, 11097000, 9547500,
> > 10255000, 8986500, 10807000, 10031500, 9847000, 12216500, 11648500,
> > 13106000, 10856500, 9679500, 9986500, 8947500, 11105500, 9950500,
> > 10922000, 9031500, 9720500, 9709000, 9470500, 9316000, 9884500,
> > 9067500, 8985000, 10888000, 9676500, 10047000, 8952000, 10191500,
> > 12763000, 14885000, 13592000, 13364500, 11924000, 13888000, 12833500,
> > 12239000, 945, 10028000, 10171500, 13648000, 13989000, 14488000,
> > 14195000, 12800500, 12703000, 1530, 14963000, 15049000, 13513000,
> > 14155500, 14047500, 12923500, 13298500, 12814000, 13492000, 14405500,
> > 12597500, 14486000, 12103500, 12815000, 11912000, 12353500, 12718500,
> > 12972000, 12499000, 13683500, 17437000, 18147000, 17008000, 1718,
> > 1616, 15096500, 13707000, 16254000, 14673500, 13661500, 17014000,
> > 16104500, 17113000, 17200500, 15304500, 17131000, 16551000, 16356000,
> > 14702000, 14488000, 14902500, 14435500, 15598500, 14754500, 15015000,
> > 16444500, 1462, 15701000, 14211000, 15243000, 13898000, 14889000,
> > 18571000, 15950500, 20171000, 20096000, 19647000, 20394500, 18213000,
> > 18714500, 18301000, 14581000, 12333000, 14482500, 17538500, 17480500,
> > 19574000, 18464500, 1941, 19013000, 16523500, 18755000, 18194000,
> > 18918000, 34130500, 34421500, 36727000, 33406500, 34779500, 35916500,
> > 36193000, 35878500, 32274500, 35097000, 34319500, 36459000, 35222500,
> > 35972000, 37382000, 34482000, 35776000, 3533, 3599, 34788500,
> > 32173500, 34879000, 33195500, 35243500, 33581000, 35632000, 32716000,
> > 33966500, 31778000, 28164500, 25729500, 23034500, 24427500, 26506500,
> > 26655500), tsp = c(1996.833, 2024.25, 12), class = "ts")
> >
> > Now that I have my time series data, I tried generating forecasts with
> the
> > following code:
> >
> > ingresos_reservas_arimamod  = auto.arima(ts_ingresos_reservas)
> > ingresos_reservas_arimafor  = forecast(ingresos_reservas_arimamod, h
> =
> > 151)
> >
> > 

Re: [R] Issues with R's forecast function

2024-05-27 Thread Jeff Newmiller via R-help
You have completely ignored mentioning what R contributed packages you may have 
been using in "back when it worked". It is critical that you keep track of 
which "library" statements are necessary to run your code, if any.

I searched for "R usemethod forecast" in Google and this [1] came up. Perhaps 
it is helpful? It seems that some people have had problems when they updated 
some but not all of their R packages.

[1] 
https://stackoverflow.com/questions/70283794/forecasting-in-r-usemethod-model-function-error

On May 27, 2024 9:24:50 AM PDT, Paul Bernal  wrote:
>Dear all,
>
>I am currently using R 4.3.2 and the data I am working with is the
>following:
>
>ts_ingresos_reservas= ts(ingresos_reservaciones$RESERVACIONES, start =
>c(1996,11), end = c(2024,4), frequency = 12)
>
>structure(c(11421.54, 388965.46, 254774.78, 228066.02, 254330.44,
>272561.38, 377802.1, 322810.02, 490996.48, 581998.3, 557009.96,
>619568.56, 578893.9, 938765.36, 566374.38, 582678.46, 931035.04,
>855661.3, 839760.22, 745521.4, 816424.96, 899616.64, 921462.88,
>942825, 1145845.74, 1260554.36, 1003983.5, 855516.22, 1273913.68,
>1204626.54, 1034135.18, 904641.14, 1003094.3, 1073084.74, 928515.64,
>854864.4, 928927.48, 1076922.34, 1031265.04, 1043755.7, 1238565.12,
>1343609.54, 1405817.92, 1243192.86, 1235505.44, 1280514.56, 1314029.08,
>1562841.28, 1405662.96, 1315083.12, 1363980.02, 1126195.72, 1542338.98,
>1577437.94, 1474855.98, 1287170.56, 1404118.3, 1528979.66, 1286690.34,
>1544495.16, 1527018.22, 1462908.72, 1682739.76, 1439027.72, 1531060.44,
>1793606.88, 1835054.26, 1616743.96, 1779745.24, 1772628, 1736200.18,
>1736792.72, 1835714.4, 2031238.04, 1937816.14, 1942473.52, 2131666.68,
>2099279.26, 1939093.78, 2135231.54, 2187614.52, 2150766.28, 2179862.62,
>2467330.32, 2421603.34, 2585889.54, 4489381.11, 4915745.55, 5313521.43,
>5185438.48, 5346116.46, 4507418.33, 5028489.81, 4931266.16, 5529189.46,
>5470279.34, 5354912.01, 5937028.11, 6422819.13, 5989941.72, 6549070.26,
>6710738.34, 6745949.78, 6345832.78, 6656868.36, 6836903.51, 6456545.14,
>7039815.42, 7288665.89, 7372047.96, 8116822.48, 7318300.42, 8742429.72,
>8780764.44, 8984081.22, 8221966.77, 8594896.69, 8319125.91, 8027227.8,
>9241082.48, 8765799.78, 9360643.68, 9384937.59, 8237007.99, 9251122.07,
>8703017.5, 9004464.9, 8099029.39, 8883214.99, 8360815.05, 8408082.51,
>9126756.64, 8610501.05, 9109139.05, 8904803.6, 12766215.9, 14055014.03,
>12789865.86, 13251587.21, 13731917.7, 14925330.72, 14295954.4,
>13346681.84, 14233732.03, 12743141.34, 13742979.78, 11770238.46,
>11655300, 12327000, 10096000, 8712000, 6742500, 7199000, 5459000,
>4442000, 7448500, 6322500, 6030500, 5521000, 4752000, 6248500,
>5233000, 7440500, 5604500, 6516500, 6001500, 9364500, 14528500,
>14076000, 11671500, 11778500, 13902500, 13073000, 11097000, 9547500,
>10255000, 8986500, 10807000, 10031500, 9847000, 12216500, 11648500,
>13106000, 10856500, 9679500, 9986500, 8947500, 11105500, 9950500,
>10922000, 9031500, 9720500, 9709000, 9470500, 9316000, 9884500,
>9067500, 8985000, 10888000, 9676500, 10047000, 8952000, 10191500,
>12763000, 14885000, 13592000, 13364500, 11924000, 13888000, 12833500,
>12239000, 945, 10028000, 10171500, 13648000, 13989000, 14488000,
>14195000, 12800500, 12703000, 1530, 14963000, 15049000, 13513000,
>14155500, 14047500, 12923500, 13298500, 12814000, 13492000, 14405500,
>12597500, 14486000, 12103500, 12815000, 11912000, 12353500, 12718500,
>12972000, 12499000, 13683500, 17437000, 18147000, 17008000, 1718,
>1616, 15096500, 13707000, 16254000, 14673500, 13661500, 17014000,
>16104500, 17113000, 17200500, 15304500, 17131000, 16551000, 16356000,
>14702000, 14488000, 14902500, 14435500, 15598500, 14754500, 15015000,
>16444500, 1462, 15701000, 14211000, 15243000, 13898000, 14889000,
>18571000, 15950500, 20171000, 20096000, 19647000, 20394500, 18213000,
>18714500, 18301000, 14581000, 12333000, 14482500, 17538500, 17480500,
>19574000, 18464500, 1941, 19013000, 16523500, 18755000, 18194000,
>18918000, 34130500, 34421500, 36727000, 33406500, 34779500, 35916500,
>36193000, 35878500, 32274500, 35097000, 34319500, 36459000, 35222500,
>35972000, 37382000, 34482000, 35776000, 3533, 3599, 34788500,
>32173500, 34879000, 33195500, 35243500, 33581000, 35632000, 32716000,
>33966500, 31778000, 28164500, 25729500, 23034500, 24427500, 26506500,
>26655500), tsp = c(1996.833, 2024.25, 12), class = "ts")
>
>Now that I have my time series data, I tried generating forecasts with the
>following code:
>
>ingresos_reservas_arimamod  = auto.arima(ts_ingresos_reservas)
>ingresos_reservas_arimafor  = forecast(ingresos_reservas_arimamod, h =
>151)
>
>ingresos_reservas_holtwintersmod = HoltWinters(ts_ingresos_reservas)
>ingresos_reservas_holtwintersfor =
>forecast(ingresos_reservas_holtwintersmod, h = 151)
>
>ingresos_reservas_etsmod= ets(ts_ingresos_reservas)
>ingresos_reservas_etsfor= forecast(ingresos_reservas_etsmod, level
>= c(90,99), h = 151)
>

Re: [R] Issues with R's forecast function

2024-05-27 Thread Sarah Goslee
Hi Paul,

It looks like you're using the forecast package, right? Have you loaded it?

What is the output of sessionInfo() ?

It looks to me like you either haven't loaded the needed packages, or
there's some kind of conflict. Your examples don't give me errors when
I run them, so we need more information.

Sarah



On Mon, May 27, 2024 at 12:25 PM Paul Bernal  wrote:
>
> Dear all,
>
> I am currently using R 4.3.2 and the data I am working with is the
> following:
>
> ts_ingresos_reservas= ts(ingresos_reservaciones$RESERVACIONES, start =
> c(1996,11), end = c(2024,4), frequency = 12)
>
> structure(c(11421.54, 388965.46, 254774.78, 228066.02, 254330.44,
> 272561.38, 377802.1, 322810.02, 490996.48, 581998.3, 557009.96,
> 619568.56, 578893.9, 938765.36, 566374.38, 582678.46, 931035.04,
> 855661.3, 839760.22, 745521.4, 816424.96, 899616.64, 921462.88,
> 942825, 1145845.74, 1260554.36, 1003983.5, 855516.22, 1273913.68,
> 1204626.54, 1034135.18, 904641.14, 1003094.3, 1073084.74, 928515.64,
> 854864.4, 928927.48, 1076922.34, 1031265.04, 1043755.7, 1238565.12,
> 1343609.54, 1405817.92, 1243192.86, 1235505.44, 1280514.56, 1314029.08,
> 1562841.28, 1405662.96, 1315083.12, 1363980.02, 1126195.72, 1542338.98,
> 1577437.94, 1474855.98, 1287170.56, 1404118.3, 1528979.66, 1286690.34,
> 1544495.16, 1527018.22, 1462908.72, 1682739.76, 1439027.72, 1531060.44,
> 1793606.88, 1835054.26, 1616743.96, 1779745.24, 1772628, 1736200.18,
> 1736792.72, 1835714.4, 2031238.04, 1937816.14, 1942473.52, 2131666.68,
> 2099279.26, 1939093.78, 2135231.54, 2187614.52, 2150766.28, 2179862.62,
> 2467330.32, 2421603.34, 2585889.54, 4489381.11, 4915745.55, 5313521.43,
> 5185438.48, 5346116.46, 4507418.33, 5028489.81, 4931266.16, 5529189.46,
> 5470279.34, 5354912.01, 5937028.11, 6422819.13, 5989941.72, 6549070.26,
> 6710738.34, 6745949.78, 6345832.78, 6656868.36, 6836903.51, 6456545.14,
> 7039815.42, 7288665.89, 7372047.96, 8116822.48, 7318300.42, 8742429.72,
> 8780764.44, 8984081.22, 8221966.77, 8594896.69, 8319125.91, 8027227.8,
> 9241082.48, 8765799.78, 9360643.68, 9384937.59, 8237007.99, 9251122.07,
> 8703017.5, 9004464.9, 8099029.39, 8883214.99, 8360815.05, 8408082.51,
> 9126756.64, 8610501.05, 9109139.05, 8904803.6, 12766215.9, 14055014.03,
> 12789865.86, 13251587.21, 13731917.7, 14925330.72, 14295954.4,
> 13346681.84, 14233732.03, 12743141.34, 13742979.78, 11770238.46,
> 11655300, 12327000, 10096000, 8712000, 6742500, 7199000, 5459000,
> 4442000, 7448500, 6322500, 6030500, 5521000, 4752000, 6248500,
> 5233000, 7440500, 5604500, 6516500, 6001500, 9364500, 14528500,
> 14076000, 11671500, 11778500, 13902500, 13073000, 11097000, 9547500,
> 10255000, 8986500, 10807000, 10031500, 9847000, 12216500, 11648500,
> 13106000, 10856500, 9679500, 9986500, 8947500, 11105500, 9950500,
> 10922000, 9031500, 9720500, 9709000, 9470500, 9316000, 9884500,
> 9067500, 8985000, 10888000, 9676500, 10047000, 8952000, 10191500,
> 12763000, 14885000, 13592000, 13364500, 11924000, 13888000, 12833500,
> 12239000, 945, 10028000, 10171500, 13648000, 13989000, 14488000,
> 14195000, 12800500, 12703000, 1530, 14963000, 15049000, 13513000,
> 14155500, 14047500, 12923500, 13298500, 12814000, 13492000, 14405500,
> 12597500, 14486000, 12103500, 12815000, 11912000, 12353500, 12718500,
> 12972000, 12499000, 13683500, 17437000, 18147000, 17008000, 1718,
> 1616, 15096500, 13707000, 16254000, 14673500, 13661500, 17014000,
> 16104500, 17113000, 17200500, 15304500, 17131000, 16551000, 16356000,
> 14702000, 14488000, 14902500, 14435500, 15598500, 14754500, 15015000,
> 16444500, 1462, 15701000, 14211000, 15243000, 13898000, 14889000,
> 18571000, 15950500, 20171000, 20096000, 19647000, 20394500, 18213000,
> 18714500, 18301000, 14581000, 12333000, 14482500, 17538500, 17480500,
> 19574000, 18464500, 1941, 19013000, 16523500, 18755000, 18194000,
> 18918000, 34130500, 34421500, 36727000, 33406500, 34779500, 35916500,
> 36193000, 35878500, 32274500, 35097000, 34319500, 36459000, 35222500,
> 35972000, 37382000, 34482000, 35776000, 3533, 3599, 34788500,
> 32173500, 34879000, 33195500, 35243500, 33581000, 35632000, 32716000,
> 33966500, 31778000, 28164500, 25729500, 23034500, 24427500, 26506500,
> 26655500), tsp = c(1996.833, 2024.25, 12), class = "ts")
>
> Now that I have my time series data, I tried generating forecasts with the
> following code:
>
> ingresos_reservas_arimamod  = auto.arima(ts_ingresos_reservas)
> ingresos_reservas_arimafor  = forecast(ingresos_reservas_arimamod, h =
> 151)
>
> ingresos_reservas_holtwintersmod = HoltWinters(ts_ingresos_reservas)
> ingresos_reservas_holtwintersfor =
> forecast(ingresos_reservas_holtwintersmod, h = 151)
>
> ingresos_reservas_etsmod= ets(ts_ingresos_reservas)
> ingresos_reservas_etsfor= forecast(ingresos_reservas_etsmod, level
> = c(90,99), h = 151)
>
> ingresos_reservas_batsmod   = bats(ts_ingresos_reservas)
> ingresos_reservas_batsfor   = 

[R] Issues with R's forecast function

2024-05-27 Thread Paul Bernal
Dear all,

I am currently using R 4.3.2 and the data I am working with is the
following:

ts_ingresos_reservas= ts(ingresos_reservaciones$RESERVACIONES, start =
c(1996,11), end = c(2024,4), frequency = 12)

structure(c(11421.54, 388965.46, 254774.78, 228066.02, 254330.44,
272561.38, 377802.1, 322810.02, 490996.48, 581998.3, 557009.96,
619568.56, 578893.9, 938765.36, 566374.38, 582678.46, 931035.04,
855661.3, 839760.22, 745521.4, 816424.96, 899616.64, 921462.88,
942825, 1145845.74, 1260554.36, 1003983.5, 855516.22, 1273913.68,
1204626.54, 1034135.18, 904641.14, 1003094.3, 1073084.74, 928515.64,
854864.4, 928927.48, 1076922.34, 1031265.04, 1043755.7, 1238565.12,
1343609.54, 1405817.92, 1243192.86, 1235505.44, 1280514.56, 1314029.08,
1562841.28, 1405662.96, 1315083.12, 1363980.02, 1126195.72, 1542338.98,
1577437.94, 1474855.98, 1287170.56, 1404118.3, 1528979.66, 1286690.34,
1544495.16, 1527018.22, 1462908.72, 1682739.76, 1439027.72, 1531060.44,
1793606.88, 1835054.26, 1616743.96, 1779745.24, 1772628, 1736200.18,
1736792.72, 1835714.4, 2031238.04, 1937816.14, 1942473.52, 2131666.68,
2099279.26, 1939093.78, 2135231.54, 2187614.52, 2150766.28, 2179862.62,
2467330.32, 2421603.34, 2585889.54, 4489381.11, 4915745.55, 5313521.43,
5185438.48, 5346116.46, 4507418.33, 5028489.81, 4931266.16, 5529189.46,
5470279.34, 5354912.01, 5937028.11, 6422819.13, 5989941.72, 6549070.26,
6710738.34, 6745949.78, 6345832.78, 6656868.36, 6836903.51, 6456545.14,
7039815.42, 7288665.89, 7372047.96, 8116822.48, 7318300.42, 8742429.72,
8780764.44, 8984081.22, 8221966.77, 8594896.69, 8319125.91, 8027227.8,
9241082.48, 8765799.78, 9360643.68, 9384937.59, 8237007.99, 9251122.07,
8703017.5, 9004464.9, 8099029.39, 8883214.99, 8360815.05, 8408082.51,
9126756.64, 8610501.05, 9109139.05, 8904803.6, 12766215.9, 14055014.03,
12789865.86, 13251587.21, 13731917.7, 14925330.72, 14295954.4,
13346681.84, 14233732.03, 12743141.34, 13742979.78, 11770238.46,
11655300, 12327000, 10096000, 8712000, 6742500, 7199000, 5459000,
4442000, 7448500, 6322500, 6030500, 5521000, 4752000, 6248500,
5233000, 7440500, 5604500, 6516500, 6001500, 9364500, 14528500,
14076000, 11671500, 11778500, 13902500, 13073000, 11097000, 9547500,
10255000, 8986500, 10807000, 10031500, 9847000, 12216500, 11648500,
13106000, 10856500, 9679500, 9986500, 8947500, 11105500, 9950500,
10922000, 9031500, 9720500, 9709000, 9470500, 9316000, 9884500,
9067500, 8985000, 10888000, 9676500, 10047000, 8952000, 10191500,
12763000, 14885000, 13592000, 13364500, 11924000, 13888000, 12833500,
12239000, 945, 10028000, 10171500, 13648000, 13989000, 14488000,
14195000, 12800500, 12703000, 1530, 14963000, 15049000, 13513000,
14155500, 14047500, 12923500, 13298500, 12814000, 13492000, 14405500,
12597500, 14486000, 12103500, 12815000, 11912000, 12353500, 12718500,
12972000, 12499000, 13683500, 17437000, 18147000, 17008000, 1718,
1616, 15096500, 13707000, 16254000, 14673500, 13661500, 17014000,
16104500, 17113000, 17200500, 15304500, 17131000, 16551000, 16356000,
14702000, 14488000, 14902500, 14435500, 15598500, 14754500, 15015000,
16444500, 1462, 15701000, 14211000, 15243000, 13898000, 14889000,
18571000, 15950500, 20171000, 20096000, 19647000, 20394500, 18213000,
18714500, 18301000, 14581000, 12333000, 14482500, 17538500, 17480500,
19574000, 18464500, 1941, 19013000, 16523500, 18755000, 18194000,
18918000, 34130500, 34421500, 36727000, 33406500, 34779500, 35916500,
36193000, 35878500, 32274500, 35097000, 34319500, 36459000, 35222500,
35972000, 37382000, 34482000, 35776000, 3533, 3599, 34788500,
32173500, 34879000, 33195500, 35243500, 33581000, 35632000, 32716000,
33966500, 31778000, 28164500, 25729500, 23034500, 24427500, 26506500,
26655500), tsp = c(1996.833, 2024.25, 12), class = "ts")

Now that I have my time series data, I tried generating forecasts with the
following code:

ingresos_reservas_arimamod  = auto.arima(ts_ingresos_reservas)
ingresos_reservas_arimafor  = forecast(ingresos_reservas_arimamod, h =
151)

ingresos_reservas_holtwintersmod = HoltWinters(ts_ingresos_reservas)
ingresos_reservas_holtwintersfor =
forecast(ingresos_reservas_holtwintersmod, h = 151)

ingresos_reservas_etsmod= ets(ts_ingresos_reservas)
ingresos_reservas_etsfor= forecast(ingresos_reservas_etsmod, level
= c(90,99), h = 151)

ingresos_reservas_batsmod   = bats(ts_ingresos_reservas)
ingresos_reservas_batsfor   = forecast(ingresos_reservas_batsmod, level
= c(90,99), h = 151, robust = TRUE)

ingresos_reservas_tbatsmod  = tbats(ts_ingresos_reservas)
ingresos_reservas_tbatsfor  = forecast(ingresos_reservas_tbatsmod,
level = c(90,99), h = 151, robust = TRUE)

ingresos_reservas_nnetarmod   = nnetar(ts_ingresos_reservas)
ingresos_reservas_nnetarfor   = forecast(ingresos_reservas_nnetarmod,
PI = TRUE, h = 151, robust = TRUE)

This code used to work, but now, I keep getting the following error:
Error in UseMethod("forecast", object) :
  no 

Re: [R] Can someone please have a look at my query on stackoverflow ?

2024-05-27 Thread David Winsemius
If I had seen that post before it got a bounty, I would have voted to migrate 
it to https://stats.stackexchange.com since it is a request for advice on 
methods as well as an implicit request for a package recommendation. 

— 
David
Sent from my iPhone

> On May 27, 2024, at 5:40 AM, Ashim Kapoor  wrote:
> 
> Dear experts,
> 
> I am having difficulty with computing spectrum of seasonal ARMA models.
> 
> My query is posted here :
> 
> https://stackoverflow.com/questions/78526800/computing-the-spectrum-of-a-seasonal-model-in-r
> 
> Will be grateful if someone has a look at it and responds.
> 
> Many thanks,
> Ashim.
> 
>[[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] Can someone please have a look at my query on stackoverflow ?

2024-05-27 Thread Ashim Kapoor
Dear experts,

I am having difficulty with computing spectrum of seasonal ARMA models.

My query is posted here :

https://stackoverflow.com/questions/78526800/computing-the-spectrum-of-a-seasonal-model-in-r

Will be grateful if someone has a look at it and responds.

Many thanks,
Ashim.

[[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] dplyr, group_by and selective action according to each group

2024-05-26 Thread Laurent Rhelp

Thank you for your answers.

Endeed, if I can do the treatment row by row, which is the case, I can 
use a condition statement with mutate. Instead of ifelse I found the 
case_when statement in order to take into account the three groups.


And the list of functions  with the relevant names is a very good idea I 
will use.


Best regards

Laurent


Le 25/05/2024 à 04:56, avi.e.gr...@gmail.com a écrit :

Although there may well be many ways to do what is being asked for with the 
tidyverse, sometimes things are simple enough to do the old-fashioned way.

The request seems to have been to do something to all rows in ONE specific 
group but was phrased in the sense of wanting to know which group your 
functionality is being called in.

What grouping gains you is more worthwhile if you are interested in doing 
things groupwise across all groups such as getting a count of how many are in 
each group or some vectorized operation like getting the mean or SD of a column 
or whatever.

But for the purposes mentioned here, consider a lower-tech alternative such as 
this.

Instead of group_by(gr) which is a trivial group, consider using other dplyr predicates 
like "mutate" to trigger on all rows that meet a condition like gr having a 
value of 3 as in:

mutate(DATAFRAME, result=ifelse(gr==3, f(), whatever)

The above is not a full-blown example but something similar can be tailored to do quite a bit. As an example, 
if gr specified whether the measure in another column was in meters or feet, you could convert that other 
column to meters if gr was == "feet" and on a second line of code, convert the "gr" value 
in that row to now say "meters" so that in the end, they are all in meters.

Of course if you have a more complex use case such as grouping by multiple 
variables, and having the same (or different) logic for multiple values, this 
can get more complex.  But if you want to get working code sooner, consider 
using methods you understand rather than seeing if someone in the tidyverse 
universe has already created exactly what you want.

There are things you can access such as if you want to keep only the first 
record in each group, you can filter by row_number==1, or use the do() function.

The dplyr (and related packages) keep evolving and functionality may be 
deprecated, but check this page for ideas:

https://dplyr.tidyverse.org/reference/group_data.html

Some of those may give you access to which rows are in each group and to other 
ways to approach the problem somewhat from outside after grouping so you can 
apply your function to the subset of the rows you want.






-Original Message-
From: R-help  On Behalf Of Bert Gunter
Sent: Friday, May 24, 2024 6:52 PM
To: Laurent Rhelp 
Cc: r-help@r-project.org
Subject: Re: [R] dplyr, group_by and selective action according to each group

Laurent:
As I don't use dplyr, this won't help you, but I hope you and others may
find it entertaining anyway.

If I understand you correctly (and ignore this if I have not), there are a
ton of ways to do this in base R, including using switch() along the lines
you noted in your post. However, when the functions get sufficiently
complicated or numerous, it may be useful to store them in a named list and
use the names to call them in some sort of loop. Here I have just used your
anonymous functions in the list, but of course you could have used already
existing functions instead.

## your example
df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))

## function list with the relevant names
funcs <- list(gr1 = \(x)x+1, gr2 = \(x)0, gr3 = \(x)x+2)
## Alternatively you could do this if you had many different functions:
## funcs <- list(\(x)x+1, \(x)0,  \(x)x+2)
## names(funcs) <- sort(unique(df_test$gr))
## note that sort() is unnecessary in your example, but I think that it
would
## be helpful if you had a lot of different groups and corresponding
functions
## to track.

##Now the little loop to call the functions
df_test$x1 <- with(df_test,{
for(nm in names(funcs))
   x1[gr == nm] <- funcs[[nm]](x1[gr == nm])
x1}
)

#
Note that the above uses one of the features that I really like about R --
functions are full first class objects that can be thrown around and
handled just like any other "variables" . So funcs[[nm]](whatever) seems to
me to be a natural way to choose and call the function you want. You may
disagree, of course.

Caveat: I make no claims about the efficiency or lack thereof of the above.

Cheers,
Bert

On Fri, May 24, 2024 at 12:35 PM Laurent Rhelp  wrote:


Dear RHelp-list,

 Using dplyr and the group_by approach on a dataframe, I want to be
able to apply a specific action according to the group name. The code
bellow works, but I am not able to write it in a more esthetic way using
dplyr. Can somebody help me to find a better solution ?

Thank you

Best regards

Laurent

df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))
df_test  <-  

Re: [R] dplyr, group_by and selective action according to each group

2024-05-24 Thread avi.e.gross
Although there may well be many ways to do what is being asked for with the 
tidyverse, sometimes things are simple enough to do the old-fashioned way.

The request seems to have been to do something to all rows in ONE specific 
group but was phrased in the sense of wanting to know which group your 
functionality is being called in.

What grouping gains you is more worthwhile if you are interested in doing 
things groupwise across all groups such as getting a count of how many are in 
each group or some vectorized operation like getting the mean or SD of a column 
or whatever.

But for the purposes mentioned here, consider a lower-tech alternative such as 
this.

Instead of group_by(gr) which is a trivial group, consider using other dplyr 
predicates like "mutate" to trigger on all rows that meet a condition like gr 
having a value of 3 as in:

mutate(DATAFRAME, result=ifelse(gr==3, f(), whatever)

The above is not a full-blown example but something similar can be tailored to 
do quite a bit. As an example, if gr specified whether the measure in another 
column was in meters or feet, you could convert that other column to meters if 
gr was == "feet" and on a second line of code, convert the "gr" value in that 
row to now say "meters" so that in the end, they are all in meters. 

Of course if you have a more complex use case such as grouping by multiple 
variables, and having the same (or different) logic for multiple values, this 
can get more complex.  But if you want to get working code sooner, consider 
using methods you understand rather than seeing if someone in the tidyverse 
universe has already created exactly what you want.

There are things you can access such as if you want to keep only the first 
record in each group, you can filter by row_number==1, or use the do() function.

The dplyr (and related packages) keep evolving and functionality may be 
deprecated, but check this page for ideas:

https://dplyr.tidyverse.org/reference/group_data.html

Some of those may give you access to which rows are in each group and to other 
ways to approach the problem somewhat from outside after grouping so you can 
apply your function to the subset of the rows you want.






-Original Message-
From: R-help  On Behalf Of Bert Gunter
Sent: Friday, May 24, 2024 6:52 PM
To: Laurent Rhelp 
Cc: r-help@r-project.org
Subject: Re: [R] dplyr, group_by and selective action according to each group

Laurent:
As I don't use dplyr, this won't help you, but I hope you and others may
find it entertaining anyway.

If I understand you correctly (and ignore this if I have not), there are a
ton of ways to do this in base R, including using switch() along the lines
you noted in your post. However, when the functions get sufficiently
complicated or numerous, it may be useful to store them in a named list and
use the names to call them in some sort of loop. Here I have just used your
anonymous functions in the list, but of course you could have used already
existing functions instead.

## your example
df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))

## function list with the relevant names
funcs <- list(gr1 = \(x)x+1, gr2 = \(x)0, gr3 = \(x)x+2)
## Alternatively you could do this if you had many different functions:
## funcs <- list(\(x)x+1, \(x)0,  \(x)x+2)
## names(funcs) <- sort(unique(df_test$gr))
## note that sort() is unnecessary in your example, but I think that it
would
## be helpful if you had a lot of different groups and corresponding
functions
## to track.

##Now the little loop to call the functions
df_test$x1 <- with(df_test,{
   for(nm in names(funcs))
  x1[gr == nm] <- funcs[[nm]](x1[gr == nm])
   x1}
)

#
Note that the above uses one of the features that I really like about R --
functions are full first class objects that can be thrown around and
handled just like any other "variables" . So funcs[[nm]](whatever) seems to
me to be a natural way to choose and call the function you want. You may
disagree, of course.

Caveat: I make no claims about the efficiency or lack thereof of the above.

Cheers,
Bert

On Fri, May 24, 2024 at 12:35 PM Laurent Rhelp  wrote:

> Dear RHelp-list,
>
> Using dplyr and the group_by approach on a dataframe, I want to be
> able to apply a specific action according to the group name. The code
> bellow works, but I am not able to write it in a more esthetic way using
> dplyr. Can somebody help me to find a better solution ?
>
> Thank you
>
> Best regards
>
> Laurent
>
> df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))
> df_test  <-  df_test %>% dplyr::group_by(gr) %>%
>group_modify(.f=function(.x,.y){
>  print(paste0("Nom du groupe : ",.y[["gr"]]))
>  switch(as.character(.y[["gr"]])
> , gr1 = {.x[,"x1"] <- .x[,"x1"]+1}
> , gr2 = {.x[,"x1"] <- 0}
> , gr3 = {.x[,"x1"] <- .x[,"x1"]+2}
> , {stop(paste0('The group ',.y[["gr"]]," is not taken into
> 

Re: [R] dplyr, group_by and selective action according to each group

2024-05-24 Thread Bert Gunter
Laurent:
As I don't use dplyr, this won't help you, but I hope you and others may
find it entertaining anyway.

If I understand you correctly (and ignore this if I have not), there are a
ton of ways to do this in base R, including using switch() along the lines
you noted in your post. However, when the functions get sufficiently
complicated or numerous, it may be useful to store them in a named list and
use the names to call them in some sort of loop. Here I have just used your
anonymous functions in the list, but of course you could have used already
existing functions instead.

## your example
df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))

## function list with the relevant names
funcs <- list(gr1 = \(x)x+1, gr2 = \(x)0, gr3 = \(x)x+2)
## Alternatively you could do this if you had many different functions:
## funcs <- list(\(x)x+1, \(x)0,  \(x)x+2)
## names(funcs) <- sort(unique(df_test$gr))
## note that sort() is unnecessary in your example, but I think that it
would
## be helpful if you had a lot of different groups and corresponding
functions
## to track.

##Now the little loop to call the functions
df_test$x1 <- with(df_test,{
   for(nm in names(funcs))
  x1[gr == nm] <- funcs[[nm]](x1[gr == nm])
   x1}
)

#
Note that the above uses one of the features that I really like about R --
functions are full first class objects that can be thrown around and
handled just like any other "variables" . So funcs[[nm]](whatever) seems to
me to be a natural way to choose and call the function you want. You may
disagree, of course.

Caveat: I make no claims about the efficiency or lack thereof of the above.

Cheers,
Bert

On Fri, May 24, 2024 at 12:35 PM Laurent Rhelp  wrote:

> Dear RHelp-list,
>
> Using dplyr and the group_by approach on a dataframe, I want to be
> able to apply a specific action according to the group name. The code
> bellow works, but I am not able to write it in a more esthetic way using
> dplyr. Can somebody help me to find a better solution ?
>
> Thank you
>
> Best regards
>
> Laurent
>
> df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))
> df_test  <-  df_test %>% dplyr::group_by(gr) %>%
>group_modify(.f=function(.x,.y){
>  print(paste0("Nom du groupe : ",.y[["gr"]]))
>  switch(as.character(.y[["gr"]])
> , gr1 = {.x[,"x1"] <- .x[,"x1"]+1}
> , gr2 = {.x[,"x1"] <- 0}
> , gr3 = {.x[,"x1"] <- .x[,"x1"]+2}
> , {stop(paste0('The group ',.y[["gr"]]," is not taken into
> account"))}
>  )
>  return(.x) }) %>% ungroup()
>
> df_test
>
> __
> 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] dplyr, group_by and selective action according to each group

2024-05-24 Thread Laurent Rhelp

Dear RHelp-list,

   Using dplyr and the group_by approach on a dataframe, I want to be 
able to apply a specific action according to the group name. The code 
bellow works, but I am not able to write it in a more esthetic way using 
dplyr. Can somebody help me to find a better solution ?


Thank you

Best regards

Laurent

df_test <- data.frame( x1=1:9, x2=1:9, gr=rep(paste0("gr",1:3),each=3))
df_test  <-  df_test %>% dplyr::group_by(gr) %>%
  group_modify(.f=function(.x,.y){
    print(paste0("Nom du groupe : ",.y[["gr"]]))
    switch(as.character(.y[["gr"]])
   , gr1 = {.x[,"x1"] <- .x[,"x1"]+1}
   , gr2 = {.x[,"x1"] <- 0}
   , gr3 = {.x[,"x1"] <- .x[,"x1"]+2}
   , {stop(paste0('The group ',.y[["gr"]]," is not taken into 
account"))}

    )
    return(.x) }) %>% ungroup()

df_test

__
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] Regexp pattern but fixed replacement?

2024-05-23 Thread Enrico Schumann
On Thu, 11 Apr 2024, Duncan Murdoch writes:

> I noticed this issue in stringr::str_replace, but it
> also affects sub() in base R.
>
> If the pattern in a call to one of these needs to be a
> regular expression, then backslashes in the replacement
> text are treated specially.
>
> For example,
>
>   gsub("a|b", "\\", "abcdef")
>
> gives "def", not "def" as I wanted.  To get the
> latter, I need to escape the replacement backslashes,
> e.g.
>
>   gsub("a|b", "", "abcdef")
>
> which gives "cdef".
>
> I have two questions:
>
> 1.  Is there a variant on sub or str_replace which
> allows the pattern to be declared as a regular
> expression, but the replacement to be declared as
> fixed?

I realize that this reply is late, but you can use raw
strings for the replacement:

   gsub("a|b", r"(\\)", "abcdef")
   ## [1] "cdef"

which might be easier to read, sometimes.

[...]

-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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, RStudio, and a server for my iPad.

2024-05-21 Thread peter dalgaard
...or look inside the administration interface for your router. Typically 
starts with opening a browser on 192.168.0.1 or 192.168.1.1 (with a password 
that you presumably have from your provider) and going to "Access Control" or 
thereabouts.

-pd

> On 12 Apr 2014, at 20:08 , Viechtbauer Wolfgang (STAT) 
>  wrote:
> 
> You will have to enter the external IP address and then use port forwarding.
> 
> Just google for that term (port forwarding) ... For example:
> 
> http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/
> http://en.wikipedia.org/wiki/Port_forwarding
> 
> Best,
> Wolfgang
> 
> From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf 
> Of John Sorkin [jsor...@grecc.umaryland.edu]
> Sent: Saturday, April 12, 2014 7:37 PM
> To: fransiepansiekever...@gmail.com
> Cc: r-help@r-project.org
> Subject: Re: [R] R, RStudio, and a server for my iPad.
> 
> Grand,
> Thank you. I have been able to use my iPad to connect to a server running 
> RStudio server as described in an earlier email and can use the virtual 
> keyboard, which works but is not convenient as one needs to go from keyboard 
> screen to another.
> My current problem is that while I can get everything to work when my iPad is 
> on my local network, I don't know how to access my server from outside my 
> LAN. I know my server's private IP address I know my cable modem's external 
> IP address, but I have no idea what IP address to enter in my iPad, when my 
> iPad is outside my LAN trying to access my server.
> John
> __
> 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.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] Listing folders on One Drive

2024-05-21 Thread Jorgen Harmse via R-help
I would just use
fi <- file.info(dir(path, recursive=TRUE, include.dirs=TRUE))
path could be the OneDrive directory or Scotland (and is not needed if you're 
already in the directory you want).
Then rownames(subset(fi, isdir)) will contain all the directories. Maybe you 
want to use grep or other machinery to thin it out.

Regards,
Jorgen Harmse.

--


Message: 1
Date: Mon, 20 May 2024 14:36:58 +0100
From: Nick Wray mailto:nickmw...@gmail.com>>
To: r-help@r-project.org 
Subject: [R] Listing folders on One Drive
Message-ID:
mailto:ds4we...@mail.gmail.com>>
Content-Type: text/plain; charset="utf-8"


Hello I have lots of folders of individual Scottish river catchments on my
uni One Drive. Each folder is labelled with the river name eg "Tay" and
they are all in a folder named "Scotland"
I want to list the folders on One Drive so that I can cross check that I
have them all against a list of folders on my laptop.
Can I somehow use list.files() - I've tried various things but none seem to
work...
Any help appreciated
Thanks Nick Wray


[[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] wrtiteBin in conjunction with seek : the position in the file is not good when writing

2024-05-21 Thread Laurent Rhelp
It works !!

Thank you VERY much because I didn't understand the rw argument for the 
seek command and endeed it is explained:

File connections can be open for both writing/appending, in which 
case*R*keeps separate positions for reading and writing. 
Which|seek|refers to can be set by its|rw|argument: the default is the 
last mode (reading or writing) which was used. Most files are only 
opened for reading or writing and so default to that state. If a file is 
open for both reading and writing but has not been used, the default is 
to give the reading position (0).

Best regards

Laurent

Le 21/05/2024 à 12:15, Ivan Krylov a écrit :
> В Tue, 21 May 2024 11:29:33 +0200
> Laurent Rhelp  пишет:
>
>> pos <- seek(con_in,2,origin="start")
>> # We have to repeat the command to return the good amount of read
>> # bytes
>> print(paste0("pos is not equal to 2, pos = ",pos))
> That's because seek() returns the previous position ("before any
> move", the one that the help page calls "current"), not the one after
> the seek. Fortunately, calling seek(origin = "start") twice with the
> same offset doesn't break anything.
>
>> # we are on position 6
>> pos <- seek(con_in,0,origin="current")
> That's strange. You started at offset 2 and read three bytes. You
> should be at offset 5 at this point. For me, seek() returns 5 here, not
> 6.
>
>> bytes = readBin(con=con_in, what="raw",n = 1)
> But after this, we should be on position 6.
>
>> writeBin(  my_string, con=con_in, useBytes = FALSE)
> It's described in help(seek) that R maintains two different pointers
> for reading and writing a file. You have been reading it, advancing the
> read pointer to 6, but the write pointer stayed at offset 0.
>
> Try seek(con_in, seek(con_in, 0, 'current', 'read'), 'start', 'write')
> to set the write pointer to the read pointer before issuing writes.
> This seems to give me the expected result.
>
[[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] wrtiteBin in conjunction with seek : the position in the file is not good when writing

2024-05-21 Thread Ivan Krylov via R-help
В Tue, 21 May 2024 11:29:33 +0200
Laurent Rhelp  пишет:

> pos <- seek(con_in,2,origin="start")
> # We have to repeat the command to return the good amount of read
> # bytes
> print(paste0("pos is not equal to 2, pos = ",pos))

That's because seek() returns the previous position ("before any
move", the one that the help page calls "current"), not the one after
the seek. Fortunately, calling seek(origin = "start") twice with the
same offset doesn't break anything.

> # we are on position 6
> pos <- seek(con_in,0,origin="current")

That's strange. You started at offset 2 and read three bytes. You
should be at offset 5 at this point. For me, seek() returns 5 here, not
6.

> bytes = readBin(con=con_in, what="raw",n = 1)

But after this, we should be on position 6.

> writeBin(  my_string, con=con_in, useBytes = FALSE)

It's described in help(seek) that R maintains two different pointers
for reading and writing a file. You have been reading it, advancing the
read pointer to 6, but the write pointer stayed at offset 0.

Try seek(con_in, seek(con_in, 0, 'current', 'read'), 'start', 'write')
to set the write pointer to the read pointer before issuing writes.
This seems to give me the expected result.

-- 
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] wrtiteBin in conjunction with seek : the position in the file is not good when writing

2024-05-21 Thread Laurent Rhelp

Dear RHelp-list,

 I want to write at a specific position in a file without reading all 
the file
because it is very large and I cannot read it in my RAM. But I miss 
something
about the use of the command writeBin in conjunction with seek. In the 
example bellow the seek
commands works well with the readBin command but not with writeBin, the 
writeBin
command write from the beginning of the file and not from the current 
position

and however in the doculentation it is written:
  If the connection is open it is read/written from its current position.
Thank you
Best regards
Laurent


Here is the tiny example:

The file_test.txt before:
1234567890
1234567890

The file_test.txt after:
 AA AA7890
1234567890

The file should have been like that:
123456 AA AA1234567890

## open the file in read/write mode + binary
fname <- file.path(".","txt","file_test.txt")
con_in <- file(fname,"r+b")
# move on 2 bytes
pos <- seek(con_in,2,origin="start")
# We have to repeat the command to return the good amount of read bytes
print(paste0("pos is not equal to 2, pos = ",pos))
pos <- seek(con_in,2,origin="start")
print(paste0("Now pos is equal to 2, pos = ",pos))

## reading 3 characters
bytes = readBin(con=con_in, what="raw",n = 3)
my_number <- as.numeric(readBin(bytes,"character"))
print(my_number)
# we are on position 6
pos <- seek(con_in,0,origin="current")
print(paste0("pos = ",pos))
bytes = readBin(con=con_in, what="raw",n = 1)
my_number <- as.numeric(readBin(bytes,"character"))
print(my_number)
my_string <- charToRaw(sprintf(paste('%',3,'s',sep=''),"AA"))
writeBin(  my_string, con=con_in, useBytes = FALSE)
writeBin(  my_string, con=con_in, useBytes = FALSE)
close(con_in)

__
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 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] Listing folders on One Drive

2024-05-20 Thread John Fox

Dear Nick,

See list.dirs(), which is documented in the same help file as list.files().

I hope this helps,
 John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://www.john-fox.ca/
--
On 2024-05-20 9:36 a.m., Nick Wray wrote:

[You don't often get email from nickmw...@gmail.com. Learn why this is 
important at https://aka.ms/LearnAboutSenderIdentification ]

Caution: External email.


Hello I have lots of folders of individual Scottish river catchments on my
uni One Drive.  Each folder is labelled with the river name eg "Tay" and
they are all in a folder named "Scotland"
I want to list the folders on One Drive so that I can cross check that I
have them all against a list of folders on my laptop.
Can I somehow use list.files() - I've tried various things but none seem to
work...
Any help appreciated
Thanks Nick Wray

 [[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] Listing folders on One Drive

2024-05-20 Thread avi.e.gross
Nick,

As Jeff said, we don't know what you tried and what did not work.

There are built-in and probably package versions but have you tried
something like list.files()?

You can tweak it to get the files you want by doing something like:

-change directory to HERE
- here.files <- list.files(recursive=TRUE)
- change directory to THERE
- here.files <- list.files(recursive=TRUE)

Now compare what you have in the two places. There are many ways but if all
the files in or, if recursive, deeper, are the same, you have them all. Of
course this does not test to see if the files are identical. Or you could
use sorting and comparing to see if you can isolate what is missing, or use
set operations that test for intersection or something like"

Missing <- setdiff(here.files, there.files)

And in that case, also test the reverse.

The function setequal() test for equality but won't tell you what is
missing.

Obviously, if your method generates full, not relative file names, you could
process the names to remove a fixed prefix.

-Original Message-
From: R-help  On Behalf Of Nick Wray
Sent: Monday, May 20, 2024 9:37 AM
To: r-help@r-project.org
Subject: [R] Listing folders on One Drive

Hello I have lots of folders of individual Scottish river catchments on my
uni One Drive.  Each folder is labelled with the river name eg "Tay" and
they are all in a folder named "Scotland"
I want to list the folders on One Drive so that I can cross check that I
have them all against a list of folders on my laptop.
Can I somehow use list.files() - I've tried various things but none seem to
work...
Any help appreciated
Thanks Nick Wray

[[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] Listing folders on One Drive

2024-05-20 Thread Jeff Newmiller via R-help
What does "doesn't work" mean? What have you tried?

On May 20, 2024 6:36:58 AM PDT, Nick Wray  wrote:
>Hello I have lots of folders of individual Scottish river catchments on my
>uni One Drive.  Each folder is labelled with the river name eg "Tay" and
>they are all in a folder named "Scotland"
>I want to list the folders on One Drive so that I can cross check that I
>have them all against a list of folders on my laptop.
>Can I somehow use list.files() - I've tried various things but none seem to
>work...
>Any help appreciated
>Thanks Nick Wray
>
>   [[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.

-- 
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] Listing folders on One Drive

2024-05-20 Thread Nick Wray
Hello I have lots of folders of individual Scottish river catchments on my
uni One Drive.  Each folder is labelled with the river name eg "Tay" and
they are all in a folder named "Scotland"
I want to list the folders on One Drive so that I can cross check that I
have them all against a list of folders on my laptop.
Can I somehow use list.files() - I've tried various things but none seem to
work...
Any help appreciated
Thanks Nick Wray

[[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] Availability of Sdatasets

2024-05-20 Thread Avro Alo via R-help
>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)

__
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] [External] Re: Removing polygons from shapefile of Scotland and Islands

2024-05-17 Thread Barry Rowlingson
Scotland is the second feature in the UK data, so get it and split this one
MULTIPOLYGON feature into individual POLYGONS

scot = st_cast(the_uk$geometry[2],"POLYGON")

# which is the largest polygon?
which.max(st_area(scot))
[1] 1

# the first one. ok...

plot(scot[[1]]) # mainland

# add the rest of the islands for context, in grey, maybe to show they're
outside our study area:

for(i in 2:length(scot)){plot(scot[[i]], col="grey", add=TRUE)}

There are 2794 polygons in Scotland (according to this data)...

Barry




On Tue, May 14, 2024 at 4:40 PM Jan van der Laan  wrote:

> This email originated outside the University. Check before clicking links
> or attachments.
>
> I believe mapshaper has functionality for removing small 'islands'.
> There is a webinterface for mapshaper, but I see there is also an
> R-package (see
>
> https://search.r-project.org/CRAN/refmans/rmapshaper/html/ms_filter_islands.html
> for island removal).
>
> If you want to manually select which islands to keep and which to
> remove, you can split multipolygons into single polygons. I believe that
> is possible using st_cast.
>
> But if it is just getting the relevant portion of the map on screen.
> With the plot-command and using st_viewport it is possible to set the
> part of the map that is drawn.
>
> HTH,
> Jsn
>
>
> On 14-05-2024 15:16, Nick Wray wrote:
> > Hello  I have a shapefile of Scotland, including the islands.  The river
> > flow data I am using is only for the mainland and for a clearer and
> larger
> > map I would like to not plot Orkney and Shetland to the north of the
> > mainland, as I don't need them.
> >
> > The map I have I got from
> >
> https://borders.ukdataservice.ac.uk/easy_download_data.html?data=infuse_ctry_2011
> >
> > then I put the uk shapefile onto my laptop with no problems (I have sf
> > running)
> >
> >
> the_uk<-st_read(dsn="C:/Users/nickm/Desktop/Shapefiles/infuse_ctry_2011.shp")
> >
> > scotland<-the_uk[2,]
> >
> > plot(scotland$geometry)
> >
> > This gives me a nice map of Scotland  plus islands but obviously there
> are
> > lots of separate polygons and if I go into the points with something like
> >
> > scot_pts<-unlist(as.data.frame(scotland$geometry))
> >
> > it's not at all clear how I can get rid of the points I don't want as
> they
> > don't seem to be listed in any easy way to find where one polygon stops
> and
> > another starts
> >
> > I am wondering whether this approach is right anyway or whether there is
> > some sf function which would allow me to identify the polygons I want -
> > essentially the big one which is the mainland without lots of elaborate
> > conversions and manipulations
> >
> > Any pointers, thoughts etc much appreciated
> >
> > Thanks Nick Wray
> >
> >   [[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] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-17 Thread Vega, Ann (she/her/hers) via R-help
We are a government agency so it's an issue.

But I appreciate your input and Duncan's as well.  We have the answer we needed 
based on Duncan's response.

Thank you for your time!

av

Ann Vega, PSPO
She/Her/Hers (Learn More)
Office of Science Information Management, Data Architect
EPA Office of Research and Development
Cincinnati, OH

Mobile: 513-418-1922 - or reach out to me on Teams!
Hours:  Monday-Thursday, 7:30am - 6:00 pm, CDO:  Fridays
Email: vega@epa.gov


From: CALUM POLWART 
Sent: Thursday, May 16, 2024 1:38 PM
To: Vega, Ann (she/her/hers) 
Cc: R-help@r-project.org
Subject: Re: [R] Current version of R, 4.4.0 and patch to correct the bug fix 
related to the RStudio viewer pane on Windows systems

Caution: This email originated from outside EPA, please exercise additional 
caution when deciding whether to open attachments or click on provided links.

Do you receive RDS objects from unknown (untrusted) sources?

?? If not - the security issue is a non-issue as I understand it.

On Thu, 16 May 2024, 16:21 Vega, Ann (she/her/hers) via R-help, 
mailto:r-help@r-project.org>> wrote:
I help to coordinate the USEPA's R user group.  We have over 500 members and 
our security officer has required us to update to R version 4.4.0 because of 
the security vulnerability to versions prior.  However, we cannot download the 
patched version because it does not have a signed certificate and Microsoft 
Defender won't allow us to install it.

Most of our users rely on the RStudio viewer pane so we are in a bit of a 
quandary.  We suspect other government agencies are impacted by this as well.

Can you give me an estimated time for when another official version will be 
released with the patch included?  I may be able to ask our security officer to 
allow us to delay our install until that official version is released.  
Alternatively, if the patched version could have a signed certificate, that 
would allow us to install it.

Thank you.

Ann Vega, PSPO
She/Her/Hers (Learn More)
Office of Science Information Management, Data Architect
EPA Office of Research and Development
Cincinnati, OH

Mobile: 513-418-1922 - or reach out to me on Teams!
Hours:  Monday-Thursday, 7:30am - 6:00 pm, CDO:  Fridays
Email: 
vega@epa.gov>



[[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] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-16 Thread Ben Bolker
  Yes, but this sounds more like a bureaucratic requirement ("all 
available patches must be installed") and less like something someone 
has thought through.


  It's conceivable that one might be able to talk to a security officer 
and convince them that this is not in fact an important issue, but I'm 
not optimistic about that ...


  Ben Bolker

On 2024-05-16 1:38 p.m., CALUM POLWART wrote:

Do you receive RDS objects from unknown (untrusted) sources?

?? If not - the security issue is a non-issue as I understand it.


On Thu, 16 May 2024, 16:21 Vega, Ann (she/her/hers) via R-help, <
r-help@r-project.org> wrote:


I help to coordinate the USEPA's R user group.  We have over 500 members
and our security officer has required us to update to R version 4.4.0
because of the security vulnerability to versions prior.  However, we
cannot download the patched version because it does not have a signed
certificate and Microsoft Defender won't allow us to install it.

Most of our users rely on the RStudio viewer pane so we are in a bit of a
quandary.  We suspect other government agencies are impacted by this as
well.

Can you give me an estimated time for when another official version will
be released with the patch included?  I may be able to ask our security
officer to allow us to delay our install until that official version is
released.  Alternatively, if the patched version could have a signed
certificate, that would allow us to install it.

Thank you.

Ann Vega, PSPO
She/Her/Hers (Learn More



 [[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@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] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-16 Thread CALUM POLWART
Do you receive RDS objects from unknown (untrusted) sources?

?? If not - the security issue is a non-issue as I understand it.


On Thu, 16 May 2024, 16:21 Vega, Ann (she/her/hers) via R-help, <
r-help@r-project.org> wrote:

> I help to coordinate the USEPA's R user group.  We have over 500 members
> and our security officer has required us to update to R version 4.4.0
> because of the security vulnerability to versions prior.  However, we
> cannot download the patched version because it does not have a signed
> certificate and Microsoft Defender won't allow us to install it.
>
> Most of our users rely on the RStudio viewer pane so we are in a bit of a
> quandary.  We suspect other government agencies are impacted by this as
> well.
>
> Can you give me an estimated time for when another official version will
> be released with the patch included?  I may be able to ask our security
> officer to allow us to delay our install until that official version is
> released.  Alternatively, if the patched version could have a signed
> certificate, that would allow us to install it.
>
> Thank you.
>
> Ann Vega, PSPO
> She/Her/Hers (Learn More >)
> Office of Science Information Management, Data Architect
> EPA Office of Research and Development
> Cincinnati, OH
>
> Mobile: 513-418-1922 - or reach out to me on Teams!
> Hours:  Monday-Thursday, 7:30am - 6:00 pm, CDO:  Fridays
> Email: vega@epa.gov
>
>
>
> [[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] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-16 Thread Duncan Murdoch
The developer.r-project.org site lists plans for releases, and no plan 
is in place yet for a 4.4.1 release.


You can look at the history of previous versions if you want to make a 
guess:


4.3.1: June, 2023
4.2.1: June, 2022
4.1.1: August, 2021
4.0.1: June, 2020
3.6.1: July, 2019
3.5.1: July, 2018
3.4.1: June, 2017
3.3.1: June, 2016

So it's a good guess that it will happen before September, and better 
than even odds it will be before July.


Duncan Murdoch

On 2024-05-16 7:39 a.m., Vega, Ann (she/her/hers) via R-help wrote:

I help to coordinate the USEPA's R user group.  We have over 500 members and 
our security officer has required us to update to R version 4.4.0 because of 
the security vulnerability to versions prior.  However, we cannot download the 
patched version because it does not have a signed certificate and Microsoft 
Defender won't allow us to install it.

Most of our users rely on the RStudio viewer pane so we are in a bit of a 
quandary.  We suspect other government agencies are impacted by this as well.

Can you give me an estimated time for when another official version will be 
released with the patch included?  I may be able to ask our security officer to 
allow us to delay our install until that official version is released.  
Alternatively, if the patched version could have a signed certificate, that 
would allow us to install it.

Thank you.

Ann Vega, PSPO
She/Her/Hers (Learn More)
Office of Science Information Management, Data Architect
EPA Office of Research and Development
Cincinnati, OH

Mobile: 513-418-1922 - or reach out to me on Teams!
Hours:  Monday-Thursday, 7:30am - 6:00 pm, CDO:  Fridays
Email: vega@epa.gov



[[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] Current version of R, 4.4.0 and patch to correct the bug fix related to the RStudio viewer pane on Windows systems

2024-05-16 Thread Vega, Ann (she/her/hers) via R-help
I help to coordinate the USEPA's R user group.  We have over 500 members and 
our security officer has required us to update to R version 4.4.0 because of 
the security vulnerability to versions prior.  However, we cannot download the 
patched version because it does not have a signed certificate and Microsoft 
Defender won't allow us to install it.

Most of our users rely on the RStudio viewer pane so we are in a bit of a 
quandary.  We suspect other government agencies are impacted by this as well.

Can you give me an estimated time for when another official version will be 
released with the patch included?  I may be able to ask our security officer to 
allow us to delay our install until that official version is released.  
Alternatively, if the patched version could have a signed certificate, that 
would allow us to install it.

Thank you.

Ann Vega, PSPO
She/Her/Hers (Learn More)
Office of Science Information Management, Data Architect
EPA Office of Research and Development
Cincinnati, OH

Mobile: 513-418-1922 - or reach out to me on Teams!
Hours:  Monday-Thursday, 7:30am - 6:00 pm, CDO:  Fridays
Email: vega@epa.gov



[[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] Least error-prone reading of Excel files?

2024-05-16 Thread Ebert,Timothy Aaron
https://www.r-bloggers.com/2021/06/reading-data-from-excel-files-xlsxlsxcsv-into-r-quick-guide/

Excel can hold a great quantity of data. However, I find that it is slow and 
often crashes when I try to use Excel at large scale. It also grinds my entire 
system to a halt. At the kb and mb scales I typically have few problems. At gb 
scales Excel will hold the data, but doing anything with it is problematic (for 
me). I have used readxl and associated read_excel() in R and not noticed issues 
at my small scales. I could read a file multiple times in different data frames 
and then compare them but that too is slow and can exceed system resources. 

I only deal with a few files, so I would use something like 7-zip to decompress 
the files before having R read them. I would bet that there are existing 
programs that would unzip large batches of files, but I have never had to do 
this where the target files are scattered amongst other files that are not 
needed. If I can use "select all" then that is simple enough.

Tim

-Original Message-
From: R-help  On Behalf Of DynV Montrealer
Sent: Thursday, May 16, 2024 9:51 AM
To: r-help@r-project.org
Subject: [R] Least error-prone reading of Excel files?

[External Email]

I'm tasked to read a table from an excel file and it doesn't mention which 
method to use. I went back some lessons ago and the 5 years old lesson 
mentioned to pick a package using the highest score the way of the attached 
(screenshot). Since there's no requirement of a method to read Excel files, I'd 
rather use the least error-prone one; what would that be? eg will try multiple 
decompression algorithm if there's a decompression error.

Thank you kindly
__
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] Least error-prone reading of Excel files?

2024-05-16 Thread DynV Montrealer
I'm tasked to read a table from an excel file and it doesn't mention which
method to use. I went back some lessons ago and the 5 years old lesson
mentioned to pick a package using the highest score the way of the attached
(screenshot). Since there's no requirement of a method to read Excel files,
I'd rather use the least error-prone one; what would that be? eg will try
multiple decompression algorithm if there's a decompression error.

Thank you kindly
__
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] Extracting values from Surv function in survival package

2024-05-16 Thread CALUM POLWART
I don't think that gives the summary of event numbers without extra work.

library(survival)
fit <- survfit( Surv(time,status)~sex,data=lung)
summary(fit)$n.event

[1] 3 1 2 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 3 1 1 1 1 1 2
 [38] 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1
 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1
[112] 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[149] 1 1


You can get something out using:

summary(fit)$table[,"events"]

sex=1 sex=2
  11253


But there are sub-options in the summary that might work.

summary(fit, times =1022, extend=T)$n.event

[1] 112  53



times=1022 is the maximum time in the lung dataset (you will need your
maximum) and extend=T, extends the other curves to that data point allowing
totals for events at that data point



On Thu, 16 May 2024, 08:53 Göran Broström,  wrote:

> Hi Dennis,
>
> look at the help page for summary.survfit, the Value n.event.
>
> Göran
>
> On 2024-05-15 22:41, Dennis Fisher wrote:
> > OS X
> > R 4.3.3
> >
> > Colleagues
> >
> > I have created objects using the Surv function in the survival package:
> >> FIT.1
> > Call: survfit(formula = FORMULA1)
> >
> > n events median 0.95LCL 0.95UCL
> > SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0 18 13345 156  NA
> > SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1 13  5 NA 186  NA
> > SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=2  5  5168  81  NA
> > SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=3  1  1 22  NA  NA
> >
> > I am interested in extracting the “n” and “events” values.
> > “n” is easy:
> >> FIT.1[[1]]
> > [1] 18 13  5  1
> >
> > or
> >> FIT.1$n
> > [1] 18 13  5  1
> >
> > But I can’t figure out how to access “events”.
> >
> > str(FIT.1) provides no insights:
> > List of 17
> >   $ n: int [1:4] 18 13 5 1
> >   $ time : num [1:37] 45 106 107 124 152 156 170 176 319 371 ...
> >   $ n.risk   : num [1:37] 18 17 16 15 14 13 12 11 10 9 ...
> >   $ n.event  : num [1:37] 1 1 1 1 1 1 1 1 1 1 ...
> >   $ n.censor : num [1:37] 0 0 0 0 0 0 0 0 0 0 ...
> >   $ surv : num [1:37] 0.944 0.889 0.833 0.778 0.722 ...
> >   $ std.err  : num [1:37] 0.0572 0.0833 0.1054 0.126 0.1462 ...
> >   $ cumhaz   : num [1:37] 0.0556 0.1144 0.1769 0.2435 0.315 ...
> >   $ std.chaz : num [1:37] 0.0556 0.0809 0.1022 0.1221 0.1414 ...
> >   $ strata   : Named int [1:4] 18 13 5 1
> >..- attr(*, "names")= chr [1:4] "SUBDATA$ARM=1, SUBDATA[,
> EXP.STRAT]=0" "SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1" "SUBDATA$ARM=2,
> SUBDATA[, EXP.STRAT]=2" "SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=3"
> >   $ type : chr "right"
> >   $ logse: logi TRUE
> >   $ conf.int : num 0.95
> >   $ conf.type: chr "log"
> >   $ lower: num [1:37] 0.844 0.755 0.678 0.608 0.542 ...
> >   $ upper: num [1:37] 1 1 1 0.996 0.962 ...
> >   $ call : language survfit(formula = FORMULA1)
> >   - attr(*, "class")= chr "survfit"
> >
> > If I could access:
> > n events median 0.95LCL 0.95UCL
> > SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0 18 13345 156  NA
> > SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=1 13  5 NA 186  NA
> > SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=2  5  5168  81  NA
> > SUBDATA$ARM=2, SUBDATA[, EXP.STRAT]=3  1  1 22  NA  NA
> > it should be easy to get “events”.
> >
> > Any thoughts?
> >
> > Dennis
> >
> > Dennis Fisher MD
> > P < (The "P Less Than" Company)
> > Phone / Fax: 1-866-PLessThan (1-866-753-7784)
> > www.PLessThan.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.
>
> __
> 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] [R-pkgs] segmented 2.1-0 is released

2024-05-16 Thread Vito Muggeo via R-packages

dear R users,
I am pleased to announce that segmented 2.1-0 is now available on CRAN.

segmented focuses on estimation of breakpoints/changepoints of 
segmented, i.e. piecewise linear, relationships in (generalized) linear 
models. Starting with version 2.0-0, it is also possible to model 
stepmented, i.e. piecewise constant, effects.


In the last release both models may be fitted via a formula interface, 
such as


segreg(y ~ seg(x1, npsi=2) + seg(x2) + z)

stepreg(y ~ seg(x1, npsi=2) + seg(x2) +seg(x3, npsi=3) + z, family=poisson)

There is virtually no limit in the number of covariates and 
corresponding number of changepoints to be estimated.


thank you,
kind regards,
Vito


--
=
Vito M.R. Muggeo, PhD
Professor of Statistics
Dip.to Sc Econom, Az e Statistiche
Università di Palermo
viale delle Scienze, edificio 13
90128 Palermo - ITALY
tel: 091 23895240; fax: 091 485726
http://www.unipa.it/persone/docenti/m/vito.muggeo
Assoc Editor: Statist Modelling, Statist Meth Appl
past chair, Statistical Modelling Society
coordinator, PhD Program in Econ, Businss, Statist

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

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