R: Read a data set from a data-sheet and turn it into a...

set_read {bioset} | R Documentation

## Read a data set from a data-sheet and turn it into a multi-column tibble.

### Description

Read a matrix of values from a csv sheet and sort them into a tibble. You can name the values and encode several additional properties into the name, which be split into several columns. Please refer to the vignette (`browseVignettes("roxygen2")`) and examples below for in-depth explanation and the whys and hows.

### Usage

    set_read(file_name = "set_#NUM#.csv", path = ".", num = 1, sep = ",",
      dec = ".", cols = 0, rows = 0, additional_vars = vector(),
      additional_sep = "[^[:alnum:]]+")

### Arguments

`file_name` | Name of the file from which to read the data. May contain "#NUM#" as a placeholder if you have multiple files.
`path` | The path to the file (no trailing "/" or "\" !).
`num` | Number of the set to read, inserted for "#NUM#".
`sep` | Separator used in the csv-file, either "," or ";" (see `utils::read.csv()`).
`dec` | The character used for decimal points (see `utils::read.csv()`). "AUTO" will result in "." if `sep` is "," and "," for ";".
`cols` | Number of columns in the input matrix (`0` means auto-detect).
`rows` | Number of rows containing values (not names / additional data) in the input matrix (`0` means auto-detect).
`additional_vars` | Vector of strings containing the names for the additional columns.
`additional_sep` | String / RegExp that separates additional vars, e.g.: `"ID_blue_cold"` with `additional_sep = "_"` will be separated into three columns containing `"ID"`, `"blue"` and `"cold"`. If the separated data would exceed the columns in `additional_vars` the last column will contain a string with separator (e.g.: `"blue_cold"`). If data is missing `NA` is inserted.

### Value

A tibble containing (at minimum) `set`, `position`, `sample_id`, `name` and `value`.

### See Also

Other set functions: `set_calc_concentrations`, `set_calc_variability`, `sets_read`

### Examples

    # a file containing only values
    read.csv(
      file = system.file("extdata", "values.csv", package = "bioset"),
      header = FALSE,
      colClasses = "character"
    )

    # read into a tibble
    set_read(
      file_name = "values_names.csv",
      path = system.file("extdata", package = "bioset"),
    )

    # file containing names
    read.csv(
      file = system.file("extdata", "values_names.csv", package = "bioset"),
      header = FALSE,
      colClasses = "character"
    )

    # read a file containing labels and store those in column "name"
    set_read(
      file_name = "values_names.csv",
      path = system.file("extdata", package = "bioset"),
      additional_vars = c("name")
    )

    # file with names and properties
    read.csv(
      file = system.file(
        "extdata", "values_names_properties.csv", package = "bioset"),
      header = FALSE,
      colClasses = "character"
    )

    # read a file containing labels and properties and store those in columns
    # "name" and "time"
    # splits names by every character that's not A-Z, a-z, 0-9
    # to change that behaviour use additional_sep
    set_read(
      file_name = "values_names_properties.csv",
      path = system.file("extdata", package = "bioset"),
      additional_vars = c("name", "time")
    )

    # read file "set_1.csv" containing labels
    set_read(
      num = 1,
      path = system.file("extdata", package = "bioset"),
      additional_vars = c("name", "time")
    )

    # read file "set_2.csv" containing labels
    set_read(
      num = 2,
      path = system.file("extdata", package = "bioset"),
      additional_vars = c("name", "time")
    )

    # read file "plate_2.csv" containing labels
    set_read(
      num = 2,
      file_name = "plate_#NUM#.csv",
      path = system.file("extdata", package = "bioset"),
      additional_vars = c("name", "time")
    )

[Package bioset version 0.2.2 Index]