Corrplot相关误差:'x'必须是数字

Mig*_*oki 0 r r-corrplot

我正在尝试使用'corrplot'库为我的数据集创建一个Correlation图.但是我得到一个错误

相关误差:'x'必须是数字

这是我的数据集的示例

 R.D.Spend Administration Marketing.Spend State   Profit
1  165349.2      136897.80        471784.1     1 192261.8
2  162597.7      151377.59        443898.5     2 191792.1
3  153441.5      101145.55        407934.5     3 191050.4
6  131876.9       99814.71        362861.4     1 156991.1
7  134615.5      147198.87        127716.8     2 156122.5
Run Code Online (Sandbox Code Playgroud)

我的代码是

library('corrplot')

M=cor(training_set)
corrplot(M,method = 'circle')
Run Code Online (Sandbox Code Playgroud)

当我尝试运行我的代码时,我得到上面提到的错误.我不明白什么是错误的,因为我的数据集中的所有值都是数字.我剩下的代码是

dataset = read.csv('50_Startups.csv')

dataset$State=factor(dataset$State, 
                     levels = c('New York', 'California', 'Florida'),
                     labels = c('1','2','3'))

head(dataset,n=5)
# Splitting the dataset into the Training set and Test set
# install.packages('caTools')
library(caTools)
set.seed(123)
split = sample.split(dataset$Profit, SplitRatio = 0.8)
training_set = subset(dataset, split == TRUE)
test_set = subset(dataset, split == FALSE)
Run Code Online (Sandbox Code Playgroud)

cat*_*ure 5

dataset$State是一个factor,cor只需要numeric变量.