Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

assign-sample_data

Assign (new) sample_data to x


Description

This replaces the current sample_data component of x with value, if value is a sample_data-class. However, if value is a data.frame, then value is first coerced to a sample_data-class, and then assigned. Alternatively, if value is phyloseq-class, then the sample_data component will first be accessed from value and then assigned. This makes possible some concise assignment/replacement statements when adjusting, modifying, or building subsets of experiment-level data. See some examples below.

Internally, this re-builds the phyloseq-class object using the standard phyloseq constructor. Thus, index mismatches between sample-describing components will not be allowed, and subsetting will occurr automatically such that only the intersection of sample IDs are included in any components. This has the added benefit of re-checking (internally) for any other issues.

Usage

sample_data(x) <- value

Arguments

x

(Required). phyloseq-class. The object to modify.

value

(Required). Either a sample_data-class, a data.frame that can be coerced into sample_data-class, or a phyloseq-class that contains a suitable sample_data component to assign to x. If unsure, try sample_data(value), which should return a sample_data-class object without error.

Value

No return. This is an assignment statement.

Examples

data(soilrep)
 soilrep
 head(sample_data(soilrep))
 sample_data(soilrep)$Time <- as.integer(substr(sample_data(soilrep)$Sample, 1, 1))
 head(sample_data(soilrep))

phyloseq

Handling and analysis of high-throughput microbiome census data

v1.34.0
AGPL-3
Authors
Paul J. McMurdie <joey711@gmail.com>, Susan Holmes <susan@stat.stanford.edu>, with contributions from Gregory Jordan and Scott Chamberlain
Initial release
2019-04-23

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.