开发者

R List row name

I have a (one column) list called Test in R.

When I view it in R I get something like this:

> Test
                    Value
569                 N
1012                Y
4279                N
7588                N
3434  开发者_开发技巧              N
2408                Y
1958                Y
1251                Y

How do I reference the "row name"? I.e. 569, 1012, 4279 etc.

I want to find for example the Value at "row" 1012 (which is "Y" here). I've tried using Test[1], Test[,1] etc. but the first column isn't really a column. I don't know what it is. Hopefully this makes some kind of sense. I don't even know what to look for to find the solution to this.


If Test is a data frame;

txt <- "                    Value
569                 N
1012                Y
4279                N
7588                N
3434                N
2408                Y
1958                Y
1251                Y
"
Test <- read.table(textConnection(txt), header = TRUE)

then,

> Test["1012", ]
[1] Y
Levels: N Y

will extract the required row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜