Last data update: 2014.03.03

R: Finds or removes empty AbstractMassObject objects in a list.
findEmptyMassObjectsR Documentation

Finds or removes empty AbstractMassObject objects in a list.

Description

These functions looks for empty AbstractMassObject objects in a list.

Usage

findEmptyMassObjects(l)

removeEmptyMassObjects(l)

Arguments

l

list, list of AbstractMassObject where empty objects should be found or removed.

Value

findEmptyMassObjects: Returns a vector of indices referring to empty AbstractMassObject objects.

removeEmptyMassObjects: Returns a list of AbstractMassObject objects but without empty ones.

Author(s)

Sebastian Gibb mail@sebastiangibb.de

See Also

isEmpty,AbstractMassObject-method, AbstractMassObject

Website: http://strimmerlab.org/software/maldiquant/

Examples

## load package
library("MALDIquant")

## create list
peakList <- list()

## create two MassPeaks objects and add them to the list
peakList[[1]] <- createMassPeaks(mass=1:100, intensity=1:100,
                                 metaData=list(name="example 1"))
peakList[[2]] <- createMassPeaks(mass=1:100, intensity=1:100,
                                 metaData=list(name="example 2"))

## find empty objects (there should not be any one)
findEmptyMassObjects(peakList)

## add an empty MassPeaks object to the list
peakList[[3]] <- createMassPeaks(mass=double(), intensity=double(),
                                 metaData=list(name="empty MassPeaks object"))

## look for empty objects (isEmptyIdx == 3)
(isEmptyIdx <- findEmptyMassObjects(peakList))

## to remove all empty MassObjects from a list
length(peakList) # 3
peakList <- removeEmptyMassObjects(peakList)
length(peakList) # 2; WARNING: all indices could changed

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MALDIquant)

This is MALDIquant version 1.15
Quantitative Analysis of Mass Spectrometry Data
 See '?MALDIquant' for more information about this package.

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MALDIquant/findEmptyMassObjects-functions.Rd_%03d_medium.png", width=480, height=480)
> ### Name: findEmptyMassObjects
> ### Title: Finds or removes empty AbstractMassObject objects in a list.
> ### Aliases: findEmptyMassObjects removeEmptyMassObjects
> ### Keywords: methods
> 
> ### ** Examples
> 
> ## load package
> library("MALDIquant")
> 
> ## create list
> peakList <- list()
> 
> ## create two MassPeaks objects and add them to the list
> peakList[[1]] <- createMassPeaks(mass=1:100, intensity=1:100,
+                                  metaData=list(name="example 1"))
> peakList[[2]] <- createMassPeaks(mass=1:100, intensity=1:100,
+                                  metaData=list(name="example 2"))
> 
> ## find empty objects (there should not be any one)
> findEmptyMassObjects(peakList)
integer(0)
> 
> ## add an empty MassPeaks object to the list
> peakList[[3]] <- createMassPeaks(mass=double(), intensity=double(),
+                                  metaData=list(name="empty MassPeaks object"))
> 
> ## look for empty objects (isEmptyIdx == 3)
> (isEmptyIdx <- findEmptyMassObjects(peakList))
[1] 3
> 
> ## to remove all empty MassObjects from a list
> length(peakList) # 3
[1] 3
> peakList <- removeEmptyMassObjects(peakList)
> length(peakList) # 2; WARNING: all indices could changed
[1] 2
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>