-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
68 lines (50 loc) · 1.38 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
output: github_document
---
[![Travis-CI Build Status](https://travis-ci.org/romainfrancois/css.svg?branch=master)](https://travis-ci.org/romainfrancois/css)
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
```{r, include = FALSE}
library(dplyr)
library(readr)
library(css)
```
# css
`css` eases the manipulation of css files with the functions `read_css` and `write_css`.
## Installation
You can install css from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("romainfrancois/css")
```
## Example
```{r example}
# one rstudio css theme
dracula <- paste0(
"https://raw.githubusercontent.com/rstudio/rstudio/",
"0d9d49aa8671527370c6c261fc031ae8a8081c45/src/gwt/src/",
"org/rstudio/studio/client/workbench/views/source/editors/text/themes/dracula.css"
)
# reading it with read_css
data <- read_css(dracula)
# ... now it's a tibble ...
glimpse(data)
DT::datatable(data)
```
You can then tidyverse it a bit and then save it back to a file using `write_css`:
```{r}
data <- data %>%
mutate( value = case_when(
property == "background-color" ~ "#ff0000",
TRUE ~ value
))
tf <- tempfile()
write_css(data, tf)
writeLines( read_lines(tf, n_max = 10))
```