-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
131 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' @name statascraper-package | ||
#' @docType package | ||
#' @title statascraper is an R package that extracts tables from STATA log files | ||
#' @description This package scrapes STATA log files, looks for tables generated | ||
#' by tab, tabstat, list, reg, and areg and then returns these tables as R | ||
#' matrices or stores them as comma separated value files. This package can be | ||
#' useful, when researchers (have to) use STATA to work with data sets but | ||
#' want to use R to analyze and display results. | ||
#' @author Jan Tilly | ||
#' @examples | ||
#' # In this example, we scrape the Stata log file "test.log" that was created | ||
#' # by "stata.do" | ||
#' | ||
#' # point to stata log file | ||
#' logfile = paste(system.file("example", package = "statascraper"), | ||
#' "test.log", sep = .Platform$file.sep) | ||
#' | ||
#' # read tab commands | ||
#' read.tab(filename = logfile, outdir = ".", RData = TRUE, tag = "tab2r") | ||
#' head(load.RData("tab.RData")) | ||
#' head(load.RData("tabsum.RData")) | ||
#' | ||
#' # read tabstat commands | ||
#' read.tabstat(filename = logfile, outdir = ".", RData = TRUE, tag = "tabstat2r") | ||
#' head(load.RData("tabstat.RData")) | ||
#' | ||
#' # read list commands | ||
#' read.list(filename = logfile, outdir = ".", RData = TRUE, tag = "list2r") | ||
#' head(load.RData("list.RData")) | ||
NULL |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
% Generated by roxygen2 (4.1.1): do not edit by hand | ||
% Please edit documentation in R/utils.R | ||
\name{load.RData} | ||
\alias{load.RData} | ||
\title{Helper function that loads a specific file and returns the variables therein} | ||
\usage{ | ||
load.RData(filename) | ||
} | ||
\arguments{ | ||
\item{filename}{The path to the RData file} | ||
} | ||
\value{ | ||
Returns the content of the RData file as data frame | ||
} | ||
\description{ | ||
Helper function that loads a specific file and returns the variables therein | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
% Generated by roxygen2 (4.1.1): do not edit by hand | ||
% Please edit documentation in R/read.list.R | ||
\name{read.list} | ||
\alias{read.list} | ||
\title{Read list} | ||
\usage{ | ||
read.list(filename, outdir = ".", RData = FALSE, tag = "list2csv") | ||
} | ||
\arguments{ | ||
\item{filename}{The filename of the STATA log file} | ||
|
||
\item{outdir}{Directory for output} | ||
|
||
\item{RData}{store output in RData} | ||
|
||
\item{tag}{specifies what tag to look for in the STATA log file} | ||
} | ||
\description{ | ||
Reads STATA tables created by \code{list x y}. For each \code{list} command found, this function will create a CSV or RData file. | ||
For this function to work there must be a statement | ||
\code{di "{tag} filename.csv"} preceding every \code{list} command, where | ||
\code{{tag}} is defined in the argument to this function. | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
% Generated by roxygen2 (4.1.1): do not edit by hand | ||
% Please edit documentation in R/readLog.R | ||
% Please edit documentation in R/read.tab.R | ||
\name{read.tab} | ||
\alias{read.tab} | ||
\title{Read tab} | ||
\usage{ | ||
read.tab(filename, outdir = ".", RData = FALSE) | ||
read.tab(filename, outdir = ".", RData = FALSE, tag = "tab2csv") | ||
} | ||
\arguments{ | ||
\item{filename}{The filename of the STATA log file} | ||
|
||
\item{outdir}{Directory for output} | ||
|
||
\item{RData}{store output in RData} | ||
|
||
\item{tag}{specifies what tag to look for in the STATA log file} | ||
} | ||
\description{ | ||
Reads STATA tables created by \code{tab x y} and \code{tab x, sum(y)}. For | ||
each \code{tab} command found, this function will create a CSV or RData file. | ||
For this function to work there must be a statement | ||
\code{di "tab2csv filename.csv"} preceding every \code{tab} command. | ||
\code{di "{tag} filename.csv"} preceding every \code{tab} command. | ||
} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
% Generated by roxygen2 (4.1.1): do not edit by hand | ||
% Please edit documentation in R/statascraper.R | ||
\docType{package} | ||
\name{statascraper-package} | ||
\alias{statascraper-package} | ||
\title{statascraper is an R package that extracts tables from STATA log files} | ||
\description{ | ||
This package scrapes STATA log files, looks for tables generated | ||
by tab, tabstat, list, reg, and areg and then returns these tables as R | ||
matrices or stores them as comma separated value files. This package can be | ||
useful, when researchers (have to) use STATA to work with data sets but | ||
want to use R to analyze and display results. | ||
} | ||
\examples{ | ||
# In this example, we scrape the Stata log file "test.log" that was created | ||
# by "stata.do" | ||
|
||
# point to stata log file | ||
logfile = paste(system.file("example", package = "statascraper"), | ||
"test.log", sep = .Platform$file.sep) | ||
|
||
# read tab commands | ||
read.tab(filename = logfile, outdir = ".", RData = TRUE, tag = "tab2r") | ||
head(load.RData("tab.RData")) | ||
head(load.RData("tabsum.RData")) | ||
|
||
# read tabstat commands | ||
read.tabstat(filename = logfile, outdir = ".", RData = TRUE, tag = "tabstat2r") | ||
head(load.RData("tabstat.RData")) | ||
|
||
# read list commands | ||
read.list(filename = logfile, outdir = ".", RData = TRUE, tag = "list2r") | ||
head(load.RData("list.RData")) | ||
} | ||
\author{ | ||
Jan Tilly | ||
} | ||
|
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