[rkward-devel] factor <-> character (was: three enhancemens)

meik michalke Meik.Michalke at uni-duesseldorf.de
Tue Feb 8 14:31:50 UTC 2011


hi,

Am Dienstag, 8. Februar 2011, um 10:42:52 schrieb Thomas Friedrichsmeier:
> I'll split the issues, and reply to the last one, first.

yes, that's better, sorry for the compressed content, it grew while writing...

> > i was first surprised that the editor still shows factor levels
> 
> Yes, the idea was to support "value labels" on data types other than
> factors, similar to e.g. SPSS. Think of likert-scales for a use case where
> data is "numeric" (not in IRT, of course), but end-points are named. Of
> course, since factor levels can only be assigned to consecutive integers,
> this does not work too well. Perhaps a feature worth removing? What do you
> think?

seemingly mixing features of factors and character vectors might bear the risk 
of RKWard behaving ("feeling") considerably different than R does. on the 
other hand i do see the feature.

maybe it would be better to keep labels strictly to factors only, but to also 
have a switch to toggle between labeled view and integer view (like with 
unclass())?

> > in fact, this doesn't work in RKWard either:
> > > some.data <- data.frame(a=c("a","b","c","d"), stringsAsFactors=FALSE)
> 
> [...]
> 
> > > some.data$a
> > 
> > [1] "1" "2" "3" "4"
> 
> I could not reproduce this, and we really don't mess with data.frame() on
> this level. Are you sure?

to my surprise i couldn't reproduce this myself at first. then i tried to 
reconstruct the steps i did yesterday. it seems even weirder now. the effect 
above occurs after rewriting a data.frame which is opened in the editor window 
at the same time:

> other.data <- data.frame(a=c("a","b","c","d"))
(open object in editor)
> other.data
  a
1 a
2 b
3 c
4 d

> other.data <- data.frame(a=c("a","b","c","d"), stringsAsFactors=FALSE)
> other.data
  a
1 1
2 2
3 3
4 4

> other.data <- data.frame(a=c("a","b","c","d"))
> other.data
     a
1 <NA>
2 <NA>
3 <NA>
4 <NA>

> other.data$a
[1] <NA> <NA> <NA> <NA>
attr(,".rk.invalid.fields")
attr(,".rk.invalid.fields")$`1`
[1] 1

attr(,".rk.invalid.fields")$`2`
[1] 2

attr(,".rk.invalid.fields")$`3`
[1] 3

attr(,".rk.invalid.fields")$`4`
[1] 4

Levels: a b c d

meanwhile, the same object is shown in the editor as a valid factor. all of 
this does not occur if the object is not opened in the editor. maybe something 
with the object binding or a race condition? or is this still caused by the 
problem you solved already? i'll try again with the next daily build.


viele grüße :: m.eik

-- 
  dipl. psych. meik michalke
  abt. f"ur diagnostik und differentielle psychologie
  institut f"ur experimentelle psychologie
  heinrich-heine-universit"at d"usseldorf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20110208/a5803935/attachment.sig>


More information about the Rkward-devel mailing list