February 2021
February 1
The {dplyr} syntax is heavily inspired by #SQL, which means it is easy to translate the {dplyr} code to its equivalent query and this is supported in {dplyr} itself! π https://t.co/rjE4S2MK8o#rstats #DataScience pic.twitter.com/SffAhyRmWh
β R Function A Day (@rfunctionaday) February 1, 2021
February 2
In case you want to peruse how a ggplot (and its various layers) are built, you can use the {ggplot_build} function from {ggplot2}! π π§ π¦Ί https://t.co/mIq2G3qAo8
β R Function A Day (@rfunctionaday) February 2, 2021
Useful also to investigate what are the aesthetic defaults for utilized {geom_}s.#rstats #DataScience pic.twitter.com/UnQdpZYCJ8
February 3
If you want to get a quick overview of descriptive statistics for a numeric variable, {describe_distribution} from {parameters} π¦ is your friend π https://t.co/KlhJNsdL90
β R Function A Day (@rfunctionaday) February 3, 2021
Also works with a {grouped_} dataframe from {dplyr} π#rstats #DataScience pic.twitter.com/FoBio2p8yk
February 4
If you want to see a beautiful, colorful tree of your directory file structure, you can use {dir_tree} function from {fs} package! π³π https://t.co/UpjcB7z7Qf#rstats #DataScience pic.twitter.com/SlXAIcePoA
β R Function A Day (@rfunctionaday) February 4, 2021
February 5
If you work a lot with web scraping and need to extract a particular node from HTML page, {html_nodes} from {rvest} π¦ is your friend π―ββοΈhttps://t.co/ob6beJEkZN#rstats #DataScience pic.twitter.com/kcouQ5rTfC
β R Function A Day (@rfunctionaday) February 5, 2021
February 6
In a long script, it can become tiresome to keep duplicating the same object name when it is being self-assigned.
β R Function A Day (@rfunctionaday) February 6, 2021
In such instances, the assignment pipe from {magrittr} π¦ proves handy! πhttps://t.co/NVHXfOZOI9#rstats #DataScience pic.twitter.com/3iGuHsUZjG
February 7
Often you might want to split an existing column into a combination of a few other columns and {separate} from {tidyr} π¦ is exactly what you are looking for! πͺ https://t.co/imqGN7ridk#rstats #DataScience pic.twitter.com/wrSFpNtNeM
β R Function A Day (@rfunctionaday) February 7, 2021
February 8
The {row_number} function from {dplyr} is a timesaver if you have to create a unique identifier for observations, especially if they belong to different groups 1οΈβ£2οΈβ£3οΈβ£https://t.co/XSagfpLHVg#rstats #DataScience pic.twitter.com/JWb0W2XMjz
β R Function A Day (@rfunctionaday) February 8, 2021
February 9
Sometimes you just want to extract the source code present in the source document (e.g., Rmd) to a separate script, and {purl} from {knitr} π¦ makes that effortless! π¦ͺhttps://t.co/2lwSJ2HhKG#rstats #DataScience pic.twitter.com/RpqD7zsQst
β R Function A Day (@rfunctionaday) February 9, 2021
February 10
Often you need to convert country names/codes from different conventions to standardized names, and {countrycode} function from the eponymous π¦ can handle most of such conversions! βοΈhttps://t.co/QVF8hBe7BE#rstats #DataScience pic.twitter.com/RByINBRutU
β R Function A Day (@rfunctionaday) February 10, 2021
February 11
Sometimes a factor level can be missing implicitly, you can make it explicit using {fct_explicit_na} function from {forcats} π¦ :https://t.co/GexbNwDl4L#rstats #DataScience pic.twitter.com/7XI2z0cXR8
β R Function A Day (@rfunctionaday) February 11, 2021
February 12
Cleaning column names so that they have a consistent pattern is probably the first and the most important step in data analysis and {clean_names} function from {janitor} π¦ is peerless in this regard π§Ό https://t.co/7w14DlhEvA#rstats #DataScience pic.twitter.com/GmmVwHVrOA
β R Function A Day (@rfunctionaday) February 12, 2021
February 13
The {markdown_} function family from {commonmark} π¦ can help you to convert markdown text into various formats (e.g., latex, html, etc.) βοΈ https://t.co/kADYv6J4lB
β R Function A Day (@rfunctionaday) February 13, 2021
Can be a useful tool for teaching, say html, if one is already comfortable with rmarkdown.#rstats #DataScience pic.twitter.com/AZyxYsPxvX
February 14
Some graphics π¦s (e.g.Β {hrbrthemes}) require special fonts. But it can be a pain to list and interrogate installed fonts.
β R Function A Day (@rfunctionaday) February 14, 2021
The {system_fonts} function from {systemfonts} π¦ outputs a beautiful richly informative table with a one-line command π#rstats #DataScience pic.twitter.com/aTiJdg7gZs
February 15
When you just need to create a list of all possible combinations of values in a vector, {combn} function from {utils} π¦ comes in handy π§°https://t.co/5tPzuFp1P9#rstats #DataScience pic.twitter.com/RoyLDraNty
β R Function A Day (@rfunctionaday) February 15, 2021
February 16
When you have to present results from a regression model in a well-formatted table, the {tbl_regression} function from {gtsummary} π¦ will be a serious time-saver πhttps://t.co/EVoZ6ZRbgY#rstats #DataScience pic.twitter.com/q3MvqXIIog
β R Function A Day (@rfunctionaday) February 16, 2021
February 17
In a deeply nested data structure (an object from JSON, e.g.), indexing can be a bit tedious in base-R.
β R Function A Day (@rfunctionaday) February 17, 2021
The {pluck} function from {purrr} π¦ provides a less tiresome way to index πhttps://t.co/ePJ6HHVKm4#rstats #DataScience pic.twitter.com/nhHEJKjkAu
February 18
For comparing performance of different functions, or plain out of curiosity, sometimes we wish to benchmark an expression, and the {mark} function from {bench} π¦ makes this very easy! ποΈββοΈhttps://t.co/0qP7sY7J9c
β R Function A Day (@rfunctionaday) February 18, 2021
Note how {cor} is faster than {cor.test}.#rstats #DataScience pic.twitter.com/8AGUg3rE4O
February 19
Nothing improves the readability of the code like a style guide, and this is exactly what {style_*} function family from {styler} π¦ does! π
β R Function A Day (@rfunctionaday) February 19, 2021
The easiest thing to do is to run this function in the directory with your R scripts π§Ή https://t.co/Xjh4j4HuhQ#rstats #DataScience pic.twitter.com/NBhgffztFN
February 20
The #rstats has a native {IN} operator but sometimes you might miss the {NOT IN} operator from SQL. πͺ
β R Function A Day (@rfunctionaday) February 20, 2021
The {%nin%} operator from {sjmisc} has you covered! πhttps://t.co/7IzXkPxlYD#rstats #DataScience pic.twitter.com/5dpgqHa8Vj
February 21
If you are well-versed in SQL and looking to learn {dplyr}, the {show_dplyr} function from {tidyquery} π¦ can be a helpful teaching assistant while translating from a SQL query to equivalent {dplyr} code! π©βπ«https://t.co/gT4ESz4h4y#rstats #DataScience pic.twitter.com/duKYJRuJN0
β R Function A Day (@rfunctionaday) February 21, 2021
February 22
Although a number of functions tend to have a {data} argument, some donβt. For such functions, the pipe operator (%>%) from {magrittr} π¦ wonβt work.
β R Function A Day (@rfunctionaday) February 22, 2021
In such contexts, one can use the exposition pipe operator (%$%) πhttps://t.co/1RODRqilaL#rstats #DataScience pic.twitter.com/qxFmzJROKU
February 23
The first important step of any data analysis workflow is to make sure that everything about your data βmakes senseβ and a few other tools out there do as good of a job describing your data as {skim} function from {skimr} π¦!https://t.co/vg3t4v8Ixq#rstats #DataScience pic.twitter.com/FtpFi8ReZY
β R Function A Day (@rfunctionaday) February 23, 2021
February 24
The infix operator (%||%) from {rlang} π¦ can be helpful for having a default value in case it is {NULL} πͺhttps://t.co/qdMs5VAgjo
β R Function A Day (@rfunctionaday) February 24, 2021
Helpful for collaborative scripts or π¦ functions where users might enter different spellings to specify the same argument.#rstats #DataScience pic.twitter.com/RDeKBpcFD1
February 25
Checking association between variables often involves carrying out correlation analysis and a few functions make this as easy as {correlation} from eponymous π¦https://t.co/VGZhhq9L0P
β R Function A Day (@rfunctionaday) February 25, 2021
Supports a huge variety of correlation methods.#rstats #DataScience pic.twitter.com/piTCGqE5Ek
February 26
If you want to conditionally select values in a dataframe, you can use {dplyr::filter}, but what if you want to do the same for a vector or a list?
β R Function A Day (@rfunctionaday) February 26, 2021
The {keep} function from {purrr} does exactly that! π± https://t.co/pAXndQ9Pl2#rstats #DataScience pic.twitter.com/6yixL2ZKae
February 27
JSON data representation format is ubiquitous and some time we might need to convert our dataframe in R to a JSON object.
β R Function A Day (@rfunctionaday) February 27, 2021
The {toJSON} function from {jsonlite} makes this a childβs play πΆhttps://t.co/0lOvOE19EW#rstats #DataScience pic.twitter.com/PAbVQy4Kiz
February 28
When you are working with free-form survey inputs, you need to consider the possibility of mistakes in data entry.
β R Function A Day (@rfunctionaday) February 28, 2021
In such contexts {stringdist_join} function from {fuzzyjoin} π¦ can save you headache while joining dataframes! βοΈhttps://t.co/HNANB6IjH2#rstats #DataScience pic.twitter.com/b3HT9Soqoa