I am able to create datatables, pivots, maps etc. but, cannot for the life of me create a dataset usable in Plotly for R.
In this example I keep getting and error in the last element ending with 'object 'prem_council' not found
My code is:
#### DATA ##
lic1 <- tbl(con, "ca_licenses") %>%
select(type,license,lic_app,status,master,prem_city_ps,class_parent,prem_council,prem_neighborhood) %>%
filter(prem_city_ps == "LOS ANGELES", lic_app == "LIC", status == "ACTIVE", master == "Y") %>%
collect()
lic2 <- tbl_df(lic1)
lic3 <- as_tibble(cbind(nms = names(lic2), t(lic2)))
plot_ly(lic3, x = prem_council, y = type, type = "bar")
I removed my comments so I don't appear as a complete donk. My question is what exactly are the steps for taking a typical dataset of row/column data and preparing it to create Plotly charts? My steps are:
lic1 <- collecting/filtering/selecting the data from a postgres table (works great), lic2 <- creating a dataframe lic3 <- creating a tibble by transposing data and where first col is now the names (nms) column And lastly creating the chart.
I have used rm(list=ls()) to flush the memory as I've tried many different things.
Loaded libraries include RPostgreSQL, DBI, dbplyr, dplyr, plotly
Any insight would be appreciated! New to R and can't wait to get this down. Thanks.