'How do I show only 2 columns but specific row data entries?
Solution 1:[1]
I created a reproducible data sample:
df <- data.frame(Area.name = c("Birmingham", "London", "Newcastle"),
Area.code = c("EO8000025", "EO8000026", "EO8000027"),
Area.type = c("utla", "utla", "utla"),
Specimen.date = c("24/04/2020", "24/04/2020", "24/04/2020"),
Daily.lab.confirmed.cases = c(72, 91, 107),
Cumulative.lab.confirmed.cases = c(2905, 2833, 2742))
Area.name Area.code Area.type Specimen.date Daily.lab.confirmed.cases Cumulative.lab.confirmed.cases
1 Birmingham EO8000025 utla 24/04/2020 72 2905
2 London EO8000026 utla 24/04/2020 91 2833
3 Newcastle EO8000027 utla 24/04/2020 107 2742
You can use the following code:
library(tidyverse)
df %>%
filter(Area.name == "London") %>%
select(Area.name, Daily.lab.confirmed.cases)
Output:
Area.name Daily.lab.confirmed.cases
1 London 91
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

