我使用以下代码创建了折线图,以显示年度资金:
ggplot(yearly, aes(x=year, y=Total_US_received)) + ggtitle("Total Funding Received") + geom_line(color="darkblue") + labs(y="US$")
这样做,我得到以下结果:
我想将变量Total_US_received除以1000,以使图形更易于阅读。到目前为止,我已经尝试将其添加到我的代码中:
transform(yearly, Total_US_received1000=Total_US_received/1000)
ggplot(yearly, aes(x=year, y=Total_US_received1000)) + ggtitle("Total Funding Received") + geom_line(color="darkblue") + labs(y="US$")
但出现以下错误:
Error in FUN(X[[i]], ...) : object 'Total_US_received1000' not found
我在做什么错了?
这是我的数据:
yearly <- structure(list(year = 2006:2010, Total_US_received_from.CERF = c(65091455.5,
204409211, 200351170.5, 180924822, 290493687.5), Total_US_required = c(828538873.5,
2986369814, 1554939106, 2144420061, 7724926517), Total_US_received = c(215790327.5,
1988581112, 1698825389, 1509823414, 4975642034)), row.names = c(NA,
5L), class = "data.frame")