saveResults: Returns an object representing a LabKey schema

View source: R/schemaObjects.R

saveResultsR Documentation

Returns an object representing a LabKey schema

Description

A wrapper function to labkey.saveBatch which uses a session object and provides defaults for the Batch/Run names.

Usage

saveResults(session, assayName, resultDataFrame, 
  batchPropertyList= list(name=paste("Batch ", as.character(date()))),
  runPropertyList= list(name=paste("Assay Run ", as.character(date()))))

Arguments

session

the session key returned from getSession

assayName

a string specifying the name of the assay instance

resultDataFrame

a data frame containing rows of data to be inserted

batchPropertyList

a list of batch Properties

runPropertyList

a list of run Properties

Details

saveResults is a wrapper function to labkey.saveBatch with two changes: First, it uses a session object in place of the separate baseUrl and folderPath arguments. Second, it provides defaults for generating Batch and Run names based on a current timestamp.

To see the save result on LabKey server, click on the "SimpleMeans" assay in the Assay List web part.

Value

an object representing the assay.

Author(s)

Peter Hussey

References

https://www.labkey.org/project/home/begin.view

See Also

getSession, getSchema, getLookups, getRows

Examples

## Not run: 

## Very simple example of an analysis flow:  query some data,
## calculate some stats, then save the calculations as an assay
## result set in LabKey Server
# library(Rlabkey)

s<- getSession(baseUrl="http://localhost:8080/labkey",
    folderPath="/apisamples")
scobj <- getSchema(s, "lists")
simpledf <- getRows(s, scobj$AllTypes)

## some dummy calculations to produce and example analysis result
testtable <- simpledf[,3:4]
colnames(testtable) <- c("IntFld", "DoubleFld")
row <- c(list("Measure"="colMeans"), colMeans(testtable, na.rm=TRUE))
results <- data.frame(row, row.names=NULL, stringsAsFactors=FALSE)
row <- c(list("Measure"="colSums"), colSums(testtable, na.rm=TRUE))
results <- rbind(results, as.vector(row))

bprops <- list(LabNotes="this is a simple demo")
bpl<- list(name=paste("Batch ", as.character(date())),properties=bprops) 
rpl<- list(name=paste("Assay Run ", as.character(date())))

assayInfo<- saveResults(s, "SimpleMeans", results,
    batchPropertyList=bpl, runPropertyList=rpl)


## End(Not run)

Rlabkey documentation built on Nov. 8, 2023, 1:06 a.m.