简体   繁体   English

R中的字符统计分析

[英]Statistical Analysis with chars in R

I'm wondering how to make an analysis with chars in R, specifically with a barplot or ggPlot.我想知道如何使用 R 中的字符进行分析,特别是使用 barplot 或 ggPlot。 If I have a read excel file that contains a list like below, how could I make a barplot with it since the data is not in chars to count the number of occurrences the name appears in a bar plot?如果我有一个包含如下列表的读取 excel 文件,我怎么能用它制作一个条形图,因为数据不在字符中来计算名称在条形图中出现的次数?

Most Popular Names
John
Tim
John
Tim
Cole
Cody

You can retrieve the frequency of each name in column 'Most Popular Names' with the table() function.您可以使用table()函数检索“最受欢迎名称”列中每个名称的频率。 This data can be used to build up a barplot.此数据可用于构建条形图。

data <- data.frame(`Most Popular Names` = c("John", "Tim", "John", "Tim", "Cole","Cody"))
barplot(table(data))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM