Search code examples
rsubsetdata-cleaning

Data cleaning using subset with 2 conditions on same variable


I am a newbie to R, I have at dataset ITEproduction_2014.2015 and I only want to see datapoints between 4 and 39 days. Currently I use 2 separate lines to create a subset. Can I do this in 1 line? something like Data.Difference >3 and < 40?

 ITEproduction_2014.2015 <- subset(ITEproduction_2014.2015,Date.Difference>3)
 ITEproduction_2014.2015 <- subset(ITEproduction_2014.2015,Date.Difference<40)

thanks in advance, Dirk


Solution

  • just a little googling would have solved your problem, for example read this about logical operators,

    like this?

    ITEproduction_2014.2015<-subset(ITEproduction_2014.2015,Date.Difference>3 & Date.Difference<40)