texttordata {CTFS} | R Documentation

## Creates CTFS R dataset from any tab delimited text file

### Description

Creates an rdata file from a text file and makes the first column the rownames, effectively duplicating the information in the first column.

### Usage

    texttordata(text.in,missvalue=NA)

### Arguments

`text.in` | any text file with defined columns, file name must be in quotes. Either change to the directory in which the file is located or provide the full path name and file name in quotes. Use `getwd` to find out the full path name if necessary to use, or use `setwd` to change to the directory where the text file is located.
`missvalue` | any value that should be considered missing and replaced with NA. `missvalue` can be a vector of strings which are to be interpreted as NA values. Blank or empty fields are also considered to be missing values.

### Details

Rownames are numbers. Column names are taken from the first row in the text file. This function uses the R function `read.table`. If the default values of `texttordata` are not sufficient, read the help pages for `read.table`.

      read.table(text.in,as.is=TRUE,header=TRUE,sep="\t",quote="",comment.char="",na.strings=missvalue)

`as.is` indicates that variable formats should be retained `header` indicates that the first row of the text file provides the column (variable) names `sep` indicates the separator, default is `tab`

### Value

Returns a dataframe with rownames as an additional column.

### Author(s)

Rick Condit

### See Also

`CTFS.readwrite`

### Examples

    ## Not run:
    > texttordata("bcispp.info.txt",missvalue=c("."))->info.test
    > str(info.test)
    `data.frame':   318 obs. of  8 variables:
     $ sp      : chr  "acacme" "acaldi" "acalma" "ade1tr" ...
     $ genus   : chr  "Acacia" "Acalypha" "Acalypha" "Adelia" ...
     $ species : chr  "melanoceras" "diversifolia" "macrostachya" "triloba" ...
     $ family  : chr  "Fabaceae:Mimos." "Euphorbiaceae" "Euphorbiaceae" "Euphorbiaceae" ...
     $ grform  : chr  "U" "S" "U" "U" ...
     $ repsize : int  4 2 2 10 4 20 16 4 4 20 ...
     $ breedsys: chr  "B" "M" "M" "D" ...
     $ maxht   : int  6 6 5 5 15 15 -1 6 10 15 ...
    > info.test[1:10,]
           sp      genus       species          family grform repsize breedsys maxht
    1  acacme     Acacia   melanoceras Fabaceae:Mimos.      U       4        B     6
    2  acaldi   Acalypha  diversifolia   Euphorbiaceae      S       2        M     6
    3  acalma   Acalypha  macrostachya   Euphorbiaceae      U       2        M     5
    4  ade1tr     Adelia       triloba   Euphorbiaceae      U      10        D     5
    5  aegipa  Aegiphila    panamensis     Verbenaceae      M       4        B    15
    6  alchco  Alchornea costaricensis   Euphorbiaceae      T      20        D    15
    7  alchla  Alchornea     latifolia   Euphorbiaceae      M      16        D    -1
    8  alibed  Alibertia        edulis       Rubiaceae      U       4        D     6
    9  allops Allophylus  psilospermus     Sapindaceae      M       4        P    10
    10 alsebl     Alseis     blackiana       Rubiaceae      T      20        B    15
    ...
    ## End(Not run)

[Package CTFS version 1.00 Index]