首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否有更简单的方法来查找分类数据和R中的多列数值数据之间的相关性?

是否有更简单的方法来查找分类数据和R中的多列数值数据之间的相关性?
EN

Stack Overflow用户
提问于 2021-11-02 12:58:56
回答 1查看 28关注 0票数 0

我正在从RStudio的一项调查中寻找分类数据和数值分数之间的相关性。我仍然在学习R,并且能够想出一种方法,从我的调查中将数字分配给类别,并将它们与单列数据进行一次比较。然而,这已经被证明是相当乏味的。有没有一种更简单的方法来创建一个表,将Column1中的原始分类数据与excel文件中的多列数据进行比较?

代码语言:javascript
复制
df <- read.table(text=" x
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Expert; has broad influence and experience within organization'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Expert; has broad influence and experience within organization'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Expert; has broad influence and experience within organization'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Expert; has broad influence and experience within organization'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Expert; has broad influence and experience within organization'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Early career; with basic skills development; work contributes to the success of team goals'
'Entry-level; learning technical and professional skills'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
'Seasoned Professional; with a variety of technical skills developed; strong problem solver'
'Advanced; very senior; can solve most problems of issues that arise'
'Advanced; very senior; can solve most problems of issues that arise'
'Early career; with basic skills development; work contributes to the success of team goals'
           ",header=TRUE, stringsAsFactors=FALSE)
代码语言:javascript
复制
library(dplyr)
column1=df%>%
  mutate(x=case_when(
    .$x=="Seasoned Professional; with a variety of technical skills developed; strong problem solver" ~ 1,
    .$x=="Entry-level; learning technical and professional skills" ~ 2,
    .$x=="Early career; with basic skills development; work contributes to the success of team goals" ~ 3,
    .$x=="Advanced; very senior; can solve most problems of issues that arise" ~ 4,
    .$x=="Expert; has broad influence and experience within organization" ~ 5
  ))
column2=read.table(file.choose(),sep=",",header=TRUE)
data=data.frame(c(column1,column2))
mydata.cor = cor(data, method = c("spearman"))
EN

回答 1

Stack Overflow用户

发布于 2021-11-02 13:24:13

将字符串转换为分类数字正是factor()所做的事情:

代码语言:javascript
复制
library(dplyr)

column1 = df %>%
  mutate(x=factor(x))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69810902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档