Skip to content

Commit

Permalink
Added installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosonH committed Dec 16, 2022
1 parent 8a43ab5 commit ce40251
Show file tree
Hide file tree
Showing 6 changed files with 876 additions and 7 deletions.
355 changes: 355 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
library('devtools')
library(devtools)
install.packages("devtools")
install.packages("roxygen2")
setwd("C:/Users/leoso/OneDrive/Desktop/Code")
devtools::create("sqlcaser")
casewhen <- function(infile){
mapping <- read.csv(infile)
statement <- "CASE"
for (i in 1:nrow(mapoubg)){
statement = paste(statement, ' WHEN ', '"', map[i, 1], '"', ' THEN ',
'"', map[i, 2], '"', '\n', sep='')
}
cat(statement)
}
casewhen("../,,/files/map_test.csv")
casewhen(",,/files/map_test.csv")
casewhen("files/map_test.csv")
casewhen <- function(infile){
mapping <- read.csv(infile)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', '"', map[i, 1], '"', ' THEN ',
'"', map[i, 2], '"', '\n', sep='')
}
cat(statement)
}
casewhen("files/map_test.csv")
casewhen <- function(infile){
mapping <- read.csv(infile)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', '"', mapping[i, 1],
'"', ' THEN ',
'"', mapping[i, 2], '"', '\n', sep='')
}
cat(statement)
}
casewhen("files/map_test.csv")
#' Load a Matrix
#'
#' This function loads a file as a matrix. It assumes that the first column
#' contains the rownames and the subsequent columns are the sample identifiers.
#' Any rows with duplicated row names will be dropped with the first one being
#' kepted.
#'
#' @param input Path to the input file
#' @return A matrix of the infile
#' @export
casewhen <- function(input){
mapping <- read.csv(input)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', '"', mapping[i, 1], '"', ' THEN ',
'"', mapping[i, 2], '"', '\n', sep='')
}
cat(statement)
}
casewhen("files/map_test.csv")
case <- casewhen("files/map_test.csv")
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param input Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(input){
mapping <- read.csv(input)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', '"', mapping[i, 1],
'"', ' THEN ',
'"', mapping[i, 2], '"', '\n', sep='')
}
return(cat(statement))
}
case <- casewhen("files/map_test.csv")
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param input Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(input){
mapping <- read.csv(input)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', '"', mapping[i, 1],
'"', ' THEN ',
'"', mapping[i, 2], '"', '\n', sep='')
}
return(capture.output(cat(statement)))
}
case <- casewhen("files/map_test.csv")
case
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param input Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(input){
mapping <- read.csv(input)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', '"', mapping[i, 1],
'"', ' THEN ',
'"', mapping[i, 2], '"', '\n', sep='')
}
return(statement)
}
case <- casewhen("files/map_test.csv")
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param input Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(input){
mapping <- read.csv(input)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', "'", mapping[i, 1],
"'", ' THEN ',
"'", mapping[i, 2], "'", '\n', sep='')
}
return(statement)
}
case <- casewhen("files/map_test.csv")
case
cat(case)
devtools::document()
setwd("C:/Users/leoso/OneDrive/Desktop/Code/sqlcaser")
devtools::document()
?casewhen
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param input Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(inputfile){
mapping <- read.csv(inputfile)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', "'", mapping[i, 1],
"'", ' THEN ',
"'", mapping[i, 2], "'", '\n', sep='')
}
return(statement)
}
case <- casewhen("../files/map_test.csv")
devtools::document()
rm(list = c("casewhen"))
devtools::document()
?casewhen
devtools::document()
?casewhen
devtools::document()
case <- casewhen("../files/map_test.csv")
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE WHEN values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param inputfile Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(inputfile){
mapping <- read.csv(inputfile)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', "'", mapping[i, 1],
"'", ' THEN ',
"'", mapping[i, 2], "'", '\n', sep='')
}
return(statement)
}
devtools::load_all()
devtools::load_all()
system.file("extdata", "sample.csv", package = "sqlcaser")
samp <- system.file("extdata", "sample.csv", package = "sqlcaser")
unloadNamespace("sqlcaser")
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE WHEN values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param inputfile Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(inputfile){
mapping <- read.csv(inputfile)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste(statement, ' WHEN ', "'", mapping[i, 1],
"'", ' THEN ',
"'", mapping[i, 2], "'", '\n', sep='')
}
cat(statement)
return(statement)
}
case <- casewhen("../files/map_test.csv")
usethat::use_vignette("introduction")
devtools::use_vignette("introduction")
library(devtools)
usethat::use_vignette("introduction")
usethis::use_vignette("introduction")
devtools::install()
case <- casewhen("../files/map_test.csv")
samp <- system.file("extdata", "sample.csv", package = "sqlcaser")
case <- casewhen(samp)
library(sqlcaser)
samp <- system.file("extdata", "sample.csv", package = "sqlcaser")
#' Generate an SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE WHEN values, and the second column contains the THEN values (the values to
#' be mapped to.)
#'
#' @param inputfile Path to the input file
#' @return A string that represents the constructed CASE WHEN statement
#' @export
casewhen <- function(inputfile){
mapping <- read.csv(inputfile)
statement <- "CASE"
for (i in 1:nrow(mapping)){
statement = paste('\n', statement, ' WHEN ', "'", mapping[i, 1],
"'", ' THEN ',
"'", mapping[i, 2], "'", '\n', sep='')
}
cat(statement)
return(statement)
}
devtools::load_all()
samp <- system.file("extdata", "sample.csv", package = "sqlcaser")
case <- casewhen(samp)
unloadNamespace("sqlcaser")
devtools::install()
case <- casewhen(samp)
library(sqlcaser)
case <- casewhen(samp)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::load_all()
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::install()
devtools::document()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::install()
devtools::document()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
casewhen(samp)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
casewhen(samp)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
casewhen(samp)
usethat::use_mit_license(copyright_holder = 'Leoson Hoay')
usethis::use_mit_license()
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
devtools::document()
devtools::install()
library(sqlcaser)
citation(sqlcase)
citation(sqlcaser)
citation("sqlcaser")
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
library(sqlcaser)
citation(sqlcaser)
citation("sqlcaser")
?casewhen
unloadNamespace("sqlcaser")
unloadNamespace("sqlcaser")
devtools::document()
?sqlcaser
devtools::install()
library(sqlcaser)
?sqlcaser
?casewhen
unloadNamespace("sqlcaser")
devtools::document()
devtools::install()
unloadNamespace("sqlcaser")
detach("package:sqlcaser", unload = TRUE)
library(sqlcaser)
remove.packages("sqlcaser")
devtools::install_github("leosonh/sqlcaser")
devtools::install_github("leosonh/sqlcaser")
detach("package:sqlcaser", unload = TRUE)
devtools::install_github("leosonh/sqlcaser")
6 changes: 3 additions & 3 deletions R/casewhen.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' Generate a SQL CASE WHEN statement from a mapping file
#'
#' This function constructs a CASE WHEN statement from a mapping file.
#' This function constructs a CASE WHEN THEN statement from a mapping file.
#' It assumes that the first column of the mapping file contains the original
#' CASE WHEN values, and the second column contains the THEN values (the values
#' WHEN values, and the second column contains the THEN values (the values
#' to be mapped to.)
#'
#' @param inputfile Path to the mapping file
#' @return A string that represents the constructed CASE WHEN statement
#' @return A string that represents the constructed CASE statement
#' @export
casewhen <- function(inputfile){
mapping <- read.csv(inputfile)
Expand Down
6 changes: 3 additions & 3 deletions man/casewhen.Rd

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

1 change: 0 additions & 1 deletion vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*.html
*.R
Loading

0 comments on commit ce40251

Please sign in to comment.