fillCSVData: Imports data from a CSV file and sort it by the first column

Description Usage Arguments Value Author(s) Examples

View source: R/lmafunctions.r

Description

This function open a CSV, copies its first three columns to a data set and then sort it by the first column, the function assumes the first column is the X values, the second one the Y values and the third one to be the weights column and names these columns accordingly

Usage

1

Arguments

str

A string containing the full path of the CSV file to be imported, should be left blank if manual data entry is desired

head

A boolean variable indicating if the imported CSV file has a header row or not, ignored if str is null

Value

A data set sorted by the first column

Author(s)

Tal Carmi, Liat Gaziel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#Assuming there is a three column csv in C drive named "data.csv" with no header
#mydata<-fillCSVData("c:/data.csv",FALSE)

## The function is currently defined as
function (str, head) 
{
    mat <- read.table(str, header = head, sep = ",")
    names(mat)[1] = "X"
    names(mat)[2] = "Y"
    if ((is.null(mat[1, 3]) && is.null(mat[2, 3])) || (mat[1, 
        3] == 0 && mat[2, 3] == 0)) 
        mat <- calcWeights(mat)
    names(mat)[3] = "Weights"
    mat <- mat[order(mat[1]), ]
    return(mat)
  }

ACCLMA documentation built on May 29, 2017, 10:52 p.m.