我正在从RStudio的一项调查中寻找分类数据和数值分数之间的相关性。我仍然在学习R,并且能够想出一种方法,从我的调查中将数字分配给类别,并将它们与单列数据进行一次比较。然而,这已经被证明是相当乏味的。有没有一种更简单的方法来创建一个表,将Column1中的原始分类数据与excel文件中的多列数据进行比较?
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)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"))发布于 2021-11-02 13:24:13
将字符串转换为分类数字正是factor()所做的事情:
library(dplyr)
column1 = df %>%
mutate(x=factor(x))https://stackoverflow.com/questions/69810902
复制相似问题