Re: [R] cygwin clipboard

2019-05-22 Thread Abby Spurdle
> I'd like to be able to access the windows clipboard from R under Cygwin.
> Is this supported in any way?  Thanks

Hi Ed

You can access the Windows clipboard under Cygwin.
I ran R within Cygwin.
I was able to use read.table (file="clipboard") for both plain text and
Excel tables.

> #table copied from excel
> tbl = read.table (file="clipboard", TRUE)
> tbl
  A B  C  D
1 1 5  9 13
2 2 6 10 14
3 3 7 11 15
4 4 8 12 16

Note that when copying plain text you may need to include a final newline
character.

The X11() message is suspicious.
I'm wondering what type of object you're trying to copy...?


Abs

[[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] Calculating date difference in days

2019-05-22 Thread Jeff Newmiller
At the point where you say "date difference in days" IMO you have departed from 
what `difftime` is for and are in the realm of a numeric measure. I ignore the 
units inside `difftime` at all times and convert to numeric with a units 
argument if I want to be that specific about how the measure is represented.

You may or may not recall the difference between angle ABC and the measure of 
angle ABC (with a bar over it) from geometry... but the idea is the same... 
distinguish the thing (time interval) from the numbers used to quantify it 
(numeric).

elapsed_days <- function(end_date, start_date){
  ed <- as.POSIXlt(end_date) 
  sd <- as.POSIXlt(start_date) 
  as.numeric( ed-sd, units="days" )
}


On May 22, 2019 2:43:42 PM PDT, reichm...@sbcglobal.net wrote:
>R Help
>
>I have a function to calculate a date difference in days but my results
>come
>back in hours.  I suspect I am using the as.POSIXlt function
>incorrectly . 
>
>Suggestions?
>
># Start time of data to be considered 
>start_day <- "2016-04-30"
>
># Make event and sequence IDs into factors 
>elapsed_days <- function(end_date, start_date){
>  ed <- as.POSIXlt(end_date) 
>  sd <- as.POSIXlt(start_date) 
>  ed-sd 
>}
>
>trans_sequence$eventID <- elapsed_days(trans_sequence$Date, start_day)
>
>
>> trans_sequence
># A tibble: 39 x 5
># Groups:   Emitter [15]
>   Emitter DateSIZE Geohash
>eventID  
>
>   
> 1   1 2016-05-0112 A;B;C;D;E;F;G;H;I;J;K;L
>19 hours
> 2   1 2016-05-02 5 A;B;C;D;E
>43 hours
> 3   1 2016-05-0511 A;B;C;D;E;F;G;H;I;J;K
>115 hours
> 4   2 2016-05-01 9 C;D;E;F;G;H;I;J;K
>19 hours
> 5   2 2016-05-02 3 F;G;H
>43 hours
> 6   2 2016-05-05 3 L;M;N
>115 hours
> 7   3 2016-05-01 3 L;M;N
>19 hours
> 8   3 2016-05-02 3 I;J;K
>43 hours
> 9   3 2016-05-0425
>A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y  91 hours
>10   3 2016-05-05 7 O;P;Q;R;S;T;U
>115 hours
>
>Jeff Reichman
>
>
>   [[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.


Re: [R] Calculating date difference in days

2019-05-22 Thread William Dunlap via R-help
You can use units<- to change the time units of the difference.  E.g.,

> d <- as.POSIXlt("2018-03-10") -  as.POSIXlt("2018-03-09 02:00:00")
> d
Time difference of 22 hours
> units(d) <- "days"
> d
Time difference of 0.917 days
>
> units(d) <- "mins"
> d
Time difference of 1320 mins
> units(d) <- "secs"
> d
Time difference of 79200 secs
> units(d) <- "weeks"
> d
Time difference of 0.1309524 weeks

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, May 22, 2019 at 2:44 PM  wrote:

> R Help
>
> I have a function to calculate a date difference in days but my results
> come
> back in hours.  I suspect I am using the as.POSIXlt function incorrectly .
>
> Suggestions?
>
> # Start time of data to be considered
> start_day <- "2016-04-30"
>
> # Make event and sequence IDs into factors
> elapsed_days <- function(end_date, start_date){
>   ed <- as.POSIXlt(end_date)
>   sd <- as.POSIXlt(start_date)
>   ed-sd
> }
>
> trans_sequence$eventID <- elapsed_days(trans_sequence$Date, start_day)
>
>
> > trans_sequence
> # A tibble: 39 x 5
> # Groups:   Emitter [15]
>Emitter DateSIZE Geohash
> eventID
> 
> 
>  1   1 2016-05-0112 A;B;C;D;E;F;G;H;I;J;K;L
> 19 hours
>  2   1 2016-05-02 5 A;B;C;D;E
> 43 hours
>  3   1 2016-05-0511 A;B;C;D;E;F;G;H;I;J;K
> 115 hours
>  4   2 2016-05-01 9 C;D;E;F;G;H;I;J;K
> 19 hours
>  5   2 2016-05-02 3 F;G;H
> 43 hours
>  6   2 2016-05-05 3 L;M;N
> 115 hours
>  7   3 2016-05-01 3 L;M;N
> 19 hours
>  8   3 2016-05-02 3 I;J;K
> 43 hours
>  9   3 2016-05-0425
> A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y  91 hours
> 10   3 2016-05-05 7 O;P;Q;R;S;T;U
> 115 hours
>
> Jeff Reichman
>
>
> [[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] Calculating date difference in days

2019-05-22 Thread Boris Steipe
ed <- as.POSIXlt("2018-03-10")
sd <- as.POSIXlt("2018-02-10")
as.numeric(ed-sd)
[1] 28

ed <- as.POSIXlt("2000-03-10")
sd <- as.POSIXlt("2000-02-10")
as.numeric(ed-sd)
[1] 29

Cheers,
B.


> On 2019-05-22, at 17:43, reichm...@sbcglobal.net wrote:
> 
> R Help
> 
> I have a function to calculate a date difference in days but my results come
> back in hours.  I suspect I am using the as.POSIXlt function incorrectly . 
> 
> Suggestions?
> 
> # Start time of data to be considered 
> start_day <- "2016-04-30"
> 
> # Make event and sequence IDs into factors 
> elapsed_days <- function(end_date, start_date){
>  ed <- as.POSIXlt(end_date) 
>  sd <- as.POSIXlt(start_date) 
>  ed-sd 
> }
> 
> trans_sequence$eventID <- elapsed_days(trans_sequence$Date, start_day)
> 
> 
>> trans_sequence
> # A tibble: 39 x 5
> # Groups:   Emitter [15]
>   Emitter DateSIZE Geohash
> eventID  
>
>
> 1   1 2016-05-0112 A;B;C;D;E;F;G;H;I;J;K;L
> 19 hours
> 2   1 2016-05-02 5 A;B;C;D;E
> 43 hours
> 3   1 2016-05-0511 A;B;C;D;E;F;G;H;I;J;K
> 115 hours
> 4   2 2016-05-01 9 C;D;E;F;G;H;I;J;K
> 19 hours
> 5   2 2016-05-02 3 F;G;H
> 43 hours
> 6   2 2016-05-05 3 L;M;N
> 115 hours
> 7   3 2016-05-01 3 L;M;N
> 19 hours
> 8   3 2016-05-02 3 I;J;K
> 43 hours
> 9   3 2016-05-0425
> A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y  91 hours
> 10   3 2016-05-05 7 O;P;Q;R;S;T;U
> 115 hours
> 
> Jeff Reichman
> 
> 
>   [[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] Calculating date difference in days

2019-05-22 Thread reichmanj
R Help

I have a function to calculate a date difference in days but my results come
back in hours.  I suspect I am using the as.POSIXlt function incorrectly . 

Suggestions?

# Start time of data to be considered 
start_day <- "2016-04-30"

# Make event and sequence IDs into factors 
elapsed_days <- function(end_date, start_date){
  ed <- as.POSIXlt(end_date) 
  sd <- as.POSIXlt(start_date) 
  ed-sd 
}

trans_sequence$eventID <- elapsed_days(trans_sequence$Date, start_day)


> trans_sequence
# A tibble: 39 x 5
# Groups:   Emitter [15]
   Emitter DateSIZE Geohash
eventID  

   
 1   1 2016-05-0112 A;B;C;D;E;F;G;H;I;J;K;L
19 hours
 2   1 2016-05-02 5 A;B;C;D;E
43 hours
 3   1 2016-05-0511 A;B;C;D;E;F;G;H;I;J;K
115 hours
 4   2 2016-05-01 9 C;D;E;F;G;H;I;J;K
19 hours
 5   2 2016-05-02 3 F;G;H
43 hours
 6   2 2016-05-05 3 L;M;N
115 hours
 7   3 2016-05-01 3 L;M;N
19 hours
 8   3 2016-05-02 3 I;J;K
43 hours
 9   3 2016-05-0425
A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y  91 hours
10   3 2016-05-05 7 O;P;Q;R;S;T;U
115 hours

Jeff Reichman


[[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] Problema estrazione file in formato "large STFDF" in formato "ASCII" compatibile con GIS

2019-05-22 Thread Michael Dewey

Dear Agostino

I am afraid this list is an English language one but I suggest that as 
well as trying to translate your message you post on the list which 
specialises in this sort of thing


https://stat.ethz.ch/mailman/listinfo/r-sig-geo

where they may be better able to help you.

Michael

On 22/05/2019 13:31, Agostino Della Porta wrote:

Salve, mi sto occupando nel mio tirocinio di analisi di dati
spazio-temporali con il Kriging spazio-temporale. Una volta ottenuta la
mappa di predizione con questa riga di codice:

pred <- krigeST ( PPB ~ 1 ,  data = dataSTIDF , modelList =
simpleSumMetric_Vgm, newdata = grid.ST, fullCovariance = FALSE)
Non riesco a trovare un comando che mi possa far estrarre il file "pred" in
formato large STFDF in formato ASCII da poter poi utilizzare in GIS


Mail
priva di virus. www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

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

---
This email has been checked for viruses by AVG.
https://www.avg.com




--
Michael
http://www.dewey.myzen.co.uk/home.html

__
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] Problema estrazione file in formato "large STFDF" in formato "ASCII" compatibile con GIS

2019-05-22 Thread Agostino Della Porta
Salve, mi sto occupando nel mio tirocinio di analisi di dati
spazio-temporali con il Kriging spazio-temporale. Una volta ottenuta la
mappa di predizione con questa riga di codice:

pred <- krigeST ( PPB ~ 1 ,  data = dataSTIDF , modelList =
simpleSumMetric_Vgm, newdata = grid.ST, fullCovariance = FALSE)
Non riesco a trovare un comando che mi possa far estrarre il file "pred" in
formato large STFDF in formato ASCII da poter poi utilizzare in GIS


Mail
priva di virus. www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

[[alternative HTML version deleted]]

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


Re: [R] Help with R coding

2019-05-22 Thread Bill Poling
Thank you William appreciate your response Sir.

WHP

From: William Michels 
Sent: Wednesday, May 22, 2019 9:58 AM
To: Bill Poling 
Cc: r-help (r-help@r-project.org) 
Subject: Re: [R] Help with R coding

Morning Bill, I take it this is dplyr? You might try:

tmp1 <- HCPC %>%
group_by(HCPCSCode) %>%
summarise(Avg_AllowByLimit =
mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0 & AllowByLimitFlag ==
TRUE)]))

The code above gives "NaN" for cases where AllowByLimitFlag == FALSE.
Maybe this is the answer you desire, otherwise you can filter out
"NaN" rows.

Cheers,

Bill.

W. Michels, Ph.D.


On Wed, May 22, 2019 at 5:41 AM Bill Poling  
wrote:
>
> Good morning.
>
> #R version 3.6.0 Patched (2019-05-19 r76539)
> #Platform: x86_64-w64-mingw32/x64 (64-bit)
> #Running under: Windows >= 8 x64 (build 9200)
>
> I need a calculated field For the Rate of Avg_AllowByLimit where the 
> Allowed_AmtFlag = TRUE BY Each Code
>
> I have almost got this.
>
> #So far I have this
> tmp1 <- tmp %>%
> group_by(HCPCSCode) %>%
> summarise(Avg_AllowByLimit = 
> mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>
> # But I need Something like that + This
>
> WHERE AllowByLimitFlag == TRUE
>
> I cannot seem to get it in there correctly
>
> Thank you for any help
>
> WHP
>
> #Here is some data
> HCPCSCode Avg_AllowByLimit AllowByLimitFlag
> 1 J1745 4.50 FALSE
> 2 J9299 18.70 FALSE
> 3 J9306 14.33 FALSE
> 4 J9355 7.13 FALSE
> 5 J0897 8.61 FALSE
> 6 J9034 3.32 FALSE
> 7 J9034 3.32 FALSE
> 8 J9045 15.60 FALSE
> 9 J9035 2.77 TRUE
> 10 J1190 3.62 FALSE
> 11 J2250 879.10 FALSE
> 12 J9033 2.92 FALSE
> 13 J1745 4.50 TRUE
> 14 J2785 12.11 FALSE
> 15 J9045 15.60 FALSE
> 16 J2350 7.81 FALSE
> 17 J2469 10.65 TRUE
> 18 J2796 6.27 FALSE
> 19 J2796 6.27 FALSE
> 20 J9355 7.13 FALSE
> 21 J9045 15.60 FALSE
> 22 J2505 2.73 FALSE
> 23 J1786 2.81 FALSE
> 24 J3262 3.26 FALSE
> 25 J0696 168.87 FALSE
> 26 J0178 1.52 TRUE
> 27 J9271 5.55 FALSE
> 28 J3380 80.99 FALSE
> 29 J9355 7.13 TRUE
> 30 J2469 10.65 FALSE
> 31 J9045 15.60 FALSE
> 32 J1459 3.64 FALSE
> 33 J9305 8.74 FALSE
> 34 J9034 3.32 FALSE
> 35 J9034 3.32 FALSE
>
> Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}
>
> __
> mailto: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.

Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.
__
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] Significance of difference in means using Monte Carlo Simulation in R

2019-05-22 Thread Bert Gunter
This list is for Help and usually expects you to first show us your own
efforts. You need to do your own homework and spend some time with one or
more of the many good R tutorials on the Web. Some suggestions canbe found
here, though you will find many more by simple web searches:

https://www.rstudio.com/online-learning/#r-programming

Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, May 22, 2019 at 12:56 AM Lyndz 
wrote:

> I want to implement a statistical test by the following paper in R:
> https://journals.ametsoc.org/doi/full/10.1175/JCLI4217.1
>
> **Details**
>
> The above paper calculates the significance of the difference in means
> between two periods :1961-1983 and 1984-2000 of tropical cyclone passage
> frequency (not-normally distributed) using Monte Carlo simulation. The
> following steps are provided:
>
> >1). First,  randomly sorted 40-yr time series of the typhoon passage
> frequency are prepared.
>
> >2). Averages of the former 23-yr values (1961-1983) minus those of the
> latter 17-yr values are calculated.
>
> >3). From the rank of the original difference value among 1 samples,
> the significance level is estimated.
>
> Suppose I have the following 40-yr time series.
>
> > dat<-floor(runif(40, min=0, max=20))
> > dput(dat)
> c(15, 14, 1, 16, 0, 18, 5, 8, 19, 7, 11, 15, 2, 17, 12, 16, 1,
> 9, 9, 19, 12, 17, 15, 10, 1, 11, 10, 12, 17, 10, 4, 2, 9, 10,
> 9, 5, 13, 6, 0, 17)
>
> **PROBLEMS**
>
> 1. I am new in R and I am not sure how to implement this test.
> Any suggestion on how to do this in R?
> I'll appreciate any help.
>
> *Lyndz*
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Help with R coding

2019-05-22 Thread Bill Poling
Thank you Jeff!

WHP

From: Jeff Newmiller 
Sent: Wednesday, May 22, 2019 10:06 AM
To: r-help@r-project.org; Rui Barradas ; Bill Poling 
; r-help (r-help@r-project.org) 
Subject: Re: [R] Help with R coding

Generally more efficient to filter before grouping.

Note that summarize clears out whatever isn't mentioned in it, so the 
subsetting currently being done in the mean call could also be done in the 
pre-filter step and you can avoid filtering other columns and then discarding 
them by limiting the operations to only those columns that will be referenced:

tmp1 <- tmp %>%
select( HCPCSCode, Avg_AllowByLimit, AllowByLimitFlag )
filter( AllowByLimitFlag & Avg_AllowByLimit != 0 ) %>%
group_by( HCPCSCode ) %>%
summarise( Avg_AllowByLimit = mean( Avg_AllowByLimit ) )


On May 22, 2019 6:45:39 AM PDT, Rui Barradas  
wrote:
>Hello,
>
>Maybe filter the AllowByLimitFlag values first (not tested)?
>
>
>tmp1 <- tmp %>%
> group_by(HCPCSCode) %>%
> filter(AllowByLimitFlag) %>%
> summarise(Avg_AllowByLimit =
>mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>
>
>Hope this helps,
>
>Rui Barradas
>
>
>Às 13:35 de 22/05/19, Bill Poling escreveu:
>> tmp1 <- tmp %>%
>> group_by(HCPCSCode) %>%
>> summarise(Avg_AllowByLimit =
>mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>>
>> # But I need Something like that + This
>>
>> WHERE AllowByLimitFlag == TRUE
>
>__
>mailto: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.

Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with R coding

2019-05-22 Thread Jeff Newmiller
Generally more efficient to filter before grouping.

Note that summarize clears out whatever isn't mentioned in it, so the 
subsetting currently being done in the mean call could also be done in the 
pre-filter step and you can avoid filtering other columns and then discarding 
them by limiting the operations to only those columns that will be referenced:

tmp1 <- tmp %>%
   select( HCPCSCode, Avg_AllowByLimit, AllowByLimitFlag )
   filter( AllowByLimitFlag & Avg_AllowByLimit != 0 ) %>%
   group_by( HCPCSCode ) %>%
   summarise( Avg_AllowByLimit = mean( Avg_AllowByLimit ) )


On May 22, 2019 6:45:39 AM PDT, Rui Barradas  wrote:
>Hello,
>
>Maybe filter the AllowByLimitFlag values first (not tested)?
>
>
>tmp1 <- tmp %>%
>   group_by(HCPCSCode) %>%
>   filter(AllowByLimitFlag) %>%
>   summarise(Avg_AllowByLimit = 
>mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>
>
>Hope this helps,
>
>Rui Barradas
>
>
>Às 13:35 de 22/05/19, Bill Poling escreveu:
>> tmp1 <- tmp %>%
>> group_by(HCPCSCode) %>%
>> summarise(Avg_AllowByLimit =
>mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>> 
>> # But I need Something like that + This
>> 
>> WHERE AllowByLimitFlag == TRUE
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Help with R coding

2019-05-22 Thread William Michels via R-help
Morning Bill, I take it this is dplyr? You might try:

tmp1 <- HCPC %>%
group_by(HCPCSCode) %>%
summarise(Avg_AllowByLimit =
mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0 & AllowByLimitFlag ==
TRUE)]))

The code above gives "NaN" for cases where AllowByLimitFlag == FALSE.
Maybe this is the answer you desire, otherwise you can filter out
"NaN" rows.

Cheers,

Bill.

W. Michels, Ph.D.


On Wed, May 22, 2019 at 5:41 AM Bill Poling  wrote:
>
> Good morning.
>
> #R version 3.6.0 Patched (2019-05-19 r76539)
> #Platform: x86_64-w64-mingw32/x64 (64-bit)
> #Running under: Windows >= 8 x64 (build 9200)
>
> I need a calculated field  For the Rate of Avg_AllowByLimit where the 
> Allowed_AmtFlag = TRUE BY Each Code
>
> I have almost got this.
>
> #So far I have this
> tmp1 <- tmp %>%
> group_by(HCPCSCode) %>%
> summarise(Avg_AllowByLimit = 
> mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>
> # But I need Something like that + This
>
> WHERE AllowByLimitFlag == TRUE
>
> I cannot seem to get it in there correctly
>
> Thank you for any help
>
> WHP
>
> #Here is some data
> HCPCSCode Avg_AllowByLimit AllowByLimitFlag
> 1  J1745 4.50FALSE
> 2  J929918.70FALSE
> 3  J930614.33FALSE
> 4  J9355 7.13FALSE
> 5  J0897 8.61FALSE
> 6  J9034 3.32FALSE
> 7  J9034 3.32FALSE
> 8  J904515.60FALSE
> 9  J9035 2.77 TRUE
> 10 J1190 3.62FALSE
> 11 J2250   879.10FALSE
> 12 J9033 2.92FALSE
> 13 J1745 4.50 TRUE
> 14 J278512.11FALSE
> 15 J904515.60FALSE
> 16 J2350 7.81FALSE
> 17 J246910.65 TRUE
> 18 J2796 6.27FALSE
> 19 J2796 6.27FALSE
> 20 J9355 7.13FALSE
> 21 J904515.60FALSE
> 22 J2505 2.73FALSE
> 23 J1786 2.81FALSE
> 24 J3262 3.26FALSE
> 25 J0696   168.87FALSE
> 26 J0178 1.52 TRUE
> 27 J9271 5.55FALSE
> 28 J338080.99FALSE
> 29 J9355 7.13 TRUE
> 30 J246910.65FALSE
> 31 J904515.60FALSE
> 32 J1459 3.64FALSE
> 33 J9305 8.74FALSE
> 34 J9034 3.32FALSE
> 35 J9034 3.32FALSE
>
> Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Help with R coding

2019-05-22 Thread Bill Poling
Thank you Rui, but that is getting me the overall mean not the mean of just the 
observations that are flagged as TRUE Grouped By the HCPCSCode
 (AllowByLimitFlag == TRUE).

I also tried adding it to the filter you suggested but that does not seem to 
work either?

tmp1 <- tmp %>%
  group_by(HCPCSCode) %>%
  filter(AllowByLimitFlag==TRUE) %>%
  summarise(Avg_AllowByLimit =
  mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))

However, I really appreciate your help Sir!

WHP


William H. Poling, Ph.D., MPH | Manager, Data Science
Data Intelligence & Analytics
Zelis Healthcare


-Original Message-
From: Rui Barradas 
Sent: Wednesday, May 22, 2019 9:46 AM
To: Bill Poling ; r-help (r-help@r-project.org) 

Subject: Re: [R] Help with R coding

Hello,

Maybe filter the AllowByLimitFlag values first (not tested)?


tmp1 <- tmp %>%
   group_by(HCPCSCode) %>%
   filter(AllowByLimitFlag) %>%
   summarise(Avg_AllowByLimit =
mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))


Hope this helps,

Rui Barradas


Às 13:35 de 22/05/19, Bill Poling escreveu:
> tmp1 <- tmp %>%
> group_by(HCPCSCode) %>%
> summarise(Avg_AllowByLimit = 
> mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))
>
> # But I need Something like that + This
>
> WHERE AllowByLimitFlag == TRUE


Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help with R coding

2019-05-22 Thread Rui Barradas

Hello,

Maybe filter the AllowByLimitFlag values first (not tested)?


tmp1 <- tmp %>%
  group_by(HCPCSCode) %>%
  filter(AllowByLimitFlag) %>%
  summarise(Avg_AllowByLimit = 
mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))



Hope this helps,

Rui Barradas


Às 13:35 de 22/05/19, Bill Poling escreveu:

tmp1 <- tmp %>%
group_by(HCPCSCode) %>%
summarise(Avg_AllowByLimit = mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))

# But I need Something like that + This

WHERE AllowByLimitFlag == TRUE


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


[R] Help with R coding

2019-05-22 Thread Bill Poling
Good morning.

#R version 3.6.0 Patched (2019-05-19 r76539)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows >= 8 x64 (build 9200)

I need a calculated field  For the Rate of Avg_AllowByLimit where the 
Allowed_AmtFlag = TRUE BY Each Code

I have almost got this.

#So far I have this
tmp1 <- tmp %>%
group_by(HCPCSCode) %>%
summarise(Avg_AllowByLimit = mean(Avg_AllowByLimit[which(Avg_AllowByLimit!=0)]))

# But I need Something like that + This

WHERE AllowByLimitFlag == TRUE

I cannot seem to get it in there correctly

Thank you for any help

WHP

#Here is some data
HCPCSCode Avg_AllowByLimit AllowByLimitFlag
1  J1745 4.50FALSE
2  J929918.70FALSE
3  J930614.33FALSE
4  J9355 7.13FALSE
5  J0897 8.61FALSE
6  J9034 3.32FALSE
7  J9034 3.32FALSE
8  J904515.60FALSE
9  J9035 2.77 TRUE
10 J1190 3.62FALSE
11 J2250   879.10FALSE
12 J9033 2.92FALSE
13 J1745 4.50 TRUE
14 J278512.11FALSE
15 J904515.60FALSE
16 J2350 7.81FALSE
17 J246910.65 TRUE
18 J2796 6.27FALSE
19 J2796 6.27FALSE
20 J9355 7.13FALSE
21 J904515.60FALSE
22 J2505 2.73FALSE
23 J1786 2.81FALSE
24 J3262 3.26FALSE
25 J0696   168.87FALSE
26 J0178 1.52 TRUE
27 J9271 5.55FALSE
28 J338080.99FALSE
29 J9355 7.13 TRUE
30 J246910.65FALSE
31 J904515.60FALSE
32 J1459 3.64FALSE
33 J9305 8.74FALSE
34 J9034 3.32FALSE
35 J9034 3.32FALSE

Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}

__
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] cygwin clipboard

2019-05-22 Thread peter dalgaard
What Duncan says, but in case you are feeling adventurous or have strong 
reasons to be in the Cygwin parallel universe, notice that the error indicates 
that R is loooking for an X11 display.

So, at a minimum, you need to have 

(a) an X11 display server running
(b) R setup so that it knows how to find X11 (usually via the DISPLAY env. 
variable)

Even so, you still risk finding that the X11 clipboard does not integrate with 
the Windows clipboard, so al bets are off.

- pd

> On 22 May 2019, at 00:54 , Duncan Murdoch  wrote:
> 
> On 21/05/2019 10:55 a.m., Ed Siefker wrote:
>> I'd like to be able to access the windows clipboard from R under Cygwin.
>> But...
>>> read.table(file="clipboard")
>> Error in file(file, "rt") : cannot open the connection
>> In addition: Warning message:
>> In file(file, "rt") : unable to contact X11 display
>>> 
>> Is this supported in any way?  Thanks
> 
> Cygwin is not supported in any way by the R project, as far as I know. 
> There's a native Windows build that is supported, and I'd strongly recommend 
> you use it instead.
> 
> 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.

-- 
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] Significance of difference in means using Monte Carlo Simulation in R

2019-05-22 Thread Lyndz
I want to implement a statistical test by the following paper in R:
https://journals.ametsoc.org/doi/full/10.1175/JCLI4217.1

**Details**

The above paper calculates the significance of the difference in means
between two periods :1961-1983 and 1984-2000 of tropical cyclone passage
frequency (not-normally distributed) using Monte Carlo simulation. The
following steps are provided:

>1). First,  randomly sorted 40-yr time series of the typhoon passage
frequency are prepared.

>2). Averages of the former 23-yr values (1961-1983) minus those of the
latter 17-yr values are calculated.

>3). From the rank of the original difference value among 1 samples,
the significance level is estimated.

Suppose I have the following 40-yr time series.

> dat<-floor(runif(40, min=0, max=20))
> dput(dat)
c(15, 14, 1, 16, 0, 18, 5, 8, 19, 7, 11, 15, 2, 17, 12, 16, 1,
9, 9, 19, 12, 17, 15, 10, 1, 11, 10, 12, 17, 10, 4, 2, 9, 10,
9, 5, 13, 6, 0, 17)

**PROBLEMS**

1. I am new in R and I am not sure how to implement this test.
Any suggestion on how to do this in R?
I'll appreciate any help.

*Lyndz*

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