I hereby claim:
- I am daroczig on github.
- I am daroczig (https://keybase.io/daroczig) on keybase.
- I have a public key is ASBYP5QGYjtBrURgkEZJXoJrs_sWW8u-ENKAFO36yUGQDwo
To claim this, I am signing this object:
#' Guess a text data file's parameters | |
#' @param file filename | |
#' @return list of \code{sep}, \code{quote}, \code{dec}, \code{header},\code{fileEncoding} | |
#' @export | |
import.text.guess <- function(file) { | |
## check encoding -> encoding | |
encoding <- sub('.*charset=', '', system(sprintf('file -bi %s', shQuote(file)), intern = TRUE)) | |
if (encoding %in% c('???', 'unknown-8bit')) { | |
warning('Could not identify encoding!') |
I hereby claim:
To claim this, I am signing this object:
## original idea & report by Henrik Bengtsson at | |
## https://stat.ethz.ch/pipermail/r-devel/2016-February/072388.html | |
## This script downloads the list of currently published R packages | |
## from CRAN and also looks at all the archived package versions to | |
## combine these into a list of all R packages ever published on | |
## CRAN with the date of first release. | |
## CRAN mirror to use | |
CRAN_page <- function(...) { |
## fetch & parse data from Wikipedia | |
library(XML) | |
wiki <- 'https://en.wikipedia.org/wiki/Chronology_of_computation_of_%CF%80' | |
tables <- readHTMLTable(readLines(wiki), stringsAsFactors = FALSE) | |
## merge data from 4 tables | |
library(data.table) | |
pis <- rbindlist(list( | |
## data data before 1400 from 3rd table extracted by hand |
-- create a new temp table with exact same schema | |
CREATE TABLE foobar_temp (LIKE foobar INCLUDING DEFAULTS); | |
-- or create this temp table with any new schema (eg updated col type) | |
CREATE TABLE foobar_temp (...) | |
-- copy everything from old table | |
INSERT INTO foobar_temp <list of columns> SELECT <list of columns> FROM foobar; | |
-- rename/drop tables |
m1 <- lm(mpg ~ hp, data = mtcars) | |
m2 <- lm(mpg ~ hp + drat, data = mtcars) | |
m3 <- lm(mpg ~ hp + drat + factor(gear), data = mtcars) | |
library(pander); library(memisc) | |
panderOptions('table.alignment.rownames', 'left') | |
pander(relabel( | |
mtable(m1, m2, m3, | |
summary.stats=c('N', 'R-squared', 'F')), | |
'(Intercept)' = 'Constant', |
ddist <- function(df, quantiles = c(0,.02, .25, .50, .75, .90, .98, .99, .999, 1), na.rm = TRUE) { | |
numvars <- which(sapply(df, is.numeric)) | |
sapply(numvars, function(v) { | |
if (is.data.table(df)) { | |
v <- df[, v, with = FALSE] | |
} else { | |
v <- df[, v] | |
} | |
c(n = length(v), | |
ndistinct = length(unique(v)), |
--- | |
title: Alkalmazott statisztika? R! | |
author: Daróczi Gergely | |
date: 2016 | |
--- | |
Az R programozási nyelvvel és adatelemző, statisztikai és adatvizualizációs rendszerrel (R Core Team 2016) kicsit több mint 10 éve ismerkedtem meg felsőfokú tanulmányaim során, amikor is egy választható gazdaságszociológia kurzus keretén belül a magyarországi burgonyapiac kaotikus viselkedésével (Vizvári, Bacsi 1997; Vizvári 2002) volt szerencsém rövidebben foglalkozni. Ezt a személyes emléket azért tartottam fontosnak leírni, mert a káoszelmélettel való ismerkedés in medias res -- a kapcsolódó meglehetősen összetettnek tűnő matematikai háttér tárgyalása nélkül --, az alkalmazással indult, és az R-nek köszönhetően a félév végén sikerrel abszolváltam a kurzust. Ezzel párhuzamosan egy új és igen gazdag világ tárult fel előttem az R eszköztárával, amely évekkel később egyik legkedvesebb szabadidős elfoglaltságommá, majd elsődleges munkaeszközömmé vált. | |
Noha az R nyelv már több mint 20 éves múltra tekinthet vissza, népszerűségét legin |
# demo transactions data | |
library(data.table) | |
txns <- data.table( | |
rpid = rep(1:3, times = 4), | |
txid = 1:12, | |
time = c(10, 10, 10, 11, 15, 20, 12, 16, 25, 13, 21, 30)) | |
## overlap join to see which transactions happened withing 3 time units on the same rpid | |
## let's define the time periods for the overlap | |
txns[, start := time - 3] |