labkey.insertRows {Rlabkey}R Documentation

Insert new rows of data into a labkey database

Description

Insert new rows of data into the database.

Usage

labkey.insertRows(baseUrl, folderPath, schemaName, queryName, toInsert) 

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
toInsert a data frame containing rows of data to be inserted

Details

A single row or multiple rows of data can be inserted. The toInsert 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 database. When inserting data into a study dataset, the sequence number must be specified.

NOTE: Each variable in a dataset has both a column label and a column name. The column label is visible at the top of each column on the web page and is longer and more descriptive. The column name is shorter and is used “behind the scenes” for database manipulation. It is the column name that must be used in the Rlabkey functions when a column name is expected. To identify a particular column name in a dataset on a web site, use the “export to R script” option available as a drop down option under the “views” tab for each dataset.

In versions 0.0.5 and earlier, labkey.insertRows had a stripAllHidden argument. This argument did not perform a useful function and has since been removed.

Value

A list is returned with named categories of command, rowsAffected, rows, 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 he number of rows affected by the API action. This will typically be the same number as passed in the request. The rows property contains a list of row objects corresponding to the rows inserted.

Author(s)

Valerie Obenchain

References

http://www.omegahat.org/RCurl/,
http://dssm.unipa.it/CRAN/web/packages/rjson/rjson.pdf,
https://www.labkey.org/project/home/begin.view

See Also

labkey.selectRows, labkey.executeSql, makeFilter, labkey.updateRows,
labkey.deleteRows

Examples


## Insert, update and delete
# Note that users must have the necessary permissions in the database
# to be able to modify data through the use of these functions

### Not run
#newrow <- data.frame(name="Frank", age=11, stringsAsFactors=FALSE)
#labkey.insertRows(
#baseUrl="https://atlas-test.scharp.org/cpas", 
#folderPath="/CHAVI/Analysis/vobencha", 
#schemaName="lists", 
#queryName="testlist", 
#toInsert=newrow)
#
#updaterow=data.frame(Key=4,name="Patty",age=11, stringsAsFactors=FALSE)
#mydata <- labkey.updateRows(
#baseUrl="https://atlas-test.scharp.org/cpas", 
#folderPath="/CHAVI/Analysis/vobencha", 
#schemaName="lists", 
#queryName="testlist", 
#toUpdate=updaterow)
#
#deleterow <- data.frame(Key=1, stringsAsFactors=FALSE)
#mydata <- labkey.deleteRows(
#baseUrl="https://atlas-test.scharp.org/cpas", 
#folderPath="/CHAVI/Analysis/vobencha", 
#schemaName="lists", 
#queryName="testlist", 
#toDelete=deleterow)


[Package Rlabkey version 0.0.7 Index]