Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 789e1b6e authored by Ben Anderson's avatar Ben Anderson
Browse files

added R project for data exploration

parent e099fd43
.Rproj.user
.Rhistory
.RData
############################################
# ONS Time Use 2000 data
# Explorations using R
#
# Copyright (C) 2014 University of Southampton
#
# Author: Ben Anderson (b.anderson@soton.ac.uk, @dataknut, https://github.com/dataknut)
# [Energy & Climate Change, Faculty of Engineering & Environment, University of Southampton]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License
# (http://choosealicense.com/licenses/gpl-2.0/), or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#YMMV - http://en.wiktionary.org/wiki/YMMV
############################################
# To do:
# prelims -----------------------------------------------------------------
# clear out all old objects etc to avoid confusion
rm(list = ls())
# load required packages
x <- c("foreign","reshape")
lapply(x, require, character.only = T)
# paths to data
dpath <- "/Users/ben/Documents/Work/Data/Social Science Datatsets/Time Use 2005/UKDA-5592-stata8-v2/stata8"
opath <- "/Users/ben/Documents/Work/Data/Social Science Datatsets/Time Use 2005/processed"
# load wide form data -----------------------------------------------------------------
# this has data in 10 minute time slots
onstu2005_wide <- read.dta(paste0(dpath, "/timeusefinal_for_archive2.dta"))
head(onstu2005_wide, n = 2)
#onstu2005_melted <- melt(onstu2005_wide, id=c("serial","time"))
# get the list of columns that have the location and activities
# why can't R do 'normal' variable name wildcarding?!
lact_cols <- grep("\\blact.", names(onstu2005_wide))
pact_cols <- grep("\\bpact.", names(onstu2005_wide))
sact_cols <- grep("\\bsact.", names(onstu2005_wide))
# in theory this should create a long form file
onstu2005_long <-reshape(onstu2005_wide, varying=c(lact_cols,pact_cols,sact_cols), direction="long", idvar="serial", sep="")
############################################
# ONS Time Use 2000 data
# Explorations using R
# - using TraMineR to examine sequences
#
# Copyright (C) 2014 University of Southampton
#
# Author: Ben Anderson (b.anderson@soton.ac.uk, @dataknut, https://github.com/dataknut)
# [Energy & Climate Change, Faculty of Engineering & Environment, University of Southampton]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License
# (http://choosealicense.com/licenses/gpl-2.0/), or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#YMMV - http://en.wiktionary.org/wiki/YMMV
############################################
# To do:
# prelims -----------------------------------------------------------------
# clear out all old objects etc to avoid confusion
rm(list = ls())
# load required packages
x <- c("foreign")
lapply(x, require, character.only = T)
# paths to data
dpath <- "/Users/ben/Documents/Work/Data/Social Science Datatsets/Time Use 2005/processed"
# load long form data -----------------------------------------------------------------
# this has data in 10 minute time slots
onstu2005_long <- read.dta(paste0(dpath, "/timeusefinal_for_archive_diary_long_v2.0.dta"))
head(onstu2005_long, n = 2)
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment