为什么在没有值的情况下显示错误消息,指示无穷大?

时间:2020-10-04 20:15:59

标签: r plot

这是代码(以前可以工作):

require('RCurl')
require(repr) 
require(RCurl)
require(foreign)
require(tidyverse) 

states = read.csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv", sep =",",header = TRUE)
states <- states %>%
  mutate(date = as.POSIXct(date, format = '%Y-%m-%d'))

last_day <- states[states$date==states$date[nrow(states)],]

with(last_day, plot(state, cases, las=2, cex.axis=.9, cex.main=1.5,
                    main="Confirmed cases by state",
                    xlab="", ylab=""))

...这是错误消息:

plot.window(...)中的错误:需要有限的“ xlim”值 另外:警告消息: 1:在xy.coords(x,y,xlabel,ylabel,log)中:强制引入的NA 2:在min(x)中:没有min的必填参数;返回Inf 3:在max(x)中:没有max的所有必输参数;返回-Inf

但是没有要求对数绘图;而且没有无限值:

> summary(last_day$cases)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
     70   23562   86525  134731  154429  831494 

2 个答案:

答案 0 :(得分:2)

我能想到的某件事以前曾经可以工作然后停止工作的唯一原因是,如果您从隐式的stringsAsFactors=TRUE更改为stringsAsFactors=FALSE(例如,从R 3.x更新为4.x ,或更改全局选项设置。

这可行(难看的情节,但是可行):

with(last_day,plot(factor(state),cases))

这是我对ggplot(几乎)单线的建议:

ggplot(last_day, aes(x = reorder(factor(state),cases), y = cases)) + 
         geom_col() + coord_flip() + labs(x="",y="confirmed cases")

答案 1 :(得分:1)

如果我们需要options = webdriver.ChromeOptions() options.headless = True driver = webdriver.Chrome('C:/Users/admin/Desktop/chromedriver.exe', options=options) driver.get(response.url) S = lambda X: driver.execute_script('return document.body.parentNode.scroll'+X) driver.set_window_size(S('Width'),S('Height')) # May need manual adjustment driver.find_element_by_tag_name('body').screenshot('./images/sample.png') ,则更容易

from scipy import stats

dist = stats.binom(100, 0.5)

# limit ourselves to [60, 100]
lo, hi = dist.cdf([60, 100])

# draw a sample
x = dist.ppf(stats.uniform(lo, hi-lo).rvs())

或与barplot

barplot(with(last_day, tapply(cases, state, FUN = sum)))
相关问题