Just came across a `.do`

file that I need to translate into `R`

because I don't have a Stata license; my Stata is rusty, so can someone confirm that the code is doing what I think it is?

Here's the Stata code:

```
collapse (min) MinPctCollected = PctCollected ///
(mean) AvgPctCollected = PctCollected ///
(median) MedianPctCollected = PctCollected ///
(sd) SDPctCollected = PctCollected ///
if PctCollected > 0, by(Year)
```

Here's what I think it's doing in `data.table`

world, if the data set on hand is called `dt`

:

```
dt[PctCollected>0,
.(MinPctCollected=min(PctCollected),
AvgPctCollected=mean(PctCollected),
MedianPctCollected=median(PctCollected),
SDPctCollected=sd(PctCollected)),
by=Year]
```

Is that correct?

This would be easy to confirm if I had used Stata in the past 18 months or if I had a copy installed--hoping I can bend the ear of someone for whom either of these is true. Thanks.