labkey.query.import {Rlabkey}R Documentation

Bulk import an R data frame into a LabKey Server table using file import.

Description

Bulk import an R data frame into a LabKey Server table using file import.

Usage

labkey.query.import(baseUrl, folderPath,
    schemaName, queryName, toImport, options = NULL)

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

options

(optional) a list containing options specific to the import action of the query

Details

This command mimics the "Import bulk data" option that you see in the LabKey server UI for a table/query. It takes the passed in toImport data frame and writes it to a temp file to be posted to the import action for the given LabKey query. It is very similar to the labkey.importRows command but will be much more performant.

Multiple rows of data can be imported in bulk using the toImport data frame. The names of the data in the data frame must be the column names from the LabKey Server.

LabKey data types support different import options. The list of valid options for each query will vary, but some common examples include:

Value

A list is returned with the row count for the number of affected rows. If options are provided, additional details may be included in the response object related to those options.

Author(s)

Cory Nathe

See Also

labkey.insertRows, labkey.updateRows, labkey.importRows

Examples

## Not run: 

## 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)

df <- data.frame(
    name=c("test1","test2","test3"),
    customInt=c(1:3),
    customString=c("aaa", "bbb", "ccc")
)

importedInfo <- labkey.query.import(
    "http://localhost:8080/labkey",
    folderPath="/apisamples", schemaName="samples", queryName="SampleType1",
    toImport=df, options=list(insertOption = "MERGE", auditBehavior = "DETAILED")
)

importedInfo$rowCount


## End(Not run)

[Package Rlabkey version 3.2.1 Index]