# `letters` contains the 26 letters of the English alphabet
# data.frames will recycle `letters` twice to match the length of `a` (52)
data.frame(
a = 1:52,
b = letters
)
#> a b
#> 1 1 a
#> 2 2 b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # measure the average number of steps a random walker takes in two | |
| # dimensions to return to origin for the first time by simulating | |
| # the random walk multiple times. | |
| library(tidyverse) | |
| # walk through an integer grid one step at a time | |
| # report the number of steps on first return to the origin | |
| steps_on_first_return <- function(max_steps = 10000L) { | |
| x <- 0L | |
| y <- 0L |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plot_data <- data_observed |> | |
| select(starts_with("y"), exposure) |> | |
| mutate(id = row_number()) |> | |
| pivot_longer( | |
| starts_with("y"), | |
| names_prefix = "y_", | |
| names_to = "potential_outcome", | |
| values_to = "happiness" | |
| ) |> | |
| mutate( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #set.seed(123) # Set seed for reproducibility | |
| library(tidymodels) | |
| fit_models <- function(n = 100) { | |
| # Step 2: Create 10 predictors, some of which are noisy or highly correlated | |
| x1 <- rnorm(n) | |
| x2 <- rnorm(n) | |
| x3 <- rnorm(n) | |
| x4 <- rnorm(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: "Untitled" | |
| format: html | |
| jupyter: python3 | |
| --- | |
| ```{python} | |
| #| label: setup | |
| #| include: false | |
| import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # or use Posit Cloud https://posit.cloud/content/5749861 | |
| quarto.workshop::use_module("quarto_whole_game") | |
| # or use Posit Cloud https://posit.cloud/content/5749854 | |
| quarto.workshop::use_module("quarto_basics") | |
| # or use Posit Cloud https://posit.cloud/content/5890555 | |
| quarto.workshop::use_module("quarto_tables") | |
| # or use Posit Cloud https://posit.cloud/content/5890550 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rhc <- readr::read_csv("https://biostat.app.vumc.org/wiki/pub/Main/DataSets/rhc.csv") | |
| rhc$swang1 <- factor(rhc$swang1, levels = c("No RHC", "RHC")) | |
| psModel <- glm( | |
| formula = swang1 ~ age + sex + race + edu + income + ninsclas + | |
| cat1 + das2d3pc + dnr1 + ca + surv2md1 + aps1 + scoma1 + | |
| wtkilo1 + temp1 + meanbp1 + resp1 + hrt1 + pafi1 + | |
| paco21 + ph1 + wblc1 + hema1 + sod1 + pot1 + crea1 + | |
| bili1 + alb1 + resp + card + neuro + gastr + renal + | |
| meta + hema + seps + trauma + ortho + cardiohx + chfhx + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Hello, | |
| # Can anyone help me: I want just to have line plot but when I plot it looks like so as it is indicated in the picture. I am using the following code: | |
| # Plot the 7th graph for Google mobility. Recreation & Retail | |
| USAMobility <- USAMobility %>% | |
| dplyr::mutate(date=dmy(j)) | |
| PLOT7 <- USAMobility %>% | |
| ggplot(aes(x=date, y=retail_and_recreation_percent_change_from_baseline)) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "panes": { | |
| "quadrants": [ | |
| "Source", | |
| "Console", | |
| "TabSet1", | |
| "TabSet2" | |
| ], | |
| "tabSet1": [ | |
| "Environment", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use_custom_build <- function(file) { | |
| stopifnot(file_exists(file)) | |
| build_pane_active <- has_buildtype() | |
| bail_out <- check_buildtype() | |
| if (bail_out) { | |
| return(invisible(NULL)) | |
| } | |
| file_chmod(file, "+x") |
NewerOlder