Hey, so I was taking a stroll through the code in this repo -- looks like a fun project! -- and I saw that you're using purrr! That package definitely revolutionized how I write code!
Anyway, just a quick tip that might be helpful. In lines like these, you might be able to skip the both the call to flatten_int and the anonymous function
If map is given a character string, it pulls out the element of each list item with that name. Adding the _int or _dbl takes care of the flattening down to integer/double.
map_int() does need each element to return a length-1 vector and the type needs to match the suffix or it will complain.
oh hey, a month late but thanks! I have only really scratched the surface of purrr and always feel like I'm not using it efficiently (as seen in this case). Thanks for the tip, that helps a lot actually.
Hey, so I was taking a stroll through the code in this repo -- looks like a fun project! -- and I saw that you're using
purrr
! That package definitely revolutionized how I write code!Anyway, just a quick tip that might be helpful. In lines like these, you might be able to skip the both the call to
flatten_int
and the anonymous functionhttps://github.com/TampaUseRs/EducationOutreach/blob/836ab9ff6334744363a4c2f629841da2c0541a7b/ParseUserData.R#L17-L18
by rewriting it like
If
map
is given a character string, it pulls out the element of each list item with that name. Adding the_int
or_dbl
takes care of the flattening down to integer/double.map_int()
does need each element to return a length-1 vector and the type needs to match the suffix or it will complain.