-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
167 lines (121 loc) · 3.84 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "##",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
```{r, include=FALSE}
options("width"=110)
tmp <- packageDescription( basename(getwd()) )
```
```{r, results='asis', echo=FALSE}
cat("##", tmp$Title)
```
```{r, include=FALSE}
filelist.R <- list.files("R", recursive = TRUE, pattern="\\.R$", ignore.case = TRUE, full.names = TRUE)
filelist.tests <- list.files("tests", recursive = TRUE, pattern="\\.R$", ignore.case = TRUE, full.names = TRUE)
filelist.cpp <- list.files("src", recursive = TRUE, pattern="\\.cpp$", ignore.case = TRUE, full.names = TRUE)
lines.R <- unlist(lapply(filelist.R, readLines))
lines.tests <- unlist(lapply(filelist.tests, readLines))
lines.cpp <- unlist(lapply(filelist.cpp, readLines))
length.R <- length(grep("(^\\s*$)|(^\\s*#)|(^\\s*//)", lines.R, value = TRUE, invert = TRUE))
length.tests <- length(grep("(^\\s*$)|(^\\s*#)|(^\\s*//)", lines.tests, value = TRUE, invert = TRUE))
length.cpp <- length(grep("(^\\s*$)|(^\\s*#)|(^\\s*//)", lines.cpp, value = TRUE, invert = TRUE))
```
**Status**
*lines of R code:* `r length.R`, *lines of test code:* `r length.tests`
[![repo status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
<a href="https://travis-ci.org/petermeissner/`r tmp$Package`">
<img src="https://api.travis-ci.org/petermeissner/`r tmp$Package`.svg?branch=master">
<a/>
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/petermeissner/`r tmp$Package`?branch=master&svg=true)](https://ci.appveyor.com/project/petermeissner/ical)
<a href="https://cran.r-project.org/package=`r tmp$Package`">
<img src="http://www.r-pkg.org/badges/version/`r tmp$Package`">
</a>
<a href="https://codecov.io/gh/petermeissner/`r tmp$Package`">
<img src="https://codecov.io/gh/petermeissner/`r tmp$Package`/branch/master/graph/badge.svg" alt="Codecov" />
</a>
<img src="http://cranlogs.r-pkg.org/badges/grand-total/`r tmp$Package`">
<img src="http://cranlogs.r-pkg.org/badges/`r tmp$Package`">
**Development version**
```{r, include=FALSE}
source_files <-
grep(
"/R/|/src/|/tests/",
list.files(recursive = TRUE, full.names = TRUE),
value = TRUE
)
last_change <-
as.character(
format(max(file.info(source_files)$mtime), tz="UTC")
)
```
```{r, results='asis', echo=FALSE}
cat(tmp$Version)
cat(" - ")
cat(stringr::str_replace(last_change, " ", " / "))
```
**Description**
```{r, results='asis', echo=FALSE}
cat(tmp$Description)
```
**License**
```{r, results='asis', echo=FALSE}
cat(tmp$License, "<br>")
cat(tmp$Author)
```
## Installation
You can install the released version of tabit from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("tabit")
```
And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("petermeissner/tabit")
```
## Example
```{r load package}
# load package
library(tabit)
```
**simple vectors**
```{r}
# simple tabulation
tabit(mtcars$cyl)
```
**simple data.frames**
```{r}
# can we do this with data.frames
tabit(mtcars[, c("cyl", "am")])
```
**simple tibbles**
```{r}
# what about this tibble thing?
suppressPackageStartupMessages({
library(dplyr)
})
mtcars %>%
select(cyl, am) %>%
tabit()
```
**grouped tibbles**
```{r}
# ... and grouped tibbles?
mtcars %>%
group_by(cyl, am) %>%
tabit()
```
**too much magic?**
```{r}
# use tabit_1() for vector usage
tabit_1(letters[1:4])
# use tabit_x for data.frames and tibbles
tabit_x(mtcars[, c("cyl", "am")])
```