如果我使用以下代码创建频率表:
mytable <- table(data$column_data)
我如何只绘制此表的前10个条目?我当前的条形码代码如下,当然会绘制整个表格:
barplot(mytable, main = "Title", xlab = "column_data", ylab = "Frequency",col='coral')
答案 0 :(得分:1)
使用[
或head
barplot(mytable[1:10], main = "Title", xlab = "column_data", ylab = "Frequency",col='coral')
或者如@dww所述,它也可以sort
编辑
barplot(sort(mytable)[1:10], main = "Title", xlab = "column_data",
ylab = "Frequency",col='coral')