Skip to content

Commit

Permalink
Merge pull request #683 from jhudsl/fix_functions_W25
Browse files Browse the repository at this point in the history
fix knit errors
  • Loading branch information
clifmckee authored Jan 16, 2025
2 parents 5fa9d24 + c3c51d3 commit a563a0b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions modules/Functions/Functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,20 @@ data_insights <- function(x, column1, column2) {
}
data_insights(x = mtcars, column1 = cyl, column2 = hp)
data_insights(x = mtcars, column1 = cyl, column2 = disp)
```

## A practical example: plotting {.smaller}

You may have a similar plot that you want to examine across columns of data.

```{r}
```{r, fig.width = 3, fig.height = 2}
simple_plots <- function(x, column1, column2) {
box_plot <- ggplot(data = x, aes(x = {{column1}}, y = {{column2}}, group = {{column1}})) +
geom_boxplot() +
geom_boxplot()
return(box_plot)
}
simple_plots(x = mtcars, column1 = cyl, column2 = hp)
simple_plots(x = mtcars, column1 = cyl, column2 = disp)
```

## Writing your own functions
Expand Down Expand Up @@ -298,9 +296,10 @@ iris %>% sapply(class)
```


## Using your custom functions: `sapply()`
## Using your custom functions: `sapply()` {.smaller}

```{r}
```{r, warning=FALSE, message=FALSE}
cars <- read_csv("https://jhudatascience.org/intro_to_r/data/kaggleCarAuction.csv")
select(cars, VehYear:VehicleAge) %>% head()
select(cars, VehYear:VehicleAge) %>%
sapply(times_2) %>%
Expand Down

0 comments on commit a563a0b

Please sign in to comment.