-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 24.7 KB
/
.Rhistory
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
!is.null(increment_version)
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes)
package_tarball
package_dir
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
?devtools::build
#' Build and install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes, path = output_directory)
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
return(package_tarball)
}
getwd()
build_and_install_package(path = "../testest")
#' Build and install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes, path = output_directory)
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
return(package_tarball)
}
build_and_install_package(path = "../testest")
build_and_install_package(output_directory = = "../testest")
build_and_install_package(output_directory = "../testest")
build_and_install_package(output_directory = "../temp/")
build_and_install_package(output_directory = "../temp/abc.txt")
dir.exists("../temp/")
dir.exists("../temp/abc.txt")
dir.exists("../temp/packageR_0.0.0.9000.tar.gz")
#' Build and install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes, path = output_directory)
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
return(package_tarball)
}
build_and_install_package(output_directory = "../temp/abc.txt")
build_and_install_package()
#' Build and install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory) & !dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes, path = output_directory)
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
return(package_tarball)
}
build_and_install_package()
#' Build and install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes, path = output_directory)
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
return(package_tarball)
}
#' Build and install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = package_dir, vignettes = build_vignettes, path = output_directory)
# Install the package and return the tarball
system(paste("R CMD INSTALL", package_tarball))
return(package_tarball)
}
build_and_install_package(output_directory = "../temp/abc.txt")
build_and_install_package()
build_and_install_package(increment_version = "dev")
#' Build vignettes for a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @return Path to the package tarball
#' @export
build_vignettes = function(package_dir = getwd()){devtools::build_vignettes(package_dir)}
x = devtools::build_vignettes()
x
?devtools::build_vignettes()
#' Run examples in a package
#'
#' @param package Path to either a package source direcory or a package tarball. Default is current working directory.
#' @export
run_examples = function(package = getwd()){
devtools::run_examples(package)
}
#' Run R check on a package tarball
#'
#' @param package_tarball Path to a package tarball.
#' @export
r_check = function(package_tarball){
system(paste("R CMD check", package_tarball))
}
#' Run BiocCheck on a package
#'
#' @param package Path to either a package source direcory or a package tarball. Default is current working directory.
#' @export
bioc_check = function(package = getwd()){
BiocCheck::BiocCheck(package = package)
}
#' Run BiocCheckGitClone on a package
#'
#' @param package Path to either a package source direcory or a package tarball. Default is current working directory.
#' @export
bioc_git_check = function(package = getwd()){
BiocCheck::BiocCheckGitClone(package)
}
?BiocCheck::BiocCheckGitClone
?BiocCheck::BiocCheck
getwd()
setwd("R/")
package = getwd()
package
dirname(package)
#' Run examples in a package
#'
#' @param package Path to either a package source directory or a package tarball. Default is current working directory.
#' @export
run_examples = function(package = getwd()){
devtools::run_examples(package)
}
#' Run R check on a package tarball
#'
#' @param package_tarball Path to a package tarball.
#' @return An object of class rcmdcheck.
#' @export
r_check = function(package_tarball){
rcmdcheck::rcmdcheck(package_tarball)
}
#' Run BiocCheck on a package
#'
#' @param package Path to either a package source directory or a package tarball. Default is current working directory.
#' @return An object of class BiocCheck which consists of three lists: error, warning and note.
#' @export
bioc_check = function(package = getwd(), checkDir){
BiocCheck::BiocCheck(package = package)
}
#' Run BiocCheckGitClone on a package
#'
#' @param package Path to a package source directory. Default is current working directory.
#' @return An object of class BiocCheck which consists of three lists: error, warning and note.
#' @export
bioc_git_check = function(package_dir = getwd()){
BiocCheck::BiocCheckGitClone(package_dir)
}
#' Run package checks on a package tarball
#'
#' @param package_dir Path to a package source directory.
#' @param run_examples Logical value indicating whether to run devtools::run_examples(). Default is TRUE.
#' @param r_check Logical value indicating whether to run R CMD check. Default is TRUE.
#' @param bioc_check Logical value indicating whether to run BiocCheck. Default is TRUE.
#' @param bioc_git_check Logical value indicating whether to run BiocCheckGitClone. Default is TRUE.
#' @export
package_check_pipeline = function(package_tarball, run_examples = TRUE, r_check = TRUE,
bioc_check = TRUE, bioc_git_check = TRUE){
# Check that a path to a directory provided to package_dir
if(!dir.exists(package_dir)){"package_dir should be the path to a package source directory"}
# Initialize a list to store results of checks
check_results = list()
# Perform specified checks
if(run_examples){list$run_examples = run_examples(package = package_tarball)}
if(r_check){list$r_check = r_check(package_tarball = package_tarball)}
if(bioc_check){list$bioc_check = bioc_check(package = package_tarball)}
if(bioc_git_check){list$bioc_git_check = bioc_git_check(package = package_tarball)}
# Return list with check results
return(check_results)
}
?rcmdcheck::rcmdcheck
funk = function(x){x+5}
funk(10)
funk = 22
funk(10)
?devtools::run_examples
?BiocCheck::BiocCheckGitClone
getwd()
library(packageR)
?bioc_check
getwd()
cd ./..
setwd("../..")
getwd()
packageR::build_and_install_package("methylTools/")
package_dir = "methylTools/"
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(".")
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
output_directory = NULL
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
increment_version
!is.null(increment_version)
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
#' Build and then optionally install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param install Logical value indicating if package should be installed after it is built. Default is TRUE.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
install = TRUE, build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
# Install the package if specified and return the tarball
if(install){devtools::install(package_tarball)}
return(package_tarball)
}
#' Build and then optionally install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param install Logical value indicating if package should be installed after it is built. Default is TRUE.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
install = TRUE, build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
# Install the package if specified and return the tarball
if(install){devtools::install(package_tarball)}
return(package_tarball)
}
getwd()
build_and_install_package(package_dir = "packageR/")
package_dir = "packageR/"
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
current_dir
getwd()
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
build_vignettes
build_vignettes = FALSE
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
# Install the package if specified and return the tarball
if(install){devtools::install(package_tarball)}
install = TRUE
# Install the package if specified and return the tarball
if(install){devtools::install(package_tarball)}
?devtools::instal
?devtools::install
?install_local
#' Build and then optionally install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param install Logical value indicating if package should be installed after it is built. Default is TRUE.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
install = TRUE, build_vignettes = FALSE, increment_version = NULL){
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
# Install the package if specified and return the tarball
if(install){install.packages(package_tarball, repos = NULL, type="source")}
return(package_tarball)
}
build_and_install_package(package_dir = "packageR/")
getwd()
#' Build and then optionally install a package
#'
#' @param package_dir Path to the package source directory. Default is the current directory.
#' @param output_directory Directory in which to save package tarball. Default is the parent directory of the package source directory.
#' @param install Logical value indicating if package should be installed after it is built. Default is TRUE.
#' @param build_vignettes A logical value indicating whether or not to build PDF vignettes. Default is FALSE.
#' @param increment_version If provided, bumps the package version using usethis::use_version().
#' Should be one of "major", "minor", "patch" or "dev".
#' @return Path to the package tarball
#' @export
build_and_install_package = function(package_dir = getwd(), output_directory = NULL,
install = TRUE, build_vignettes = FALSE, increment_version = NULL){
# Check that package_dir exists
if(!dir.exists(package_dir)){
stop("Path provided to package_dir is not a directory")
}
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
# Install the package if specified and return the tarball
if(install){install.packages(package_tarball, repos = NULL, type="source")}
return(package_tarball)
}
build_and_install_package(package_dir = "packageR/")
build_and_install_package(package_dir = ".")
library(packageR)
reload_package("packageR")
package = "packageR"
detach(name = paste0("package:", package), unload = T, character.only = T)
library(package, character.only = T)
reload_package("packageR")
#' Reload a package
#'
#' @param package A string giving the name of a package
#' @export
reload_package = function(package){
detach(name = paste0("package:", package), unload = T, character.only = T)
library(package, character.only = T)
}
reload_package("packageR")
getwd()
build_and_install_package(".")
reload_package("packageR")
package_dir = getwd()
increment_version = NULL
output_directory = NULL
build_vignettes = FALSE
install = TRUE
# Check that package_dir exists
if(!dir.exists(package_dir)){
stop("Path provided to package_dir is not a directory")
}
# Save path to current directory and then change into path for package
current_dir = getwd()
on.exit(setwd(current_dir))
setwd(package_dir)
# Check that allowed value provided for increment_version and that output_directory is the path to a directory
match.arg(increment_version, choices = c("major", "minor", "patch", "dev"))
if(!is.null(output_directory)){
if(!dir.exists(output_directory)){stop("output_directory must be the path to a directory")}
}
# If increment_version is TRUE, increment version
if(!is.null(increment_version)){usethis::use_version(which = increment_version)}
# Build the package and save the path to its tarball
package_tarball = devtools::build(pkg = ".", vignettes = build_vignettes, path = output_directory)
package_tarball
getwd()
# Install the package if specified and return the tarball
if(install){install.packages(package_tarball, repos = NULL, type = "source")}