I am very new to R and have managed to scrape some data from a website for a project that is due. I now need to reformat the data into a dataframe but can't seem to figure out how to do this. Here is what I have:
library('rvest')
library('xml2')
url<- 'https://usedfirst.com/cars/ford/escape/'
webpage<- read_html(url)
resale_price_html<-html_nodes(webpage,'#DepreciationTableSmall')
resale_price<-html_text(resale_price_html)
resale_price<-gsub("\n\t","", resale_price)
resale_price<-gsub("\t","", resale_price)
head(resale_price)
[1] "YearPrice% Paid% LeftNUV ®2019$27,075100%100%02018$19,27272.9%91.67%18.772017$18,29567.17%83.33%16.162016$16,90961.02%75%13.982015$14,65752.82%66.67%13.852014$13,17647.41%58.33%10.922013$11,33138.61%50%11.392012$9,24929.26%41.67%12.412011$8,33225.59%33.33%7.742010$7,47022.01%25%2.992009$6,73819.48%16.67%-2.812008$6,05217.76%8.33%-9.432007$5,17012.87%0%-12.87"
The data should look like a table with 5 columns:
Year Price %Paid %Left NUV
2019 $27,075 100% 100%
2018 $19,272 72.9% 91.67% 18.77
and so on...
Can anyone please help me out with this??