Question: Subsetting in R based on row name?
1
gravatar for hakimelakhrass
4.3 years ago by
hakimelakhrass80 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 • 35k views
ADD COMMENTlink modified 4.3 years ago by Devon Ryan95k • written 4.3 years ago by hakimelakhrass80
8
gravatar for vivekbhr
4.3 years ago by
vivekbhr560
Germany
vivekbhr560 wrote:

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

ADD COMMENTlink written 4.3 years ago by vivekbhr560
6
gravatar for Devon Ryan
4.3 years ago by
Devon Ryan95k
Freiburg, Germany
Devon Ryan95k wrote:

help("%in%")

ADD COMMENTlink written 4.3 years ago by Devon Ryan95k
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: 771 users visited in the last hour