r - 将调查数据转换为 R 中的数值数据
问题描述
我有一些测量信任度的调查数据,每个国家/地区的每个受访者都会回答“倾向于信任它”、“倾向于不信任它”或“不知道”。
数据是时间序列的,跨国的,我想转换它,所以每年每个变量都有一个数值。
我已经下载了 SPSS 格式的数据并使用 read.spss 函数放入 R 中,但我现在不知道如何更改它。
我在下面有一个净信任公式,但不知道在 R 中我需要什么命令或包来执行此操作。
“净信任 =  信任/(信任 + 不信任 + 不知道)- 不信任/(信任 + 不信任 + 不知道)”
抱歉,如果这个问题之前已经发布过,但我真的很感激一些建议。
干杯!
structure(list(qb1_2 = structure(c(2L, 3L, 1L, 2L, 2L, 2L, 3L,
2L, 1L, 2L), .Label = c("Totally agree", "Tend to agree", "Tend to disagree"
), class = "factor"), qb1_3 = structure(c(2L, 4L, 1L, 2L, 2L,
2L, 3L, 3L, 1L, 1L), .Label = c("Totally agree", "Tend to agree",
"Tend to disagree", "Totally disagree"), class = "factor"), qb1_4 = structure(c(2L,
3L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L), .Label = c("Totally agree",
"Tend to agree", "Tend to disagree"), class = "factor"), qb2_1 = structure(c(2L,
2L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 1L), .Label = c("Very important",
"Fairly important", "Not very important"), class = "factor"),
qb2_2 = structure(c(2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L
), .Label = c("Very important", "Fairly important"), class = "factor"),
qb2_3 = structure(c(1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L
), .Label = c("Very important", "Fairly important"), class = "factor"),
qb2_4 = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 1L, 3L, 1L, 1L
), .Label = c("Very important", "Fairly important", "Not very important"
), class = "factor"), qb2_5 = structure(c(2L, 2L, 1L, 3L,
2L, 2L, 2L, 1L, 1L, 2L), .Label = c("Very important", "Fairly important",
"Not very important"), class = "factor"), qb3_1 = structure(c(2L,
4L, 1L, 3L, 3L, 2L, 3L, 2L, 3L, 3L), .Label = c("Totally agree",
"Tend to agree", "Tend to disagree", "Totally disagree"), class = "factor"),
qb3_2 = structure(c(2L, 3L, 1L, 2L, 3L, 2L, 2L, 2L, 3L, 3L
), .Label = c("Totally agree", "Tend to agree", "Tend to disagree"
), class = "factor"), qb3_3 = structure(c(2L, 3L, 1L, 2L,
2L, 2L, 3L, 2L, 2L, 1L), .Label = c("Totally agree", "Tend to agree",
"Tend to disagree"), class = "factor"), qb3_4 = structure(c(2L,
2L, 1L, 4L, 2L, 2L, 3L, 1L, 3L, 2L), .Label = c("Totally agree",
"Tend to agree", "Tend to disagree", "Totally disagree"), class = "factor"),
qb3_5 = structure(c(2L, 4L, 1L, 3L, 2L, 2L, 2L, 2L, 3L, 2L
), .Label = c("Totally agree", "Tend to agree", "Tend to disagree",
"Totally disagree"), class = "factor"), qb3_6 = structure(c(2L,
4L, 1L, 5L, 3L, 2L, 3L, 1L, 3L, 3L), .Label = c("Totally agree",
"Tend to agree", "Tend to disagree", "Totally disagree",
"DK"), class = "factor"), qb3_7 = structure(c(2L, 4L, 1L,
3L, 3L, 2L, 2L, 5L, 3L, 2L), .Label = c("Totally agree",
"Tend to agree", "Tend to disagree", "Totally disagree",
"DK"), class = "factor"), qb4_1 = structure(c(2L, 3L, 1L,
3L, 2L, 2L, 2L, 2L, 3L, 2L), .Label = c("Totally agree",
"Tend to agree", "Tend to disagree"), class = "factor"),
qb4_2 = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L
), .Label = c("Totally agree", "Tend to agree"), class = "factor"),
qb5 = structure(c(2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("On a case by case basis",
"Always, in every case"), class = "factor"), qb6.1 = structure(c(2L,
2L, NA, 2L, 2L, NA, 2L, 1L, 2L, 2L), .Label = c("Not mentioned",
"Mentioned"), class = "factor"), qb6.2 = structure(c(2L,
2L, NA, 1L, 2L, NA, 1L, 1L, 2L, 1L), .Label = c("Not mentioned",
"Mentioned"), class = "factor"), qb6.3 = structure(c(2L,
1L, NA, 2L, 2L, NA, 1L, 2L, 2L, 1L), .Label = c("Not mentioned",
"Mentioned"), class = "factor")), .Names = c("qb1_2", "qb1_3",
"qb1_4", "qb2_1", "qb2_2", "qb2_3", "qb2_4", "qb2_5", "qb3_1",
"qb3_2", "qb3_3", "qb3_4", "qb3_5", "qb3_6", "qb3_7", "qb4_1",
"qb4_2", "qb5", "qb6.1", "qb6.2", "qb6.3"), row.names = c(NA,
10L), class = "data.frame")
解决方案
推荐阅读
- php - 类 Illuminate\Validation\Rules\RequiredIf 的对象无法转换为 int
- google-colaboratory - Colab pro 改进和用户反馈
- java - 使用 ${} 的 log4j 属性中的 Weblogic 12 相对路径不起作用
- extjs - ExtJS 无法读取 null 的属性“addClass”
- html - 为什么我的元素不能与导航栏内联?
- azure - Microsoft Graph API - Is there a way to get all the service principals?
- reactjs - 当有打字稿错误时,故事书不应该编译
- docker - Go 应用程序无法通过 docker-compose 内的 websocket 连接
- php - 如何将参数传递给自定义作曲家脚本
- php - 如何在结帐页面上找到总金额的简码,并将其与 wordpress 中的统一运费相结合?