[R-es] Plot. window error- Usando R base. Gráfico

Antonio Rodriguez Andres @nton|orodr|guez@ndre@70 @end|ng |rom gm@||@com
Mie Sep 4 19:52:57 CEST 2019


Aqui estan en formato csv,

Antonio

On Wed, 4 Sep 2019 at 19:19, Carlos Ortega <cof using qualityexcellence.es> wrote:

> ¿Puedes compartir los datos?...
> No veo otra forma...
>
> El mié., 4 sept. 2019 a las 18:54, Antonio Rodriguez Andres (<
> antoniorodriguezandres70 using gmail.com>) escribió:
>
>> No me sale error pero no me imprime la linea, ni ningun gráfico por pais.
>>
>> On Wed, 4 Sep 2019 at 18:42, neo <ericconchamunoz using gmail.com> wrote:
>>
>>> podría ser el problema el tipo de dato en X y el tipo de gráfico que
>>> intentas hacer ?
>>>
>>> si Year es entero y estas pidiendo que el gráfico sea tipo "I", podría
>>> ser que quizá eso te produce el error ?
>>>
>>> si pruebas a cambiar X a numérico (continuo) ?
>>>
>>> Slds,
>>>
>>> Eric.
>>>
>>>
>>>
>>>
>>> On 04-09-19 13:06, Antonio Rodriguez Andres wrote:
>>> > Lo que obtengo es dim(currcty)  = NULL
>>> >
>>> > lo que hice es crear una lista de paises
>>> >
>>> > countrylist <- unique(length(eco_freedom2$Countries)
>>> >
>>> > Los datos son de esta forma
>>> > head(eco_freedom2, 5)
>>> >      Year ISO_Code Countries SUMMARY.INDEX X1..Size.of.Government
>>> > 641 2000      AGO    Angola            NA                     NA
>>> > 601 2001      AGO    Angola            NA                     NA
>>> > 561 2002      AGO    Angola            NA                     NA
>>> > 521 2003      AGO    Angola            NA                     NA
>>> > 481 2004      AGO    Angola            NA                     NA
>>> >
>>> > On Wed, 4 Sep 2019 at 16:53, Carlos Ortega <cof using qualityexcellence.es>
>>> wrote:
>>> >
>>> >> ¿Puedes compartir los datos?..
>>> >>
>>> >> Otra cosa que puede ayudar es esto lo destaco en rojo.
>>> >> Creo que en alguno de los casos te quedas sin datos en tu data.frame.
>>> >>
>>> >> Con ese mensaje puedes ver justamente el tamaño de cada dataframe en
>>> cada
>>> >> iteración.
>>> >>
>>> >>
>>> >> for (i in 1:length(countrylist)){
>>> >>       currcty <- countrylist[i]
>>> >>      * print(dim(currcty))*
>>> >>      filename <- paste("index",currcty,".png",sep="")
>>> >>      png(filename,width=800,height=600)
>>> >>
>>> >> plot(y=eco_freedom3$SUMMARY.INDEX[eco_freedom3$Countries==currcty],
>>> >> x=eco_freedom3$Year[eco_freedom3$Countries==currcty], ylim = c(2.85,
>>> 8.20),
>>> >> xlim = c(2000, 2016), type="l", ylab="INDEX",xlab="YEAR", main =
>>> >> paste("Countries", currcty))
>>> >>      dev.off()
>>> >>    }
>>> >>
>>> >> El mié., 4 sept. 2019 a las 14:52, Antonio Rodriguez Andres (<
>>> >> antoniorodriguezandres70 using gmail.com>) escribió:
>>> >>
>>> >>> Carlos
>>> >>> Al especificar los limites, no me sale ningun error, aunque no
>>> consigue
>>> >>> graficar, nada,
>>> >>>
>>> >>>
>>> >>>    # Look at the time series for each country for the time period,
>>> for
>>> >>> instance GDPPC
>>> >>>    for (i in 1:length(countrylist)){
>>> >>>       currcty <- countrylist[i]
>>> >>>      filename <- paste("index",currcty,".png",sep="")
>>> >>>      png(filename,width=800,height=600)
>>> >>>
>>> >>> plot(y=eco_freedom3$SUMMARY.INDEX[eco_freedom3$Countries==currcty],
>>> >>> x=eco_freedom3$Year[eco_freedom3$Countries==currcty], ylim = c(2.85,
>>> 8.20),
>>> >>> xlim = c(2000, 2016), type="l", ylab="INDEX",xlab="YEAR",
>>> >>>           main = paste("Countries", currcty))
>>> >>>      dev.off()
>>> >>>    }
>>> >>>
>>> >>> On Wed, 4 Sep 2019 at 11:57, Carlos Ortega <cof using qualityexcellence.es
>>> >
>>> >>> wrote:
>>> >>>
>>> >>>> Hola,
>>> >>>>
>>> >>>> Pon un "print(i)" en tu bucle para ver en qué número/paso del bucle
>>> te
>>> >>>> aparece el error.
>>> >>>> Y con ese "i" haz la selección del dataframe y mira que pasa..
>>> puede que
>>> >>>> para ese caso, al quitar los NAs te quedes sin datos...
>>> >>>>
>>> >>>> Es una forma de debugear...
>>> >>>>
>>> >>>> Gracias,
>>> >>>> Carlos Ortega
>>> >>>> www.qualityexcellence.es
>>> >>>>
>>> >>>>
>>> >>>> El mié., 4 sept. 2019 a las 11:17, Antonio Rodriguez Andres (<
>>> >>>> antoniorodriguezandres70 using gmail.com>) escribió:
>>> >>>>
>>> >>>>> Hola queridos usuarios de R
>>> >>>>>
>>> >>>>> Estoy intentando hacer un gráfico de una variable en el tiempo
>>> para un
>>> >>>>> conjunto de países usando R base, con el comando plot. Tengo 40
>>> países y
>>> >>>>> son 15 años. Lo quiero salvar como formato png, cada uno de ellos.
>>> >>>>>
>>> >>>>> Tengo el siguiente código,
>>> >>>>>
>>> >>>>> for (i in 1:length(countrylist)){
>>> >>>>>      currcty <- countrylist[i]
>>> >>>>>      filename <- paste("index",currcty,".png",sep="")
>>> >>>>>      png(filename,width=800,height=600)
>>> >>>>>
>>> >>>>> plot(y=eco_freedom2$SUMMARY.INDEX[eco_freedom2$Countries==currcty],
>>> >>>>> x=eco_freedom2$Year[eco_freedom2$Countries==currcty], type="l",
>>> >>>>> ylab="INDEX",xlab="YEAR",
>>> >>>>>           main = paste("Countries", currcty))
>>> >>>>>      dev.off()
>>> >>>>>    }
>>> >>>>>
>>> >>>>> Pero me aparece el error Error in plot.window(...) : se necesitan
>>> >>>>> valores
>>> >>>>> finitos de 'xlim'. La variable y = SUMMARY.INDEX tiene valores
>>> Nas, y es
>>> >>>>> tipo numerico, y la variable x= Year es integer. Entiendo que es
>>> por el
>>> >>>>> problema de los NAs, por lo que da error.
>>> >>>>> Si embargo al usar na.omit(dataset), y quedarnos con los valores
>>> que no
>>> >>>>> son
>>> >>>>> NA, me sigue saliendo el mismo error
>>> >>>>>
>>> >>>>> Alguna idea,
>>> >>>>>
>>> >>>>> gracias
>>> >>>>>
>>> >>>>> --
>>> >>>>>
>>> >>>>> Member, Editorial Committee, *The Economic and Labour Relations
>>> Review*
>>> >>>>> (a
>>> >>>>> SAGE journal)
>>> >>>>>
>>> >>>>> http://elr.sagepub.com/
>>> >>>>>
>>> >>>>> Member, Editorial Committee, African Journal of Economic and
>>> Management
>>> >>>>> Studies
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems
>>> >>>>>
>>> >>>>> https://www.researchgate.net/profile/Antonio_Andres (Research Gate
>>> >>>>> profile)
>>> >>>>>
>>> >>>>>          [[alternative HTML version deleted]]
>>> >>>>>
>>> >>>>> _______________________________________________
>>> >>>>> R-help-es mailing list
>>> >>>>> R-help-es using r-project.org
>>> >>>>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>> >>>>>
>>> >>>>
>>> >>>> --
>>> >>>> Saludos,
>>> >>>> Carlos Ortega
>>> >>>> www.qualityexcellence.es
>>> >>>>
>>> >>>
>>> >>> --
>>> >>>
>>> >>> Member, Editorial Committee, *The Economic and Labour Relations
>>> Review* (a
>>> >>> SAGE journal)
>>> >>>
>>> >>> http://elr.sagepub.com/
>>> >>>
>>> >>> Member, Editorial Committee, African Journal of Economic and
>>> Management
>>> >>> Studies
>>> >>>
>>> >>>
>>> >>>
>>> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems
>>> >>>
>>> >>> https://www.researchgate.net/profile/Antonio_Andres (Research Gate
>>> >>> profile)
>>> >>>
>>> >>>
>>> >>>
>>> >> --
>>> >> Saludos,
>>> >> Carlos Ortega
>>> >> www.qualityexcellence.es
>>> >>
>>> >
>>>
>>
>>
>> --
>>
>> Member, Editorial Committee, *The Economic and Labour Relations Review* (a
>> SAGE journal)
>>
>> http://elr.sagepub.com/
>>
>> Member, Editorial Committee, African Journal of Economic and Management
>> Studies
>>
>>
>> http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems
>>
>> https://www.researchgate.net/profile/Antonio_Andres (Research Gate
>> profile)
>>
>>
>>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>


-- 

Member, Editorial Committee, *The Economic and Labour Relations Review* (a
SAGE journal)

http://elr.sagepub.com/

Member, Editorial Committee, African Journal of Economic and Management
Studies

http://emeraldgrouppublishing.com/products/journals/editorial_team.htm?id=ajems

https://www.researchgate.net/profile/Antonio_Andres (Research Gate profile)

------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20190904/c6744806/attachment-0001.html>

------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: EconomicFreedom.csv
Type: application/octet-stream
Size: 31208 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20190904/c6744806/attachment-0001.obj>


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