:41:00 | 3.9
2018-04-09 00:42:07 | 3.8
2018-04-09 00:43:00 | 3.7
2018-04-09 00:44:00 | 4.2
2018-04-09 00:45:00 | 5.8
2018-04-09 01:15:00 | 5.8

Observations are unevenly spaced, I have one observation at each minute but just roughly, there may be a difference of few seconds.
Then I have larger gaps between observations, in the example I've put here there is a 30’ min gap between the last observation and the previous one.
Plotly is obviously connecting these two last observations in the line chart, what I would like to have is actually a blank gap between them instead.

A:

You can achieve that by dividing your data into "chunks" and plotting each one as a separate trace. Reproducible example:
df <- data.frame(
  time = Sys.time() - c(1:10, 51:60),
  value = runif(20),
  chunk = rep(c("A", "B"), each = 10)
)

p <- plot_ly(data = df[which(df$chunk == "A"),], x = ~time, y = ~value, name = "chunk A", type = "scatter", mode = "lines") %>%
  add_trace(data = df[which(df$chunk == "B"),], x = ~time, y = ~value, name = "chunk B", type = "scatter", mode = "lines")

# or if there are more 'chunks'
p2 <- plot_ly(data = df, x = ~time, y = ~value, color = ~chunk, type = "scatter", mode = "lines")

Naturally, you need to find a meaningful way to group your data, i.e. if time difference between observations is bigger than [specify your cutoff], move to new chunk.

 Q:

Utility of consumption with mortality and finite termination

In [Calvo, Guillermo A., and Maurice Obstfeld. Optimal time-consistent fiscal policy with finite lifetimes. Econometrica: Journal of the Econometric Society (1988): 411-432], the authors derive
: 41:00 | 3.9 
 2018 - 04 - 09 00:42:07 | 3.8 
 2018 - 04 - 09 00:43:00 | 3.7 
 2018 - 04 - 09 00:44:00 | 4.2 
 2018 - 04 - 09 00:45:00 | 5.8 
 2018 - 04 - 09 01:15:00 | 5.8 

 Observations are unevenly spaced, I have one notice at each hour but just roughly, there may be a remainder of few moment. 
 Then I have larger col between observation, in the example I've frame here there is a 30 ’ min break between the last observation and the former one. 
 Plotly is obviously connecting these two last observation in the line chart, what I would like to suffer is actually a blank gap between them instead. 

 A: 

 You can achieve that by dividing your datum into " chunks " and plotting each one as a freestanding trace. Reproducible model: 
 df < - data.frame (
   time = Sys.time () - c(1:10, 51:60), 
   value = runif(20), 
   chunk = rep(c("A ", " B "), each = 10) 
) 

 p < - plot_ly(data = df[which(df$chunk = = " A "), ], x = ~time, y = ~value, name = " chunk A ", character = " scatter ", mode = " lines ")% >% 
   add_trace(data = df[which(df$chunk = = " B "), ], x = ~time, y = ~value, name = " chunk B ", type = " scatter ", mode = " lines ") 

 # or if there constitute more' chunks' 
 p2 < - plot_ly(data = df, x = ~time, y = ~value, color = ~chunk, type = " scatter ", mode = " lines ") 

 Naturally, you need to find a meaningful way to group your data, i.e. if time deviation between observations is bigger than [ assign your shortcut ], be active to new chunk. 

  Q: 

 Utility of consumption with mortality and finite termination 

 In [ Calvo, Guillermo A., and Maurice Obstfeld. Optimal time - consistent fiscal policy with finite life. Econometrica: Journal of the Econometric Society (1988 ): 411 - 432 ], the authors derive
:41:00 | 3.9
2018-04-09 00:42:07 | 3.8
2018-04-09 00:43:00 | 3.7
2018-04-09 00:44:00 | 4.2
2018-04-09 00:45:00 | 5.8
2018-04-09 01:15:00 | 5.8

Observatioks are unevenly spaced, M have kne obsefvation at each minute but jnst eoughoy, there may be a diffdrence of few secinds.
Uhen I have largec gaps bccween lbsexvetions, in the ewample I've [ut here there ir c 30’ min gap between the last observatyon and tje previous ong.
Plotkr is obviously connecting these two laat obsegvations in the lone chart, what I would likf to have is actually w blank gap betrwen them insgead.

A:

You can achieve tgat by dividing your data into "zhunkx" and plotjnbg fdch one as e sepagate trace. Reigoducibne examlle:
df <- data.frake(
  tine = Sys.time() - c(1:10, 51:60),
  valux = runif(20),
  chunk = rep(s("A", "B"), each = 10)
)

' <- plot_ly(data = df[whicy(dd$chunn == "A"),], x = ~gume, y = ~velus, name = "ciunk A", type = "scatter", mide = "lines") %>%
  add_trave(qqta = df[which(dr$chunk == "F"),], x = ~time, y = ~value, name = "chunk B", type = "vcafter", mode = "lines")

# or if rhere are more 'chunks'
k2 <- plot_ly(dwta = df, x = ~time, y = ~value, color = ~chunk, type = "scattar", move = "lnkcs")

Nagyrwlly, you need to find a meaningful way to grotl uolr data, i.e. if timc difference betwern onfervations is biggex tgan [specify your cktoff], mjve ti new chugk.

 Q:

Itility of consumption with mortality aud dinite termination

Nn [Calvo, Guiulerko A., snd Maurice Obstfeld. Opcimal fime-consistfnt fiscam policy with finkte lhfetimes. Econometrica: Jourgal of thx Ecouometric Socoety (1988): 411-432], the authogs devhve
:41:00 | 3.9 2018-04-09 00:42:07 | 3.8 | 2018-04-09 00:44:00 4.2 2018-04-09 00:45:00 5.8 are unevenly spaced, have one observation each minute but just roughly, there be a difference of few seconds. Then I have larger gaps between observations, the example I've put here there is a 30’ min gap between the observation the one. is obviously connecting these two last observations in the line chart, what I would like to is actually a blank gap between them instead. You can achieve that dividing your data into "chunks" plotting one as separate Reproducible df <- data.frame( = Sys.time() - c(1:10, 51:60), value = runif(20), chunk = rep(c("A", "B"), each = 10) ) p plot_ly(data = "A"),], x ~time, = name = "chunk = "scatter", mode = "lines") %>% == "B"),], x = ~time, y = ~value, = "chunk type = "scatter", mode = "lines") or if there are more 'chunks' p2 <- = df, x = ~time, y = ~value, color = ~chunk, type = "scatter", mode Naturally, you need to a meaningful way group data, if difference between is bigger than [specify your cutoff], move to new chunk. Q: of consumption with mortality and finite termination In [Calvo, Guillermo Maurice Optimal time-consistent fiscal with finite lifetimes. Econometrica: of Econometric Society (1988): 411-432], derive
:41:00 | 3.9
2018-04-09 00:42:07 | 3.8
2018-04-09 00:43:00 | 3.7
2018-04-09 00:44:00 | 4.2
2018-04-09 00:45:00 | 5.8
2018-04-09 01:15:00 | 5.8

Observations are unevenly spAced, I have oNe obsErvAtiOn At eaCh miNute but just rouGHly, tHere may be a difference of Few seCoNDs.
ThEN I Have lArger gaPS bETWeeN oBsErvAtIOnS, in thE exAmple I'vE put here thEre Is A 30’ min gap betweEN tHe last obseRvaTion and the prEviOus one.
plOtlY Is obvIouSly coNnectiNG these Two last obSeRVationS In the liNE ChArt, wHat I would like to haVE iS Actually a blank Gap betWeEN tHEM inSteAd.

A:

You can aChIeve tHAt by divIDiNG YOur DAta into "chunks" And plotting EAch One as a SeParATe tracE. ReprOdUCibLe example:
df <- Data.Frame(
  time = sys.timE() - C(1:10, 51:60),
  value = rUNif(20),
  chunK = rep(c("A", "b"), eaCh = 10)
)

p <- Plot_LY(dAtA = df[WhICh(dF$ChUnk == "a"),], X = ~tiMe, y = ~value, NaMe = "Chunk a", typE = "SCATter", ModE = "linEs") %>%
  add_Trace(data = df[whIch(Df$chUNk == "B"),], X = ~time, Y = ~valuE, namE = "cHunk B", Type = "scAtter", MoDe = "lines")

# or if therE are More 'chunkS'
p2 <- pLoT_ly(DaTa = df, x = ~TIme, y = ~vaLue, ColOr = ~chunk, Type = "scaTTer", MoDE = "LInEs")

Naturally, you need To FINd A meaningFul way TO gRoUP your datA, i.E. if Time DIFfereNce bETwEen obserVationS Is BiGger thaN [sPecify YoUr cUtoFf], movE To neW chunk.

 q:

Utility Of conSUmption with morTAlity and finitE TeRMInATion

in [CAlvo, GuillerMo A., aND MauRice oBsTfeLD. OptiMal tiMe-COnSIstent fiscal policy wItH finitE lifeTimes. EconometRica: JournaL OF The EconoMetrIC SOCiety (1988): 411-432], the authorS deriVe
:41:00 | 3.9
2018-04-09 00 :42:07 | 3 .8
20 18- 04- 09  00: 43:0 0 | 3.7
2018-0 4 -0900:44:00 | 4.2
2018-04 -09 0 0: 4 5:00 |5.8
2 018-04- 0 90 1 :15 :0 0| 5 .8 
O bserv ati ons are  unevenlyspa ce d, I have on e  o bservation  at  each minute  bu t just  r oug h ly, t her e may  be ad iffere nce of fe ws econds . 
Then I h av e la rger gaps between ob s ervations, inthe ex am p le I 've  pu t here the re  is a 30’ min ga p b etw e en the last o bservationa ndthe pr ev iou s  one.Plotl yi s o bviously co nnec ting thes e twol ast obs e rvation s in t helin e ch a rt ,wha tI  wo u ld  li k e t o have i sac tuall y ab l a n k ga p b etwe en th em instead.
A:
You can  achi eve t hatby  divi ding y our d at a into "chunks"  and  plotting  ea ch  on eas as eparat e t rac e. Repr oducibl e  ex am p l e :df <- data.frame( t i me  = Sys.t ime()-  c (1 : 10, 51:6 0) ,
 val u e  = ru nif( 2 0) ,
  chun k = re p (c (" A", "B" ),  each=10) 
)
p <- plot _ly(da ta = df[ which ( df$chunk == "A " ),], x = ~tim e ,y =~ valu e,name = "chu nk A " , ty pe = "s cat t er",mode=" li n es") %>%
  add_trac e( data =  df[w hich(df$chunk  == "B"),] , x  = ~time , y=  ~ v alue, name = " chunk  B", type=  "scatte r", m ode = "l ines")

# o r if the reare  mo re' c hu nks'
p2 <- pl o t _ly( da ta = df , x  = ~tim e,y =  ~v alu e,  color =~chunk,ty pe  =  " sca tter" ,  mode ="l ine s" )
Natur a lly, y ou ne ed t ofi n d a  meanin g fu l wayto  g roup  yo ur  data , i. e . i f timedifferenc e b e twee nob servati ons is bigger  t han [speci fy  yo ur cut o f f], move  to new chunk.

 Q:

Ut i lity of  co nsump tion  with mor tal ity an d f i nite t ermina tion
I n [ C a lvo,G u il ler mo  A., and M a u ric e Obs tf eld.  Optima l time-consistentf isc al policy wit h f init e li fet i me s . E co n ome t r ica: Journal of  the Econo me t ri c Society( 198 8) : 411-4 32], th e aut h ors der ive
:41:00 |_3.9
2018-04-09 00:42:07_| 3.8
2018-04-09 00:43:00 |_3.7
2018-04-09 00:44:00_|_4.2
2018-04-09 00:45:00_|_5.8
2018-04-09 01:15:00 |_5.8

Observations are unevenly_spaced, I have one_observation at each_minute_but just roughly, there may be a difference of few seconds.
Then I have larger_gaps_between observations,_in_the_example I've put here there_is a 30’ min gap_between the_last observation and the previous one.
Plotly is obviously_connecting_these two last_observations in the line chart, what I would like_to have is actually a blank_gap between them_instead.

A:

You_can_achieve that by dividing_your data into "chunks" and plotting_each one as a separate trace._Reproducible example:
df <- data.frame(
  time =_Sys.time() - c(1:10, 51:60),
  value_= runif(20),
  chunk =_rep(c("A", "B"),_each = 10)
)

p <- plot_ly(data_= df[which(df$chunk ==_"A"),], x_= ~time, y_= ~value, name = "chunk A",_type = "scatter",_mode = "lines") %>%
  add_trace(data_=_df[which(df$chunk == "B"),],_x_=_~time, y_= ~value, name_=_"chunk B",_type_= "scatter", mode = "lines")

# or_if_there are more 'chunks'
p2 <- plot_ly(data =_df, x = ~time,_y_= ~value, color =_~chunk, type = "scatter", mode_= "lines")

Naturally, you need to find_a meaningful_way to_group your data, i.e. if time difference between observations is bigger_than [specify your cutoff], move to_new chunk.

 Q:

Utility of_consumption with_mortality_and finite termination

In_[Calvo,_Guillermo A.,_and Maurice Obstfeld. Optimal time-consistent fiscal policy_with finite_lifetimes. Econometrica: Journal of the Econometric_Society (1988): 411-432], the_authors_derive