[BioC] read.phenoData vs read.AnnotatedDataFrame

Seth Falcon sfalcon at fhcrc.org
Sat Aug 4 21:16:47 CEST 2007


"Steven McKinney" <smckinney at bccrc.ca> writes:

> Hi Alice,
>
> A coding alternative that helps in debugging
> those mis-spelled column names is to use the
> square bracket "[" extractor instead of the 
> dollar "$" extractor for data frames, e.g.
>
>   > Data<-ReadAffy(filenames=as.character(pData(pd)[T, "Filename"]),phenoData=pd)
>
> instead of 
>
>   > Data<-ReadAffy(filenames=as.character(pData(pd)$Filename),phenoData=pd)
>
> This will throw an error when you try to reference a column
> that does not exist, instead of silently returning NULL
> as you experienced.
>
> pData(pd)[T, "Filename"]  will return the same result as
> pData(pd)$Filename  if the column exists.  
>
> The "T" or "TRUE" in the row argument position ensures that an
> error message is returned, as 

I like this suggestion, but want to add that using T instead of TRUE
is a bad idea:

   T = FALSE

is a perfectly valid assignment whereas TRUE is a keyword.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
BioC: http://bioconductor.org/
Blog: http://userprimary.net/user/



More information about the Bioconductor mailing list