Edilson, boa tarde!O ideal é que você disponibilizasse uma amostra de seus dados pra testar. Mas pela saída do str() é quase certo que o problema está na incompatibilidade dos índices de Shanghai e vale.xts, pois um é Date e o outro POSIX. Os dois precisam ter o mesmo formato.Você pode tentar criar seu objeto "td" como POSIX ou mudar o padrão de index(vale.xts) pra Date.Um CMR reproduzindo o erro abaixo...### <code r>require(xts)xts1 <-structure(c(50.0397819115463, 50.2304961977954, 50.420955209067,50.3734680543285, 50.2443255196795, 50.1177772350145, 50.421876002125,50.420955209067, 50.3734680543285, 50.2443255196795, 49.9504146442813,50.2304961977954, 50.2641365663597, 50.2210338242788, 50.1112075487643,50.1177772350145, 50.3976663383861, 50.3323571013133, 50.3345948961691,50.1811210391819), .Dim = c(5L, 4L), .Dimnames = list(NULL, c("Open","High", "Low", "Close")), index = structure(c(1167710400, 1167796800,1167883200, 1167969600, 1168056000), tzone = "", tclass = c("POSIXct","POSIXt")), .indexCLASS = c("POSIXct", "POSIXt"), tclass = c("POSIXct","POSIXt"), .indexTZ = "", tzone = "", class = c("xts", "zoo"))xts3 <- xts2 <- structure(c(50.420955209067, 50.3734680543285, 50.2443255196795,50.1321122972067, 50.0355467742705, 50.420955209067, 50.3734680543285,50.2443255196795, 50.2156114607262, 50.1036323973342, 50.2641365663597,50.2210338242788, 50.1112075487643, 49.9918544993091, 49.9697097184701,50.3323571013133, 50.3345948961691, 50.1811210391819, 49.9918544993091,49.988063256042), .Dim = c(5L, 4L), .Dimnames = list(NULL, c("Open","High", "Low", "Close")), index = structure(c(1167868800, 1167955200,1168041600, 1168128000, 1168214400), tclass = "Date"), .indexCLASS = "Date", tclass = c("POSIXct","POSIXt"), .indexTZ = "", tzone = "", class = c("xts", "zoo"))str(xts1); str(xts2)index(xts1)# [1] "2007-01-02 AMT" "2007-01-03 AMT" "2007-01-04 AMT" "2007-01-05 AMT" "2007-01-06 AMT"index(xts3) <- as.POSIXct(as.POSIXlt(index(xts2)), tz=Sys.timezone()); index(xts3)# [1] "2007-01-04 AMT" "2007-01-05 AMT" "2007-01-06 AMT" "2007-01-07 AMT" "2007-01-08 AMT"merge.xts(xts1, xts2, join="inner")# Open High Low Close Open.1 High.1 Low.1 Close.1# 2007-01-04 50.42096 50.42096 50.26414 50.33236 50.42096 50.42096 50.26414 50.33236# 2007-01-05 50.37347 50.37347 50.22103 50.33459 50.37347 50.37347 50.22103 50.33459# 2007-01-06 50.24433 50.24433 50.11121 50.18112 50.24433 50.24433 50.11121 50.18112### </code>
_______________________________________________
R-br mailing list
R-br@listas.c3sl.ufpr.br
https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código mínimo reproduzível.