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
library('RSQLite') | |
# Establishes a connection to the specified SQLite database file. | |
db_filename <- "choose_filename.db3" | |
db_driver <- dbDriver("SQLite") | |
db_conn <- dbConnect(db_driver, dbname = db_filename) | |
# An alternative is... (not sure about the difference) | |
# db_conn <- dbConnect(SQLite(), dbname = db_filename) |
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
# Creates a zero-padded string from an integer. | |
# | |
# The number of digits is defaulted to 3 but can be specified by the user. | |
# Examples: | |
# padded_integer(5) => "005" | |
# padded_integer(42) => "042" | |
# padded_integer(421) => "421" | |
# padded_integer(421, digits = 4) => "0421 | |
# | |
padded_integer <- function(x, digits = 3) { |
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
# The Error | |
> mdy_hms(my_dates) | |
Error in data.frame(c("14", "19", "01"), c("14", "20"), check.names = TRUE, : | |
arguments imply differing number of rows: 3, 2 | |
# The Cause | |
> str_split(dates, fixed(sep[1])) | |
[[1]] | |
[1] "14" "19" "01" |
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
from numpy import array | |
raw_data = """75 | |
95 64 | |
17 47 82 | |
18 35 87 10 | |
20 04 82 47 65 | |
19 01 23 75 03 34 | |
88 02 77 73 07 63 67 | |
99 65 04 28 06 16 70 92 | |
41 41 26 56 83 40 80 70 33 |
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
library('plyr') | |
library('reshape2') | |
library('ggplot2') | |
bivar_unif <- function(n, a1, b1, a2, b2) { | |
cbind(runif(n, a1, b1), runif(n, a2, b2)) | |
} | |
gen_unif <- function(n = 25, delta = 0, seed = NULL) { | |
if(is.null(seed)) { |
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
# The colors are used with the Solarized dark color theme in Putty. | |
# They make look terrible if Solarized is not installed. | |
# Here's the link to Solarized: | |
# http://ethanschoonover.com/solarized | |
# | |
# I used the following website to generate my prompt: | |
# http://www.linuxhelp.net/guides/bashprompt/bashprompt-print.php | |
# | |
# There, I used the following code: | |
# <green>(<white>\d<yellow>@<white>\@<green>) (<white>\u<yellow>@<white>\h<green>) (<white>\W<green>)<space>$<space> |
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
(require 'mouse) | |
(xterm-mouse-mode t) | |
(defun track-mouse (e)) | |
;; Save all backup file in this directory. |
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
.First <- function() { | |
options( | |
repos = c(CRAN = "http://cran.fhcrc.org/"), | |
browserNLdisabled = TRUE, | |
deparse.max.lines = 2 | |
) | |
} | |
# This code is copied directly from ?savehistory | |
# It saves the history of commands from interactive sessions to my home path |
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
R_LIBS=~/local/Rpackages |
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
library('plyr') | |
library('pixmap') | |
library('random') | |
rand_bit_matrix <- function(num_rows = 500, num_cols = 500, | |
max_n_random.org = 10000, seed = NULL) { | |
# I have copied the following function directly from help("integer"). | |
is.wholenumber <- function(x, tol = .Machine$double.eps^0.5) { | |
abs(x - round(x)) < tol | |
} |
OlderNewer