diff --git a/R-Code-Samples/DataEnginePrimaryFunctions.Rmd b/R-Code-Samples/DataEnginePrimaryFunctions.Rmd index 8717c71e..0d375bca 100644 --- a/R-Code-Samples/DataEnginePrimaryFunctions.Rmd +++ b/R-Code-Samples/DataEnginePrimaryFunctions.Rmd @@ -112,6 +112,9 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end else if (grepl("<<>>", temp, fixed=TRUE)) { temp <- readLines(socket, 1) + while(grepl("<<>>", temp, fixed=TRUE)) { + temp <- readLines(socket, 1) + } response <- fromJSON(temp) break } @@ -122,8 +125,13 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end print(paste("Processed", counter, "lines for", protocol)) # add data point line to data frame - temp.df <- as.data.frame(fromJSON(temp)) - df <- rbind.fill(df, temp.df) + tryCatch(expr={ + temp.df <- as.data.frame(fromJSON(temp)) + df <- rbind.fill(df, temp.df) + }, + error=function(e){ + message("Heartbeat execption caught and not parsed.") + }) } output <- list("response"=response, "df"=df) diff --git a/R-Code-Samples/ExampleUserClusteringStarter.Rmd b/R-Code-Samples/ExampleUserClusteringStarter.Rmd index 0b767a6f..c571bd10 100644 --- a/R-Code-Samples/ExampleUserClusteringStarter.Rmd +++ b/R-Code-Samples/ExampleUserClusteringStarter.Rmd @@ -130,6 +130,9 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end else if (grepl("<<>>", temp, fixed=TRUE)) { temp <- readLines(socket, 1) + while(grepl("<<>>", temp, fixed=TRUE)) { + temp <- readLines(socket, 1) + } response <- fromJSON(temp) break } @@ -140,8 +143,13 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end print(paste("Processed", counter, "lines for", protocol)) # add data point line to data frame - temp.df <- as.data.frame(fromJSON(temp)) - df <- rbind.fill(df, temp.df) + tryCatch(expr={ + temp.df <- as.data.frame(fromJSON(temp)) + df <- rbind.fill(df, temp.df) + }, + error=function(e){ + message("Heartbeat execption caught and not parsed.") + }) } output <- list("response"=response, "df"=df) diff --git a/R-Code-Samples/GetTransactions.Rmd b/R-Code-Samples/GetTransactions.Rmd index 83f20a14..15667edf 100644 --- a/R-Code-Samples/GetTransactions.Rmd +++ b/R-Code-Samples/GetTransactions.Rmd @@ -114,6 +114,9 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end else if (grepl("<<>>", temp, fixed=TRUE)) { temp <- readLines(socket, 1) + while(grepl("<<>>", temp, fixed=TRUE)) { + temp <- readLines(socket, 1) + } response <- fromJSON(temp) break } @@ -124,8 +127,13 @@ request <- function(protocol, properties = "", headers = "", startdate = "", end print(paste("Processed", counter, "lines for", protocol)) # add data point line to data frame - temp.df <- as.data.frame(fromJSON(temp)) - df <- rbind.fill(df, temp.df) + tryCatch(expr={ + temp.df <- as.data.frame(fromJSON(temp)) + df <- rbind.fill(df, temp.df) + }, + error=function(e){ + message("Heartbeat execption caught and not parsed.") + }) } output <- list("response"=response, "df"=df)