[R] Error in FUN(X[[1L]], ...) : STRING_ELT() can only be applied to a 'character vector', not a 'integer'
sedm1000
gdoran at mit.edu
Sun May 23 00:45:30 CEST 2010
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'
>dput(fold,file="fred123")
function (s, t = 37)
{
.Call("foldR", s, t, PACKAGE = "GeneRfold")
}
> dput(sq)
structure(list(c..ATGTGTGATATGCATGTACAGCATCGAC....ACTAGCACTAGCATCAGCTGTAGATAGA...
= structure(c(4L,
1L, 2L, 5L, 3L), .Label = c("ACTAGCACTAGCATCAGCTGTAGATAGA",
"ACTAGCATCGACATCATCGACATGATAG",
"ATCAGCACTACGACACATAGATAGAATA", "ATGTGTGATATGCATGTACAGCATCGAC",
"CATCGACTACGACTACGTAGATAGATAG"), class = "factor")), .Names =
"c..ATGTGTGATATGCATGTACAGCATCGAC....ACTAGCACTAGCATCAGCTGTAGATAGA...",
row.names = c(NA,
-5L), class = "data.frame")
> dput(s)
"ATTATGCATCGACTAGCATCACTAG"
> sessionInfo()
R version 2.11.0 (2010-04-22)
i386-apple-darwin9.8.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] GeneRfold_1.6.0 GeneR_2.18.0
loaded via a namespace (and not attached):
[1] tools_2.11.0
--
View this message in context: http://r.789695.n4.nabble.com/Error-in-FUN-X-1L-STRING-ELT-can-only-be-applied-to-a-character-vector-not-a-integer-tp2226811p2227512.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list