我的样本数据如下;
它有40行和26列,包括标题
Constituency: 01 | HP Deprivation Score | Total Population 2011| 5?year Population Change| Age Dependency Rate| Proportion of Lone Parents | |
Carlow-Kilkenny -1.70 145,659 8.9 34.1 19.0
Cavan-Monaghan -3.90 120,483 11.9 35.2 17.5
Clare -0.40 111,336 5.5 34.7 17.5
Cork East 0.50 114,365 14.2 34.7 18.6
Cork North-Central -0.40 117,131 3.2 30.6 26.1
Cork North-West 2.10 86,593 9.7 34.2 15.8
Cork South-Central 4.90 117,991 5.6 31.2 20.0
Cork South-West 2.00 82,952 7.8 36.0 15.4
Donegal -6.30 152,358 9.7 36.3 23.0
我尝试为每列获取相关系数表/矩阵,并希望保留选区名称。以下是我根据其他答案尝试过的代码;
library(corrplot)
election2016[is.na(election2016)] = 0
df <- data.frame(matrix(unlist(election2016), nrow=39, byrow=T),stringsAsFactors=FALSE)
M <- cor(df)
corrplot(M, method="circle")
我得到的表格不准确,因为它在数据框中包含不同的数字。
有人可以帮忙吗?