Ok I’m myself not able to reproduce the problem.
After I closed and reopened R, everything works as it should.
 
I’m sorry to have disturbed you.
 
Thank you very much. 

 

 

-----Message d'origine-----
De : Joshua Ulrich [mailto:josh.m.ulrich@gmail.com] 
Envoyé : mardi 1 mai 2012 17:48
À : Karim
Cc : r-sig-finance@r-project.org
Objet : Re: [R-SIG-Finance] Time indexation after selection in an xts object

 

It's not because the index isn't unique.

 

> set.seed(21)

> x <- .xts(trunc(runif(1e4)*10), 1:1e4, dimnames=list(NULL,"SIZE"))

> x <- rbind(x,x)

> s <- cumsum(x$SIZE['1969-12-31'])

> head(s)

                    SIZE

1969-12-31 18:00:01    7

1969-12-31 18:00:01   14

1969-12-31 18:00:02   16

1969-12-31 18:00:02   18

1969-12-31 18:00:03   24

1969-12-31 18:00:03   30

 

--

Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

 

R/Finance 2012: Applied Finance with R

www.RinFinance.com

 

 

On Tue, May 1, 2012 at 10:40 AM, Karim <kktrash.k@gmail.com> wrote:

> I could send the file itself, but maybe that's because the index is not

> unique? (yours is unique)

>> sessionInfo()

> R version 2.14.1 (2011-12-22)

> Platform: i386-pc-mingw32/i386 (32-bit)

> 

> locale:

> [1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252

> LC_MONETARY=French_France.1252 LC_NUMERIC=C

> [5] LC_TIME=French_France.1252

> 

> attached base packages:

> [1] datasets  stats     graphics  grDevices utils     methods   base

> 

> other attached packages:

>  [1] RTAQ_0.1                   timeDate_2131.00
quantstrat_0.6.4

> blotter_0.8.4

>  [5] FinancialInstrument_0.13.6 quantmod_0.3-17            TTR_0.21-0

> xts_0.8-2

>  [9] zoo_1.7-7                  Defaults_1.1-1

> randomForest_4.6-6         RRF_1.1

> [13] fractal_1.1-1              scatterplot3d_0.3-33       akima_0.5-7

> wmtsa_1.1-1

> [17] sapa_1.1-0                 ifultools_1.1-2            MASS_7.3-16

> splus2R_1.1-0

> [21] RODBC_1.3-4

> 

> loaded via a namespace (and not attached):

> [1] grid_2.14.1    lattice_0.20-0 tools_2.14.1

> 

> -----Message d'origine-----

> De : Joshua Ulrich [mailto:josh.m.ulrich@gmail.com]

> Envoyé : mardi 1 mai 2012 15:41

> À : Karim

> Cc : r-sig-finance@r-project.org

> Objet : Re: [R-SIG-Finance] Time indexation after selection in an xts
object

> 

> I cannot replicate this behavior.  Please provide a reproducible example.

> 

>> library(xts)

>> set.seed(21)

>> x <- .xts(trunc(runif(1e4)*10), 1:1e4, dimnames=list(NULL,"SIZE"))

>> s <- cumsum(x$SIZE['1969-12-31'])

>> head(s)

>                    SIZE

> 1969-12-31 18:00:01    7

> 1969-12-31 18:00:02    9

> 1969-12-31 18:00:03   15

> 1969-12-31 18:00:04   16

> 1969-12-31 18:00:05   25

> 1969-12-31 18:00:06   34

>> sessionInfo()

> R version 2.15.0 (2012-03-30)

> Platform: i386-pc-mingw32/i386 (32-bit)

> 

> locale:

> [1] LC_COLLATE=English_United States.1252

> [2] LC_CTYPE=English_United States.1252

> [3] LC_MONETARY=English_United States.1252

> [4] LC_NUMERIC=C

> [5] LC_TIME=English_United States.1252

> 

> attached base packages:

> [1] stats     graphics  grDevices utils     datasets  methods   base

> 

> other attached packages:

> [1] xts_0.8-6 zoo_1.7-7

> 

> loaded via a namespace (and not attached):

> [1] grid_2.15.0    lattice_0.20-6

> 

> Best,

> --

> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

> 

> R/Finance 2012: Applied Finance with R

> www.RinFinance.com

> 

> 

> On Tue, May 1, 2012 at 6:04 AM, Karim <kktrash.k@gmail.com> wrote:

>> 

>> Hi,

>> 

>> My xts object : SP500TiSa

>> 

>> > head(SP500TiSa)

>> 

>>                         BID  OFR   PRICE SIZE

>> 2012-01-23 06:00:58 1306.75 1307 1307.00    2

>> 2012-01-23 06:00:58 1306.75 1307 1306.75    6

>> 2012-01-23 06:00:58 1306.75 1307 1307.00    1

>> 2012-01-23 06:00:58 1306.75 1307 1307.00    2

>> 2012-01-23 06:00:59 1306.75 1307 1307.00    1

>> 2012-01-23 06:00:59 1306.75 1307 1307.00    1

>> 

>> What I want to do is to calculate the cumulated sum of the column SIZE of

> the records of day 2012-01-24 but I want the resulting selection to keep
the

> time information

>> 

>> > s=cumsum(SP500TiSa$SIZE['2012-01-24'])

>> 

>> 

>> When I plot s, that’s ok, I have the time information on the x-axis of
the

> graph :

>> 

>> > plot(s,type="l")

>> 

>> 

>> But when I display s on the console :

>> 

>> > head(s)

>>            SIZE

>> 2012-01-24    4

>> 2012-01-24    5

>> 2012-01-24    6

>> 2012-01-24   16

>> 2012-01-24   17

>> 2012-01-24   32

>> 

>> We have only the day information on the index. The time info is lost, how

> to keep it ?

>> 

>> Thank you

>> 

>> _______________________________________________

>> R-SIG-Finance@r-project.org mailing list

>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance

>> -- Subscriber-posting only. If you want to post, subscribe first.

>> -- Also note that this is not the r-help list where general R questions

> should go.

> -----

> Aucun virus trouvé dans ce message.

> Analyse effectuée par AVG - www.avg.fr

> Version: 2012.0.1913 / Base de données virale: 2411/4971 - Date:
01/05/2012

> 

-----

Aucun virus trouvé dans ce message.

Analyse effectuée par AVG - www.avg.fr

Version: 2012.0.1913 / Base de données virale: 2411/4971 - Date: 01/05/2012


	[[alternative HTML version deleted]]

