# basic
tabular <- BIDSTabularSamples(
data.frame(
sample_id = "sample-001",
participant_id = "sub-001",
sample_type = "cell line"
)
)
tabular
# convert existing tabular
tabular <- BIDSTabular(
data.frame(
sample_id = "sample-001",
participant_id = "sub-001",
sample_type = "cell line"
)
)
tabular <- as_bids_tabular(tabular, cls = BIDSTabularSamples)
# save to tsv
tsv <- file.path(tempdir(), "samples.tsv")
paths <- save_bids_tabular(tabular, tsv)
print(paths)
# use base R to read
read.table(tsv, header = TRUE, na.strings = "n/a")
# get sidecar
cat(readLines(paths$sidecar_path), sep = "\n")
# clean up
unlink(tsv)
unlink(paths$sidecar_path)
Run the code above in your browser using DataLab