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-05 13:21:53 +01:00
|
|
|
string <- gsub("\\\\{2,}", "", string)
|
2014-12-01 17:41:33 +01:00
|
|
|
string <- str_replace_all(string, pattern = "[^[:print:]]", replacement = " ")
|
2014-12-05 12:28:51 +01:00
|
|
|
string <- str_replace_all(string, pattern = "&..;", 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
|
|
|
}
|