【发布时间】:2016-10-17 01:34:49
【问题描述】:
这里是新手,所以你可能会判断,但这是我的问题。
我有一个非常简单的结构化 CSV 文件,它有 2 列:标签(ASCII 文本值)作为第 1 列,它们各自的计数(数字)作为第 2 列。
例如,CSV 的格式为:
type,count
cat,23000
dog,444566,
wolf,3442
tiger,306
...
我想在 R 中绘制一个简单的折线图,其中 'counts' 作为 y 轴,标签在 x 轴。我希望能够真正看到标记在 x 轴或数据点上的“标签”,例如“狗”“猫”。我如何在 R 中做到这一点?
这是我目前所拥有的:
> heresmydata <- read.csv("data.csv")
> matplot(heresmydata[, 1], heresmydata[, -1], type="l")
Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log = log) :
NAs introduced by coercion
2: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
>
它会生成一个带有不正确标签的空图。
【问题讨论】: