0
$\begingroup$

I have a dataframe with the following columns:

enter image description here

If a year (see "year" column) has less than 10 weeks reported, I would like to delete it from the dataframe. The column "weeks_reporting" gives the order of the week in a year. How can I accomplish this task in R?

$\endgroup$

2 Answers 2

1
$\begingroup$

You can accomplish this using a logic index as follows:

us_contagious_diseases<-us_contagious_diseases[!(us_contagious_diseases$weeks_reporting<"10"),]
$\endgroup$
1
$\begingroup$

you can accomplish in multiple ways, eg with with dplyr:

 library(dplyr)
 us_contagious_diseases %>%
   filter(weeks_reporting >= 10)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.