I want to use some of my R functions in the website i'm creating.
Some of my R functions will scrape data from others website, clean some data and then show the remaining data as table in my website. Others R functions will plot differents graph using the previous data.
So I'm looking to a way to embed my R script in the html website or to convert my R Scripts to JavaScript so that it can be easyly added to my html website.
Is there a R package or function than can help me converting any R function to Javascript function? Any advice about tackling an issue like this is greatly appreciated.
A minimal r function code example :
library(rvest)
library(tidyverse)
BRVM_cap <- function(){
# company<-toupper(company)
tryCatch({
brvm_cap <- rvest::read_html("https://www.brvm.org/en/capitalisations/0/status/200") %>%
rvest::html_nodes('table') %>%
rvest::html_table()
brvm_cap <- brvm_cap[[4]]
brvm_cap$`Global capitalization (%)`<-gsub(",", ".",brvm_cap$`Global capitalization (%)`)
brvm_cap <- tibble::as.tibble(brvm_cap)
return(brvm_cap)
},
error = function(e) {
print("Make sure you have an active internet connection")
},
warning = function(w) {
print("Make sure you have an active internet connection")
})
}
How can i convert BRVM_cap (R function) to a similar javascript function?
Or how can i embed BRVM_cap script function to the web (the embeded code must be hide to users)?
Thanks