Skip to content

Commit

Permalink
Merge pull request #6 from larsvilhuber/add-tidylog-example
Browse files Browse the repository at this point in the history
Add an example with tidylog to the R logging section
  • Loading branch information
larsvilhuber authored Dec 18, 2024
2 parents f4d5e4c + d9bf03a commit 1131e27
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 00-preliminaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ This does not ensure
- because many intermediate files might be present that are not in the replication package
- because it does not guarantee that all the directory names are correctly adjusted everywhere in your code
- that it actually produces all the outputs
- because some outputs might be present from test runs
- because some outputs might be present from test runs
24 changes: 24 additions & 0 deletions 04-01-creating_log_files_manually.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@ sink()
close(globallog)
```

### Using `tidylog` for logging data manipulations in R

To install `tidylog`, you can add it to your `requirements.txt` file or install it directly in your R script:

```R
install.packages("tidylog")
```

Here is an example of using `tidylog` to log data manipulations:

```R
library(tidylog)
library(dplyr)

# Example data manipulation
data <- data %>%
filter(!is.na(variable)) %>%
mutate(new_variable = variable * 2) %>%
group_by(group_variable) %>%
summarize(mean_value = mean(new_variable, na.rm = TRUE))
```

In this example, `tidylog` will automatically log the data manipulations performed by the `dplyr` functions, making it easier to track and understand the changes made to your data.

:::

:::{tab-item} MATLAB
Expand Down
2 changes: 1 addition & 1 deletion 04-creating_log_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ If not, ensure that they are (avoid *Stata SMCL* files, for example).

> It may be useful at this time to understand how to run code non-interactively.
>
> - [Useful resource for R](https://github.com/gastonstat/tutorial-R-noninteractive/)
> - [Useful resource for R](https://github.com/gastonstat/tutorial-R-noninteractive/)

0 comments on commit 1131e27

Please sign in to comment.