This is a little cheatsheet for anyone interested in writing about or teaching statistics in Spanish. Please feel free to expand and correct.
Values: valores
| library(dplyr) | |
| df_list <- list( | |
| mutate(mtcars[1:5, ], jurisdiction = 'New Guernsey'), | |
| mutate(iris[1:5, ], mean = mean(Sepal.Length)), | |
| mutate(beaver1[1:5, ], jurisdiction = 'New Guernsey', mean = mean(temp)) | |
| ) |
| library(dplyr) | |
| library(rvest) | |
| # Get the list of files to work on | |
| files_to_process <- list.files('r:/shared documents/', | |
| pattern = 'html', | |
| full.names = TRUE) | |
| # Two main things I can't figure out: | |
| # 1. How do I get the name of each function to prefix its log entry? | |
| # e.g., INFO:testmodule:outsideFun:{msg} instead of just INFO:testmodule:{msg} | |
| # 2. How do I get bound values to persist through subsequent functions? | |
| # e.g., user:matt.parker and outsideArg:foo should appear in both | |
| # outsideFun and insideFun log messages | |
| import logging |
| options(stringsAsFactors = FALSE, | |
| scipen = 9999) | |
| library(shiny) | |
| library(ggplot2) | |
| library(dplyr) |
| library(dplyr) | |
| # Set up a temp sqlite database | |
| db <- src_sqlite(tempfile(), create = TRUE) | |
| iris2 <- copy_to(db, iris) | |
| # if_else with named true and false on a data.frame -> no problem | |
| iris %>% mutate(Sepal.Size = if_else(Sepal.Length > 5, | |
| true = "big", |
| # Always | |
| options(stringsAsFactors = FALSE) | |
| library(tidyverse) | |
| # Setting the ggplot2 theme |
| # Setup | |
| options(stringsAsFactors = FALSE) | |
| library(lubridate) | |
| library(ggplot2) | |
| # This is an example of how to apply the lagging function from this | |
| # StackOverflow answer: http://stackoverflow.com/a/30874772/143319 | |
| # to grouped data. In short: | |
| # 1. Use rxSplit() to put each group in its own XDF file | |
| # 2. Use lapply() to iterate over the list of XDF files | |
| # Pick a sample dataset | |
| xdfPath <- file.path(rxGetOption("sampleDataDir"), "DJIAdaily.xdf") |
| # Pick some dynamic date - here's the start of the current month | |
| start_date <- format(Sys.Date(), "%Y-%m-01") | |
| # Then use paste0() to construct a query that includes it | |
| # Here's an example to get all the positive QFTs this month | |
| # (I have probably misremembered the field names). | |
| # I'm pretty sure you have to put a # on each side of the | |
| # date in order for Access to recognize it as a date. | |
| test_query <- sqlQuery(tbdb, | |
| paste0("SELECT person_id, test_date |