This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import polars as pl | |
| # Making data frames ------------------------------------------ | |
| # with dictionary | |
| df = pl.DataFrame({ | |
| 'name': ['foo', 'bar', 'baz'], | |
| 'bar': [0, 1, 2], | |
| 'qux': [0.0, 1.0, 2.0] | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| # "faithful" is a dataset about a geyser, showing size of eruption vs. waiting | |
| # time before the eruption | |
| data <- as_tibble(datasets::faithful) %>% | |
| mutate(index = 1:n()) %>% | |
| head(10) | |
| data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sigfig <- function(x, n = 2) { | |
| formatC(signif(x, digits = n), digits = n, format = "fg", flag = "#") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Say I have some short-hand labels like "Ec/q", | |
| # which actually stand for "E. coli & quinolones", | |
| # but I want "E. coli" to be in italics | |
| library(tidyverse) | |
| n <- 100 | |
| tibble( | |
| x = rnorm(n), |
NewerOlder