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

2010-05-23 Thread sedm1000

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..ATGTGTGATATGCATGTACAGCATCGACACTAGCACTAGCATCAGCTGTAGATAGA...
= structure(c(4L, 
1L, 2L, 5L, 3L), .Label = c(ACTAGCACTAGCATCAGCTGTAGATAGA,
ACTAGCATCGACATCATCGACATGATAG, 
ATCAGCACTACGACACATAGATAGAATA, ATGTGTGATATGCATGTACAGCATCGAC, 
CATCGACTACGACTACGTAGATAGATAG), class = factor)), .Names =
c..ATGTGTGATATGCATGTACAGCATCGACACTAGCACTAGCATCAGCTGTAGATAGA...,
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.

__
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.


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

2010-05-23 Thread Erik Iverson

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

__
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.


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

2010-05-23 Thread David Winsemius


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.


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

2010-05-23 Thread sedm1000

Thanks for your time with this. Erik's solution works best to deal with the
input... I'll try to reshape the output back into the appropriate columns.

David, fold(sq$s1) only outputs the result for the first sequence in the
list I'm afraid. The 'fold' function doesn't deal well with spaces...

Thanks again.


-- 
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-tp2226811p2228157.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


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

2010-05-21 Thread Erik Iverson

Hello,

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

We don't know the function you're using or the data you applied the function to, 
which makes it almost impossible to help.  Can you use ?dput to output the 
data.frame you're experiencing trouble with, and the function definition you're 
using to give us a reproducible, self-contained example?



sedm1000 wrote:

I am receiving this error running a command on a multi-row data-frame. The
data is strings of text (each with new line separator, no spaces, no
numerical characters).

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

I can run single text string into the same command, and so the issue seems
to be how the package deals with the second row - but I can't work out quite
where the deficit is. 


If anybody has spotted this error before, and knows how to resolve it, that
would be much appreciated.

Cheers.

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   



__
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.