Skip to content

Commit

Permalink
Minor documentation fix to convert comments to markdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karandeep Singh committed Apr 30, 2023
1 parent 28bcb41 commit 061d827
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/examples/UserGuide/filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using RDatasets

movies = dataset("ggplot2", "movies");

# Let’s take a look at the movies whose budget was more than average. We will select only the first 5 rows for the sake of brevity.
# ## Let’s take a look at the movies whose budget was more than average. We will select only the first 5 rows for the sake of brevity.

@chain movies begin
@mutate(Budget = Budget / 1_000_000)
Expand All @@ -14,49 +14,49 @@ movies = dataset("ggplot2", "movies");
@slice(1:5)
end

# Let's search for movies that have at least 200 votes and a rating of greater than or equal to 8. There are 3 ways you can specify an "and" condition inside of `Tidier.jl`.
# ## Let's search for movies that have at least 200 votes and a rating of greater than or equal to 8. There are 3 ways you can specify an "and" condition inside of `Tidier.jl`.

## The first option is to use the short-circuiting `&&` operator as shown below. This is the preferred approach because the second expression is only evaluated (per element) if the first one is true.
# ### The first option is to use the short-circuiting `&&` operator as shown below. This is the preferred approach because the second expression is only evaluated (per element) if the first one is true.

@chain movies begin
@filter(Votes >= 200 && Rating >= 8)
@select(Title, Votes, Rating)
@slice(1:5)
end

## The second option is to use the bitwise `&` operator. However, there is a key difference in syntax. Because the `&` operator takes a higher operator precendence than `>=`, you have to wrap the `>=` expressions inside of parentheses to ensure that the expression is evaluated correctly.
# ### The second option is to use the bitwise `&` operator. Note that there is a key difference in syntax between `&` and `&&`. Because the `&` operator takes a higher operator precendence than `>=`, you have to wrap the comparison expressions inside of parentheses to ensure that the overall expression is evaluated correctly.

@chain movies begin
@filter((Votes >= 200) & (Rating >= 8))
@select(Title, Votes, Rating)
@slice(1:5)
end

## Finally, for "and" conditions only, you can separate the expressions with commas, similar to the behavior of `filter()` in `tidyverse`.
# ### The third option for "and" conditions only is to separate the expressions with commas. This is similar to the behavior of `filter()` in `tidyverse`.

@chain movies begin
@filter(Votes >= 200, Rating >= 8)
@select(Title, Votes, Rating)
@slice(1:5)
end

# Now let's see how to use `@filter()` with `in`. Here's an example with a tuple.
# ## Now let's see how to use `@filter()` with `in`. Here's an example with a tuple.

@chain movies begin
@filter(Title in ("101 Dalmatians",
"102 Dalmatians"))
@select(1:5)
end

# We can also use `@filter()` with `in` using a vector, denoted by a `[]`.
# ## We can also use `@filter()` with `in` using a vector, denoted by a `[]`.

@chain movies begin
@filter(Title in ["101 Dalmatians",
"102 Dalmatians"])
@select(1:5)
end

# Finally, we can combine `@filter` with `row_number()` to retrieve the first 5 rows, which can be used to mimic the functionality provided by `@slice`.
# ## Finally, we can combine `@filter` with `row_number()` to retrieve the first 5 rows, which can be used to mimic the functionality provided by `@slice`.

@chain movies begin
@filter(row_number() <= 5)
Expand Down

2 comments on commit 061d827

@kdpsingh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/82571

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.5 -m "<description of version>" 061d827f6587c13379ec78cc1eda04ca954b49bd
git push origin v0.7.5

Please sign in to comment.