Skip to content

Commit

Permalink
Merge pull request #7 from TidierOrg/clean-up-documentation
Browse files Browse the repository at this point in the history
Cleaned up docs and documentation typos.
  • Loading branch information
drizk1 committed Aug 7, 2023
2 parents 8ce8989 + fe9886e commit 732e25a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@

`TidierStrings.jl `is a 100% Julia implementation of the R stringr package.

`TidierStrings.jl` has one main goal: to implement stringr's straightforward syntax and of ease of use for Julia users. While this package was develeoped to work seamelessly with `Tidier.jl` fucntions and macros, it can also work as a indepentenly as a standalone package.
`TidierStrings.jl` has one main goal: to implement stringr's straightforward syntax and of ease of use for Julia users. While this package was developed to work seamlessly with `TidierData.jl` functions and macros, it also works independently as a standalone package.

## Installation

For the stable version:

```
] add TidierStrings
```

The `]` character starts the Julia [package manager](https://docs.julialang.org/en/v1/stdlib/Pkg/). Press the backspace key to return to the Julia prompt.

or


For the development version:

```julia
Expand Down Expand Up @@ -93,7 +104,7 @@ end
7 │ Grace San Jose 9876543210 Teacher Grace is a teacher in San Antonio
```

#### `str_detect`, `str_replace`, `str_replace_all`, `str_count`, `str_equal`, and `str_subset` support regex use
#### Support Regex: `str_detect`, `str_replace`, `str_replace_all`, `str_remove`, `str_remove_all`, `str_count`, `str_equal`, and `str_subset`

#### `str_detect()`
'str_detect()' checks if a pattern exists in a string. It takes a string and a pattern as arguments and returns a boolean indicating the presence of the pattern in the string. This can be used inside of `@filter`, `@mutate`, `if_else()` and `case_when()`. `str_detect` supports logical operators | and &.
Expand Down
27 changes: 10 additions & 17 deletions docs/examples/UserGuide/supported_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ df = DataFrame(
"Grace is a teacher in San Antonio"]
)

# str_detect, str_replace, str_replace_all, str_count, str_equal, str_split, str_subset support regex use as well
# Support Regex: `str_detect`, `str_replace`, `str_replace_all`, `str_remove`, `str_remove_all` `str_count`, `str_equal`, `str_subset`

# ## str_squish()
# ## `str_squish()`
# Removes leading and trailing white spaces from a string and also replaces consecutive white spaces in between
# words with a single space. It will also remove new lines.

df = @chain df begin
@mutate(City = str_squish(City))
end

# ## str_replace()
# Replaces the first occurrence of a pattern in a string with a specified text. Takes a string, pattern to search for, and the replacement text as arguments. It also supports the use of regex and logical operator | . This is in contrast to str_replace_all() which will replace each occurence of a match within a string.
# ## `str_replace()`, `str_replace_all`
# Replaces the first occurrence of a pattern in a string with a specified text. Takes a string, pattern to search for, and the replacement text as arguments. It also supports the use of regex and logical operator | . This is in contrast to `str_replace_all()` which will replace each occurence of a match within a string.

@chain df begin
@mutate(City = str_replace(City, r"\s*20\d{2}-\d{2,4}\s*", " ####-## "))
Expand All @@ -35,15 +35,15 @@ end

end

# also available is `str_remove` and `str_remove_all`
# ## `str_remove()`, `str_remove_all()`
# These functions will remove the first occurence or all occurences of a match, respectively.

@chain df begin
@mutate(split = str_remove_all(Description, "is"))
end


# ## str_detect()

# ## `str_detect()`
# Checks if a pattern exists in a string. It takes a string and a pattern as arguments and returns a boolean indicating
# the presence of the pattern in the string. This can be used inside of `@filter`, `@mutate`, `if_else()` and `case_when()`.
# `str_detect` supports logical operators `|` and `&`. `case_when()` with `filter()` and `str_detect()`.
Expand All @@ -61,30 +61,23 @@ end
end


# ## str_equal()
# ## `str_equal()`
# Checks if two strings are exactly the same. Takes two strings as arguments and returns a boolean indicating
# whether the strings are identical.

@chain df begin
@mutate(Same_City = case_when(str_equal(City, Occupation) => "Yes", true => "No"))
end

# ## `str_to_upper`, `str_to_lower`
# ## `str_to_upper()`, `str_to_lower()`
# These will take a string and convert it to all uppercase or lowercase

@chain df begin
@mutate(Names = str_to_upper(Names))
end

# ## `str_split()`
# Splits a string into substrings based on a pattern (like a delimiter). Takes a string and a pattern as
# arguments and returns a list of substrings.

# @chain df begin
# @mutate(split = str_split(Description, "in"))
# end

# ## str_subset()
# ## `str_subset()`
# Returns the subset of strings that match a pattern. Takes a vector of strings and a pattern as arguments
# and returns the subset of strings that contain the pattern.

Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ plugins:
exclude:
- "_overrides"
# - mknotebooks # Jupyter notebooks
- mkdocs-video
#- mkdocs-video
nav:
- "Home": "index.md"
- "Supported Functions" : "examples/generated/UserGuide/supported_functions.md"
Expand Down
3 changes: 1 addition & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## TidierStrings

The goal of this package is to replicate the beauty of Stringr from R in Julia in a way that works with Tidier or as a stand alone function.
The goal of this package is to replicate the beauty of stringr from R in Julia in a way that works with Tidier or as a stand alone function.

This package includes:

Expand All @@ -17,5 +17,4 @@ This package includes:
- `str_equal()`
- `str_to_upper()`
- `str_to_lower()`
- `str_split()`
- `str_subset()`

0 comments on commit 732e25a

Please sign in to comment.