Files
uni-ba-socialagenda/functions.R
T

19 lines
747 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) {
string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ")
2014-11-30 03:41:23 +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 = " ")
\xed\xa0\xbd\xed\xb1\x8d\xed\xa0\xbd\xed\xb8\x8e\
2014-11-29 21:41:28 +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-11-29 21:41:28 +01:00
}