-2

if the 'minimum_nights' column matches

enter image description here

then return certain values from the 'host_column' column.

I filtered the minimum_nights column with values '> 90'. Now, is it possible to get values from host_location? just some certain values (if only outside the 'UK' region?

attached data

airbnb1 <- airbnb1 %>%
select(host_location, minimum_nights, revenue) %>%
filter(minimum_nights > 90) %>%  
mutate(host_location = ifelse(host_location== "", 'unknown', 
host_location)) %>%
reframe(host_location, minimum_nights, revenue)
  • Hi @JayPrakash, please dont post your data as an image for [these reasons](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557). Also, please dont add links to your data (they may go dead over time, etc), but instead add the data in as code. If you need help converting your dataset to reproducible code, [you can find help here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Good luck! – jpsmith Jun 20 '23 at 20:42
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 21 '23 at 12:24

1 Answers1

0

I solved my issue on my own and some help from StackOverflow. It took me almost half of my day.

no problem if someone downvotes me, I'm keeping this post alive for someone who needed the fix as I did.

here :

airbnb_outside <- airbnb

airbnb_outside <- airbnb_outside %>%  
filter(minimum_nights > 90) %>% 
mutate(host_location = ifelse(host_location== "", 'unknown', host_location))

filter > mutated the 'host_column'

airbnb_outside<- airbnb_outside %>% 
mutate(really = if_else(str_ends(host_location, "Kingdom"), "in", "out"))

 

filter > mutated another 'column'

airbnb_outside <- airbnb_outside %>% 
select(host_location, minimum_nights, revenue, really) %>%
filter(really == 'out') %>% 
reframe(host_location, minimum_nights, revenue, really)

we have a new funny column 'really' with a new data frame 'airbnb_outside' and an original data frame 'airbnb'.

airbnb <- airbnb(airbnb, airbnb_outside, by = "host_location")

anti-join on original dataframe