0

私は調査からのデータを持っています。いくつかのリッカート型の質問からのデータがあります。例: 「次の要因は、博士課程に入学するというあなたの決定にどの程度影響しましたか?」4 つのカテゴリ: 1: まったくない。2:少し。3: ある程度; 4:かなり)

データをエクスポートしましたが、現在は次のようになっています。

id  Q1_Item1  Q1_Item2  Q1_Item3  Q1_Item4
 1         4         4         4         2
 2         1         2         3         4
 3         3         4         4         4
 4         3         3         3         3
 5         2         1         1         1

このようにデータを集計したい

      Not at all  To a small extent  To some extent  To a great extent 
Item1          1                  1               2                  1
Item2          1                  1               1                  2
Item3          1                  0               2                  2
Item4          1                  1               1                  2

ここで、数字は各カテゴリの回答数を表しています。Rでこれを行うにはどうすればよいですか?

4

1 に答える 1

4

これらが要素として読み込まれ、テキスト エントリがラベルとして読み込まれたと仮定すると、次のように動作します。

# If the data was read in as numeric, then this will convert to factor-class
dfrm[-1] <- lapply(dfrm[-1], factor, levels=1:4, labels=c("Not at all", 
                        "To a small extent", "To some extent", "To a great extent") )
t( sapply(dfrm[-1], table) )
        Not at all To a small extent To some extent To a great extent
factor1          2                 1              4                 3
factor2          0                 0              3                 8
factor3          0                 0              3                 9
factor4          0                 0              6                 6
factor5          0                 0              3                 8
factor6          2                 0              0                10
factor7          0                 0              2                10
于 2012-07-04T12:57:40.560 に答える