Learn R Programming

shotGroups (version 0.2-2)

readDataOT2: Read data files exported by OnTarget PC v2.10 or OnTarget TDS v3.71

Description

Reads in data from files exported by OnTarget PC v2.10 or OnTarget TDS v3.71. Several files can be read with one call.

Usage

readDataOT2(fPath = getwd(), fNames, fPat, combine = FALSE)

Arguments

fPath
a character string containing the path to the folder with the OnTarget PC/TDS output files, e.g. 'c:/folder/otFiles'.
fNames
a character vector containing the file names of the files that should be read in.
fPat
a character string containing the regular-expression that describes all names of files that should be read in. E.g., '^points[[:digit:]]{2}\\.txt$' for filenames 'points**.txt', where ** are 2 digits. See
combine
a logical value indicating whether the data should be combined into one big data frame with combineData.

Value

  • With combine=FALSE: a list of data frames, each from one file that was read in. This list can then be combined into one big data frame by combineData.
  • file1data frame containing data from the first file
  • file2data frame containing data from the second file
  • ...more data frames
  • With combine=TRUE: a combined data frame from combineData.

Details

If fNames is provided, fPat is ignored. If neither fNames nor fPat is provided, and we are in interactive mode under Windows, files can be chosen interactively. This function is basically a wrapper for read.csv. Output files need to be comma-separated files from OnTarget PC v2.10 or OnTarget TDS v3.71: 'Tools -> Export Point Data'. Files need to contain exactly the following variable names in this order: Project Title, Group, Ammunition, Distance, Aim X, Aim Y, Center X, Center Y, Point X, Point Y. For reading in files exported from OnTarget PC v1.10, see readDataOT1. For reading in other tab-delimited text files, see readDataMisc.

See Also

read.csv, regex, glob2rx, combineData, readDataOT1, readDataMisc

Examples

Run this code
# folder with OnTarget PC v2.10 or OnTarget TDS v3.71 output files
fPath   <- 'c:/folder/otFiles'
fileNam <- c('pts01.csv', 'pts02.csv')   # desired files in that folder
DFlist  <- readDataOT2(path, fNames=fileNam, combine=FALSE)

## alternatively specify filename pattern for all files to be read in
fPath  <- 'c:/folder/otFiles'            # folder with data files
fPat   <- '^pts[[:digit:]]{2}\\.txt$'  # filename pattern
DFlist <- readDataOT2(path, fPat=pattern, combine=FALSE)

## result should look like this
data(DFlistInch)

## overview over list
sapply(DFlistInch, dim)                  # number of obs and vars
str(DFlistInch)                          # variables in each data frame
lapply(DFlistInch, head)                 # first rows in each data frame

Run the code above in your browser using DataLab