{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#Pkg.add(\"DataFrames\")\n", "using DataFrames" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###DataFrames gives us readtable which loads a csv file into a DatFrame object" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
StationDateTmaxTminTavgDepartDewPointWetBulbHeatCoolSunriseSunsetCodeSumDepthWater1SnowFallPrecipTotalStnPressureSeaLevelResultSpeedResultDirAvgSpeed
112007-05-018350671451560 204481849 0M0.00.0029.1029.821.7279.2
222007-05-01845268M51570 3-- MMM0.0029.1829.822.7259.6
312007-05-02594251-3424714 004471850BR0M0.00.0029.3830.0913.0413.4
422007-05-02604352M424713 0--BR HZMMM0.0029.4430.0813.3213.4
512007-05-03664656 240489 004461851 0M0.00.0029.3930.1211.7711.9
622007-05-03674858M40507 0--HZMMM0.0029.4630.1212.9613.2
712007-05-04664958 441507 004441852RA0M0.0 T29.3130.0510.4810.8
822007-05-047851MM4250MM-- MMM0.0029.3630.0410.1710.4
912007-05-05665360 538495 004431853 0M0.0 T29.4030.1011.7712.0
1022007-05-05665460M39505 0-- MMM T29.4630.0911.2711.5
1112007-05-06684959 430466 004421855 0M0.00.0029.5730.2914.41115.0
1222007-05-06685260M30465 0-- MMM0.0029.6230.2813.81014.5
1312007-05-078347651041540 004411856RA0M0.0 T29.3830.128.61810.5
1422007-05-07845067M39530 2-- MMM0.0029.4430.128.5179.9
1512007-05-088254681258620 304391857BR0M0.00.0029.2930.032.7115.8
1622007-05-08806070M57630 5--HZMMM T29.3630.022.585.4
1712007-05-097761691359630 404381858BR HZ0M0.00.1329.2129.943.996.2
1822007-05-09766370M60630 5--BR HZMMM0.0229.2829.933.975.9
1912007-05-108456701452600 504371859BR0M0.00.0029.2029.920.7174.1
2022007-05-10835971M52610 6--BR HZMMM0.0029.2629.912.093.9
2112007-05-11705161 442514 004361860 0M0.00.0029.3330.0411.3312.9
2222007-05-11734961M44514 0-- MMM0.0029.3930.0311.73612.8
2312007-05-12644655-2364610 004351901 0M0.00.0029.4930.2012.4312.9
2422007-05-12654756M37469 0-- MMM0.0029.5430.1912.7113.0
2512007-05-13694356-233469 004341902 0M0.00.0029.4930.246.6148.1
2622007-05-13694457M32468 0-- MMM0.0029.5530.246.4117.6
2712007-05-149056731547590 804331903 0M0.00.0029.2329.9716.92117.3
2822007-05-14905472M45580 7-- MMM0.0029.3129.9814.12114.6
2912007-05-158057691156610 404321904RA BR0M0.00.3829.1329.848.12712.3
3022007-05-15825669M56610 4--TSRA RA BRMMM0.6029.1929.838.12510.8
" ], "text/plain": [ "2944x22 DataFrame\n", "| Row | Station | Date | Tmax | Tmin | Tavg | Depart | DewPoint |\n", "|------|---------|--------------|------|------|------|--------|----------|\n", "| 1 | 1 | \"2007-05-01\" | 83 | 50 | \"67\" | \"14\" | 51 |\n", "| 2 | 2 | \"2007-05-01\" | 84 | 52 | \"68\" | \"M\" | 51 |\n", "| 3 | 1 | \"2007-05-02\" | 59 | 42 | \"51\" | \"-3\" | 42 |\n", "| 4 | 2 | \"2007-05-02\" | 60 | 43 | \"52\" | \"M\" | 42 |\n", "| 5 | 1 | \"2007-05-03\" | 66 | 46 | \"56\" | \" 2\" | 40 |\n", "| 6 | 2 | \"2007-05-03\" | 67 | 48 | \"58\" | \"M\" | 40 |\n", "| 7 | 1 | \"2007-05-04\" | 66 | 49 | \"58\" | \" 4\" | 41 |\n", "| 8 | 2 | \"2007-05-04\" | 78 | 51 | \"M\" | \"M\" | 42 |\n", "| 9 | 1 | \"2007-05-05\" | 66 | 53 | \"60\" | \" 5\" | 38 |\n", "| 10 | 2 | \"2007-05-05\" | 66 | 54 | \"60\" | \"M\" | 39 |\n", "| 11 | 1 | \"2007-05-06\" | 68 | 49 | \"59\" | \" 4\" | 30 |\n", "⋮\n", "| 2933 | 1 | \"2014-10-26\" | 64 | 42 | \"53\" | \" 5\" | 32 |\n", "| 2934 | 2 | \"2014-10-26\" | 66 | 44 | \"55\" | \"M\" | 33 |\n", "| 2935 | 1 | \"2014-10-27\" | 77 | 51 | \"64\" | \"16\" | 51 |\n", "| 2936 | 2 | \"2014-10-27\" | 79 | 54 | \"67\" | \"M\" | 52 |\n", "| 2937 | 1 | \"2014-10-28\" | 68 | 45 | \"57\" | \"10\" | 38 |\n", "| 2938 | 2 | \"2014-10-28\" | 66 | 48 | \"57\" | \"M\" | 40 |\n", "| 2939 | 1 | \"2014-10-29\" | 49 | 36 | \"43\" | \"-4\" | 32 |\n", "| 2940 | 2 | \"2014-10-29\" | 49 | 40 | \"45\" | \"M\" | 34 |\n", "| 2941 | 1 | \"2014-10-30\" | 51 | 32 | \"42\" | \"-4\" | 34 |\n", "| 2942 | 2 | \"2014-10-30\" | 53 | 37 | \"45\" | \"M\" | 35 |\n", "| 2943 | 1 | \"2014-10-31\" | 47 | 33 | \"40\" | \"-6\" | 25 |\n", "| 2944 | 2 | \"2014-10-31\" | 49 | 34 | \"42\" | \"M\" | 29 |\n", "\n", "| Row | WetBulb | Heat | Cool | Sunrise | Sunset | CodeSum | Depth |\n", "|------|---------|------|------|---------|--------|------------|-------|\n", "| 1 | \"56\" | \"0\" | \" 2\" | \"0448\" | \"1849\" | \" \" | \"0\" |\n", "| 2 | \"57\" | \"0\" | \" 3\" | \"-\" | \"-\" | \" \" | \"M\" |\n", "| 3 | \"47\" | \"14\" | \" 0\" | \"0447\" | \"1850\" | \"BR\" | \"0\" |\n", "| 4 | \"47\" | \"13\" | \" 0\" | \"-\" | \"-\" | \"BR HZ\" | \"M\" |\n", "| 5 | \"48\" | \"9\" | \" 0\" | \"0446\" | \"1851\" | \" \" | \"0\" |\n", "| 6 | \"50\" | \"7\" | \" 0\" | \"-\" | \"-\" | \"HZ\" | \"M\" |\n", "| 7 | \"50\" | \"7\" | \" 0\" | \"0444\" | \"1852\" | \"RA\" | \"0\" |\n", "| 8 | \"50\" | \"M\" | \"M\" | \"-\" | \"-\" | \" \" | \"M\" |\n", "| 9 | \"49\" | \"5\" | \" 0\" | \"0443\" | \"1853\" | \" \" | \"0\" |\n", "| 10 | \"50\" | \"5\" | \" 0\" | \"-\" | \"-\" | \" \" | \"M\" |\n", "| 11 | \"46\" | \"6\" | \" 0\" | \"0442\" | \"1855\" | \" \" | \"0\" |\n", "⋮\n", "| 2933 | \"44\" | \"12\" | \" 0\" | \"0617\" | \"1654\" | \" \" | \"0\" |\n", "| 2934 | \"45\" | \"10\" | \" 0\" | \"-\" | \"-\" | \" \" | \"M\" |\n", "| 2935 | \"58\" | \"1\" | \" 0\" | \"0618\" | \"1653\" | \" \" | \"0\" |\n", "| 2936 | \"59\" | \"0\" | \" 2\" | \"-\" | \"-\" | \"RA\" | \"M\" |\n", "| 2937 | \"47\" | \"8\" | \" 0\" | \"0619\" | \"1651\" | \" \" | \"0\" |\n", "| 2938 | \"48\" | \"8\" | \" 0\" | \"-\" | \"-\" | \"RA\" | \"M\" |\n", "| 2939 | \"40\" | \"22\" | \" 0\" | \"0620\" | \"1650\" | \" \" | \"0\" |\n", "| 2940 | \"42\" | \"20\" | \" 0\" | \"-\" | \"-\" | \" \" | \"M\" |\n", "| 2941 | \"40\" | \"23\" | \" 0\" | \"0622\" | \"1649\" | \" \" | \"0\" |\n", "| 2942 | \"42\" | \"20\" | \" 0\" | \"-\" | \"-\" | \"RA\" | \"M\" |\n", "| 2943 | \"33\" | \"25\" | \" 0\" | \"0623\" | \"1647\" | \"RA SN\" | \"0\" |\n", "| 2944 | \"36\" | \"23\" | \" 0\" | \"-\" | \"-\" | \"RA SN BR\" | \"M\" |\n", "\n", "| Row | Water1 | SnowFall | PrecipTotal | StnPressure | SeaLevel |\n", "|------|--------|----------|-------------|-------------|----------|\n", "| 1 | \"M\" | \"0.0\" | \"0.00\" | \"29.10\" | \"29.82\" |\n", "| 2 | \"M\" | \"M\" | \"0.00\" | \"29.18\" | \"29.82\" |\n", "| 3 | \"M\" | \"0.0\" | \"0.00\" | \"29.38\" | \"30.09\" |\n", "| 4 | \"M\" | \"M\" | \"0.00\" | \"29.44\" | \"30.08\" |\n", "| 5 | \"M\" | \"0.0\" | \"0.00\" | \"29.39\" | \"30.12\" |\n", "| 6 | \"M\" | \"M\" | \"0.00\" | \"29.46\" | \"30.12\" |\n", "| 7 | \"M\" | \"0.0\" | \" T\" | \"29.31\" | \"30.05\" |\n", "| 8 | \"M\" | \"M\" | \"0.00\" | \"29.36\" | \"30.04\" |\n", "| 9 | \"M\" | \"0.0\" | \" T\" | \"29.40\" | \"30.10\" |\n", "| 10 | \"M\" | \"M\" | \" T\" | \"29.46\" | \"30.09\" |\n", "| 11 | \"M\" | \"0.0\" | \"0.00\" | \"29.57\" | \"30.29\" |\n", "⋮\n", "| 2933 | \"M\" | \"0.0\" | \"0.00\" | \"29.21\" | \"29.95\" |\n", "| 2934 | \"M\" | \"M\" | \"0.00\" | \"29.28\" | \"29.95\" |\n", "| 2935 | \"M\" | \"0.0\" | \"0.00\" | \"28.92\" | \"29.66\" |\n", "| 2936 | \"M\" | \"M\" | \"0.02\" | \"29.00\" | \"29.67\" |\n", "| 2937 | \"M\" | \"0.0\" | \" T\" | \"29.15\" | \"29.85\" |\n", "| 2938 | \"M\" | \"M\" | \"0.03\" | \"29.23\" | \"29.85\" |\n", "| 2939 | \"M\" | \"0.0\" | \"0.00\" | \"29.36\" | \"30.06\" |\n", "| 2940 | \"M\" | \"M\" | \"0.00\" | \"29.42\" | \"30.07\" |\n", "| 2941 | \"M\" | \"0.0\" | \"0.00\" | \"29.34\" | \"30.09\" |\n", "| 2942 | \"M\" | \"M\" | \" T\" | \"29.41\" | \"30.10\" |\n", "| 2943 | \"M\" | \"0.1\" | \"0.03\" | \"29.49\" | \"30.20\" |\n", "| 2944 | \"M\" | \"M\" | \"0.04\" | \"29.54\" | \"30.20\" |\n", "\n", "| Row | ResultSpeed | ResultDir | AvgSpeed |\n", "|------|-------------|-----------|----------|\n", "| 1 | 1.7 | 27 | \"9.2\" |\n", "| 2 | 2.7 | 25 | \"9.6\" |\n", "| 3 | 13.0 | 4 | \"13.4\" |\n", "| 4 | 13.3 | 2 | \"13.4\" |\n", "| 5 | 11.7 | 7 | \"11.9\" |\n", "| 6 | 12.9 | 6 | \"13.2\" |\n", "| 7 | 10.4 | 8 | \"10.8\" |\n", "| 8 | 10.1 | 7 | \"10.4\" |\n", "| 9 | 11.7 | 7 | \"12.0\" |\n", "| 10 | 11.2 | 7 | \"11.5\" |\n", "| 11 | 14.4 | 11 | \"15.0\" |\n", "⋮\n", "| 2933 | 0.9 | 5 | \"5.8\" |\n", "| 2934 | 1.6 | 11 | \"5.4\" |\n", "| 2935 | 12.0 | 19 | \"12.9\" |\n", "| 2936 | 12.7 | 19 | \"13.6\" |\n", "| 2937 | 14.8 | 26 | \"15.6\" |\n", "| 2938 | 14.0 | 26 | \"14.6\" |\n", "| 2939 | 9.5 | 29 | \"9.9\" |\n", "| 2940 | 8.5 | 29 | \"9.0\" |\n", "| 2941 | 5.1 | 24 | \"5.5\" |\n", "| 2942 | 5.9 | 23 | \"6.5\" |\n", "| 2943 | 22.6 | 34 | \"22.9\" |\n", "| 2944 | 21.7 | 34 | \"22.6\" |" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ " df = readtable(\"input/weather.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###DataFrames can be subset by rows or columns" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
DateTmaxTminTavgDepartDewPointWetBulbHeatCool
12007-05-018350671451560 2
22007-05-01845268M51570 3
" ], "text/plain": [ "2x9 DataFrame\n", "| Row | Date | Tmax | Tmin | Tavg | Depart | DewPoint | WetBulb | Heat |\n", "|-----|--------------|------|------|------|--------|----------|---------|------|\n", "| 1 | \"2007-05-01\" | 83 | 50 | \"67\" | \"14\" | 51 | \"56\" | \"0\" |\n", "| 2 | \"2007-05-01\" | 84 | 52 | \"68\" | \"M\" | 51 | \"57\" | \"0\" |\n", "\n", "| Row | Cool |\n", "|-----|------|\n", "| 1 | \" 2\" |\n", "| 2 | \" 3\" |" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[1:1]\n", "df[2:10]\n", "df[1:2,2:10]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "22-element Array{Symbol,1}:\n", " :Station \n", " :Date \n", " :Tmax \n", " :Tmin \n", " :Tavg \n", " :Depart \n", " :DewPoint \n", " :WetBulb \n", " :Heat \n", " :Cool \n", " :Sunrise \n", " :Sunset \n", " :CodeSum \n", " :Depth \n", " :Water1 \n", " :SnowFall \n", " :PrecipTotal\n", " :StnPressure\n", " :SeaLevel \n", " :ResultSpeed\n", " :ResultDir \n", " :AvgSpeed " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "names(df)\n", "\n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2944-element DataArray{UTF8String,1}:\n", " \"2007-05-01\"\n", " \"2007-05-01\"\n", " \"2007-05-02\"\n", " \"2007-05-02\"\n", " \"2007-05-03\"\n", " \"2007-05-03\"\n", " \"2007-05-04\"\n", " \"2007-05-04\"\n", " \"2007-05-05\"\n", " \"2007-05-05\"\n", " \"2007-05-06\"\n", " \"2007-05-06\"\n", " \"2007-05-07\"\n", " ⋮ \n", " \"2014-10-26\"\n", " \"2014-10-26\"\n", " \"2014-10-27\"\n", " \"2014-10-27\"\n", " \"2014-10-28\"\n", " \"2014-10-28\"\n", " \"2014-10-29\"\n", " \"2014-10-29\"\n", " \"2014-10-30\"\n", " \"2014-10-30\"\n", " \"2014-10-31\"\n", " \"2014-10-31\"" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rename!(df,:Date,:Day)\n", "df[:Day]\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###Can also use symbols as column names" ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
TmaxDepart
18314
284M
359-3
460M
566 2
667M
766 4
878M
966 5
1066M
1168 4
1268M
138310
1484M
158212
1680M
177713
1876M
198414
2083M
2170 4
2273M
2364-2
2465M
2569-2
2669M
279015
2890M
298011
3082M
" ], "text/plain": [ "2944x2 DataFrame\n", "| Row | Tmax | Depart |\n", "|------|------|--------|\n", "| 1 | 83 | \"14\" |\n", "| 2 | 84 | \"M\" |\n", "| 3 | 59 | \"-3\" |\n", "| 4 | 60 | \"M\" |\n", "| 5 | 66 | \" 2\" |\n", "| 6 | 67 | \"M\" |\n", "| 7 | 66 | \" 4\" |\n", "| 8 | 78 | \"M\" |\n", "| 9 | 66 | \" 5\" |\n", "| 10 | 66 | \"M\" |\n", "| 11 | 68 | \" 4\" |\n", "⋮\n", "| 2933 | 64 | \" 5\" |\n", "| 2934 | 66 | \"M\" |\n", "| 2935 | 77 | \"16\" |\n", "| 2936 | 79 | \"M\" |\n", "| 2937 | 68 | \"10\" |\n", "| 2938 | 66 | \"M\" |\n", "| 2939 | 49 | \"-4\" |\n", "| 2940 | 49 | \"M\" |\n", "| 2941 | 51 | \"-4\" |\n", "| 2942 | 53 | \"M\" |\n", "| 2943 | 47 | \"-6\" |\n", "| 2944 | 49 | \"M\" |" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[:,[:Tmax,:Depart]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Rows can be selected using selection criteria" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
StationDayTmaxTminTavgDepartDewPointWetBulbHeatCoolSunriseSunsetCodeSumDepthWater1SnowFallPrecipTotalStnPressureSeaLevelResultSpeedResultDirAvgSpeed
" ], "text/plain": [ "0x22 DataFrame\n" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df[:Tavg].==68,:]" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "11-element DataArray{UTF8String,1}:\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"\n", " \"M\"" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df[:Cool].==\"M\",:Cool] " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###you can assing a value to each element of a DataArray" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "collapsed": false }, "outputs": [ { "ename": "TypeError", "evalue": "type: non-boolean (NAtype) used in boolean context", "output_type": "error", "traceback": [ "type: non-boolean (NAtype) used in boolean context", "" ] } ], "source": [ "df[df[:Cool].==\"M\",:Cool] = NA" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###Here we change all \"M\" values to NA" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "df = readtable(\"input/weather.csv\")\n", "for name in names(df)\n", " df[df[name].==\"M\",name] = NA\n", "end" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "###The RDatasets package provides plenty of Data to play with" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": true }, "outputs": [], "source": [ "using RDatasets" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
PackageTitle
1COUNTFunctions, data and code for count data.
2EcdatData sets for econometrics
3HSAURA Handbook of Statistical Analyses Using R (1st Edition)
4HistDataData sets from the history of statistics and data visualization
5ISLRData for An Introduction to Statistical Learning with Applications in R
6KMsurvData sets from Klein and Moeschberger (1997), Survival Analysis
7MASSSupport Functions and Datasets for Venables and Ripley's MASS
8SASmixedData sets from \"SAS System for Mixed Models\"
9ZeligEveryone's Statistical Software
10adehabitatLTAnalysis of Animal Movements
11bootBootstrap Functions (Originally by Angelo Canty for S)
12carCompanion to Applied Regression
13clusterCluster Analysis Extended Rousseeuw et al.
14datasetsThe R Datasets Package
15gapGenetic analysis package
16ggplot2An Implementation of the Grammar of Graphics
17latticeLattice Graphics
18lme4Linear mixed-effects models using Eigen and S4
19mgcvMixed GAM Computation Vehicle with GCV/AIC/REML smoothness estimation
20mlmRevExamples from Multilevel Modelling Software Review
21nlregHigher Order Inference for Nonlinear Heteroscedastic Models
22plmLinear Models for Panel Data
23plyrTools for splitting, applying and combining data
24psclPolitical Science Computational Laboratory, Stanford University
25psychProcedures for Psychological, Psychometric, and Personality Research
26quantregQuantile Regression
27reshape2Flexibly Reshape Data: A Reboot of the Reshape Package.
28robustbaseBasic Robust Statistics
29rpartRecursive Partitioning and Regression Trees
30sandwichRobust Covariance Matrix Estimators
" ], "text/plain": [ "33x2 DataFrame\n", "| Row | Package |\n", "|-----|----------------|\n", "| 1 | \"COUNT\" |\n", "| 2 | \"Ecdat\" |\n", "| 3 | \"HSAUR\" |\n", "| 4 | \"HistData\" |\n", "| 5 | \"ISLR\" |\n", "| 6 | \"KMsurv\" |\n", "| 7 | \"MASS\" |\n", "| 8 | \"SASmixed\" |\n", "| 9 | \"Zelig\" |\n", "| 10 | \"adehabitatLT\" |\n", "| 11 | \"boot\" |\n", "⋮\n", "| 22 | \"plm\" |\n", "| 23 | \"plyr\" |\n", "| 24 | \"pscl\" |\n", "| 25 | \"psych\" |\n", "| 26 | \"quantreg\" |\n", "| 27 | \"reshape2\" |\n", "| 28 | \"robustbase\" |\n", "| 29 | \"rpart\" |\n", "| 30 | \"sandwich\" |\n", "| 31 | \"sem\" |\n", "| 32 | \"survival\" |\n", "| 33 | \"vcd\" |\n", "\n", "| Row | Title |\n", "|-----|---------------------------------------------------------------------------|\n", "| 1 | \"Functions, data and code for count data.\" |\n", "| 2 | \"Data sets for econometrics\" |\n", "| 3 | \"A Handbook of Statistical Analyses Using R (1st Edition)\" |\n", "| 4 | \"Data sets from the history of statistics and data visualization\" |\n", "| 5 | \"Data for An Introduction to Statistical Learning with Applications in R\" |\n", "| 6 | \"Data sets from Klein and Moeschberger (1997), Survival Analysis\" |\n", "| 7 | \"Support Functions and Datasets for Venables and Ripley's MASS\" |\n", "| 8 | \"Data sets from \\\"SAS System for Mixed Models\\\"\" |\n", "| 9 | \"Everyone's Statistical Software\" |\n", "| 10 | \"Analysis of Animal Movements\" |\n", "| 11 | \"Bootstrap Functions (Originally by Angelo Canty for S)\" |\n", "⋮\n", "| 22 | \"Linear Models for Panel Data\" |\n", "| 23 | \"Tools for splitting, applying and combining data\" |\n", "| 24 | \"Political Science Computational Laboratory, Stanford University\" |\n", "| 25 | \"Procedures for Psychological, Psychometric, and Personality Research\" |\n", "| 26 | \"Quantile Regression\" |\n", "| 27 | \"Flexibly Reshape Data: A Reboot of the Reshape Package.\" |\n", "| 28 | \"Basic Robust Statistics\" |\n", "| 29 | \"Recursive Partitioning and Regression Trees\" |\n", "| 30 | \"Robust Covariance Matrix Estimators\" |\n", "| 31 | \"Structural Equation Models\" |\n", "| 32 | \"Survival Analysis\" |\n", "| 33 | \"Visualizing Categorical Data\" |" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "RDatasets.packages()" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
PackageDatasetTitleRowsColumns
1COUNTaffairsaffairs60118
2COUNTazdrg112azdrg11217984
3COUNTazproazpro35896
4COUNTbadhealthbadhealth11273
5COUNTfasttrakgfasttrakg159
6COUNTlbwlbw18910
7COUNTlbwgrplbwgrp67
8COUNTloomisloomis41011
9COUNTmdvismdvis222713
10COUNTmedparmedpar149510
11COUNTrwmrwm273264
12COUNTrwm5yrrwm5yr1960917
13COUNTshipsships407
14COUNTtitanictitanic13164
15COUNTtitanicgrptitanicgrp125
" ], "text/plain": [ "15x5 DataFrame\n", "| Row | Package | Dataset | Title | Rows | Columns |\n", "|-----|---------|--------------|--------------|-------|---------|\n", "| 1 | \"COUNT\" | \"affairs\" | \"affairs\" | 601 | 18 |\n", "| 2 | \"COUNT\" | \"azdrg112\" | \"azdrg112\" | 1798 | 4 |\n", "| 3 | \"COUNT\" | \"azpro\" | \"azpro\" | 3589 | 6 |\n", "| 4 | \"COUNT\" | \"badhealth\" | \"badhealth\" | 1127 | 3 |\n", "| 5 | \"COUNT\" | \"fasttrakg\" | \"fasttrakg\" | 15 | 9 |\n", "| 6 | \"COUNT\" | \"lbw\" | \"lbw\" | 189 | 10 |\n", "| 7 | \"COUNT\" | \"lbwgrp\" | \"lbwgrp\" | 6 | 7 |\n", "| 8 | \"COUNT\" | \"loomis\" | \"loomis\" | 410 | 11 |\n", "| 9 | \"COUNT\" | \"mdvis\" | \"mdvis\" | 2227 | 13 |\n", "| 10 | \"COUNT\" | \"medpar\" | \"medpar\" | 1495 | 10 |\n", "| 11 | \"COUNT\" | \"rwm\" | \"rwm\" | 27326 | 4 |\n", "| 12 | \"COUNT\" | \"rwm5yr\" | \"rwm5yr\" | 19609 | 17 |\n", "| 13 | \"COUNT\" | \"ships\" | \"ships\" | 40 | 7 |\n", "| 14 | \"COUNT\" | \"titanic\" | \"titanic\" | 1316 | 4 |\n", "| 15 | \"COUNT\" | \"titanicgrp\" | \"titanicgrp\" | 12 | 5 |" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "RDatasets.datasets(\"COUNT\")" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
LowSmokeRaceAgeLWtPTLHtUIFTVBWt
10021918200102523
20033315500032551
30112010500012557
40112110800122594
50111810700102600
60032112400002622
70012211800012637
80031710300012637
90112912300012663
100112611300002665
11003199500002722
120031915000012733
13003229501002750
140033010710122750
150111810000002769
160111810000002769
17002159800002778
180112511800032782
190032012000102807
200112812000012821
210033212100022835
220013110000132835
230013620200012836
240032812000002863
250032512000122877
260012816700002877
270111712200002906
280012915000022920
290122616800002920
300021711300012920
" ], "text/plain": [ "189x10 DataFrame\n", "| Row | Low | Smoke | Race | Age | LWt | PTL | Ht | UI | FTV | BWt |\n", "|-----|-----|-------|------|-----|-----|-----|----|----|-----|------|\n", "| 1 | 0 | 0 | 2 | 19 | 182 | 0 | 0 | 1 | 0 | 2523 |\n", "| 2 | 0 | 0 | 3 | 33 | 155 | 0 | 0 | 0 | 3 | 2551 |\n", "| 3 | 0 | 1 | 1 | 20 | 105 | 0 | 0 | 0 | 1 | 2557 |\n", "| 4 | 0 | 1 | 1 | 21 | 108 | 0 | 0 | 1 | 2 | 2594 |\n", "| 5 | 0 | 1 | 1 | 18 | 107 | 0 | 0 | 1 | 0 | 2600 |\n", "| 6 | 0 | 0 | 3 | 21 | 124 | 0 | 0 | 0 | 0 | 2622 |\n", "| 7 | 0 | 0 | 1 | 22 | 118 | 0 | 0 | 0 | 1 | 2637 |\n", "| 8 | 0 | 0 | 3 | 17 | 103 | 0 | 0 | 0 | 1 | 2637 |\n", "| 9 | 0 | 1 | 1 | 29 | 123 | 0 | 0 | 0 | 1 | 2663 |\n", "| 10 | 0 | 1 | 1 | 26 | 113 | 0 | 0 | 0 | 0 | 2665 |\n", "| 11 | 0 | 0 | 3 | 19 | 95 | 0 | 0 | 0 | 0 | 2722 |\n", "⋮\n", "| 178 | 1 | 1 | 1 | 17 | 120 | 0 | 0 | 0 | 3 | 2414 |\n", "| 179 | 1 | 1 | 1 | 23 | 110 | 1 | 0 | 0 | 0 | 2424 |\n", "| 180 | 1 | 0 | 2 | 17 | 120 | 0 | 0 | 0 | 2 | 2438 |\n", "| 181 | 1 | 0 | 3 | 26 | 154 | 1 | 1 | 0 | 1 | 2442 |\n", "| 182 | 1 | 0 | 3 | 20 | 106 | 0 | 0 | 0 | 3 | 2450 |\n", "| 183 | 1 | 1 | 1 | 26 | 190 | 0 | 0 | 0 | 0 | 2466 |\n", "| 184 | 1 | 1 | 3 | 14 | 101 | 1 | 0 | 0 | 0 | 2466 |\n", "| 185 | 1 | 1 | 1 | 28 | 95 | 0 | 0 | 0 | 2 | 2466 |\n", "| 186 | 1 | 0 | 3 | 14 | 100 | 0 | 0 | 0 | 2 | 2495 |\n", "| 187 | 1 | 1 | 3 | 23 | 94 | 0 | 0 | 0 | 0 | 2495 |\n", "| 188 | 1 | 0 | 2 | 17 | 142 | 0 | 1 | 0 | 0 | 2495 |\n", "| 189 | 1 | 1 | 1 | 21 | 130 | 0 | 1 | 0 | 3 | 2495 |" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lbw = dataset(\"COUNT\", \"lbw\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Julia 0.3.8", "language": "julia", "name": "julia-0.3" }, "language_info": { "name": "julia", "version": "0.3.8" } }, "nbformat": 4, "nbformat_minor": 0 }