Error in plot.window(…) : 'xlim' needs finite values - How to solve it ?

Multi tool use
Multi tool use












0















So I have been trying to plot the following data frame :



head(MonthlyAveragePriceHAIRPEPE)

month AveragePrice pct.chg

1 2016-09 3.17 NA
2 2016-10 0.792 -0.750
3 2016-11 0.225 -0.715
4 2016-12 0.179 -0.204
5 2017-01 0.445 1.48
6 2017-02 3.36 6.55


The problem is that, when I plot with the following line of code plot(MonthlyAveragePriceHAIRPEPE$month, MonthlyAveragePriceHAIRPEPE$AveragePrice), I get the following :



Error in plot.window(...) : need finite 'xlim' values. 
In addition : Warning messages :
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf


I don't know how to solve those problems... I think it comes from the class of the month column, which is "character", but when I try to pass it to "factor", all I get are NA's... The class of the Average price is numeric and I get no problem plotting it alone. I think the problem really concerns the "month" column and its class...



The infos of the df are the following :



dput(head(MonthlyAveragePriceHAIRPEPE, 10))

structure(list(month = c("2016-09", "2016-10", "2016-11", "2016-12",
"2017-01", "2017-02", "2017-03", "2017-04", "2017-05", "2017-06"
), AveragePrice = c(3.16968709677419, 0.791904347826087, 0.225412279295455,
0.179445766423358, 0.444554531722054, 3.35761658783784, 5.6894554715794,
16.6639257580906, 53.1994216287425, 66.4208618873239), pct.chg = c(NA,
-0.750163242096669, -0.71535415872605, -0.203921955874672, 1.4773754242451,
6.55276652974736, 0.694492305103592, 1.9289139956068, 2.19249031716991,
0.24852601501664)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))


Many thanks in advance !










share|improve this question























  • Try plot(as.Date(paste0(df$month,'-1')), df$AveragePrice) but you will need more robust way to change month from character to a valid R Date type, so R can find the min(x) and max(x) as shown in the Error message.

    – A. Suliman
    Dec 29 '18 at 21:13













  • Many thanks, it works ! Just, how can I change durably the month from character to a valid R Data type ?

    – NewCommer
    Dec 30 '18 at 12:03











  • See stackoverflow.com/questions/6242955/…

    – A. Suliman
    Dec 30 '18 at 14:16











  • I used to try this but gave up because i have the following error : "Error in textConnection(text) : argument 'text' incorrect"

    – NewCommer
    Dec 30 '18 at 14:20
















0















So I have been trying to plot the following data frame :



head(MonthlyAveragePriceHAIRPEPE)

month AveragePrice pct.chg

1 2016-09 3.17 NA
2 2016-10 0.792 -0.750
3 2016-11 0.225 -0.715
4 2016-12 0.179 -0.204
5 2017-01 0.445 1.48
6 2017-02 3.36 6.55


The problem is that, when I plot with the following line of code plot(MonthlyAveragePriceHAIRPEPE$month, MonthlyAveragePriceHAIRPEPE$AveragePrice), I get the following :



Error in plot.window(...) : need finite 'xlim' values. 
In addition : Warning messages :
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf


I don't know how to solve those problems... I think it comes from the class of the month column, which is "character", but when I try to pass it to "factor", all I get are NA's... The class of the Average price is numeric and I get no problem plotting it alone. I think the problem really concerns the "month" column and its class...



The infos of the df are the following :



dput(head(MonthlyAveragePriceHAIRPEPE, 10))

structure(list(month = c("2016-09", "2016-10", "2016-11", "2016-12",
"2017-01", "2017-02", "2017-03", "2017-04", "2017-05", "2017-06"
), AveragePrice = c(3.16968709677419, 0.791904347826087, 0.225412279295455,
0.179445766423358, 0.444554531722054, 3.35761658783784, 5.6894554715794,
16.6639257580906, 53.1994216287425, 66.4208618873239), pct.chg = c(NA,
-0.750163242096669, -0.71535415872605, -0.203921955874672, 1.4773754242451,
6.55276652974736, 0.694492305103592, 1.9289139956068, 2.19249031716991,
0.24852601501664)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))


Many thanks in advance !










share|improve this question























  • Try plot(as.Date(paste0(df$month,'-1')), df$AveragePrice) but you will need more robust way to change month from character to a valid R Date type, so R can find the min(x) and max(x) as shown in the Error message.

    – A. Suliman
    Dec 29 '18 at 21:13













  • Many thanks, it works ! Just, how can I change durably the month from character to a valid R Data type ?

    – NewCommer
    Dec 30 '18 at 12:03











  • See stackoverflow.com/questions/6242955/…

    – A. Suliman
    Dec 30 '18 at 14:16











  • I used to try this but gave up because i have the following error : "Error in textConnection(text) : argument 'text' incorrect"

    – NewCommer
    Dec 30 '18 at 14:20














0












0








0








So I have been trying to plot the following data frame :



head(MonthlyAveragePriceHAIRPEPE)

month AveragePrice pct.chg

1 2016-09 3.17 NA
2 2016-10 0.792 -0.750
3 2016-11 0.225 -0.715
4 2016-12 0.179 -0.204
5 2017-01 0.445 1.48
6 2017-02 3.36 6.55


The problem is that, when I plot with the following line of code plot(MonthlyAveragePriceHAIRPEPE$month, MonthlyAveragePriceHAIRPEPE$AveragePrice), I get the following :



Error in plot.window(...) : need finite 'xlim' values. 
In addition : Warning messages :
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf


I don't know how to solve those problems... I think it comes from the class of the month column, which is "character", but when I try to pass it to "factor", all I get are NA's... The class of the Average price is numeric and I get no problem plotting it alone. I think the problem really concerns the "month" column and its class...



The infos of the df are the following :



dput(head(MonthlyAveragePriceHAIRPEPE, 10))

structure(list(month = c("2016-09", "2016-10", "2016-11", "2016-12",
"2017-01", "2017-02", "2017-03", "2017-04", "2017-05", "2017-06"
), AveragePrice = c(3.16968709677419, 0.791904347826087, 0.225412279295455,
0.179445766423358, 0.444554531722054, 3.35761658783784, 5.6894554715794,
16.6639257580906, 53.1994216287425, 66.4208618873239), pct.chg = c(NA,
-0.750163242096669, -0.71535415872605, -0.203921955874672, 1.4773754242451,
6.55276652974736, 0.694492305103592, 1.9289139956068, 2.19249031716991,
0.24852601501664)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))


Many thanks in advance !










share|improve this question














So I have been trying to plot the following data frame :



head(MonthlyAveragePriceHAIRPEPE)

month AveragePrice pct.chg

1 2016-09 3.17 NA
2 2016-10 0.792 -0.750
3 2016-11 0.225 -0.715
4 2016-12 0.179 -0.204
5 2017-01 0.445 1.48
6 2017-02 3.36 6.55


The problem is that, when I plot with the following line of code plot(MonthlyAveragePriceHAIRPEPE$month, MonthlyAveragePriceHAIRPEPE$AveragePrice), I get the following :



Error in plot.window(...) : need finite 'xlim' values. 
In addition : Warning messages :
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf


I don't know how to solve those problems... I think it comes from the class of the month column, which is "character", but when I try to pass it to "factor", all I get are NA's... The class of the Average price is numeric and I get no problem plotting it alone. I think the problem really concerns the "month" column and its class...



The infos of the df are the following :



dput(head(MonthlyAveragePriceHAIRPEPE, 10))

structure(list(month = c("2016-09", "2016-10", "2016-11", "2016-12",
"2017-01", "2017-02", "2017-03", "2017-04", "2017-05", "2017-06"
), AveragePrice = c(3.16968709677419, 0.791904347826087, 0.225412279295455,
0.179445766423358, 0.444554531722054, 3.35761658783784, 5.6894554715794,
16.6639257580906, 53.1994216287425, 66.4208618873239), pct.chg = c(NA,
-0.750163242096669, -0.71535415872605, -0.203921955874672, 1.4773754242451,
6.55276652974736, 0.694492305103592, 1.9289139956068, 2.19249031716991,
0.24852601501664)), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))


Many thanks in advance !







r






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 29 '18 at 21:08









NewCommerNewCommer

104




104













  • Try plot(as.Date(paste0(df$month,'-1')), df$AveragePrice) but you will need more robust way to change month from character to a valid R Date type, so R can find the min(x) and max(x) as shown in the Error message.

    – A. Suliman
    Dec 29 '18 at 21:13













  • Many thanks, it works ! Just, how can I change durably the month from character to a valid R Data type ?

    – NewCommer
    Dec 30 '18 at 12:03











  • See stackoverflow.com/questions/6242955/…

    – A. Suliman
    Dec 30 '18 at 14:16











  • I used to try this but gave up because i have the following error : "Error in textConnection(text) : argument 'text' incorrect"

    – NewCommer
    Dec 30 '18 at 14:20



















  • Try plot(as.Date(paste0(df$month,'-1')), df$AveragePrice) but you will need more robust way to change month from character to a valid R Date type, so R can find the min(x) and max(x) as shown in the Error message.

    – A. Suliman
    Dec 29 '18 at 21:13













  • Many thanks, it works ! Just, how can I change durably the month from character to a valid R Data type ?

    – NewCommer
    Dec 30 '18 at 12:03











  • See stackoverflow.com/questions/6242955/…

    – A. Suliman
    Dec 30 '18 at 14:16











  • I used to try this but gave up because i have the following error : "Error in textConnection(text) : argument 'text' incorrect"

    – NewCommer
    Dec 30 '18 at 14:20

















Try plot(as.Date(paste0(df$month,'-1')), df$AveragePrice) but you will need more robust way to change month from character to a valid R Date type, so R can find the min(x) and max(x) as shown in the Error message.

– A. Suliman
Dec 29 '18 at 21:13







Try plot(as.Date(paste0(df$month,'-1')), df$AveragePrice) but you will need more robust way to change month from character to a valid R Date type, so R can find the min(x) and max(x) as shown in the Error message.

– A. Suliman
Dec 29 '18 at 21:13















Many thanks, it works ! Just, how can I change durably the month from character to a valid R Data type ?

– NewCommer
Dec 30 '18 at 12:03





Many thanks, it works ! Just, how can I change durably the month from character to a valid R Data type ?

– NewCommer
Dec 30 '18 at 12:03













See stackoverflow.com/questions/6242955/…

– A. Suliman
Dec 30 '18 at 14:16





See stackoverflow.com/questions/6242955/…

– A. Suliman
Dec 30 '18 at 14:16













I used to try this but gave up because i have the following error : "Error in textConnection(text) : argument 'text' incorrect"

– NewCommer
Dec 30 '18 at 14:20





I used to try this but gave up because i have the following error : "Error in textConnection(text) : argument 'text' incorrect"

– NewCommer
Dec 30 '18 at 14:20












1 Answer
1






active

oldest

votes


















0














library(zoo)
MonthlyAveragePriceHAIRPEPE$month_ymon <- as.yearmon(MonthlyAveragePriceHAIRPEPE$month)
plot(MonthlyAveragePriceHAIRPEPE$month_ymon, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
library(lubridate)
MonthlyAveragePriceHAIRPEPE$month_parse <- parse_date_time(MonthlyAveragePriceHAIRPEPE$month, 'ym')
plot(MonthlyAveragePriceHAIRPEPE$month_parse, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
MonthlyAveragePriceHAIRPEPE$month_base <- as.Date(paste0(MonthlyAveragePriceHAIRPEPE$month,'-1'))





share|improve this answer



















  • 1





    Wow, thanks ! The first one is definitely the best format in my case

    – NewCommer
    Dec 30 '18 at 15:08











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53973350%2ferror-in-plot-window-xlim-needs-finite-values-how-to-solve-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














library(zoo)
MonthlyAveragePriceHAIRPEPE$month_ymon <- as.yearmon(MonthlyAveragePriceHAIRPEPE$month)
plot(MonthlyAveragePriceHAIRPEPE$month_ymon, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
library(lubridate)
MonthlyAveragePriceHAIRPEPE$month_parse <- parse_date_time(MonthlyAveragePriceHAIRPEPE$month, 'ym')
plot(MonthlyAveragePriceHAIRPEPE$month_parse, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
MonthlyAveragePriceHAIRPEPE$month_base <- as.Date(paste0(MonthlyAveragePriceHAIRPEPE$month,'-1'))





share|improve this answer



















  • 1





    Wow, thanks ! The first one is definitely the best format in my case

    – NewCommer
    Dec 30 '18 at 15:08
















0














library(zoo)
MonthlyAveragePriceHAIRPEPE$month_ymon <- as.yearmon(MonthlyAveragePriceHAIRPEPE$month)
plot(MonthlyAveragePriceHAIRPEPE$month_ymon, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
library(lubridate)
MonthlyAveragePriceHAIRPEPE$month_parse <- parse_date_time(MonthlyAveragePriceHAIRPEPE$month, 'ym')
plot(MonthlyAveragePriceHAIRPEPE$month_parse, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
MonthlyAveragePriceHAIRPEPE$month_base <- as.Date(paste0(MonthlyAveragePriceHAIRPEPE$month,'-1'))





share|improve this answer



















  • 1





    Wow, thanks ! The first one is definitely the best format in my case

    – NewCommer
    Dec 30 '18 at 15:08














0












0








0







library(zoo)
MonthlyAveragePriceHAIRPEPE$month_ymon <- as.yearmon(MonthlyAveragePriceHAIRPEPE$month)
plot(MonthlyAveragePriceHAIRPEPE$month_ymon, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
library(lubridate)
MonthlyAveragePriceHAIRPEPE$month_parse <- parse_date_time(MonthlyAveragePriceHAIRPEPE$month, 'ym')
plot(MonthlyAveragePriceHAIRPEPE$month_parse, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
MonthlyAveragePriceHAIRPEPE$month_base <- as.Date(paste0(MonthlyAveragePriceHAIRPEPE$month,'-1'))





share|improve this answer













library(zoo)
MonthlyAveragePriceHAIRPEPE$month_ymon <- as.yearmon(MonthlyAveragePriceHAIRPEPE$month)
plot(MonthlyAveragePriceHAIRPEPE$month_ymon, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
library(lubridate)
MonthlyAveragePriceHAIRPEPE$month_parse <- parse_date_time(MonthlyAveragePriceHAIRPEPE$month, 'ym')
plot(MonthlyAveragePriceHAIRPEPE$month_parse, MonthlyAveragePriceHAIRPEPE$AveragePrice)

#OR
MonthlyAveragePriceHAIRPEPE$month_base <- as.Date(paste0(MonthlyAveragePriceHAIRPEPE$month,'-1'))






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 30 '18 at 14:55









A. SulimanA. Suliman

4,71041122




4,71041122








  • 1





    Wow, thanks ! The first one is definitely the best format in my case

    – NewCommer
    Dec 30 '18 at 15:08














  • 1





    Wow, thanks ! The first one is definitely the best format in my case

    – NewCommer
    Dec 30 '18 at 15:08








1




1





Wow, thanks ! The first one is definitely the best format in my case

– NewCommer
Dec 30 '18 at 15:08





Wow, thanks ! The first one is definitely the best format in my case

– NewCommer
Dec 30 '18 at 15:08


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53973350%2ferror-in-plot-window-xlim-needs-finite-values-how-to-solve-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







jvs71j,nNf0EH4afXLaMyK9u2BGhePKvt7uCfNG5HB8I2lSmWcqMP TJ
80V985QuO9DuKUkfC6OkQ,kiXK16,Xj57tvP,JD28RJ00qA4KH Id63hGlNOvjnHlcgSn8XwZpws

Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas