Skip to content

Commit

Permalink
Updated examples and directory parameter in InterVA5() to conform wit…
Browse files Browse the repository at this point in the history
…h CRAN requirements.
  • Loading branch information
jarathomas committed Apr 5, 2018
1 parent 62c9c5b commit 9cc6911
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 51 deletions.
Binary file modified InterVA5_1.0.tar.gz
Binary file not shown.
23 changes: 13 additions & 10 deletions InterVA5_1.0/R/InterVA5.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
#' be one of the following: "h"(high),"l"(low), or "v"(very low).
#' @param Malaria An indicator of the level of prevalence of Malaria. The input
#' should be one of the following: "h"(high),"l"(low), or "v"(very low).
#' @param write A logical value indicating whether or not the output (including
#' errors and warnings) will be saved to file. If the value is set to TRUE, the
#' user must also provide a value for the parameter "directory".
#' @param directory The directory to store the output from InterVA5. It should
#' either be an existing valid directory, or a new folder to be created. If no
#' path is given, the current working directory will be used.
#' path is given and the parameter for "write" is true, then the function stops
#' and and error message is produced.
#' @param filename The filename the user wish to save the output. No extension
#' needed. The output is in .csv format by default.
#' @param output "classic": The same deliminated output format as InterVA5; or
Expand All @@ -32,8 +36,6 @@
#' should be appended to the existing file.
#' @param groupcode A logical value indicating whether or not the group code
#' will be included in the output causes.
#' @param write A logical value indicating whether or not the output (including
#' errors and warnings) will be saved to file.
#' @param ... not used
#' @return \item{ID }{ identifier from batch (input) file} \item{MALPREV
#' }{ selected malaria prevalence} \item{HIVPREV }{ selected HIV prevalence}
Expand All @@ -57,17 +59,16 @@
#' ## orders match interVA5 standard input this can be monitored by checking
#' ## the warnings of column names
#'
#' sample.output1 <- InterVA5(SampleInputV5, HIV = "h", Malaria = "l", directory = "VA5_test",
#' filename = "VA5_result", output = "extended", append = FALSE)
#' sample.output1 <- InterVA5(SampleInputV5, HIV = "h", Malaria = "l", write=TRUE,
#' directory = tempdir(), filename = "VA5_result", output = "extended", append = FALSE)
#'
#' ## to get causes of death with group code for further usage
#' sample.output2 <- InterVA5(SampleInputV5, HIV = "h", Malaria = "l", directory = "VA5_test",
#' filename = "VA5_result_wt_code", output = "classic", append = FALSE,
#' groupcode = TRUE)
#' sample.output2 <- InterVA5(SampleInputV5, HIV = "h", Malaria = "l",
#' write = TRUE, directory = tempdir(), filename = "VA5_result_wt_code", output = "classic",
#' append = FALSE, groupcode = TRUE)
#'
InterVA5 <- function (Input, HIV, Malaria, directory = NULL, filename = "VA5_result",
InterVA5 <- function (Input, HIV, Malaria, write = FALSE, directory = NULL, filename = "VA5_result",
output = "classic", append = FALSE, groupcode = FALSE,
write = TRUE,
...)
{
va5 <- function(ID, MALPREV, HIVPREV, PREGSTAT, PREGLIK, CAUSE1, LIK1, CAUSE2, LIK2, CAUSE3, LIK3, INDET,
Expand Down Expand Up @@ -104,6 +105,8 @@ InterVA5 <- function (Input, HIV, Malaria, directory = NULL, filename = "VA5_res
filename <- paste(filename, ".csv", sep = "")
write.table(t(x), file = filename, sep = ",", append = TRUE, row.names = FALSE, col.names = FALSE)
}
if (is.null(directory) & write)
stop("error: please provide a directory (required when write=TRUE)")
if (is.null(directory))
directory = getwd()
dir.create(directory, showWarnings = FALSE)
Expand Down
18 changes: 10 additions & 8 deletions InterVA5_1.0/R/InterVA5.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#' @examples
#'
#' data(SampleInputV5)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", directory = "VA5_test",
#' filename = "VA5_result", output = "extended", append = FALSE)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", write=TRUE,
#' directory = tempdir(), filename = "VA5_result", output = "extended", append = FALSE)
#' ## Get CSMF without plots
#' csmf <- CSMF.interVA5(sample.output$VA5)
#'
Expand Down Expand Up @@ -105,10 +105,11 @@ CSMF.interVA5 <- function(va){
#' @examples
#'
#' data(SampleInputV5)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", directory = "VA5_test",
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v",
#' write=TRUE, directory = tempdir(),
#' filename = "VA5_result", output = "extended", append = FALSE)
#' ## Get CSMF without plots
#' comcat<- COMCAT.interVA5(sample.output$VA5)
#' comcat <- COMCAT.interVA5(sample.output$VA5)
#'
COMCAT.interVA5 <- function(va){
# for future compatibility with non-standard input
Expand Down Expand Up @@ -186,8 +187,9 @@ COMCAT.interVA5 <- function(va){
#' @examples
#'
#' data(SampleInputV5)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", directory = "VA5_test",
#' filename = "VA5_result", output = "extended", append = FALSE)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", write = TRUE,
#' directory = tempdir(), filename = "VA5_result", output = "extended",
#' append = FALSE)
#'
#' ## Get CSMF by considering only top 3 causes reported by InterVA5.
#' ## This is equivalent to using CSMF.interVA5() command Note that
Expand Down Expand Up @@ -346,8 +348,8 @@ CSMF5 <- function (va, top.aggregate = NULL, InterVA.rule = FALSE, noplot = FALS
#' @examples
#'
#' data(SampleInputV5)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", directory = "VA5_test",
#' filename = "VA5_result", output = "extended", append = FALSE)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", write = TRUE,
#' directory = tempdir(), filename = "VA5_result", output = "extended", append = FALSE)
#'
#' ## Individual level summary using pie chart
#' InterVA5.plot(sample.output$VA5[[3]], type = "pie", min.prob = 0.01,
Expand Down
5 changes: 3 additions & 2 deletions InterVA5_1.0/R/InterVA5.summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
#' ## orders match interVA5 standard input this can be monitored by checking
#' ## the warnings of column names
#'
#' sample.output1 <- InterVA5(SampleInputV5, HIV = "h", Malaria = "l", directory = "VA5_test",
#' filename = "VA5_result", output = "extended", append = FALSE)
#' sample.output1 <- InterVA5(SampleInputV5, HIV = "h", Malaria = "l",
#' write = TRUE, directory = tempdir(), filename = "VA5_result",
#' output = "extended", append = FALSE)
#'
#' summary(sample.output1)
#' summary(sample.output1, top = 10)
Expand Down
5 changes: 3 additions & 2 deletions InterVA5_1.0/R/InterVA5_1.0-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ NULL
#' @examples
#'
#' data(SampleInputV5)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v", directory = "VA5 test",
#' filename = "VA5_result", output = "extended", append = FALSE)
#' sample.output <- InterVA5(SampleInputV5, HIV = "h", Malaria = "v",
#' write = TRUE, directory = tempdir(), filename = "VA5_result",
#' output = "extended", append = FALSE)
#'
NULL

Expand Down
5 changes: 3 additions & 2 deletions InterVA5_1.0/man/COMCAT.interVA5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions InterVA5_1.0/man/CSMF.interVA5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions InterVA5_1.0/man/CSMF5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions InterVA5_1.0/man/InterVA5-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions InterVA5_1.0/man/InterVA5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions InterVA5_1.0/man/InterVA5.plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions InterVA5_1.0/man/SampleInputV5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions InterVA5_1.0/man/summary.interVA5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9cc6911

Please sign in to comment.