y轴应该能够在0-535,000之间运行,并且线的位置应该是成比例的。我没有充分描述这个问题的词汇,所以这里有两张图片。
carbon_emissions <- read.csv("/Users/mathewsayer/Documents/Work/Level 7/Shiny Flat Tax/Carbon/Carbon_Emissions/data/carbon_emissions0513.csv")
output$carbonPlot <- renderPlot({
pCarbon <- ggplot(data=carbon_emissions[carbon_emissions$category%in%input$emission_choose,],
aes(x=year, y=co2, group=category, colour=category))+
geom_line()+
geom_point()
pCarbon + labs(title="UK Domestic, Industry and Transport CO2 Emissions")
})
checkboxGroupInput(
"emission_choose",
label = "Plot CO2 emissions from various sectors",
choices = c(
"Industrial and Commericial Electricity" = "i_c_electric",
"Industrial and Commericial Gas" = "i_c_gas",
"Large Industrial Installations" =
"large_industry",
"Other Industrial and Commericial Fuels" = "i_c_other_fuel",
"Agriculture" =
"agriculture",))
plotOutput("carbonPlot")
year,co2,category
2005,"110,579.1",i_c_electric
2006,"116,665.8",i_c_electric
2007,"113,343.8",i_c_electric
2008,"112,510.3",i_c_electric
...
2010,7.6,pc_emission
2011,6.9,pc_emission
2012,7.1,pc_emission
2013,7.0,pc_emission
先谢谢好人。
答案 0 :(得分:3)
您的co2
变量看起来像是一个字符而不是数字。
阅读完文件后,请执行以下操作。
carbon_emissions$co2 <- as.numeric(gsub(",", "", carbon_emissions$co2))