forcats
cheatsheets
forcats | cheatsheets | |
---|---|---|
4 | 61 | |
553 | 5,921 | |
-0.2% | 0.8% | |
1.7 | 8.7 | |
5 months ago | 5 days ago | |
R | TeX | |
GNU General Public License v3.0 or later | Creative Commons Attribution 4.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
forcats
-
Using scale_x_discrete on graphs
Have a look at the forcats package https://forcats.tidyverse.org/
-
[Q] 'pivot_longer' applied to an object of class "character"
Such a function wouldn't add anything that factor() or as.factor() don't already do, but the forcats tidyverse package does make it easier to work with factor variables afterwards: https://forcats.tidyverse.org/
-
This chart has the days of the week on the x-axis, but they are all over the place, starting with Sunday and then going to Wednesday. My table has the correct sequence of days. So why is this happening to me? :\
Turn weekdays to factors to have some control over order. https://forcats.tidyverse.org/ https://r4ds.had.co.nz/factors.html#modifying-factor-order
-
Frustration: One Year with R
This was fun to play around with. I made some very minor changes and posted at https://gist.github.com/hadley/d54895557fbb0fe0402d2277b9011....
It revealed to me that there's a buglet in `forcats::last()` (https://github.com/tidyverse/forcats/issues/303) and made me wonder if `pivot_longer()` should be able to rename the columns as you pivot them (https://github.com/tidyverse/tidyr/issues/1338)
cheatsheets
-
KlongPy: High-Performance Array Programming in Python
I 100% agree, I think the functional features that have been added across all the popular languages (map, reduce, fold etc.) has been a positive. Nothing demonstrates it better (imo) than purrr in R: https://github.com/rstudio/cheatsheets/blob/main/purrr.pdf
I also think there is some merit to “high syntactical density” clearly if you can see the entire code in one place instead of having to navigate through many files or sections that’s beneficial. (Heavily discussed in the last big HN thread: https://news.ycombinator.com/item?id=38981639)
I also think JQ has proven the merit of tacit functional languages in that you can concisely write arbitrary transforms/queries on json that can be more expressive than SQL (many SQL engines have added JSONPath anyway). And I also think postfix is great for processing pipelines.
But I am not totally convinced in the approach of APL/J/Q/KDB for the combination of terse style + prefix + tacit because it makes the code so difficult to read. I think if you took an approach similar to JQ where instead of relying on symbols operators were just human readable words it would be easier to get us half way there to trying out the verb, adverbs etc. approach of the APL family. The problem with making it human readable text is that you lose the conciseness which is part of the draw of the APL family as they want to have a high syntax density and analogous code to mathematical expressions.
-
Tools a Data Scientist should know:
If you're an R user, stringr + its cheatsheet gets you very close to remembering what to do without needing to look further!
-
JSON to PDF Magic: Harnessing LaTeX and JSON for Effortless Customization and Dynamic PDF Generation
For more information on how to use ggplot2 and create charts consult the ggplot2 official page or the ggplot2 cheat graphic.
-
Best packages to learn?
I'd suggest you have a look at cheatsheets (or download them from GitHub) if you want to get to know your way around a package or set if functions, it saves you a lot of time.
-
How do I make these shapes (pictured below) in ggplot?
You could use geom_hline and geom_vline, geom_abline, or geom_segment for this. (The ggplot cheat sheet is very useful for answering these kinds of questions, BTW.)
-
Why does my scatter plot look like this?
I can't say for sure because I don't know what your ultimate aim is for your visualization. Check out the cheat sheet for ggplot2 here.
-
Import from Excel
Finally just do your analysis. You should also should give a try and see the cheat sheet for data importing on the tidyverse package.
-
[Request] How to best visualize percentages with R?
That said, when I’m trying to come up with an interesting way to visualize data, I find the ggplot cheat sheet very helpful: https://github.com/rstudio/cheatsheets/raw/main/data-visualization-2.1.pdf
-
Need help with variables
Here's a cheat sheet: https://github.com/rstudio/cheatsheets/blob/main/strings.pdf
-
Data manipulation in R
The cheat sheet of the stringr package should give you good overview of string manipulation/ regex in R.
What are some alternatives?
desctable - An R package to produce descriptive and comparative tables
mostly-adequate-guide - Mostly adequate guide to FP (in javascript)
ggplot2-book - ggplot2: elegant graphics for data analysis
tidytuesday - Official repo for the #tidytuesday project
dtplyr - Data table backend for dplyr
mech - 🦾 Mech is a programming language for building data-driven systems like robots, games, and interfaces. Start here!
tidyr - Tidy Messy Data
Frustration-One-Year-With-R - An extremely long review of R.
stringr - A fresh approach to string manipulation in R