Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to put web scraped numbers into a data frame that adds to the data frame when auto refreshed

$
0
0

I want to create a data frame that updates each time my script is run. I want one column to have the number and the other to have the date that it was recorded. Here is what I have so far.

# Packages
library(miniUI)
library(shiny)
library(shinyFiles)
library(taskscheduleR)
library(rvest)
library(dplyr)
library(magrittr)

# Read in data
team_trees <- read_html("https://teamtrees.org/")

# Number of Trees
count <- team_trees %>% 
  html_nodes("#totalTrees") %>%
  html_attr("data-count")

total_trees <- count %>%
  as.numeric()
# Columns for data frame
day <- Sys.Date()

data <- data.frame(total_trees, day)
data

How can I have this data frame update each time I run the script instead of replace the data frame?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>