.Rhistory 15.7 KB
Newer Older
Armin Rauschenberger's avatar
Armin Rauschenberger committed
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
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else if (family == "binomial") {
if (type.measure == "deviance") {
limit <- 1e-05
fit[[i]][fit[[i]] < limit] <- limit
fit[[i]][fit[[i]] > 1 - limit] <- 1 - limit
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(-2 * (y * log(x) + (1 -
y) * log(1 - x))))
}
else if (type.measure == "mse") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) 2 * mean((x - y)^2))
}
else if (type.measure == "mae") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) 2 * mean(abs(x - y)))
}
else if (type.measure == "class") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(abs(round(x) - y)))
}
else if (type.measure == "auc") {
weights <- table(foldid)
cvraw <- matrix(data = NA, nrow = length(weights),
ncol = ncol(fit[[i]])) # typo in palasso package !
for (k in seq_along(weights)) {
cvraw[k, ] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) glmnet::auc(y = y[foldid ==
k], prob = x[foldid == k]))
}
loss[[i]] <- apply(X = cvraw, MARGIN = 2, FUN = function(x) stats::weighted.mean(x = x,
w = weights, na.rm = TRUE))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else if (family == "poisson") {
if (type.measure == "deviance") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(2 * (ifelse(y == 0,
0, y * log(y/x)) - y + x), na.rm = TRUE))
}
else if (type.measure == "mse") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean((x - y)^2))
}
else if (type.measure == "mae") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(abs(x - y)))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else if (family == "cox") {
if (type.measure == "deviance") {
weights <- tapply(X = y[, "status"], INDEX = foldid,
FUN = sum)
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) stats::weighted.mean(x = x/weights,
w = weights, na.rm = TRUE))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else {
stop("Invalid family.", call. = FALSE)
}
if (sum(diff(is.na(loss[[i]]))) == 1) {
loss[[i]] <- loss[[i]][!is.na(loss[[i]])]
}
}
return(loss)
}
list <- list()
for(i in seq_len(100)){
n <- 100
p <- 500
beta <- stats::rnorm(n=p)
cond <- stats::rbinom(n=p,size=1,prob=0.2)
beta[cond==0] <- 0
X <- matrix(stats::rnorm(n=n*p),nrow=n,ncol=p)
mean <- X %*% beta
y <- stats::rnorm(n=n,mean=mean,sd=1)
#z <- 1*(y > 0)
#y <- rnorm(n) # testing ... REMOVE THIS
#y <- sample(y) # testing ...
#z <- sample(z) # testing ...
#test <- bilasso(y=y,cutoff=0,X=X)
#plot(x=test$pi,y=test$cvm)
#test$pi.min
list[[i]] <- bilasso_compare(y=y,cutoff=0,X=X)
}
class <- t(sapply(list,function(x) x$class))
colMeans(class)
auc <- t(sapply(list,function(x) x$auc))
colMeans(auc)
deviance <- t(sapply(list,function(x) x$deviance)
deviance <- t(sapply(list,function(x) x$deviance))
deviance <- t(sapply(list,function(x) x$deviance))
colMeans(deviance)
deviance <- t(sapply(list,function(x) x$deviance))
colMeans(deviance)
class <- t(sapply(list,function(x) x$class))
colMeans(class)
auc <- t(sapply(list,function(x) x$auc))
colMeans(auc)
#' @export
#' @title
#' bilasso
#'
#' @description
#' Implements penalised regression with response duality.
#'
#' @param y
#' continuous response\strong{:}
#' vector of length \eqn{n}
#'
#' @param z
#' binary response\strong{:}
#' vector of length \eqn{n}
#'
#' @param cutoff
#' value between \code{min(y)} and \code{max(y)}
#'
#' @param X
#' covariates\strong{:}
#' matrix with \eqn{n} rows (samples) and \eqn{p} columns (variables)
#'
#' @param alpha
#' elastic net parameter\strong{:}
#' numeric between \eqn{0} and \eqn{1};
#' \eqn{alpha=1} for lasso,
#' \eqn{alpha=0} for ridge
#'
#' @param nfolds
#' number of folds
#'
#' @examples
#' NA
#'
bilasso <- function(y,cutoff,X,alpha=1,nfolds=10){
z <- 1*(y > cutoff)
# alpha <- 1; nfolds <- 10
Armin Rauschenberger's avatar
Armin Rauschenberger committed
151
152
153
# properties
n <- nrow(X); p <- ncol(X)
if(length(y)!=n){stop("sample size")}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
154
155
foldid <- palasso:::.folds(y=z,nfolds=nfolds)
if(cutoff < min(y) | max(y) < cutoff){stop("Cutoff outside.")}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
156
157
# model fitting
fit <- list()
Armin Rauschenberger's avatar
Armin Rauschenberger committed
158
159
160
161
fit$gaussian <- glmnet::glmnet(y=y,x=X,family="gaussian",alpha=alpha)
fit$binomial <- glmnet::glmnet(y=z,x=X,family="binomial",alpha=alpha)
# weights
fit$pi <- seq(from=0,to=1,length.out=101) # adapt this
Armin Rauschenberger's avatar
Armin Rauschenberger committed
162
# inner cross-validation
Armin Rauschenberger's avatar
Armin Rauschenberger committed
163
164
165
pred_y <- pred_z <- matrix(data=NA,nrow=length(y),ncol=100)
pred <- matrix(data=NA,nrow=length(y),ncol=length(fit$pi))
for(k in unique(foldid)){
Armin Rauschenberger's avatar
Armin Rauschenberger committed
166
167
y0 <- y[foldid!=k]
y1 <- y[foldid==k]
Armin Rauschenberger's avatar
Armin Rauschenberger committed
168
169
z0 <- z[foldid!=k]
z1 <- z[foldid==k]
Armin Rauschenberger's avatar
Armin Rauschenberger committed
170
171
X0 <- X[foldid!=k,,drop=FALSE]
X1 <- X[foldid==k,,drop=FALSE]
Armin Rauschenberger's avatar
Armin Rauschenberger committed
172
173
174
175
176
177
178
179
180
181
182
183
184
185
foldid_int <- palasso:::.folds(y=z0,nfolds=nfolds)
net_y <- glmnet::glmnet(y=y0,x=X0,family="gaussian",alpha=alpha)
net_z <- glmnet::glmnet(y=z0,x=X0,family="binomial",alpha=alpha)
temp_y <- stats::predict(object=net_y,newx=X1,type="response",s=fit$gaussian$lambda)
cvm_y <- .loss(y=y1,fit=temp_y,family="gaussian",type.measure="deviance")[[1]]
sel_y <- which.min(cvm_y)
pred_y[foldid==k,seq_len(ncol(temp_y))] <- temp_y
temp_z <- stats::predict(object=net_z,newx=X1,type="response",s=fit$binomial$lambda)
cvm_z <- .loss(y=z1,fit=temp_z,family="binomial",type.measure="deviance")[[1]]
sel_z <- which.min(cvm_z)
pred_z[foldid==k,seq_len(ncol(temp_z))] <- temp_z
for(i in seq_along(fit$pi)){
pred[foldid==k,i] <- fit$pi[i]*(temp_y[,sel_y] > cutoff) + (1-fit$pi[i])*temp_z[,sel_z]
}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
186
}
Armin Rauschenberger's avatar
Armin Rauschenberger committed
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
fit$gaussian$cvm <- .loss(y=y,fit=pred_y,family="gaussian",type.measure="deviance")[[1]]
fit$gaussian$lambda.min <- fit$gaussian$lambda[which.min(fit$gaussian$cvm)]
fit$binomial$cvm <- .loss(y=z,fit=pred_z,family="binomial",type.measure="deviance")[[1]]
fit$binomial$lambda.min <- fit$binomial$lambda[which.min(fit$binomial$cvm)]
fit$cvm <- .loss(y=z,fit=pred,family="binomial",type.measure="deviance")[[1]]
sel <- which.min(fit$cvm)
fit$pi.min <- fit$pi[sel]
class(fit) <- "bilasso"
return(fit)
}
bilasso_compare <- function(y,cutoff,X){
z <- 1*(y > cutoff)
fold <- palasso:::.folds(y=z,nfolds=5)
pred <- matrix(data=NA,nrow=length(y),ncol=3,
dimnames=list(NULL,c("gaussian","binomial","mixed")))
select <- list()
for(i in sort(unique(fold))){
cat("i =",i,"\n")
fit <- bilasso(y=y[fold!=i],X=X[fold!=i,],cutoff=cutoff)
gaussian <- 1*(stats::predict(object=fit$gaussian,
newx=X[fold==i,],
s=fit$gaussian$lambda.min,
type="response") > cutoff)
binomial <- stats::predict(object=fit$binomial,
newx=X[fold==i,],
s=fit$binomial$lambda.min,
type="response")
pred[fold==i,"gaussian"] <- gaussian
pred[fold==i,"binomial"] <- binomial
pred[fold==i,"mixed"] <- fit$pi.min*pred[fold==i,"gaussian"] + (1-fit$pi.min)*pred[fold==i,"binomial"]
}
loss <- list()
loss$deviance <- .loss(y=z,fit=pred,family="binomial",type.measure="deviance")[[1]]
loss$class <- .loss(y=z,fit=pred,family="binomial",type.measure="class")[[1]]
loss$mse <- .loss(y=z,fit=pred,family="binomial",type.measure="mse")[[1]]
loss$mae <- .loss(y=z,fit=pred,family="binomial",type.measure="mae")[[1]]
loss$auc <- .loss(y=z,fit=pred,family="binomial",type.measure="auc",foldid=fold)[[1]]
return(loss)
}
# Correct this function in the palasso package (search for "# typo").
.loss <- function (y, fit, family, type.measure, foldid = NULL)
{
if (!is.list(fit)) {
fit <- list(fit)
}
loss <- list()
for (i in seq_along(fit)) {
if (is.vector(fit[[i]])) {
fit[[i]] <- as.matrix(fit[[i]])
}
if (is.null(foldid) & (family == "cox" | type.measure ==
"auc")) {
stop("Missing foldid.", call. = FALSE)
}
if (family == "gaussian") {
if (type.measure %in% c("deviance", "mse")) {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean((x - y)^2))
}
else if (type.measure == "mae") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(abs(x - y)))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else if (family == "binomial") {
if (type.measure == "deviance") {
limit <- 1e-05
fit[[i]][fit[[i]] < limit] <- limit
fit[[i]][fit[[i]] > 1 - limit] <- 1 - limit
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(-2 * (y * log(x) + (1 -
y) * log(1 - x))))
}
else if (type.measure == "mse") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) 2 * mean((x - y)^2))
}
else if (type.measure == "mae") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) 2 * mean(abs(x - y)))
}
else if (type.measure == "class") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(abs(round(x) - y)))
}
else if (type.measure == "auc") {
weights <- table(foldid)
cvraw <- matrix(data = NA, nrow = length(weights),
ncol = ncol(fit[[i]])) # typo in palasso package !
for (k in seq_along(weights)) {
cvraw[k, ] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) glmnet::auc(y = y[foldid ==
k], prob = x[foldid == k]))
}
loss[[i]] <- apply(X = cvraw, MARGIN = 2, FUN = function(x) stats::weighted.mean(x = x,
w = weights, na.rm = TRUE))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else if (family == "poisson") {
if (type.measure == "deviance") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(2 * (ifelse(y == 0,
0, y * log(y/x)) - y + x), na.rm = TRUE))
}
else if (type.measure == "mse") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean((x - y)^2))
}
else if (type.measure == "mae") {
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) mean(abs(x - y)))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else if (family == "cox") {
if (type.measure == "deviance") {
weights <- tapply(X = y[, "status"], INDEX = foldid,
FUN = sum)
loss[[i]] <- apply(X = fit[[i]], MARGIN = 2,
FUN = function(x) stats::weighted.mean(x = x/weights,
w = weights, na.rm = TRUE))
}
else {
stop("Invalid type measure.", call. = FALSE)
}
}
else {
stop("Invalid family.", call. = FALSE)
}
if (sum(diff(is.na(loss[[i]]))) == 1) {
loss[[i]] <- loss[[i]][!is.na(loss[[i]])]
}
}
return(loss)
}
list <- list()
for(i in seq_len(100)){
n <- 100
p <- 500
beta <- stats::rnorm(n=p)
cond <- stats::rbinom(n=p,size=1,prob=0.2)
beta[cond==0] <- 0
X <- matrix(stats::rnorm(n=n*p),nrow=n,ncol=p)
mean <- X %*% beta
y <- stats::rnorm(n=n,mean=mean,sd=1)
#z <- 1*(y > 0)
#y <- rnorm(n) # testing ... REMOVE THIS
#y <- sample(y) # testing ...
#z <- sample(z) # testing ...
#test <- bilasso(y=y,cutoff=0,X=X)
#plot(x=test$pi,y=test$cvm)
#test$pi.min
list[[i]] <- bilasso_compare(y=y,cutoff=0,X=X)
}
deviance <- t(sapply(list,function(x) x$deviance))
colMeans(deviance)
class <- t(sapply(list,function(x) x$class))
colMeans(class)
auc <- t(sapply(list,function(x) x$auc))
colMeans(auc)
list <- list()
for(i in seq_len(100)){
n <- 100
p <- 500
beta <- stats::rnorm(n=p)
cond <- stats::rbinom(n=p,size=1,prob=0.2)
beta[cond==0] <- 0
X <- matrix(stats::rnorm(n=n*p),nrow=n,ncol=p)
mean <- X %*% beta
y <- stats::rnorm(n=n,mean=mean,sd=1)
#z <- 1*(y > 0)
#y <- rnorm(n) # testing ... REMOVE THIS
#y <- sample(y) # testing ...
#z <- sample(z) # testing ...
#test <- bilasso(y=y,cutoff=0,X=X)
#plot(x=test$pi,y=test$cvm)
#test$pi.min
list[[i]] <- bilasso_compare(y=y,cutoff=2,X=X)
}
deviance <- t(sapply(list,function(x) x$deviance))
colMeans(deviance)
class <- t(sapply(list,function(x) x$class))
colMeans(class)
auc <- t(sapply(list,function(x) x$auc))
colMeans(auc)
list <- list()
pi <- rep(NA,times=100)
for(i in seq_len(100)){
n <- 100
p <- 500
beta <- stats::rnorm(n=p)
cond <- stats::rbinom(n=p,size=1,prob=0.2)
beta[cond==0] <- 0
X <- matrix(stats::rnorm(n=n*p),nrow=n,ncol=p)
mean <- X %*% beta
y <- stats::rnorm(n=n,mean=mean,sd=1)
#z <- 1*(y > 0)
#y <- rnorm(n) # testing ... REMOVE THIS
#y <- sample(y) # testing ...
#z <- sample(z) # testing ...
fit <- bilasso(y=y,cutoff=0,X=X)
pi[i] <- fit$pi.min
#plot(x=test$pi,y=test$cvm)
#test$pi.min
#list[[i]] <- bilasso_compare(y=y,cutoff=2,X=X)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
400
401
}
i
Armin Rauschenberger's avatar
Armin Rauschenberger committed
402
403
404
pi
hist(pi)
hist(pi,xlim=c(0,1))
Armin Rauschenberger's avatar
Armin Rauschenberger committed
405
406
407
408
409
410
411
412
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
#delete <- "..."
#sapply(delete,function(x) file.remove(file.path(pkg,"vignettes",x)))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
429
430
431
432
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
Armin Rauschenberger's avatar
Armin Rauschenberger committed
433
rm(list=ls())
Armin Rauschenberger's avatar
Armin Rauschenberger committed
434
435
436
437
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
438
439
440
441
442
443
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
444
#load("D:/colasso/package/toydata.RData")
Armin Rauschenberger's avatar
Armin Rauschenberger committed
445
446
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
447
448
449
450
451
452
453
454
455
456
457
458
459
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/package/colasso"
setwd(dir=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
460
461
462
463
464
465
466
467
468
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
pkg <- "C:/Users/armin.rauschenberger/Desktop/colasso"
setwd(dir=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
469
devtools::as.package(x=pkg,create=FALSE)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
470
pkg <- "C:/Users/armin.rauschenberger/Desktop/colasso/package"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
471
472
473
474
475
476
477
478
479
480
481
482
setwd(dir=pkg)
#################
### colasso ###
#################
#--- generate toydata ----------------------------------------------------------
set.seed(1)
#toydata <- NULL
#save(toydata,file=file.path("C:/Users/armin.rauschenberger/Desktop/package/colasso/data/toydata.R"))
#--- compile package -----------------------------------------------------------
rm(list=ls())
name <- "colasso"
#load("D:/colasso/package/toydata.RData")
Armin Rauschenberger's avatar
Armin Rauschenberger committed
483
pkg <- "C:/Users/armin.rauschenberger/Desktop/colasso/colasso"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
setwd(dir=pkg)
devtools::as.package(x=pkg,create=FALSE)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
devtools::load_all(path=pkg)
#usethis::use_data(toydata,overwrite=TRUE)
devtools::document(pkg=pkg)
unlink(file.path(pkg,"vignettes","figure"),recursive=TRUE)
all <- dir(file.path(pkg,"vignettes"))
setwd(dir=pkg)
unlink(file.path(pkg,"docs"),recursive=TRUE)
pkgdown::build_site(pkg=pkg)
file.remove(file.path(pkg,".Rbuildignore"))
usethis::use_build_ignore(files=c("Readme.Rmd",".travis.yml","_pkgdown.yml","docs","cran-comments.md","appveyor.yml"))
devtools::check(pkg=pkg,quiet=FALSE,manual=TRUE)
devtools::build(pkg=pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
506
#pkg <- "E:/colasso/package/colasso"
Armin Rauschenberger's avatar
Armin Rauschenberger committed
507
setwd(pkg)
Armin Rauschenberger's avatar
Armin Rauschenberger committed
508
system("git remote set-url origin https://rauschenberger:Eu57Rom!@github.com/rauschenberger/colasso.git")
Armin Rauschenberger's avatar
Armin Rauschenberger committed
509
510
511
512
system("git remote -v")
system("git add --all")
system("git commit -m \"automation\"")
system("git push origin master") # GitHub