knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This package is created for price analysis of shopping sites.The motivation behind it is the problems that shoppers face when looking at two different sites and wanting to easily compare the prices. In this package will be ways to compare prices in a data frame while also searching the table. Other functions includes web scrapping for price bar plots, currency changes, and parsing numbers. This can be used for big shopping events like black Friday or even better cyber Monday. In the future I would like to update the currency function to take in more currencies and update the functionality of the bar plots.
library(shopscrape)
Run the command
Install.packages("shopscrape")
shopScrape()
scrapes data and puts it in interactive table.
Allows you to search the table and find relatable items and compare prices. The user places two urls as arguments and the nodes which obtain the information.shopScrape("https://www.thereformation.com/categories/new?gclid=CjwKCAiAm7OMBhAQEiwArvGi3EYt2jozZbzQktEYy2iInclcxHpJKKnWfqu3Jo2mHfABJ-R90ghQVhoCmwAQAvD_BwE" , ".product-prices__price span , .product-summary__name a","https://www.zara.com/us/en/woman-must-haves-l4503.html?v1=1609213", ".price__amount-current , #main .link span")
basicPrice()
This function scrapes url and the price node and put it in basic histogram for visual effects.basicPrice("https://www.thereformation.com/categories/new?gclid=CjwKCAiAm7OMBhAQEiwArvGi3EYt2jozZbzQktEYy2iInclcxHpJKKnWfqu3Jo2mHfABJ-R90ghQVhoCmwAQAvD_BwE" , ".product-prices__price span , .product-summary__name a")
priceAna()
This function, similar to basicPrice function, scrapes price node and url and turn category means into histogram. Taking the last word in product description as the categories.priceAna("https://www.thereformation.com/categories/new?gclid=CjwKCAiAm7OMBhAQEiwArvGi3EYt2jozZbzQktEYy2iInclcxHpJKKnWfqu3Jo2mHfABJ-R90ghQVhoCmwAQAvD_BwE" , ".product-prices__price span , .product-summary__name a")
priceNum()
Scrapes prices and turns them into numerical values. The arguments include a list the node of prices that you want to parse. It filters the content of anything that is not of numerical value.library(rvest) resultsZara <- read_html("https://www.zara.com/us/en/woman-must-haves-l4503.html?v1=1609213") vals <- priceNum(resultsZara,".price__amount-current")
currencyFunc()
This simple function changes currency values from USD, Peso, and Euro. The argument is the type currency and what the numerical values arecurrencyFunc(usd= 2.78) currencyFunc(euro=3)
samelNa()
Changes the number of the rows and add NA's to get two lists of same length. Can be used to make lengths of list the same to better fit into a dataframe.x<- c(1:10) y<- c(1:9) samelNA(x,y)
This package can be used in the future to do a price analysis of similar type of eCommerce stores. For example, one can do a study of the two similar eCommerce stores that sells groceries and clothes like Walmart and Target. To do so you would create a table of their products with my shopScrape function to get a general view. Then you can use the priceAna function to generate a histogram of the products based on their category.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.