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<mailto: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 le

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<mailto: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 
>

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 communicati

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<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://urldefense.com/v3/__https:/stat.ethz.ch/mailman/listinfo/r-help__;!!Fou38LsQmgU!p3fE1cCl7_IxAOT0Fvr1vPWF3xDeYl1FCDaqXi4Z6HH7tOMmDULawS8DAa7XcG5s5PrfqmeMC0XA$>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html<

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.