title: $ operator is invalid for atomic vectors :: R shiny
body: <p>I have a customer survey of 25 questions. Question's answer are available in "1", "2", "3", "4" (1-Very Good, 2-Good, 3-Normal, 4-Bad)
  Each rows contains the respondent name with all the answers given by him.</p>
  
  <p>Data is in this format, respondent ID and the response value, Column header contains the Question name.</p>
  
  <p>21044194-   1-  2-  4-  1-  3-  1-  1-  2-  1-  2-  1-  3-  2-  2-  1-  2-  4-  2 <BR>
  21044198-   1-  2-  4-  4-  3-  1-  1-  2-  1-  2-  1-  3-  2-  4-  1-  3-  4-  2 <BR>
  21044199-   1-  2-  3-  1-  2-  3-  2-  1-  1-  2-  1-  3-  2-  4-  1-  3-  4-  2</p>
  
  <p>Now I want to create a shiny app, in which I have a list of all 25 questions as an input and on the basis of selected question I need to display the pie chart of answers. Like this for 1 question 31% ppl choose Very Good, 22% choose Good, 31% choose Normal and 17% choose Bad.</p>
  
  <p>I have written the following code -></p>
  
  <p><strong>Ui.R</strong></p>
  
  <pre><code>library(shiny)
  maxraw &lt;- read.csv("C:/Users/Suchita/Desktop/maxraw.csv")
  coln &lt;- colnames(maxraw)
  
  # Define UI for dataset viewer application
      shinyUI(pageWithSidebar(
      headerPanel('Iris k-means clustering'),
      sidebarPanel(
      selectInput('xcol', 'X Variable', choices = c(coln[26], coln[27], coln[28], coln[29])),
      #selectInput('ycol', 'Y Variable', names(iris),
                  #selected=names(iris)[[2]]),
      numericInput('clusters', 'Cluster count', 3,
                   min = 1, max = 9)
      ),
       mainPanel(
       plotOutput('plot1')
      )
     ))
  </code></pre>
  
  <p><strong>Server.R</strong></p>
  
  <pre><code> library(shiny)
   library(datasets)
   maxraw &lt;- read.csv("C:/Users/Suchita/Desktop/maxraw.csv")
  
   # Define server logic required to summarize and view the selected
   # dataset
   shinyServer(function(input, output, session) {
  
    # Combine the selected variables into a new data frame
    selectedData &lt;- reactive({
    ss &lt;- switch(input$xcol,
         "Question1." = 26,
         "Question2" =      27,
           "Question3" = 28)
    a = table(maxraw[,ss])
    a = as.data.frame(a)
  
    a$pct &lt;- round(a$Freq/sum(a$Freq)*100) #calculated percentage
    a$pcts &lt;- paste(a$pct, "%") # add percents to labels 
     })
  
    output$plot1 &lt;- renderPlot({
    pie(a$pct,labels = a$pcts, main = "Hospital Survey")
   })
  
   })
  </code></pre>
  
  <p>Here is the str(maxraw)</p>
  
  <blockquote>
    <p>str(maxraw)
        'data.frame':   43 obs. of  48 variables:
         $ Response.ID                                                                                                                                                                                         : int  21044194 21044264 21044287 21044402 21044435 21044481 21044529 21059249 21059266 21059297 ... <BR>
         $ IP.Address                                                                                                                                                                                          : Factor w/ 6 levels "","122.177.157.116",..: 5 5 5 5 5 5 5 5 5 5 ...<BR>
         $ Timestamp..MM.DD.YYYY.                                                                                                                                                                              : Factor w/ 44 levels "","02/12/2014 04:30:20",..: 2 3 4 5 6 7 8 9 10 11 ...<BR>
         $ Duplicate                                                                                                                                                                                           : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...<BR>
         $ Time.Taken.to.Complete..Seconds.                                                                                                                                                                    : int  146 125 181 94 111 112 575 149 115 0 ...<BR>
         $ Response.Status                                                                                                                                                                                     : Factor w/ 3 levels "","Complete",..: 2 2 2 2 2 2 2 2 2 3 ...<BR>
         $ Seq..Number                                                                                                                                                                                         : int  1 1 1 1 1 1 1 1 1 1 ...<BR>
         $ External.Reference                                                                                                                                                                                  : logi  NA NA NA NA NA NA ...<BR>
         $ Custom.Variable.1                                                                                                                                                                                   : logi  NA NA NA NA NA NA ...<BR>
         $ Custom.Variable.2                                                                                                                                                                                   : logi  NA NA NA NA NA NA ...<BR>
         $ Custom.Variable.3                                                                                                                                                                                   : logi  NA NA NA NA NA NA ...<BR>
         $ Custom.Variable.4                                                                                                                                                                                   : logi  NA NA NA NA NA NA ...<BR>
         $ Custom.Variable.5                                                                                                                                                                                   : logi  NA NA NA NA NA NA ...<BR>
         $ Respondent.Email                                                                                                                                                                                    : logi  NA NA NA NA NA NA ...<BR>
         $ Email.Group.Code                                                                                                                                                                                    : logi  NA NA NA NA NA NA ...<BR>
         $ Country.Code                                                                                                                                                                                        : Factor w/ 2 levels "","IN": 2 2 2 2 2 2 2 2 2 2 ...<BR>
         $ Region                                                                                                                                                                                              : int  10 10 10 10 10 10 10 10 10 10 ...<BR>
         $ Please.take.a.minute.to.give.us.your.feedback...it.helps.us.improve.Thank.you.very.much.for.your.time.and.support..Please.start.with.the.survey.now.by.clicking.on.the..B.Continue..B..button.below. : logi  NA NA NA NA NA NA ...<BR>
         $ Date.Of.Visit                                                                                                                                                                                       : Factor w/ 28 levels "","01/01/2014",..: 22 6 24 1 19 2 21 7 5 1 ...<BR>
         $ First.Name                                                                                                                                                                                          : Factor w/ 39 levels "","Abhi","Afsar",..: 16 21 39 15 14 29 26 38 17 1 ...<BR>
         $ Last.Name                                                                                                                                                                                           : Factor w/ 40 levels "","Abhinav","Ali",..: 24 37 35 19 33 13 29 25 9 1 ...<BR>
         $ Phone                                                                                                                                                                                               : num  4.1e+07 4.1e+07 4.1e+07 4.1e+07 4.1e+07 ...<BR>
         $ Email.Address                                                                                                                                                                                       : Factor w/ 40 levels "","aali@gmail.com",..: 17 24 39 16 15 29 28 38 18 1 ...<BR>
         $ Name.of.the.doctor.                                                                                                                                                                                 : Factor w/ 29 levels "","Dr Jholu",..: 29 17 14 28 28 26 12 5 18 1 ...<BR>
         $ Max.ID.                                                                                                                                                                                             : num  45367298 65438900 67534373 67543923 78654389 ...<BR>
         $ Satisfaction.With.Doctor.Was.the.Doctor.available.on.time.                                                                                                                                          : int  4 3 2 3 NA 3 4 2 1 NA ...<BR>
         $ Satisfaction.With.Doctor.Did.the.Doctor.treat.you.with.courtesy.and.respect.                                                                                                                        : int  4 2 3 4 2 3 4 3 1 NA ...<BR>
         $ Satisfaction.With.Doctor.Did.the.Doctor.explain.your.diagnosis.and.treatment.plan.in.a.way.you.could.understand.                                                                                    : int  4 3 2 3 3 3 4 3 1 NA ...<BR>
         $ Satisfaction.with.Nurses.Did.the.Nurses.treat.you.with.courtesy.and.respect.                                                                                                                        : int  4 3 2 4 3 4 4 3 1 NA ...<BR>
         $ Appointment.Was.your.appointment.call.handled.efficiently.and.queries.resolved.to.your.satisfaction.                                                                                                : int  4 2 3 3 4 3 4 3 1 NA ...<BR>
         $ Reception.Helpdesk.Was.the.Help.Desk.staff.at.the.hospital.helpful.and.courteous.                                                                                                                   : int  4 3 4 3 4 3 4 2 1 NA ...<BR>
         $ Hospital.Infrastructure.Environment.Was.the.out.patient.department.location.convenient.to.identify.                                                                                                 : int  4 2 2 3 4 2 4 3 1 NA ...<BR>
         $ Hospital.Infrastructure.Environment.Did.the.areas.you.visited.in.the.hospital.look.clean.and.orderly.                                                                                               : int  4 3 3 4 3 1 4 2 1 NA ...<BR>
         $ Hospital.Infrastructure.Environment.Were.the.public.area.washrooms.clean.and.hygienic.                                                                                                              : int  4 3 2 3 4 2 4 2 1 NA ...<BR>
         $ Front.Office.and.Billing.Did.the.front.office.staff.explain.and.resolve.your.query.regarding.registration.consult.diagnostics.charges.efficiently.                                                  : int  4 3 2 3 2 3 4 2 1 NA ...<BR>
         $ Front.Office.and.Billing.Was.your.billing.handled.in.a.timely.and.accurate.manner.                                                                                                                  : int  4 2 3 2 1 2 4 NA 1 NA ...<BR>
         $ Diagnostics.Services.Were.the.diagnostic.tests.conducted.in.a.timely.manner.                                                                                                                        : int  4 3 2 1 1 3 4 2 1 NA ...<BR>
         $ Diagnostics.Services.Were.the.diagnostic.tests.conducted.efficiently.and.sensitively.                                                                                                               : int  4 3 3 1 2 3 4 2 1 NA ...<BR>
         $ Diagnostics.Services.Were.you.clearly.informed.about.report.delivery.time.and.mode.of.collection.                                                                                                   : int  4 3 3 1 2 NA 4 2 1 NA ...<BR>
         $ Max.Chemist.Were.all.the.prescribed.medicines.or.substitutes.available.at.the.chemist.                                                                                                              : int  4 3 NA 2 1 4 4 2 1 NA ...<BR>
         $ Max.Chemist.Did.you.find.the.services.at.the.pharmacy.efficient.and.timely.                                                                                                                         : int  4 4 NA 3 1 2 4 2 1 NA ...<BR>
         $ Security...Parking.Did.you.find.our.car.parking.Valet.service.polite.and.efficient.                                                                                                                 : int  4 3 3 3 3 3 4 2 1 NA ...<BR>
         $ How.likely.is.that.you.would.recommend.Max.Healthcare.to.a.friend.or.colleague.                                                                                                                     : int  9 7 6 4 7 8 10 6 1 NA ...<BR>
         $ Any.additional.suggestions.or.comments                                                                                                                                                              : Factor w/ 31 levels ""," No","Abhinz was good",..: 28 29 18 21 31 NA 28 30 6 1 ...<BR>
         $ Help.us.recognize.any.of.our.staff.who.served.you.exceptionally.well..by.providing.his.her.name.                                                                                                    : logi  NA NA NA NA NA NA ...<BR>
         $ A.                                                                                                                                                                                                  : Factor w/ 25 levels "","Abhinav","Abhinav ",..: 21 21 21 20 14 8 9 12 16 1 ...<BR>
         $ B.                                                                                                                                                                                                  : Factor w/ 24 levels "","Abhinav","balu ",..: 21 18 19 20 14 10 16 22 1 1 ...<BR>
         $ C.                                                                                                                                                                                                  : Factor w/ 17 levels "","Chiya","Dimple",..: 1 15 1 7 9 1 3 4 1 1 ...<BR></p>
  </blockquote>
  
  <p>I'm getting the error "$ operator is invalid for atomic vectors".
  Can someone pls suggest the way around.</p>
  
  <p>Thanks.</p>