read_spectogram_file <- function(path) {
lines <- readLines(path)
powers <- lines |>
stringr::str_match("z \\[(\\d+)\\] \\[(\\d+)\\] = (\\S+) ") |>
as.data.frame() |>
stats::setNames(c("line", "y", "x", "power"))
# ugly bc i removed dplyr functions
powers <- powers[!is.na(powers$line), 2:4] |>
library(tidyverse)
example <-
tibble::tribble(
~token, ~surprisal, ~sentence,
"them", 15.291, "them eat them hotdogs soon.",
"eat", 6.539, "them eat them hotdogs soon.",
"them", 2.739, "them eat them hotdogs soon.",
"hot", 2.164, "them eat them hotdogs soon.",
"##dog", 11.064, "them eat them hotdogs soon.",
library(glmmTMB)
library(splines)
x <- glmmTMB(
am ~ ns(wt, df = 3),
dispformula = ~ ns(wt, df = 2),
data = mtcars
)
This file contains 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
path_uncommon <- function(paths) { | |
# How long is the common part when we split it up? | |
common_lengths <- paths |> | |
fs::path_common() |> | |
fs::path_split() |> | |
unlist() | |
if (length(common_lengths)) { | |
paths |> | |
fs::path_split() |> |
This file contains 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" | |
output: pdf_document | |
date: '2022-04-13' | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
library(targets)
dir <- tempdir()
setwd(dir)
tar_script()
dir.create("data")
write.csv(mtcars, "data/mtcars.csv")
library(tidyverse)
library(ordinal)
#>
#> Attaching package: 'ordinal'
#> The following object is masked from 'package:dplyr':
#>
#> slice
wine <- as_tibble(wine)
wine
library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.1.2
#> Warning: package 'readr' was built under R version 4.1.2
d <- readr::read_tsv("C:/Users/Tristan/Downloads/dogs.txt")
#> Rows: 30 Columns: 26
#> -- Column specification --------------------------------------------------------
#> Delimiter: "\t"
#> dbl (26): Dog, T.0, T.1, T.2, T.3, T.4, T.5, T.6, T.7, T.8, T.9, T.10, T.11,...
#>
library(tidyverse)
mtcars2 <- mtcars %>%
tibble::rownames_to_column()
# create a list of dataframe with a shared id column and
# a random subset of rows
tables_to_combine <- names(mtcars2)[-1] %>%
lapply(function(x) mtcars2[c("rowname", x)]) %>%
library(nlme)
library(ggplot2)
CO2$is_qc1 <- CO2$Plant == "Qc1"
ggplot(subset(CO2, Type == "Quebec" & Treatment == "chilled")) +
aes(x = conc, y = uptake) +
stat_smooth(
method = nls,
formula = y ~ SSasymp(x, Asym, lrc, c0),
se = FALSE,