首页 > 解决方案 > 将调查数据转换为 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")

标签: rdatasetsurvey

解决方案


推荐阅读