mercredi 18 novembre 2020

How can I convert values from meters to km in a list (from html_nodes) with r?

I have the following list from

distance_to_center <- html_nodes(HouseRentingPage, xpath = '//*[@class="distance"]')
distance_to_center <- html_text(distance_to_center)

(ps: it is a partial list - the original has more than 3 thousand observations)

 distance_to_center

[1]"822 m" "500 m" "12.8 km" "435 m" NA "1 km" "985 m" "3.5 km" "4.9 km" "623 m"

How can I convert the values that are in meters to km? I tried to use if-statement but it is not working.

Aucun commentaire:

Enregistrer un commentaire