Skip to content

Commit 5122587

Browse files
committed
For piping docs, select first 5 columns to make output cleaner.
1 parent 32e2a1b commit 5122587

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docs/examples/UserGuide/piping.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ end
8888
@chain movies begin
8989
@filter(Year >= 2000 && Rating >= 9)
9090
@slice(1:5)
91+
@select(1:5)
9192
end
9293

9394
# Note: we generally prefer using `&&` in Julia because it is a "short-cut" operator. If the first condition evaluates to `false`, then the second condition is not even evaluated, which makes it faster (because it takes a short-cut).
@@ -97,13 +98,15 @@ end
9798
@chain movies begin
9899
@filter(Year >= 2000, Rating >= 9)
99100
@slice(1:5)
101+
@select(1:5)
100102
end
101103

102104
# Another to write this expression is take advantage of the fact that Julia macros can be called without parentheses. In this case, we will add back the `&&` for the sake of readability.
103105

104106
@chain movies begin
105107
@filter Year >= 2000 && Rating >= 9
106108
@slice 1:5
109+
@select 1:5
107110
end
108111

109112
# Lastly, TidierData.jl also supports multi-line expressions within each of the macros that accept multiple expressions. So you could also write this as follows:
@@ -114,6 +117,7 @@ end
114117
Rating >= 9
115118
end
116119
@slice 1:5
120+
@select 1:5
117121
end
118122

119123
# What's nice about this approach is that if you want to remove some criteria, you can easily comment out the relevant parts. For example, if you're willing to consider older movies, just comment out the `Year >= 2000`.
@@ -124,6 +128,7 @@ end
124128
Rating >= 9
125129
end
126130
@slice 1:5
131+
@select 1:5
127132
end
128133

129134
# ## Which approach to use?

0 commit comments

Comments
 (0)