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

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Feb 8 09:42:52 UTC 2011


Hi,

I'll split the issues, and reply to the last one, first.

On Monday 07 February 2011, meik michalke wrote:
> > some.data <- data.frame(a=c("a","b","c","d"))
[...]
> > some.data$a
> 
> [1] a b c d
> Levels: a b c d
> 
> so "a" was converted to a factor. then open "some.data" in the editor
> component and change the type of column "a" from "factor" to "strings". now
> 
> look at the object in the R console:
[...]
> > some.data$a
> 
> [1] "1" "2" "3" "4"
> attr(,"levels")
> [1] "a" "b" "c" "d"
> attr(,".rk.invalid.fields")
> list()
>
> this is not really what i expect of the conversion to "string".

Indeed. Fixed.

> 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?

> , and even though type
> says "string" you cannot remove those levels safely.

True. But that was just a side-effect of the conversion problem, above. I.e. 
that should be fixed, too.

> 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?

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20110208/be23dc7c/attachment.sig>


More information about the Rkward-devel mailing list