[R-es] GRAFICAR FECHAS Y DATOS EN R

daniel daniel319 en gmail.com
Mar Ene 22 17:20:31 CET 2013


Tienes el TTR que se carga cuando cargas quantmod. Visita el sitio:

http://www.quantmod.com/

Daniel Merino




El 22 de enero de 2013 12:57, FERRER MARTINEZ, DIEGO <
FERRERDIEGO en bancsabadell.com> escribió:

>  Esto es lo que acaba de sacar aplicando al vector x
> charts.PerformanceSummary(diff(log(x)[,1]))
>
> No conoceras algún paquete de análisis técnico o chartista
>
>  ------------------------------
>
> *De:* daniel [mailto:daniel319 en gmail.com]
> *Enviado el:* martes, 22 de enero de 2013 16:40
>
> *Para:* FERRER MARTINEZ, DIEGO
> *CC:* Carlos J. Gil Bellosta; Diego; r-help-es en r-project.org
> *Asunto:* Re: [R-es] GRAFICAR FECHAS Y DATOS EN R
>
>
>
> A continuación te envío mi sesión y el gráfico resultante.  ¿tienes los
> paquetes xts y zoo? Por tu gráfico parece que no.
>
>
>
> > setwd("D:/L01359/Mis documentos/Downloads")
>
> > # Leo los datos teniendo en cuenta que es archivo de texto con
> separación por tab y con fechas, las que normalmente serán leídas como
> factores cosa que no quiero, adicionalmente el decimal se indica con coma y
> no tienen nombre las columnas.
>
> > x <- read.table("Duda_R_graficar.txt", header=FALSE, sep="\t", dec =
> ",", stringsAsFactors = FALSE)
>
> > str(x)  # lo leí bien y tengo un data.frame con caracteres y números
>
> 'data.frame':   500 obs. of  2 variables:
>
>  $ V1: chr  "21/01/2013" "18/01/2013" "17/01/2013" "16/01/2013" ...
>
>  $ V2: num  8654 8617 8619 8583 8602 ...
>
> > head(x)
>
>           V1     V2
>
> 1 21/01/2013 8654.3
>
> 2 18/01/2013 8617.3
>
> 3 17/01/2013 8619.0
>
> 4 16/01/2013 8583.3
>
> 5 15/01/2013 8602.0
>
> 6 14/01/2013 8596.6
>
> > library(xts) # voy a usar la liberías zoo xts
>
> > x <- xts( x[,2], order.by = as.Date(x[,1], format = "%d/%m/%Y")) # le
> digo a la base de datos que e
>
> > str(x)
>
> An ‘xts’ object on 2011-02-16/2013-01-21 containing:
>
>   Data: num [1:500, 1] 11044 11130 11064 10818 10726 ...
>
>   Indexed by objects of class: [Date] TZ: UTC
>
>   xts Attributes:
>
> List of 2
>
>  $ tclass: chr "Date"
>
>  $ tzone : chr "UTC"
>
> > colnames(x) <- c("Valor")
>
> > tail(x) # los datos originales estaban en orden decreciente
>
>             Valor
>
> 2013-01-14 8596.6
>
> 2013-01-15 8602.0
>
> 2013-01-16 8583.3
>
> 2013-01-17 8619.0
>
> 2013-01-18 8617.3
>
> 2013-01-21 8654.3
>
> > summary(x)
>
>      Index                Valor
>
>  Min.   :2011-02-16   Min.   : 5948
>
>  1st Qu.:2011-08-10   1st Qu.: 7706
>
>  Median :2012-02-02   Median : 8315
>
>  Mean   :2012-02-02   Mean   : 8441
>
>  3rd Qu.:2012-07-26   3rd Qu.: 8901
>
>  Max.   :2013-01-21   Max.   :11130
>
> > plot(x) # luego de aquí puedes seguir con el ejemplo que te di ayer.
>
> > sessionInfo()
>
> R version 2.15.2 (2012-10-26)
>
> Platform: i386-w64-mingw32/i386 (32-bit)
>
>
>
> locale:
>
> [1] LC_COLLATE=Spanish_Argentina.1252  LC_CTYPE=Spanish_Argentina.1252
>
> [3] LC_MONETARY=Spanish_Argentina.1252 LC_NUMERIC=C
>
> [5] LC_TIME=Spanish_Argentina.1252
>
>
>
> attached base packages:
>
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
>
>
> other attached packages:
>
> [1] xts_0.9-1 zoo_1.7-9
>
>
>
> loaded via a namespace (and not attached):
>
> [1] grid_2.15.2     lattice_0.20-13
>
> >
>
>
>
> [image: Imágenes integradas 1]
>
>
>
> Daniel Merino
>
>
>
>
>
> El 22 de enero de 2013 12:29, FERRER MARTINEZ, DIEGO <
> FERRERDIEGO en bancsabadell.com> escribió:
>
> Versión de r 2.12.2 (2011-02-25)
>
>
>
> Básicamente lo que trato de hacer es crear dos vectores uno con fechas y
> otro con datos.
>
>
>
> Y graficarlos….. con lo que me has mandado he conseguido sacar esto pero
> claro en el eje de abcisas no me salen las fechas
>
>
>
>
>  ------------------------------
>
> *De:* daniel [mailto:daniel319 en gmail.com]
> *Enviado el:* martes, 22 de enero de 2013 16:25
> *Para:* FERRER MARTINEZ, DIEGO
> *CC:* Carlos J. Gil Bellosta; Diego; r-help-es en r-project.org
>
>
> *Asunto:* Re: [R-es] GRAFICAR FECHAS Y DATOS EN R
>
>
>
> Diego,
>
>
>
> Aparentemente estamos en universos diferentes. Cuando dices que es la
> forma en que aprendiste el programa, disculpa pero no trato de ser grosero,
> ¿qué programa? si la respuesta es R ¿qué versión de R usas? ¿corristes el
> ejemplo anterior donde uso tus propios datos? si la respuesta es que si
> pero no funcionó, ¿dónde y cuál fue el error?
>
>
>
> Daniel Merino
>
>
>
>
>
> El 21 de enero de 2013 12:40, FERRER MARTINEZ, DIEGO <
> FERRERDIEGO en bancsabadell.com> escribió:
>
> Me vais a disculpar pero no se como hacerlo.
> La idea que tengo es definir dos vectores al menos es como he aprendido el
> programa.
> A<-scan(xxx)
> B<-scan(xxx)
>
> A, por ejemplo contendría las fechas (en la abcisa) y B, los precios (en
> la ordenada)
>
> Luego los graficaría...
>
> Os adjunto el Excel con los datos por si tuvierais un momento para pasarme
> el código
>
>
> Gracias
>
>
> -----Mensaje original-----
> De: gilbellosta en gmail.com [mailto:gilbellosta en gmail.com] En nombre de
> Carlos J. Gil Bellosta
> Enviado el: lunes, 21 de enero de 2013 15:57
> Para: Diego
> CC: FERRER MARTINEZ, DIEGO; r-help-es en r-project.org
>
> Asunto: Re: [R-es] GRAFICAR FECHAS Y DATOS EN R
>
> Hola, ¿qué tal?
>
> Usa el paquete zoo (por ejemplo). Tienes ejemplos en el blog de
> Gregorio Serrano:
>
>
> http://www.grserrano.es/wp/2012/04/gebr-5-regresion-con-series-temporales-i/
>
> Un saludo,
>
> Carlos J. Gil Bellosta
> http://www.datanalytics.com
>
> El día 21 de enero de 2013 15:50, Diego <diego.ferrer en telefonica.net>
> escribió:
> >
> >
> > Enviado desde mi iPhone
> >
> > El 21/01/2013, a las 13:17, "FERRER MARTINEZ, DIEGO" <
> FERRERDIEGO en bancsabadell.com> escribió:
> >
> >> Buenas,
> >>
> >> Como podría graficar fechas en el eje de abcisas y datos en el de
> ordenadas. Son series financieras
> >>
> >> Gracias
> >>
> >> 21/01/2013
> >> 8.628,300
> >> 18/01/2013
> >> 8.662,300
> >> 17/01/2013
> >> 8.568,400
> >> 16/01/2013
> >> 8.588,900
> >> 15/01/2013
> >> 8.549,600
> >> 14/01/2013
> >> 8.699,200
> >> 11/01/2013
> >> 8.638,000
> >> 10/01/2013
> >> 8.607,300
> >> 09/01/2013
> >> 8.491,800
> >> 08/01/2013
> >> 8.388,200
> >> 07/01/2013
> >> 8.434,300
> >> 04/01/2013
> >> 8.411,700
> >> 03/01/2013
> >> 8.375,000
> >> 02/01/2013
> >> 8.337,900
> >> 31/12/2012
> >> 8.111,900
> >> 28/12/2012
> >> 8.276,600
> >> 27/12/2012
> >> 8.236,500
> >> 24/12/2012
> >> 8.261,600
> >> 21/12/2012
> >> 8.223,500
> >> 20/12/2012
> >> 8.226,700
> >> 19/12/2012
> >> 8.192,300
> >> 18/12/2012
> >> 8.068,600
> >> 17/12/2012
> >> 8.017,800
> >> 14/12/2012
> >> 8.025,900
> >> 13/12/2012
> >> 8.005,900
> >> 12/12/2012
> >> 7.935,100
> >> 11/12/2012
> >> 7.813,600
> >> 10/12/2012
> >> 7.796,100
> >> 07/12/2012
> >> 7.915,700
> >> 06/12/2012
> >> 7.905,800
> >> 05/12/2012
> >> 7.948,500
> >> 04/12/2012
> >> 7.871,900
> >> 03/12/2012
> >> 7.963,400
> >> 30/11/2012
> >> 7.967,900
> >> 29/11/2012
> >> 7.887,400
> >> 28/11/2012
> >> 7.839,400
> >> 27/11/2012
> >> 7.936,600
> >> 26/11/2012
> >> 7.882,800
> >> 23/11/2012
> >> 7.887,200
> >> 22/11/2012
> >> 7.828,500
> >> 21/11/2012
> >> 7.751,800
> >> 20/11/2012
> >> 7.722,400
> >> 19/11/2012
> >> 7.661,800
> >> 16/11/2012
> >> 7.694,000
> >> 15/11/2012
> >> 7.615,400
> >> 14/11/2012
> >> 7.695,600
> >> 13/11/2012
> >> 7.521,900
> >> 12/11/2012
> >> 7.632,100
> >
> >         [[alternative HTML version deleted]]
> >
> >
> > _______________________________________________
> > R-help-es mailing list
> > R-help-es en r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
>
> ________________________________
> Advertencia legal: Este mensaje y, en su caso, los ficheros anexos son
> confidenciales, especialmente en lo que respecta a los datos personales, y
> se dirigen exclusivamente al destinatario referenciado. Si usted no lo es y
> lo ha recibido por error o tiene conocimiento del mismo por cualquier
> motivo, le rogamos que nos lo comunique por este medio y proceda a
> destruirlo o borrarlo, y que en todo caso se abstenga de utilizar,
> reproducir, alterar, archivar o comunicar a terceros el presente mensaje y
> ficheros anexos, todo ello bajo pena de incurrir en responsabilidades
> legales. El emisor no garantiza la integridad, rapidez o seguridad del
> presente correo, ni se responsabiliza de posibles perjuicios derivados de
> la captura, incorporaciones de virus o cualesquiera otras manipulaciones
> efectuadas por terceros.
> ________________________________
> Advertiment legal: Aquest missatge i, si escau, els fitxers annexos tenen
> caire confidencial, especialment pel que fa a les dades personals, i
> s'adrecen exclusivament al destinatari referenciat. Si no es tracta
> d'aquest i l'ha rebut per error o se li ha fet arribar per qualsevol motiu,
> li preguem que ens ho comuniqui per aquesta mateixa via i el destrueixi o
> l'esborri, i que en tot cas s'abstingui d'utilitzar, reproduir, alterar,
> arxivar o comunicar a tercers aquest missatge i fitxers annexos, tot sota
> pena d'entrar en responsabilitats legals. L'emissor no garanteix la
> integritat, la rapidesa o la seguretat d'aquest correu, ni es
> responsabilitza de possibles perjudicis derivats de la captura,
> incorporacions de virus o qualsevol altres manipulacions que facin tercers.
> ________________________________
> Disclaimer: This message and any attached files transmitted with it, is
> confidential, especially as regards personal data. It is intended solely
> for the use of the individual or entity to whom it is addressed. If you are
> not the intended recipient and have received this information in error or
> have accessed it for any reason, please notify us of this fact by email
> reply and then destroy or delete the message, refraining from any
> reproduction, use, alteration, filing or communication to third parties of
> this message and attached files on penalty of incurring legal
> responsibilities. The sender does not guarantee the integrity, the
> accuracy, the swift delivery or the security of this email transmission,
> and assumes no responsibility for any possible damage incurred through data
> capture, virus incorporation or any manipulation carried out by third
> parties.
>
> ________________________________
>
>
> _______________________________________________
> R-help-es mailing list
> R-help-es en r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
>
>
>
> --
> Daniel
>     ------------------------------
>
> *Advertencia legal:* *Este mensaje y, en su caso, los ficheros anexos son
> confidenciales, especialmente en lo que respecta a los datos personales, y
> se dirigen exclusivamente al destinatario referenciado. Si usted no lo es y
> lo ha recibido por error o tiene conocimiento del mismo por cualquier
> motivo, le rogamos que nos lo comunique por este medio y proceda a
> destruirlo o borrarlo, y que en todo caso se abstenga de utilizar,
> reproducir, alterar, archivar o comunicar a terceros el presente mensaje y
> ficheros anexos, todo ello bajo pena de incurrir en responsabilidades
> legales. El emisor no garantiza la integridad, rapidez o seguridad del
> presente correo, ni se responsabiliza de posibles perjuicios derivados de
> la captura, incorporaciones de virus o cualesquiera otras manipulaciones
> efectuadas por terceros.*
>  ------------------------------
>
> *Advertiment legal:* *Aquest missatge i, si escau, els fitxers annexos
> tenen caire confidencial, especialment pel que fa a les dades personals, i
> s'adrecen exclusivament al destinatari referenciat. Si no es tracta
> d'aquest i l'ha rebut per error o se li ha fet arribar per qualsevol motiu,
> li preguem que ens ho comuniqui per aquesta mateixa via i el destrueixi o
> l'esborri, i que en tot cas s'abstingui d'utilitzar, reproduir, alterar,
> arxivar o comunicar a tercers aquest missatge i fitxers annexos, tot sota
> pena d'entrar en responsabilitats legals. L'emissor no garanteix la
> integritat, la rapidesa o la seguretat d'aquest correu, ni es
> responsabilitza de possibles perjudicis derivats de la captura,
> incorporacions de virus o qualsevol altres manipulacions que facin tercers.
> *
>  ------------------------------
>
> *Disclaimer:* *This message and any attached files transmitted with it,
> is confidential, especially as regards personal data. It is intended solely
> for the use of the individual or entity to whom it is addressed. If you are
> not the intended recipient and have received this information in error or
> have accessed it for any reason, please notify us of this fact by email
> reply and then destroy or delete the message, refraining from any
> reproduction, use, alteration, filing or communication to third parties of
> this message and attached files on penalty of incurring legal
> responsibilities. The sender does not guarantee the integrity, the
> accuracy, the swift delivery or the security of this email transmission,
> and assumes no responsibility for any possible damage incurred through data
> capture, virus incorporation or any manipulation carried out by third
> parties.*
>  ------------------------------
>
>
>
>
>
> --
> Daniel
>
> ------------------------------
> *Advertencia legal:* *Este mensaje y, en su caso, los ficheros anexos son
> confidenciales, especialmente en lo que respecta a los datos personales, y
> se dirigen exclusivamente al destinatario referenciado. Si usted no lo es y
> lo ha recibido por error o tiene conocimiento del mismo por cualquier
> motivo, le rogamos que nos lo comunique por este medio y proceda a
> destruirlo o borrarlo, y que en todo caso se abstenga de utilizar,
> reproducir, alterar, archivar o comunicar a terceros el presente mensaje y
> ficheros anexos, todo ello bajo pena de incurrir en responsabilidades
> legales. El emisor no garantiza la integridad, rapidez o seguridad del
> presente correo, ni se responsabiliza de posibles perjuicios derivados de
> la captura, incorporaciones de virus o cualesquiera otras manipulaciones
> efectuadas por terceros.*
>
>  ------------------------------
> *Advertiment legal:* *Aquest missatge i, si escau, els fitxers annexos
> tenen caire confidencial, especialment pel que fa a les dades personals, i
> s'adrecen exclusivament al destinatari referenciat. Si no es tracta
> d'aquest i l'ha rebut per error o se li ha fet arribar per qualsevol motiu,
> li preguem que ens ho comuniqui per aquesta mateixa via i el destrueixi o
> l'esborri, i que en tot cas s'abstingui d'utilitzar, reproduir, alterar,
> arxivar o comunicar a tercers aquest missatge i fitxers annexos, tot sota
> pena d'entrar en responsabilitats legals. L'emissor no garanteix la
> integritat, la rapidesa o la seguretat d'aquest correu, ni es
> responsabilitza de possibles perjudicis derivats de la captura,
> incorporacions de virus o qualsevol altres manipulacions que facin tercers.
> *
>
>  ------------------------------
> *Disclaimer:* *This message and any attached files transmitted with it,
> is confidential, especially as regards personal data. It is intended solely
> for the use of the individual or entity to whom it is addressed. If you are
> not the intended recipient and have received this information in error or
> have accessed it for any reason, please notify us of this fact by email
> reply and then destroy or delete the message, refraining from any
> reproduction, use, alteration, filing or communication to third parties of
> this message and attached files on penalty of incurring legal
> responsibilities. The sender does not guarantee the integrity, the
> accuracy, the swift delivery or the security of this email transmission,
> and assumes no responsibility for any possible damage incurred through data
> capture, virus incorporation or any manipulation carried out by third
> parties.*
>
> ------------------------------
>



-- 
Daniel
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20130122/74b406f0/attachment-0001.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: no disponible
Type: image/gif
Size: 17441 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20130122/74b406f0/attachment-0003.gif>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: no disponible
Type: image/gif
Size: 9729 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20130122/74b406f0/attachment-0004.gif>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: no disponible
Type: image/gif
Size: 22851 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20130122/74b406f0/attachment-0005.gif>


Más información sobre la lista de distribución R-help-es