Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dplyr operations #4

Open
3 of 4 tasks
ocramz opened this issue May 20, 2019 · 3 comments
Open
3 of 4 tasks

add dplyr operations #4

ocramz opened this issue May 20, 2019 · 3 comments
Labels
enhancement 🚀 New feature or request

Comments

@ocramz
Copy link
Owner

ocramz commented May 20, 2019

  • mutate() adds new variables that are functions of existing variables
  • select() picks variables based on their names.
    • see the text, int etc. lenses
  • filter() picks cases based on their values.
  • summarise() reduces multiple values down to a single summary.
    - [ ] arrange() changes the ordering of the rows. not needed
@ocramz ocramz added the enhancement 🚀 New feature or request label May 20, 2019
@ocramz
Copy link
Owner Author

ocramz commented May 30, 2019

filter() -> filter
summarise() -> dataframes are Foldable

@ocramz
Copy link
Owner Author

ocramz commented Oct 22, 2019

mutate() is interesting; in the current implementation, we are lacking a typesafe way to re-insert values into a row.

@ocramz
Copy link
Owner Author

ocramz commented May 17, 2021

@adamConnerSax shows this workaround for a row function :

let add_nwnh_dem r = K.knitMaybe "Missing column when computing nwnh_dem" $ do
        vocT <- r ^? Heidi.double (BR.heidiColKey "VOC Total")
        wnhT <- r ^? Heidi.double (BR.heidiColKey "WNH Total")
        voc <- r ^? Heidi.int (BR.heidiColKey "NWNH VEP")
        wnh <- r ^? Heidi.int (BR.heidiColKey "WNH VEP")
        vocSST <- r ^? Heidi.double (BR.heidiColKey "State-Specific")
        let turnout = ((vocT * realToFrac voc) + (wnhT * realToFrac wnh))/realToFrac (voc + wnh)
            voc_dem = vocT - turnout - vocSST
        return
          $ Heidi.insert (BR.heidiColKey "Demographic") (Heidi.VPDouble voc_dem)
          $ Heidi.insert (BR.heidiColKey "VOC - State Average") (Heidi.VPDouble $ voc_dem + vocSST) r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant