Source: https://www.ers.usda.gov/data-products/adoption-of-genetically-engineered-crops-in-the-us/
library(datasets)
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
usgenefile <- paste0(getwd(),"/","alltablesGEcrops.csv")
usgene <- read.csv(usgenefile)
usgene$Value <- as.numeric(usgene$Value)
Adoption Rate of Genetically Engineered Crops in the U.S.
usgeneag <- aggregate(x = usgene$Value
,by=list(usgene$Year,usgene$State)
,FUN = mean
)
colnames(usgeneag) <- c("Year","State","Value")
df <- usgeneag[which(usgeneag$State == "U.S."),]
#df <- data.frame(Year = index(usgene), usgene$Value)
#colnames(df) <- c("Year","Value")
usplot <- df %>%
plot_ly(
x = ~Year,
y = ~Value,
type = 'scatter',
mode = 'markers'
) %>%
layout(
xaxis = list(
rangeslider = list(type = "date")
)
)
usplot