writePos: Function to write plain text data file like .dat or .asc...

Description Usage Arguments Value Examples

View source: R/readPos.R

Description

Function to write plain text data file like .dat or .asc delimited by positions fixen in csv definition file.

Usage

1
writePos(df, file, positions)

Arguments

df

Data frame where data is stored. Each column in input data frame will be a variable in plain text data file output.

file

Path with the name of the file that will be generated.

positions

Path of a csv that specifies the name of the variable, type and positions where data will be stored in data file. The csv must be the following structure, otherwise this function will not work: Four five columns (you can add more at the rigth of these four, they will be not used but can help you to add comments or somewhat) 1 - variables: that column contains the name of the variables to write. Text written here must match with some column name of the data frame. Names don't allow blank spaces, you must replace it with other character. 2 - type: specifies the type of the variable, allows "character", "single", "multiple" or "numeric". 3 - start: positions that starts the range of data that will definie the variable. 4 - finish: positions that finish the range of data that will definie the variable. 5 - aligment: with "left" or "right" allowed values. Indicates where data will aligment in the positions range defined. Default value is "left" when the camp is empty.

Value

A plain text data file like .asc or .dat that got the information of each data frame's column in sepecified positions by csv.

Examples

1
2
3
4
5
6
7
8
readPos(datasource = "C:/Desktop/datum.dat", positions = "C:/Documents/map.csv" )

CSV structure example(headers must be like this): 

   variable,type,start,finish,alignment
   sex,single,5,6,right
   age,numeric,12,14,
   satisfaction,character,75,100,left

ODECdmorales/readPos documentation built on Oct. 30, 2019, 10:19 p.m.