-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
81 lines (63 loc) · 2.36 KB
/
README.Rmd
File metadata and controls
81 lines (63 loc) · 2.36 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
## Welcome
<!-- badges: start -->
<!-- badges: end -->
The `save` package is an experimental tool designed to simplify file-saving tasks for data analysis and visualization. It offers methods like csv, text, and plot to save data, text, and plot outputs with ease. As an experimental package, it aims to provide a user-friendly experience while exploring file-saving options. Please note that this package is still under development and may undergo changes in future releases.
You can install the development version of `save` like so:
``` r
devtools::install_github("tpq/save")
```
## Example
The `save` package is an experimental tool designed to streamline file-saving tasks for data analysis and visualization in R. With its intuitive interface, the package supports piping using the %>% operator, providing a seamless workflow for saving data and plot outputs.
Let's see a minimal example of how to use the `save` package with piping:
```{r, message = FALSE, warning = FALSE}
library(dplyr)
library(ggplot2)
library(save)
# Set directory to use for all saved files
save <- Save$new(wd = getwd())
# Save data as CSV
data <-
data.frame(A = 1:5, B = 6:10) %>%
save$csv(file = "csv-1") %>%
mutate(C = A + B) %>%
save$csv(file = "csv-2")
# Save data as text
model <-
lm(C ~ A + B, data) %>%
save$text(file = "model")
# Save data as plot (base R plot)
# (note: pipe with %>%)
null <-
plot(data$A, data$B) %>%
save$plot(file = "plot-1")
# Save data as plot (ggplot2)
# (note: pipe with +)
gg <-
data %>%
ggplot(aes(x = A, y = B)) +
geom_point() +
save$gg(file = "plot-2") +
theme_bw() +
save$gg(file = "plot-3")
```
In these examples, the `save` package allows you to directly pipe data frames and plot objects into the respective saving methods, providing a concise and efficient workflow for file-saving operations. Please note that the package is still under development, and your feedback is valuable for further improvements and enhancements.
```{r, echo = FALSE}
file.remove("csv-1.csv")
file.remove("csv-2.csv")
file.remove("model.txt")
file.remove("plot-1.png")
file.remove("plot-2.png")
file.remove("plot-3.png")
```