[R] filter() question

Dr Eberhard Lisse no@p@m @end|ng |rom ||@@e@NA
Fri Aug 21 13:45:48 CEST 2020


Eric, Rasmus,

thank you very much,

	 ALLPAP  %>%
		 group_by(Provider) %>%
		 mutate( minDt=min(CollectionDate),
			 maxDt=max(CollectionDate)) %>%
		 summarize( minDt = min(minDt),
			 maxDt = max(maxDt), .groups="keep" ) %>%
		 ungroup() %>%
		 mutate(MAX_MIN_DATE = max(minDt),
			 MIN_MAX_DATE = min(maxDt)) %>%
		 distinct(MAX_MIN_DATE, MIN_MAX_DATE)

gives me

	 # A tibble: 1 x 2
		MAX_MIN_DATE MIN_MAX_DATE
		<chr>        <chr>       
	 1 2010-02-05   2019-08-30  

which is correct, and what I wanted.

This is so cool :-)-O

el

On 21/08/2020 11:41, Eric Berger wrote:
> Hi Eberhard,
> Here is one possibility using dplyr. 
[...]
> 
> HTH,
> Eric
> 
> 
> On Fri, Aug 21, 2020 at 12:34 PM Rasmus Liland <jral using posteo.no> wrote:
>> On 2020-08-21 09:03 +0200, Dr Eberhard Lisse wrote:
[...]
>> 
>> Dear Eberhard,
>> 
>> Is each report in a csv file with those two columns, and you want to
>> unify them into a dataframe with CollectionDate along the rows, and
>> other details for each provider along the columns?  This can be done
>> with various apply calls and reshape.  Can you please subset some
>> more example data here using dput.  It makes it so much easier.
>> 
>> /Rasmus
[...]
-- 
Dr. Eberhard W. Lisse   \         /       Obstetrician & Gynaecologist 
el using lisse.NA             / *      |  Telephone: +264 81 124 6733 (cell)
PO Box 8421 Bachbrecht  \      /  If this email is signed with GPG/PGP
10007, Namibia           ;____/ Sect 20 of Act No. 4 of 2019 may apply

-- 
If you want to email me, replace nospam with el



More information about the R-help mailing list