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

labkey.importRows

Import rows of data into a LabKey Server


Description

Bulk import rows of data into the database.

Usage

labkey.importRows(baseUrl, folderPath,
    schemaName, queryName, toImport, na)

Arguments

baseUrl

a string specifying the baseUrlfor the labkey server

folderPath

a string specifying the folderPath

schemaName

a string specifying the schemaName for the query

queryName

a string specifying the queryName

toImport

a data frame containing rows of data to be imported

na

(optional) the value to convert NA's to, defaults to NULL

Details

Multiple rows of data can be imported in bulk. The toImport data frame must contain values for each column in the dataset and must be created with the stringsAsFactors option set to FALSE. The names of the data in the data frame must be the column names from the LabKey Server.To import a value of NULL, use an empty string ("") in the data frame (regardless of the database column type). Also, when importing data into a study dataset, the sequence number must be specified.

Note: requires LabKey server version 13.3 or greater.

Value

A list is returned with named categories of command, rowsAffected, queryName, containerPath and schemaName. The schemaName, queryName and containerPath properties contain the same schema, query and folder path used in the request. The rowsAffected property indicates the number of rows affected by the API action. This will typically be the same number as passed in the request.

Author(s)

Cory Nathe

See Also

Examples

## Note that users must have the necessary permissions in the database
## to be able to modify data through the use of these functions
# library(Rlabkey)

newrows <- data.frame(
	DisplayFld="Imported from R"
	, RequiredText="abc"
	, RequiredInt=1
	, stringsAsFactors=FALSE)
newrows = newrows[rep(1:nrow(newrows),each=5),]

importedInfo <- labkey.importRows("http://localhost:8080/labkey",
    folderPath="/apisamples", schemaName="lists", queryName="AllTypes",
    toImport=newrows)

importedInfo$rowsAffected

Rlabkey

Data Exchange Between R and 'LabKey' Server

v2.6.0
Apache License 2.0
Authors
Peter Hussey
Initial release
2021-02-02

We don't support your browser anymore

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