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
1 parent
d13de92
commit 29fef4f
Showing
16 changed files
with
317 additions
and
93 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
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
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 +1,4 @@ | ||
gsubfn-cut Use strapply to extract endpoints from cut labels | ||
gsubfn-chron read in zoo data with chron datetimes. | ||
gsubfn-gries Stefan Gries' Linguistics code. | ||
gsubfn-cut Use strapply to extract endpoints from cut labels. | ||
gsubfn-si Replace SI scale letter with number, |
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,22 @@ | ||
|
||
# Use read.zoo to read data with a chron time index | ||
# Ignore fractional seconds. | ||
|
||
library(zoo) | ||
library(chron) | ||
library(gsubfn) | ||
|
||
# test data | ||
Lines <- "2006-01-24 02:41:24.00011,1.22930000,5,1.22950000,7 | ||
2006-01-25 04:41:24.00011,1.22930000,5,1.22950000,7 | ||
2006-01-26 07:41:24.00011,1.22930000,5,1.22950000,7" | ||
|
||
# convert to chron | ||
to.chron <- function(x) | ||
strapply(format(x), "([0-9-]+) ([0-9:]+)", | ||
~ chron(as.Date(dd), tt), backref = -2,simplify = c) | ||
|
||
con <- textConnection(Lines) | ||
read.zoo(con, sep = ",", FUN = to.chron) | ||
close(con) | ||
|
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,29 @@ | ||
|
||
# linguistic applications by Stefan Th. Gries | ||
|
||
# create word frequency list from the gsubfn COPYING file | ||
|
||
fn1 <- system.file("COPYING", package = "gsubfn") | ||
Lines1 <- tolower(scan(fn1, what = "char", sep = "\n")) | ||
tail(sort(table(unlist(strapply(Lines1, "\\w+", perl = TRUE))))) | ||
|
||
# frequency list of words from an SGML-annotated text file | ||
# sampled from the British National Corpus" | ||
|
||
fn2 <- system.file("sample.txt", package = "gsubfn") | ||
Lines2 <- scan(fn2, what = "char", sep = "\n") | ||
tagged.corpus.sentences <- grep("^<s n=", Lines2, value = TRUE) | ||
# just to see what it looks like | ||
tagged.corpus.sentences[c(3, 8)] | ||
words <- unlist(strapply(tagged.corpus.sentences, ">([^<]*)", backref = -1)) | ||
words <- gsub(" $", "", words) | ||
tail(words, 25) | ||
|
||
# frequency list of words AND tags from same file | ||
|
||
word.tag.pairs <- unlist(strapply(tagged.corpus.sentences, "<[^<]*")) | ||
cleaned.word.tag.pairs <- grep("<w ", word.tag.pairs, value = TRUE) | ||
cleaned.word.tag.pairs <- gsub(" +$", "", cleaned.word.tag.pairs) | ||
tail(sort(table(cleaned.word.tag.pairs))) | ||
tail(cleaned.word.tag.pairs) | ||
|
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,11 @@ | ||
|
||
|
||
# given number possibly followed by SI letter (e.g. 32.5k where k means 1000) | ||
# replace letter with e followed by appropriate digits. | ||
# (see formatEng2R by Hans-Joerg Bibiko in the R Wiki) | ||
|
||
conv <- c(y = "e-24", z = "e-21", a = "e-18", f = "e-15", p = "e-12", | ||
n = "e-9", `µ` = "e-6", m = "e-3", d = "e-1", c = "e-2", k = "e3", | ||
M = "e6", G = "e9", T = "e12", P = "e15", E = "e18", Z = "e21", Y = "e24") | ||
gsubfn(".$", x ~ if (x %in% names(conv)) conv[x] else x, c("19", "32.5M")) | ||
|
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
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,6 @@ | ||
|
||
Thanks to the following for contributing examples and demos: | ||
|
||
Hans-Joerg Bibiko, bibiko at eva.mpg.de | ||
Stefan Th. Gries, stgries at linguistics dot ucsb dot edu | ||
|
Oops, something went wrong.