[R] Error in FUN(X[[1L]], ...) : STRING_ELT() can only be applied to a 'character vector', not a 'integer'
dwinsemius at comcast.net
Sun May 23 14:35:28 CEST 2010
On May 23, 2010, at 3:27 AM, Erik Iverson wrote:
> sedm1000 wrote:
>> Sorry - I figured that this to be a more common defined error than
>> 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.
>>> s<- "ATTATGCATCGACTAGCATCACTAG"
>>  "...((((........))))......"
>>  -2.3
>>> sq <- data.frame(c("ATGTGTGATATGCATGTACAGCATCGAC",
>> + "ACTAGCACTAGCATCAGCTGTAGATAGA",
>> + "ACTAGCATCGACATCATCGACATGATAG",
>> + "CATCGACTACGACTACGTAGATAGATAG",
>> + "ATCAGCACTACGACACATAGATAGAATA"))
Building on Erik's comments, perhaps trying:
> sq <- data.frame(s1 = c("ATGTGTGATATGCATGTACAGCATCGAC",
+ "ATCAGCACTACGACACATAGATAGAATA"), stringsAsFactors=FALSE)
stringsAsFactors=FALSE leaves the character vector "unfactored".
'data.frame': 5 obs. of 1 variable:
$ s1: chr "ATGTGTGATATGCATGTACAGCATCGAC"
Passing sq would still be passing a list. You probably want just the
first and only column.
chr [1:5] "ATGTGTGATATGCATGTACAGCATCGAC"
fold(sq$s1) # passing a character vector, which is what the error
message says is needed.
>> 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
> 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 ?
> lapply(sq[, 1], function(x) fold(as.character(x)))
> If that doesn't work, try the other list.
> Good luck,
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help