# 主題:社群平台議題分析
# 任務:RQ.3社群平台使用功能分析
# 組別:應用藝術學系 第一組
### 資料框處理
# 請至台灣傳播資料庫下載「2019年調查」的sav檔
# 網址:https://www.crctaiwan.nctu.edu.tw/AnnualSurvey.asp
## 1. 將輸入的sav檔案命名為tcs2019
library(sjlabelled)
tcs2019 <- read_spss("tcs2019.sav")
# (2)變數整理
# 年齡「變數重新分類」為4類:18-35,36-49,50-64,65UP
# 備註:break的值(x,y,z)是指: group1 >x & <=y; group2 >y & <=z
tcs2019$agegroup <- cut(tcs2019$ra2, breaks = c(17,35,49,64,Inf),
labels = c("18至35歲", "36至49歲","50至64歲","65歲以上"))
# 製作次數分配表
# install.packages("sjmisc")
library(sjmisc)
frq(tcs2019$agegroup, encoding = "big-5", out="v")
| val | label | frq | raw.prc | valid.prc | cum.prc | |
|---|---|---|---|---|---|---|
| 18至35歲 |
|
343 | 17.15 | 17.15 | 17.15 | |
| 36至49歲 |
|
534 | 26.70 | 26.70 | 43.85 | |
| 50至64歲 |
|
583 | 29.15 | 29.15 | 73.00 | |
| 65歲以上 |
|
540 | 27.00 | 27.00 | 100.00 | |
| NA | NA | 0 | 0.00 | NA | NA | |
| total N=2000 · valid N=2000 · x̄=2.66 · σ=1.05 | ||||||
table(tcs2019$k5.1)
##
## 1 2 3 4
## 153 527 406 151
table(tcs2019$k5.2)
##
## 1 2 3 4
## 181 537 379 140
table(tcs2019$k5.3)
##
## 1 2 3 4
## 25 166 489 557
table(tcs2019$k5.4)
##
## 1 2 3 4
## 17 123 481 616
### (3)回答RQ
#RQ.3各年齡使用社群平台功能比較
## 製表
#install.packages("sjPlot")
library(sjPlot)
sjt.xtab(tcs2019$k5.1,tcs2019$agegroup,encoding = "utf-8",show.cell.prc = T,
show.row.prc = T,
show.col.prc = T)
| K5.(01)請問你有多常在社群媒體(如:臉書)上分享或轉貼訊息? | agegroup | Total | |||
|---|---|---|---|---|---|
| 18至35歲 | 36至49歲 | 50至64歲 | 65歲以上 | ||
| 從來沒有 |
23 15 % 7 % 1.9 % |
37 24.2 % 7.8 % 3 % |
65 42.5 % 20.1 % 5.3 % |
28 18.3 % 25.5 % 2.3 % |
153 100 % 12.4 % 12.5 % |
| 很少 |
171 32.4 % 52 % 13.8 % |
203 38.5 % 42.7 % 16.4 % |
116 22 % 35.9 % 9.4 % |
37 7 % 33.6 % 3 % |
527 100 % 42.6 % 42.6 % |
| 有時 |
91 22.4 % 27.7 % 7.4 % |
173 42.6 % 36.4 % 14 % |
107 26.4 % 33.1 % 8.6 % |
35 8.6 % 31.8 % 2.8 % |
406 100 % 32.8 % 32.8 % |
| 經常 |
44 29.1 % 13.4 % 3.6 % |
62 41.1 % 13.1 % 5 % |
35 23.2 % 10.8 % 2.8 % |
10 6.6 % 9.1 % 0.8 % |
151 100 % 12.2 % 12.2 % |
| Total |
329 26.6 % 100 % 26.6 % |
475 38.4 % 100 % 38.4 % |
323 26.1 % 100 % 26.1 % |
110 8.9 % 100 % 8.9 % |
1237 100 % 100 % 100 % |
χ2=65.542 · df=9 · Cramer’s V=0.133 · p=0.000 |
sjt.xtab(tcs2019$k5.2,tcs2019$agegroup,encoding = "utf-8",show.cell.prc = T,
show.row.prc = T,
show.col.prc = T)
| K5.(02)請問你有多常在社群媒體(如:臉書)上發文或發照片? | agegroup | Total | |||
|---|---|---|---|---|---|
| 18至35歲 | 36至49歲 | 50至64歲 | 65歲以上 | ||
| 從來沒有 |
24 13.3 % 7.3 % 1.9 % |
44 24.3 % 9.3 % 3.6 % |
79 43.6 % 24.5 % 6.4 % |
34 18.8 % 30.9 % 2.7 % |
181 100 % 14.6 % 14.6 % |
| 很少 |
170 31.7 % 51.7 % 13.7 % |
218 40.6 % 45.9 % 17.6 % |
118 22 % 36.5 % 9.5 % |
31 5.8 % 28.2 % 2.5 % |
537 100 % 43.4 % 43.3 % |
| 有時 |
93 24.5 % 28.3 % 7.5 % |
156 41.2 % 32.8 % 12.6 % |
94 24.8 % 29.1 % 7.6 % |
36 9.5 % 32.7 % 2.9 % |
379 100 % 30.6 % 30.6 % |
| 經常 |
42 30 % 12.8 % 3.4 % |
57 40.7 % 12 % 4.6 % |
32 22.9 % 9.9 % 2.6 % |
9 6.4 % 8.2 % 0.7 % |
140 100 % 11.3 % 11.3 % |
| Total |
329 26.6 % 100 % 26.6 % |
475 38.4 % 100 % 38.4 % |
323 26.1 % 100 % 26.1 % |
110 8.9 % 100 % 8.9 % |
1237 100 % 100 % 100 % |
χ2=82.028 · df=9 · Cramer’s V=0.149 · p=0.000 |
sjt.xtab(tcs2019$k5.3,tcs2019$agegroup,encoding = "utf-8",show.cell.prc = T,
show.row.prc = T,
show.col.prc = T)
| K5.(03)請問你有多常在社群媒體(如:臉書)上看朋友所分享或轉貼的訊息? | agegroup | Total | |||
|---|---|---|---|---|---|
| 18至35歲 | 36至49歲 | 50至64歲 | 65歲以上 | ||
| 從來沒有 |
3 12 % 0.9 % 0.2 % |
5 20 % 1.1 % 0.4 % |
13 52 % 4 % 1.1 % |
4 16 % 3.6 % 0.3 % |
25 100 % 2 % 2 % |
| 很少 |
53 31.9 % 16.1 % 4.3 % |
58 34.9 % 12.2 % 4.7 % |
38 22.9 % 11.8 % 3.1 % |
17 10.2 % 15.5 % 1.4 % |
166 100 % 13.4 % 13.5 % |
| 有時 |
131 26.8 % 39.8 % 10.6 % |
187 38.2 % 39.4 % 15.1 % |
130 26.6 % 40.2 % 10.5 % |
41 8.4 % 37.3 % 3.3 % |
489 100 % 39.5 % 39.5 % |
| 經常 |
142 25.5 % 43.2 % 11.5 % |
225 40.4 % 47.4 % 18.2 % |
142 25.5 % 44 % 11.5 % |
48 8.6 % 43.6 % 3.9 % |
557 100 % 45 % 45.1 % |
| Total |
329 26.6 % 100 % 26.6 % |
475 38.4 % 100 % 38.4 % |
323 26.1 % 100 % 26.1 % |
110 8.9 % 100 % 8.9 % |
1237 100 % 100 % 100 % |
χ2=16.489 · df=9 · Cramer’s V=0.067 · Fisher’s p=0.074 |
sjt.xtab(tcs2019$k5.4,tcs2019$agegroup,encoding = "utf-8",show.cell.prc = T,
show.row.prc = T,
show.col.prc = T)
| K5.(04)請問你有多常在社群媒體(如:臉書)上看朋友的發文或照片? | agegroup | Total | |||
|---|---|---|---|---|---|
| 18至35歲 | 36至49歲 | 50至64歲 | 65歲以上 | ||
| 從來沒有 |
1 5.9 % 0.3 % 0.1 % |
4 23.5 % 0.8 % 0.3 % |
7 41.2 % 2.2 % 0.6 % |
5 29.4 % 4.5 % 0.4 % |
17 100 % 1.4 % 1.4 % |
| 很少 |
35 28.5 % 10.6 % 2.8 % |
48 39 % 10.1 % 3.9 % |
30 24.4 % 9.3 % 2.4 % |
10 8.1 % 9.1 % 0.8 % |
123 100 % 9.9 % 9.9 % |
| 有時 |
124 25.8 % 37.7 % 10 % |
180 37.4 % 37.9 % 14.6 % |
137 28.5 % 42.4 % 11.1 % |
40 8.3 % 36.4 % 3.2 % |
481 100 % 38.9 % 38.9 % |
| 經常 |
169 27.4 % 51.4 % 13.7 % |
243 39.4 % 51.2 % 19.6 % |
149 24.2 % 46.1 % 12 % |
55 8.9 % 50 % 4.4 % |
616 100 % 49.8 % 49.7 % |
| Total |
329 26.6 % 100 % 26.6 % |
475 38.4 % 100 % 38.4 % |
323 26.1 % 100 % 26.1 % |
110 8.9 % 100 % 8.9 % |
1237 100 % 100 % 100 % |
χ2=16.309 · df=9 · Cramer’s V=0.066 · Fisher’s p=0.103 |
## 製圖
# 1. 變數處理
# (1) 將要繪製的連續變數轉換成各類別變數的平均數
# 使用dplyr套件
library(dplyr)
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:sjlabelled':
##
## as_label
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
df1 <- tcs2019 %>%
group_by(agegroup) %>%
summarise(feel = mean(k5.1, na.rm=T))
df2 <- tcs2019 %>%
group_by(agegroup) %>%
summarise(feel = mean(k5.2, na.rm=T))
df3 <- tcs2019 %>%
group_by(agegroup) %>%
summarise(feel = mean(k5.3, na.rm=T))
df4 <- tcs2019 %>%
group_by(agegroup) %>%
summarise(feel = mean(k5.4, na.rm=T))
#View(df1)
# (2) 透過垂直合併,重建一個繪圖用的資料框
df <- rbind(df1,df2,df3,df4)
df$type <- c((rep(1, times=4)),(rep(2, times=4)),(rep(3, times=4)),(rep(4, times=4)))
df$type <- as.factor(df$type)
str(df)
## tibble [16 × 3] (S3: tbl_df/tbl/data.frame)
## $ agegroup: Factor w/ 4 levels "18至35歲","36至49歲",..: 1 2 3 4 1 2 3 4 1 2 ...
## $ feel : num [1:16] 2.47 2.55 2.35 2.25 2.47 ...
## $ type : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 2 2 2 2 3 3 ...
# 2. 安裝並載入 ggplot2
#install.packages("ggplot2")
# 載入 ggplot2
library(ggplot2)
# 解決Rstudio cloud圖形中文顯示問題
# install.packages("showtext")
library(showtext)
## Loading required package: sysfonts
## Loading required package: showtextdb
showtext_auto()
# 折線圖
ggplot(diamonds, aes(clarity, group = cut)) +
geom_line(aes(color = cut), position="identity", stat = "count")
g1 <- ggplot(df,
aes(x=type, y=feel,color=agegroup, group=agegroup))+
geom_line()+
geom_point()+
labs(title = "台灣民眾各年齡層社群平台使用功能比較",
x="使用功能",y="程度",
subtitle="使用功能年齡上有差異?",
caption="資料來源:台灣傳播調查資料庫",
colour = "年齡層")+
theme_classic()+
ylim(1, 5)+
theme(axis.title.y = element_text(vjust = 0.5, hjust = 0.5, angle = 0))+
scale_x_discrete("使用功能的差異",labels = c("1" = "分享或轉貼訊息","2" = "發文或發照片",
"3" = "看朋友所分享或轉貼的訊息","4" = "看朋友的發文或照片"))+
theme(legend.position="bottom")+
geom_text(aes(label=round(feel, digits = 2)),size = 2, color = "black")+
scale_colour_brewer(palette = "Set2")+
theme(plot.title = element_text(vjust = 2,hjust = 0.5))
g1