对R来说很新!
我对从0到10回答的人进行了一项调查。我想补充一下有多少人< = 6.多少7和8.多少> = 9.
我不得不将问题(Return,Trustworthy ......)变成一个因子来制作x轴上1到10的ggpl。
uk_super_q<-read.csv("SUPR_Q_UK.csv", header = TRUE)
uk_super_q.Return <- as.factor(uk_super_q$Return)
uk_super_q.Trustworthy <- as.factor(uk_super_q$Trustworthy)
uk_super_q.Credible <- as.factor(uk_super_q$Credible)
uk_super_q.Trustworthy <- as.factor(uk_super_q$Trustworthy)
uk_super_q.Clean.and.Simple <- as.factor(uk_super_q$Clean.and.Simple)
uk_super_q.Easy.to.use <- as.factor(uk_super_q$Easy.to.use)
uk_super_q.Attractive <- as.factor(uk_super_q$Attractive)
uk_super_q.NPS <- as.factor(uk_super_q$NPS)
uk_super_q$Return <- as.factor(uk_super_q$Return)
ggplot(uk_super_q, aes(x = Return)) +
geom_bar() +
xlab("Return") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Return)
uk_super_q$Easy.Nav <- as.factor(uk_super_q$Easy.Nav)
ggplot(uk_super_q, aes(x = Easy.Nav)) +
geom_bar() +
xlab("Easy.Nav") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Trustworthy)
uk_super_q$Credible <- as.factor(uk_super_q$Credible)
ggplot(uk_super_q, aes(x = Credible)) +
geom_bar() +
xlab("Credible") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Credible)
uk_super_q$Attractive <- as.factor(uk_super_q$Attractive)
ggplot(uk_super_q, aes(x = Attractive)) +
geom_bar() +
xlab("Attractive") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Attractive)
uk_super_q$Trustworthy <- as.factor(uk_super_q$Trustworthy)
ggplot(uk_super_q, aes(x = Trustworthy)) +
geom_bar() +
xlab("Trustworthy") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Trustworthy)
uk_super_q$Clean.and.Simple <- as.factor(uk_super_q$Clean.and.Simple)
ggplot(uk_super_q, aes(x = Clean.and.Simple)) +
geom_bar() +
xlab("Clean.and.Simple") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Clean.and.Simple)
uk_super_q$Easy.to.use <- as.factor(uk_super_q$Easy.to.use)
ggplot(uk_super_q, aes(x = Easy.to.use)) +
geom_bar() +
xlab("Easy.to.use") +
ylab("Total Count") +
labs(fill = "Blah")
table(uk_super_q.Easy.to.use)
uk_super_q$NPS <- as.factor(uk_super_q$NPS)
ggplot(uk_super_q, aes(x = NPS)) +
geom_bar() +
xlab("NPS") +
ylab("Total Count")
table(uk_super_q.NPS)
答案 0 :(得分:0)
将逻辑语句应用于data.frame
将返回TRUE / FALSE值的矩阵,这些值在R中分别编码为1和0。这样,您就可以使用TRUE
或sum
更有效地计算每列中colSums
值的数量。
colSums(uk_super_q <= 6)
colSums(uk_super_q >= 7 & uk_super_q <= 8)
colSums(uk_super_q >= 9)