[Solved] how we can filter data in dataframe in R [closed]


# Filter
dat.filtered <- subset(dat, f2 > 0)

# Convert to time-series
library(xts);
xts.sample <- xts(dat.filtered$f2, order.by = as.Date(dat.filtered$f1, "%d/%m/%Y"))

Sample data

dat <- read.table(text =
    "                              f1              f2
1                         11/1/16               0
2                         12/1/16               0
3                         11/2/16           56.25
4                         12/2/16               0
5                         11/3/16           56.25
6                         12/3/16               0
7                         11/4/16             111
8                         12/4/16               0
9                         11/5/16               0
10                        12/5/16              13
11                        11/6/16               0
12                        12/6/16               0
13                        11/7/16               0
14                        12/7/16               0
15                        10/8/16               0
16                        11/8/16              35
17                        12/8/16               0
18                        10/9/16               0
19                        11/9/16          415.21
20                        12/9/16               0
21                       10/10/16               0
22                       11/10/16             280
23                       12/10/16             817
24                       10/11/16             830
25                       11/11/16             644
26                       12/11/16               0
27                       10/12/16               0
28                       11/12/16              90
29                       12/12/16               0
30                         1/1/17               0
31                         2/1/17             250
32                         2/1/17               0
33                         3/1/17              45
34                         3/1/17             184
35                         4/1/17          578.16
36                         4/1/17             160
37                         5/1/17              21
38                         5/1/17               0
39                         6/1/17             352
40                         6/1/17               0", header = T, row.names = 1)

12

solved how we can filter data in dataframe in R [closed]