如何用表格从R绘制小节? [英] How to make a barplot with R from a table?

查看:77
本文介绍了如何用表格从R绘制小节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.cvs中有一些数据.我想用这个数据在R中创建一个简单的barplot,但是我在R中有点迷失了.

I have some data in .cvs. I would like to make a simple barplot in R, with this data, but I a little lost in R.

Specie   Number
A        18756
V        8608 
R        3350 
P        3312 
O        1627

我已经有了每个硬币的编号.我只想绘制结果? A,V,R,P,O是物种的名称.

I already have the number of each specie. I just want to plot the results? A, V, R, P, O are the names of the species.

我对首先要做的事情有些困惑?我必须将表格转换为矩阵吗?我必须在R中使用哪些命令?

I am a little confused of what I have to do first? Do I have to convert the table to a matrix? What commands do I have to use in R?

推荐答案

下面是一个简单的示例:

Here's a simple example:

y = data.frame(Specie=c('A','V','R','P','O'),Number=c(18756,8608,3350,3312,1627))
barplot(y$Number, names.arg=y$Specie)

您将使用read.csv(或其一个朋友)将文件从文件读入数据框.

You would use read.csv (or one of its friends) to read from a file into a Data Frame.

这篇关于如何用表格从R绘制小节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆