Skip to content

Commit

Permalink
final docs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeffebach committed Mar 1, 2024
1 parent edf22c3 commit 0afba2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ In addition, DataFramesMeta provides
* `@astable` to create multiple columns within a single transformation.
* `@chain`, from [Chain.jl](https://github.com/jkrumbiegel/Chain.jl) for piping the above macros together, similar to [magrittr](https://cran.r-project.org/web/packages/magrittr/vignettes/magrittr.html)'s
`%>%` in R.
* `@label!` and `@note!` for attaching metadata to columns.

See below the convenience of DataFramesMeta compared to DataFrames.

Expand Down
32 changes: 21 additions & 11 deletions src/metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function addlabel_helper(df, args...)
end

"""
label!(df, args...)
@label!(df, args...)
Assign labels to columns in a data frame using `:col = label` syntax.
Shorthand for `label!(df, ...)` from TablesMetaDataTools.jl.
Expand All @@ -56,7 +56,7 @@ renaming and transformations. `@label! :x = "Lab"` over-writes any
existing label for the column `:x`. To add information without overwriting,
use [`@note!`](@ref).
`@label!` returns the input data frame for use with `@chain`.
Returns `df`, with the labels of `df` modified.
Like other DataFramesMeta.jl macros, `@label!` can be used in "keyword"
format as well as block format.
Expand Down Expand Up @@ -98,40 +98,50 @@ function addnote_helper(df, args...)
end

"""
note!(df, args...)
@note!(df, args...)
Assign notes to columns in a data frame using `:col = note` syntax.
Shorthand for `note!(df, col, note)` from TablesMetadataTools.jl.
Use `@note!` for longer explanations of columns.
Use `@label!` for short descriptions, primarily for pretty printing.
Returns `df`, with the notes of `df` modified.
```julia-repl
julia> df = DataFrame(wage = 12);
julia> @note! df :wage = "
Long discussion of variable construction.
";
Wage per hour in 2014 USD taken from ACS data provided by IPUMS.
Wage per hour is measured directly for hourly workers. For
salaried workers, equal to salary / hours worked.
";
julia> printnotes(df)
Column: wage
────────────
Long discussion of variable construction.
```
Unlike labels, notes are appended.
Wage per hour in 2014 USD taken from ACS data provided by IPUMS.
Wage per hour is measured directly for hourly workers. For
salaried workers, equal to salary / hours worked.
```julia-repl
julia> @note! df :wage = "Another comment on variable construction";
julia> @note! df :wage = "Wage is capped at 99th percentile";
julia> printnotes(df)
Column: wage
────────────
Wage per hour in 2014 USD taken from ACS data provided by IPUMS.
Wage per hour is measured directly for hourly workers. For
salaried workers, equal to salary / hours worked.
Values capped at the 99th percentile
Wage is capped at 99th percentile
```
"""
macro note!(df, args...)
Expand Down

0 comments on commit 0afba2b

Please sign in to comment.