Subsetting in R based on row name?
2
1
Entering edit mode
8.6 years ago

Hello,

So I am trying to take a subset of my data based on row names. When I used one row name it works no problem. When I use a list I get an error.

x <- subset(dataset, rownames(dataset) == names)
Warning message:
In rownames(dataset) == names :
  longer object length is not a multiple of shorter object length

Thanks.

R • 75k views
ADD COMMENT
13
Entering edit mode
8.6 years ago
vivekbhr ▴ 700

Hi. . Just replace your == with %in%

ADD COMMENT
6
Entering edit mode
8.6 years ago

help("%in%")

ADD COMMENT

Login before adding your answer.

Traffic: 2065 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6