-2

Hi I want to extract somes rows of my data corresponding to the months(2 and 3) Here is my data.

station build   Year Month  
1   Bariko 24.5  1961     1      
2   Bariko 29.1  1962     1       
3   Bariko 26.4  1963     1       
4   Bariko 29.0  1961     2       
5   Bariko 22.0  1962     2      
6   Bariko 25.9  1963     2       
7   Bariko 24.2  1961     3       
8   Bariko 23.9  1962     3       
9   Bariko 24.4  1963     3       
10  Bariko 24.0  1961     4      
11  Bariko 24.2  1962     4      
12  Bariko 24.8  1963     4      

And this what I want:

station build   Year Month  
4   Bariko 29.0  1961     2       
5   Bariko 22.0  1962     2      
6   Bariko 25.9  1963     2       
7   Bariko 24.2  1961     3       
8   Bariko 23.9  1962     3       
9   Bariko 24.4  1963     3       
NVega
  • 81
  • 9

1 Answers1

1

You could use the dplyr package:

library(dplyr)
data_filtered = filter(data, Month == 2 | Month == 3)

How's that? Assuming data is your dataframe

nathaneastwood
  • 3,664
  • 24
  • 41