Hi I have a dataset in which I have countries and investigator email 2 columns that I want to use and rest other data. WHen trying to create a bar chart using R and Shiny, I am getting below error:
Aesthetics must be either length 1 or the same as the data (806): x, y
In bar chart, I want to show the count of investigators for each country with countries on x axis and no of investigators on Y.
ui.R
shinyUI(fluidPage(
#title of the page
titlePanel("No of Investigator by Country and Sponsor"),
sidebarLayout(
sidebarPanel(),
#placeholder for bar pannel
mainPanel(
fluidRow(
column(width = 6,plotlyOutput("investogatorByCountry")) ,
column(width = 6,plotlyOutput("investogatorBySponsor"))
)
)
)
))
server.R
shinyServer(function(input,output){
#code for investigator by country
output$investogatorByCountry <- renderPlotly({
#reading the data file
whoData <- read.csv(file="ICTRP-Results.csv", header=TRUE, sep = ",")
#counting no of investigators in country
investigatorCount <- count(whoData, vars = c("Contact_Email"))
Countries <- whoData$Countries
#print(investigatorCount)
p <- ggplot(data = investigatorCount, aes(x=Countries, y=Contact_Email)) + geom_bar(stat = "identity")
})
})