unique for more than one variable

0 votes
In R, I've got the following data frame:

> 'data.frame' str(df): 545227 observations of 15 variables:
$ ykod: int 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93 93
$ yad : Factor with 42 levels "BAKUGAN","BARBIE",...: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
$ donem: int 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 2011
sayi: int 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101 201101
$ mkod: int 4 5 9 11 12 18 20 22 25 26...$ mkod: int 4 5 9 11 12 18 20 22 25 26...$ mkod: int
405 8075 9710 10145 9297 7973 $ mad: Factor with 10464 levels " Defne Market ",..: 405 8075 9710 10145 9297 7973
Jun 19, 2022 in Data Science by Avinash
• 1,260 points
326 views

1 answer to this question.

0 votes
df <- data.frame(yad = c("BARBIE", "BARBIE", "BAKUGAN", "BAKUGAN"),
                 per = c("AYLIK",  "AYLIK",  "2 AYLIK", "2 AYLIK"),
                 hmm = 1:4)

df
#       yad     per hmm
# 1  BARBIE   AYLIK   1
# 2  BARBIE   AYLIK   2
# 3 BAKUGAN 2 AYLIK   3
# 4 BAKUGAN 2 AYLIK   4

unique(df[c("yad", "per")])
#       yad     per
# 1  BARBIE   AYLIK
# 3 BAKUGAN 2 AYLIK

Unleash the power of data with our comprehensive Data Science Training.

answered Jun 24, 2022 by Sohail
• 3,040 points

Related Questions In Data Science

0 votes
1 answer

What does |> (pipe greater than) mean in R?

The "pipe" operator in R is |>. ...READ MORE

answered Jun 14, 2022 in Data Science by Sohail
• 3,040 points
1,761 views
0 votes
1 answer

Unexpected behavior for setdiff() function in R

Asymmetric difference is provided by 18 setdiff. ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
955 views
0 votes
0 answers

Calculate correlation with cor(), only for numerical columns

I have a dataframe and would like ...READ MORE

Jun 24, 2022 in Data Science by Sohail
• 3,040 points
443 views
0 votes
1 answer

R command for setting working directory to source file location in Rstudio

Yes, you can specify your working directory ...READ MORE

answered Sep 8, 2023 in Data Science by anonymous
• 1,380 points
685 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,570 points
1,030 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
1,180 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,890 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
1,113 views
0 votes
1 answer

How to make loop for one-at-a time logistic regression in R?

You're probably looking for something similar to ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
1,037 views
0 votes
1 answer

Reasons for using the set.seed function

The requirement is a desire for repeatable ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
403 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP