-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
876 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
*.html | ||
*.R |
Oops, something went wrong.