On May 23, 2010, at 3:27 AM, Erik Iverson wrote:

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)

Building on Erik's comments, perhaps trying:

> sq <- data.frame(s1 = c("ATGTGTGATATGCATGTACAGCATCGAC",
+               "ACTAGCACTAGCATCAGCTGTAGATAGA",
+               "ACTAGCATCGACATCATCGACATGATAG",
+               "CATCGACTACGACTACGTAGATAGATAG",
+               "ATCAGCACTACGACACATAGATAGAATA"), stringsAsFactors=FALSE)

stringsAsFactors=FALSE leaves the character vector "unfactored".

> str(sq)
'data.frame':   5 obs. of  1 variable:
$ s1: chr "ATGTGTGATATGCATGTACAGCATCGAC" "ACTAGCACTAGCATCAGCTGTAGATAGA" "ACTAGCATCGACATCATCGACATGATAG" "CATCGACTACGACTACGTAGATAGATAG" ...

Passing sq would still be passing a list. You probably want just the first and only column.

> str(sq$s1)
chr [1:5] "ATGTGTGATATGCATGTACAGCATCGAC" "ACTAGCACTAGCATCAGCTGTAGATAGA" ...

fold(sq$s1) # passing a character vector, which is what the error message says is needed.

--
David.

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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to