-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipe_examples.R
34 lines (16 loc) · 955 Bytes
/
pipe_examples.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -- pipe %>% Kullanýmý--
# pipe %>% ile ara iþlemler için deðiþken tanýmlamaya gerek kalmadan iþlemler yapýlabilir.
library(dplyr)
data(murders)
murders <- mutate(murders, rate = total / population * 100000, rank = (-rate))
my_states <- filter(murders, region %in% c("Northeast", "West") & rate < 1)
select(my_states, state, rate, rank)
# Yukarýdaki iþlemi tek satýrda, ekstra deðiþken tanýmlamadan pipe ile yapabiliriz;
mutate(murders, rate = total / population * 100000, rank = (-rate)) %>% select(state, rate, rank)
murders <- mutate(murders, rate = total / population * 100000, rank = rank(-rate))
filter(murders, region %in% c("Northeast", "West") & rate < 1) %>%
select(state, rate, rank)
# --mutate, filter ve select--
my_states_pipe <- murders %>% mutate(rate = total / population * 100000, rank = rank(-rate)) %>%
filter(region %in% c("Northeast", "West") & rate < 1) %>% select(state, rate, rank)
my_states_pipe