Files
uni-ba-socialagenda/functions.R
T

29 lines
967 B
R
Raw Normal View History

2014-11-29 13:52:09 +01:00
require(stringr)
2014-11-29 21:41:28 +01:00
# Replace characters messing up JSON validation (\,\n,^)
correctJSON <- function(string) {
2014-12-01 17:41:33 +01:00
# string <- str_replace_all(string, pattern = "\n", replacement = " ")
# string <- str_replace_all(string, pattern = "\r", replacement = " ")
# string <- str_replace_all(string, pattern = "\\^", replacement = " ")
string <- str_replace_all(string, pattern = "[^[:print:]]", replacement = " ")
2014-11-29 21:41:28 +01:00
string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ")
2014-11-30 18:58:47 +01:00
return(string)
}
2014-11-30 03:41:23 +01:00
insertRow <- function(existingDF, newrow, r) {
r <- as.numeric(nrow(existingDF)) + 1
existingDF <- rbind(existingDF,newrow)
existingDF <- existingDF[order(c(1:(nrow(existingDF)-1),r-0.5)),]
row.names(existingDF) <- 1:nrow(existingDF)
return(existingDF)
2014-12-01 23:17:55 +01:00
}
# mergeIfExists <- function(fulldf, tempdf) {
# if(exists(fulldf)) {
# fulldf <- insertRow(fulldf, tempdf)
# }
# else {
# fulldf <- tempdf
# }
# return(fulldf)
# }