Files
uni-ba-socialagenda/functions.R
T
2014-12-05 13:21:53 +01:00

19 lines
679 B
R

require(stringr)
# Replace characters messing up JSON validation (\,\n,^)
correctJSON <- function(string) {
string <- gsub("\\\\{2,}", "", string)
string <- str_replace_all(string, pattern = "[^[:print:]]", replacement = " ")
string <- str_replace_all(string, pattern = "&..;", replacement = " ")
string <- str_replace_all(string, pattern = perl('\\\\(?![tn"])'), replacement = " ")
return(string)
}
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)
}