Nader Mehri
Nader Mehri

Reputation: 556

selecting a cell of a column using select () function

For the code below, I need to select the first row of the data frame.

    IDD_mapdata_1 <- reactive ({
    IDD_nhmap$race_black <- round(IDD_nhmap$race_black, 1)
    out_map_1 <- IDD_nhmap %>%
      filter (ProjectID %in% input$Disability_map)
    return(out_map_1)
    #list(cat)
  })

Upvotes: 0

Views: 41

Answers (1)

Brian
Brian

Reputation: 96

To get the first row only of the dataframe you could do this:

head(out_map_1) or out_map_1[1,]

This gives you the dataframe headers if you want just the row as a vector of strings, or numbers just wrap this. For example, if you need just a :

as.character(out_map_1[1,])

enter image description here

To get a specific value from the select statement you can do something like this:

df[1,] %>% select('Age') %>% pull()

enter image description here

Upvotes: 1

Related Questions