Duck
1
Hello everyone,
When i try to use the filter function on my data_set like this:
songs %>%
filter(name == "RAP DEVIL", artists == "Machine Gun Kelly")
The output is just like this:
# A tibble: 0 × 18
# … with 18 variables: acousticness <dbl>, artists <chr>, danceability <dbl>, duration_ms <dbl>, energy <dbl>, explicit <dbl>,
# instrumentalness <dbl>, key <dbl>, liveness <dbl>, loudness <dbl>, mode <dbl>, name <chr>, popularity <dbl>,
# speechiness <dbl>, tempo <dbl>, valence <dbl>, year <dbl>, cluster <int>
# ℹ Use `colnames()` to see all variable names
can anybody help me what i did wrong. Thanks
Are you able to share the songs dataset? It's hard to troubleshoot without it.
1 Like
Duck
3
Sure! Here is the data set
fcas80
4
I see the first artist is ['Carl Woitschach']
Try
filter(name == "RapDevil", artists == "['Machine Gun Kelly']")
1 Like
Duck
5
Thank you so much! I really thought that I should not include the ['..'] hahaha my mistake.
It looks like this would work.
filter(name == 'RAP DEVIL', str_detect(artists, 'Machine Gun Kelly'))
1 Like
Duck
7
It also worked thanks so much!
system
Closed
8
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.