I plot my data set using this code :
activity <- unlist(dActivityProbe$value)
> tail(activity,10)
[1] "high" "high" "high" "high" "high" "low" "high" "none" "none" "none"
> head(dActivityProbe$time,10)
timestamp
[1,] 1406613553
[2,] 1406613585
[3,] 1406613586
[4,] 1406613706
[5,] 1406613706
[6,] 1406613825
[7,] 1406613826
[8,] 1406613945
[9,] 1406613947
[10,] 1406614065
> date_time <- as.POSIXlt(as.numeric(dActivityProbe$time), origin="1970-01-01", tz = "GMT")
> head(date_time,10)
[1] "2014-07-29 05:59:12 GMT" "2014-07-29 05:59:45 GMT" "2014-07-29 05:59:46 GMT" "2014-07-29 06:01:45 GMT"
[5] "2014-07-29 06:01:46 GMT" "2014-07-29 06:03:45 GMT" "2014-07-29 06:03:45 GMT" "2014-07-29 06:05:45 GMT"
[9] "2014-07-29 06:05:46 GMT" "2014-07-29 06:07:44 GMT"
> p <- qplot(data=dActivityProbe,,color=activity,x=date_time,y=activity)
> print(p)
And it's success for generating plot like this image
But the problem is, when I tried to move this code into shiny, I got error.
The error look like this In R console :
Warning in as.POSIXlt(as.numeric(dActivityProbe$time), origin = "1970-01-01", :
NAs introduced by coercion
Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite
In shiny web :
'to' cannot be NA, NaN or infinite
Shiny Apps :
ui.R
tabPanel("Time Series",
titlePanel("Time Series Activity Probe Plot"),
mainPanel(
plotOutput("Activity_time_series")
)
dActivityProbe :
head(dActivityProbe)
time value
1 1406613553 none
2 1406613585 none
3 1406613586 none
4 1406613706 none
5 1406613706 none
6 1406613825 none
server.R
library(shiny)
library("RSQLite")
library("rjson")
library("ggplot2")
library("scales")
activity <- unlist(dActivityProbe$value)
date_time <- as.POSIXlt(as.numeric(dActivityProbe$time), origin="1970-01-01", tz = "GMT")
shinyServer(function(input, output) {
output$Activity_time_series <- renderPlot({
p <- qplot(data=dActivityProbe,,color=activity,x=date_time,y=activity)
print(p)
})
Thank you for helping