INPUT
df <- data.frame(value = c(1,2,4,1), name = c("bob","john","bob","james"))
df
# value name
# 1 1 bob
# 2 2 john
# 3 4 bob
# 4 1 james
I.分享Tweet计数频率
df
# value name
# 1 1 bob
# 2 2 john
# 3 4 bob
# 4 1 james
vec <- table(df$value)
vec
# 1 2 4
# 2 1 1
xx <- barplot(table(df$value), xlab = "Tweet Count", ylab = "Frequency of Tweet Counts", main = "Frequency of Tweets posted \nBased on Tweet Count", cex.main = 1, ylim = c(0,10))
text(x = xx, y = vec, label = vec, pos = 3, cex = 1, col = "blue")
二,鸣叫每人计数
df
# value name
# 1 1 bob
# 2 2 john
# 3 4 bob
# 4 1 james
vec <- tapply(df$value, df$name, sum)
vec
# bob james john
# 5 1 2
xx <- barplot(vec, ylim = c(0,10), main = "Count of tweets per person")
text(x = xx, y = vec, label = vec, pos = 3, cex = 1, col = "blue")
也许我的措辞我的问题很差。我希望x轴有1到n个推文的数量。因此,由于2人分别发布了1条推文,因此1的x轴值的频率为2. – Liam
了解。将udpate –
更新它。请检查。两种都在那里。 –