我对R比较新,但我已经使用了几个月。刚才我开始得到以下错误 - “运行此代码时无法找到函数ggplot”:
library(ggplot2)
library(dplyr)
library(plotly)
library(sqldf)
library(tidyverse)
library(lubridate)
options(scipen =999) #disable scientific notation
#prepare data:
setwd("C:/Users/hayescod/Desktop/BuysToForecastTracking")
Buys_To_Forecast <- read.csv("BuysToForecastTrack.csv")
colnames(Buys_To_Forecast) <- c("Date", "BusinessSegment", "Material", "StockNumber", "POCreatedBy", "PlantCode", "StockCategory", "Description", "Excess", "QuantityBought", "WareHouseSalesOrders", "GrandTotal", "Comments" )
Buys_To_Forecast$PlantCode <-factor(Buys_To_Forecast$PlantCode) #update PlantCode to factor
#use SQL to filter and order the data set:
btf <- sqldf("SELECT Date,
SUM(QuantityBought) AS 'QuantityBought',
Comments
FROM Buys_To_Forecast
GROUP BY Date, Comments
ORDER BY Date")
#use ggplot:
ggplot(data=btf, aes(x=Date, y=QuantityBought)) + geom_point()
我尝试重新安装ggplot2,重置我的R会话无济于事。完整的错误是:
Error in ggplot(data = btf, aes(x = Date, y = QuantityBought)) :
could not find function "ggplot"
有什么想法吗?
我会说我在这个开始发生之前安装了devtools,所以不确定它是否起了作用。
感谢。