GitHub account: HenrikBengtsson
Package<html> | |
<style> | |
body { | |
font-size: 80%; | |
} | |
</style> | |
<body> | |
<head> | |
<title>Speedtest benchmarks (2014-02-23 -- 2014-04-19)</title> | |
</head> |
<%-------------------------------------------------------------- | |
Usage: | |
md <- R.rsp::rfile('table-pandoc.md.rsp', postprocess=FALSE) | |
pdf <- gsub("md$", "pdf", md) | |
system2("pandoc", args=c(normalizePath(md), "-o", pdf)) | |
!pdf # Opens PDF in viewer | |
Requires Pandoc [http://johnmacfarlane.net/pandoc/] and | |
LaTeX, because Pandoc uses LaTeX to generate PDFs. | |
--------------------------------------------------------------%> |
source("mixedsortRoman.R") | |
# Basics | |
yi <- c(1, 5, 10, 50, 100) | |
print(yi) | |
## [1] 1 5 10 50 100 | |
yr <- as.character(as.roman(yi)) | |
print(yr) | |
## [1] "I" "V" "X" "L" "C" |
####################################################################### | |
# rforge2git.R by Henrik Bengtsson | |
# | |
# USAGE: | |
# | |
# Rscript rpkg_svn2git.R <pkg> | |
# | |
# EXAMPLE: | |
# Rscript rpkg_svn2git.R r-forge:r-dots/R.menu | |
# Rscript rpkg_svn2git.R bioc-devel:illuminaio |
Below are the first few lines(*) of two files exported from the Agilent CytoGenomics Software. These files are plain text files with a few "metadata" rows before the actual tab-delimited data begins. The tab-delimited data appears to have a header row with tab-delimited column names followed by corresponding tab-delimited data rows. But it also appears as if there are "random" TABs (ASCII 0x09 = '\t') added to the end of either to header row or the data rows. What's up with that?
PS. (*) I cut out the top few lines by reading the files as a binary file in order to remove the risk of it being me/my editor introducing these TAB outliers. Also, I've verified using binary diff that these example files are identicial to the top of the full files.
> countTABs <- function(x) sum(charToRaw(x) == cha
The overhead of method dispatching can be noticable, particularly if done on small objects and it adds up if doing many many times. For instance,
> add <- function(a,b) UseMethod("add")
> add.integer <- function(a,b) a+b
gives with method dispatching:
> system.time({ for (kk in 1:10e6) add(1L, 2L) })
user system elapsed
35.43 0.05 35.70
source("https://gist.githubusercontent.com/HenrikBengtsson/ed1eeb41a1b4d6c43b47/raw/ebe58f76e518dd014423bea466a5c93d2efd3c99/readtable-fix.R") | |
kkk <- c("a\tb", | |
"3.14\tx") | |
colClasses <- c(a="numeric", b="character") | |
data <- read.table(textConnection(kkk), | |
sep="\t", | |
header = TRUE, | |
colClasses = colClasses) |
## Identify installed packages that fail to load | |
rscript <- function(...) { | |
system2(file.path(R.home("bin"), "Rscript"), ...) | |
} | |
works <- function(pkg) { | |
## Need to call in separate R session to not use up all DLLs | |
rcmd <- sprintf("cat(isTRUE(requireNamespace('%s')))", pkg) | |
as.logical(rscript(args=c("-e", dQuote(rcmd)), stdout=TRUE)) | |
} |