Accessing the Contents of an R Language Object

Asked 2 years ago, Updated 2 years ago, 38 views

Please tell me how to access the contents of the object.
Specifically...

sex<-c("F", "M", "M", "M", "F")
number<-c (1, 2, 3, 4, 5)
x<-data.frame (SEX=sex, NUMBER=number)

y<-c (1, 2, 4)

At times like this...

c<-subset(x,NUMBER!=y)

I want to do it like above, but it doesn't work
In other words, I would like to leave only 3,5 of NUMBER in the end.

It's hard to understand how to ask questions, but I appreciate your cooperation.

r

2022-09-30 21:43

1 Answers

>x [!(x$NUMBER%in%y),]

  SEX NUMBER
3M3
5F5

That's right. The %in% operator matches multiple conditions.


2022-09-30 21:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.