-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusefullfunctions.R
More file actions
48 lines (34 loc) · 1.11 KB
/
Copy pathusefullfunctions.R
File metadata and controls
48 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
###########################################################
# check if packages are installed, if yes require, if no install
# pkg <- c("sfsmisc","MASS","nnet","regr0")
# as.matrix(pkg)
chkinst <- function(x){
require(x) || install.packages(x)
}
# apply(as.matrix(pkg), 2, inst)
###########################################################
# regr0 package (W.Stahel ETHZ)
# source("http://stat.ethz.ch/~stahel/regression/regr.R")
# install.packages("regr0", repos="http://R-Forge.R-project.org")
###########################################################
# german umlauts
# defining dataset
d.data <- as.data.frame(cbind(c("äzÄzüzÜZöZÖ"), c("äzÄzüzÜZöZÖ")))
d.data
# defining "Umlauts"
a <- c("ä", "ae")
A <- c("Ä", "Ae")
u <- c("ü", "ue")
U <- c("Ü", "Ue")
o <- c("ö", "oe")
O <- c("Ö", "Oe")
# Matrix of substitutions
m <- cbind(a,A,u,U,o,O, deparse.level=0)
swiss2 <- function(m, data){
for (i in seq_len(ncol(m))){
data <- gsub(paste(m[,i], sep=",")[1],paste(m[,i], sep=",")[2], data,
ignore.case=F, perl = F, fixed = F, useBytes = F)
}
data
}
swiss2(m, d.data$V1)