0

Hi I am trying to create a pie chart in R using genderizer package. I am referring below code from site https://www.r-bloggers.com/the-gender-of-big-data/:

 library(rvest)
 library(stringr)
 library(dplyr)
 library(genderizeR)
 library(ggplot2)
 library(googleVis)
 paste0("http://www.crn.com/slide-shows/data-center/300076704/2015-big-data-
 100-business-analytics.htm/pgno/0/", 1:45) %>%
 c(., paste0("http://www.crn.com/slide-shows/data-center/300076709/2015-big-
data-100-data-management.htm/pgno/0/",1:30)) %>%
c(., paste0("http://www.crn.com/slide-shows/data-center/300076740/2015-big-
data-100-infrastructure-tools-and-services.htm/pgno/0/",1:25)) -> webpages
results=data.frame()
for(x in webpages)
{
 read_html(x) %>% html_nodes("p:nth-child(1)") %>% .[[2]] %>% html_text() -> 
 Company
 read_html(x) %>% html_nodes("p:nth-child(2)") %>% .[[1]] %>% html_text() -> 
 Executive
 results=rbind(results, data.frame(Company, Executive))
 }
 results=data.frame(lapply(results, as.character), stringsAsFactors=FALSE)
 results[74,]=c("Trifacta", "Top Executive: CEO Adam Wilson")
 results %>% 
 mutate(Name=gsub("Top|\bExec\S*|\bCEO\S*|President|Founder|and|Co-
 Founder|\:", "", Executive)) %>%
 mutate(Name=word(str_trim(Name))) -> results
 results %>%
 select(Name) %>%
 findGivenNames() %>%
 filter(probability > 0.9 & count > 15) %>%
 as.data.frame() -> data
 data %>% group_by(gender) %>% summarize(Total=n()) -> dat
 doughnut=gvisPieChart(dat,
 options=list(
 width=450,
 height=450,
 legend="{ position: 'bottom', textStyle: {fontSize: 10}}",
 chartArea="{left:25,top:50}",
 title='TOP 100 BIG DATA COMPANIES 2015
 Gender of CEOs',
 colors="['red','blue']",
 pieHole=0.5),
 chartid="doughnut")
 plot(doughnut)

It throws an error saying that mutate function is not found, i have installed all the packages properly. Can someone please guide me here.

Or Can someone pls share sample code to create a pie chart using R and Sparklyr. This is my first assignment and I m just trying to understand the concept. TIA

RJ_Programmer
  • 31
  • 1
  • 6
  • Could you paste the exact error message you're getting? Could you try calling `mutate` with the package? Like this: `dplyr::mutate(...` Maybe it's overwritten by another `mutate` function of other package you load after `dplyr` – Jaime Caffarel Aug 10 '17 at 10:06

1 Answers1

1

if instead of a pie chart you go with a bar chart, try this package: https://github.com/edgararuiz/dbplot

edgararuiz
  • 625
  • 5
  • 9