Saptarshi Guha
2009-Oct-01 18:26 UTC
[Rd] Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character' & 'getEncChar' must be called on a CHARSXP
Hello, I have list of 600K lists, each sublist a list of two elements, the first a character, the second a list of six named elements, some characters some numrics. LISTA (600K) (:= h) |__ List of two elements |__ Character |__ Named List of 6 elements (characters and numerics) This works, sip <- lapply(h,function(r) r[[2]][['sip']]) but I wish to unlist this sip <- unlist(lapply(h,function(r) r[[2]][['sip']])) and get the following error: Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'list' Debugging to find which: i<-1 sip <- unlist(lapply(h,function(r) { i<<-i+1 #debug messages cat(i,"------------------>","\n"); print( r[[2]] ) #debug message r[[2]][['sip']] })) [1]Error in print.default(r[[2]]) : 'getEncChar' must be called on a CHARSXP Which occurs on the 122,204'th item. All entries r[[2]] are similar so I don't know why this happening? The strangest thing is that this error never happened a few days ago and the same code causes this to occur today. Any ideas would be helpful. Regards Saptarshi
Simon Urbanek
2009-Oct-01 21:36 UTC
[Rd] Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character' & 'getEncChar' must be called on a CHARSXP
Saptarshi, how did you create those lists? Can you send us the code? If not, can you put up the .RData file? Without a reproducible example this is hard to debug ... Thanks, Simon On Oct 1, 2009, at 14:26 , Saptarshi Guha wrote:> Hello, > I have list of 600K lists, each sublist a list of two elements, the > first a character, the second a list of six named elements, some > characters some numrics. > LISTA (600K) (:= h) > |__ List of two elements > |__ Character > |__ Named List of 6 elements (characters and numerics) > > This works, > sip <- lapply(h,function(r) r[[2]][['sip']]) > > but I wish to unlist this > > sip <- unlist(lapply(h,function(r) r[[2]][['sip']])) > > and get the following error: > Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'list' > Debugging to find which: > > i<-1 > sip <- unlist(lapply(h,function(r) { > i<<-i+1 #debug messages > cat(i,"------------------>","\n"); print( r[[2]] ) #debug message > r[[2]][['sip']] > })) > > [1]Error in print.default(r[[2]]) : 'getEncChar' must be called on a > CHARSXP > > > Which occurs on the 122,204'th item. All entries r[[2]] are similar > so I don't know why this happening? > The strangest thing is that this error never happened a few days ago > and the same code causes this to occur today. > > > Any ideas would be helpful. > Regards > Saptarshi > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >