[R] Error in FUN(X[[1L]], ...) : STRING_ELT() can only be applied to a 'character vector', not a 'integer'

Erik Iverson eriki at ccbr.umn.edu
Sun May 23 09:27:50 CEST 2010


Hello,

sedm1000 wrote:
> Sorry - I figured that this to be a more common defined error than anything
> specific to the data/function...  Thanks for looking at this.
> 
> The data and function are below. Creating a single line of the data.frame at
> a time will work (i.e. fold(s))
> 
> For multiple line data.frames, an error is generated. Ideally I would like
> to record the output from fold(sq) in a two column data.frame, whether it
> requires reading in the data to fold one line at a time or in bulk.
> 
>> library(GeneRfold)
>> s<- "ATTATGCATCGACTAGCATCACTAG"
>> fold(s)
> [[1]]
> [1] "...((((........))))......"
> 
> [[2]]
> [1] -2.3
> 
> 
>> sq <- data.frame(c("ATGTGTGATATGCATGTACAGCATCGAC",
> + 		"ACTAGCACTAGCATCAGCTGTAGATAGA",
> + 		"ACTAGCATCGACATCATCGACATGATAG",
> + 		"CATCGACTACGACTACGTAGATAGATAG",
> + 		"ATCAGCACTACGACACATAGATAGAATA"))
> 
>> fold(sq)
> Error in fold(sq) : 
>   STRING_ELT() can only be applied to a 'character vector', not a 'list'
> 
>> struct <- t(as.data.frame(sapply(sq[,1], fold, t=37)))
> 
> Error in FUN(X[[1L]], ...) :
>  STRING_ELT() can only be applied to a 'character vector', not a 'integer'
> 

This appears to be a Bioconductor package, so if this doesn't help, I'd ask on 
the specific bioconductor mailing list.  I don't have the package installed, so 
take the following advice with that in mind.

Did you look at the str(sq) ?  It is not a character vector, it is a factor, so 
you might need to convert or see stringsAsFactors in ?options.

Try

lapply(sq[, 1], function(x) fold(as.character(x)))

If that doesn't work, try the other list.

Good luck,
Erik



More information about the R-help mailing list