Skip to content

Commit d9693cd

Browse files
committed
passing checks
1 parent 87c30ab commit d9693cd

File tree

9 files changed

+39
-70
lines changed

9 files changed

+39
-70
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.RData
44
.Ruserdata
55
inst/doc
6+
README.html

R/diffrproject.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ diffrproject <-
1717
R6::R6Class(
1818

1919
#### class name ============================================================
20-
"diffrproject",
21-
20+
classname = "diffrproject",
21+
22+
#### misc ====================================================================
23+
active = NULL,
24+
inherit = rtext::R6_rtext_extended,
25+
lock_objects = TRUE,
26+
class = TRUE,
27+
portable = TRUE,
28+
lock_class = FALSE,
29+
cloneable = TRUE,
30+
parent_env = asNamespace('rtext'),
2231

2332

2433
#### private ===============================================================

R/tools.R

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
#' checking if value is uniqe in set
22
#' @param x vector to check
3+
#' @keywords internal
34
is_unique <- function(x){
45
!is_duplicate(x)
56
}
67

78
#' checking if value is duplicated in set
89
#' @param x vector to check
10+
#' @keywords internal
911
is_duplicate <- function(x){
1012
x %in% x[duplicated(x)]
1113
}
1214

1315
#' extract specific item from each list element
1416
#' @param l list
1517
#' @param item name or index of item to extract
18+
#' @param unlist defaults to TRUE, whether to unlist results or leave as list
19+
#' @keywords internal
1620
get_list_item <- function(l, item, unlist=TRUE){
1721
tmp <- lapply(l, `[`, item)
1822
index <- vapply(tmp, is.null, TRUE)
@@ -25,47 +29,6 @@ get_list_item <- function(l, item, unlist=TRUE){
2529
}
2630

2731

28-
#' text function: wrapper for system.file() to access test files
29-
#' @param x name of the file
30-
#' @param pattern pattern of file name
31-
#' @keywords internal
32-
test_file <- function(x=NULL, pattern=NULL, full.names=FALSE){
33-
if(is.numeric(x)){
34-
return(dp_tf(dp_tf()[(x-1) %% length(dp_tf()) +1 ]))
35-
}
36-
if(is.null(x)){
37-
return(
38-
list.files(
39-
system.file(
40-
"testfiles",
41-
package = "diffrprojects"
42-
),
43-
pattern = pattern,
44-
full.names = full.names
45-
)
46-
)
47-
}else if(x==""){
48-
return(
49-
list.files(
50-
system.file(
51-
"testfiles",
52-
package = "diffrprojects"
53-
),
54-
pattern = pattern,
55-
full.names = full.names
56-
)
57-
)
58-
}else{
59-
return(
60-
system.file(
61-
paste("testfiles", x, sep="/"),
62-
package = "diffrprojects")
63-
)
64-
}
65-
}
66-
67-
68-
6932

7033
#' function rbinding list elements
7134
#' @param l list

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ library(diffrprojects)
8282
8383
dp <- diffrproject$new()
8484
85-
testfiles <- diffrprojects:::test_file(pattern="rc_\\d.txt", full.names = TRUE)
85+
testfiles <- rtext:::testfile(pattern="rc_\\d.txt", full.names = TRUE)
8686
8787
dp$text_add(testfiles)
8888
names(dp$texts)

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ http://dx.doi.org/10.1111/lsq.12106>.
9191

9292
```r
9393
library(diffrprojects)
94+
```
95+
96+
```
97+
## Loading required package: stringb
98+
```
9499

100+
```
101+
## Loading required package: rtext
102+
```
103+
104+
```r
95105
dp <- diffrproject$new()
96106

97107
testfiles <- diffrprojects:::test_file(pattern="rc_\\d.txt", full.names = TRUE)
@@ -101,6 +111,9 @@ dp$text_add(testfiles)
101111

102112
```
103113
## rtext : initializing
114+
```
115+
116+
```
104117
## rtext : initializing
105118
## rtext : initializing
106119
```
@@ -118,14 +131,10 @@ dp$text_data()
118131
```
119132

120133
```
121-
## text_file character encoding
122-
## 1 /home/peter/R/x86_64-pc-linux-gnu-library/3.3/diffrprojects/testfiles/rc_1.txt 1501 UTF-8
123-
## 2 /home/peter/R/x86_64-pc-linux-gnu-library/3.3/diffrprojects/testfiles/rc_2.txt 10842 UTF-8
124-
## 3 /home/peter/R/x86_64-pc-linux-gnu-library/3.3/diffrprojects/testfiles/rc_3.txt 10268 UTF-8
125-
## sourcetype
126-
## 1 text_file
127-
## 2 text_file
128-
## 3 text_file
134+
## text_file character encoding sourcetype
135+
## 1 C:/Users/peter/R/win-library/3.3/diffrprojects/testfiles/rc_1.txt 926166 UTF-8 text_file
136+
## 2 C:/Users/peter/R/win-library/3.3/diffrprojects/testfiles/rc_2.txt 844551 UTF-8 text_file
137+
## 3 C:/Users/peter/R/win-library/3.3/diffrprojects/testfiles/rc_3.txt 643012 UTF-8 text_file
129138
```
130139

131140
```r

man/get_list_item.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/is_duplicate.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/is_unique.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/test_file.Rd

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)