Question: Subsetting in R based on row name?
0
gravatar for hakimelakhrass
3.5 years ago by
hakimelakhrass70 wrote:

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 • 23k views
ADD COMMENTlink modified 3.5 years ago by Devon Ryan92k • written 3.5 years ago by hakimelakhrass70
7
gravatar for vivekbhr
3.5 years ago by
vivekbhr530
Germany
vivekbhr530 wrote:

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

ADD COMMENTlink written 3.5 years ago by vivekbhr530
6
gravatar for Devon Ryan
3.5 years ago by
Devon Ryan92k
Freiburg, Germany
Devon Ryan92k wrote:

help("%in%")

ADD COMMENTlink written 3.5 years ago by Devon Ryan92k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1337 users visited in the last hour