fillCSVData {ACCLMA}R Documentation

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

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

fillCSVData(str, head)

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

#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)
  }

[Package ACCLMA version 1.0 Index]