R データフレームの絞り込み filter{dplyr}

Script
head(tmp)
tail(tmp)
dataset<-tmp%>%filter(tmp[,2]!="NA",tmp[,3]!="NA")
head(dataset)
tail(dataset)
buf<-nrow(dataset%>%filter(dataset[,2]<0,dataset[,3]<0))/nrow(dataset)*100
cat(paste("ドル円下落かつ日経下落:",round(buf,2),"%"))
buf<-nrow(dataset%>%filter(dataset[,2]<0,dataset[,3]>=0))/nrow(dataset)*100
cat(paste("ドル円下落かつ日経上昇:",round(buf,2),"%"))
buf<-nrow(dataset%>%filter(dataset[,2]>=0,dataset[,3]>=0))/nrow(dataset)*100
cat(paste("ドル円上昇かつ日経上昇:",round(buf,2),"%"))
buf<-nrow(dataset%>%filter(dataset[,2]>=0,dataset[,3]<0))/nrow(dataset)*100
cat(paste("ドル円上昇かつ日経下落:",round(buf,2),"%"))
Result
> head(tmp)
        Date Japan / U.S. Foreign Exchange Rate-前日差 NIKKEI225-前日差
1 1971-01-04                                        NA               NA
2 1971-01-05                                      0.08           -11.90
3 1971-01-06                                      0.05            -7.70
4 1971-01-07                                      0.01            19.22
5 1971-01-08                                     -0.05            39.97
6 1971-01-11                                      0.13            44.39

> tail(tmp)
            Date Japan / U.S. Foreign Exchange Rate-前日差 NIKKEI225-前日差
11750 2016-01-15                                     -1.25           -93.84
11751 2016-01-18                                        NA          -191.54
11752 2016-01-19                                        NA            92.80
11753 2016-01-20                                     -1.28          -632.18
11754 2016-01-21                                      1.23          -398.93
11755 2016-01-22                                      0.76           941.27

> head(dataset)
        Date Japan / U.S. Foreign Exchange Rate-前日差 NIKKEI225-前日差
1 1971-01-05                                      0.08           -11.90
2 1971-01-06                                      0.05            -7.70
3 1971-01-07                                      0.01            19.22
4 1971-01-08                                     -0.05            39.97
5 1971-01-11                                      0.13            44.39
6 1971-01-12                                      0.11             7.01

> tail(dataset)
            Date Japan / U.S. Foreign Exchange Rate-前日差 NIKKEI225-前日差
10039 2016-01-13                                      0.28           496.67
10040 2016-01-14                                     -0.03          -474.68
10041 2016-01-15                                     -1.25           -93.84
10042 2016-01-20                                     -1.28          -632.18
10043 2016-01-21                                      1.23          -398.93
10044 2016-01-22                                      0.76           941.27

> cat(paste("ドル円下落かつ日経下落:",round(buf,2),"%"))
ドル円下落かつ日経下落: 23.53 %

> cat(paste("ドル円下落かつ日経上昇:",round(buf,2),"%"))
ドル円下落かつ日経上昇: 24.42 %

> cat(paste("ドル円上昇かつ日経上昇:",round(buf,2),"%"))
ドル円上昇かつ日経上昇: 28.42 %

> cat(paste("ドル円上昇かつ日経下落:",round(buf,2),"%"))
ドル円上昇かつ日経下落: 23.63 %