Hi
First off - I am really impressed with what you are doing with rkward - thanks!
I am on
ubuntu 7.04
rkward 0.4.2 (kde 3.5.6)
R 2.4.1.
I breifly tried rkward 0.4.8 but reverted to 0.4.2.
My question regards adding labels to a data.frame via R-script.
I am in the process of moving a large project from SPSS to R/rkward for testing out rkward in a real setting.
I have imported data as data.frame and the labels as a character vector. It has more than 1400 variables so I need to be able to add labels to data.frames via scripts.
I looked into how rkward stores labels and made this loop which apparently works fine in 0.4.2: Labels are added, and recognized by the editor.
for(i in 1:length(ghdata)){
attr(ghdata[[i]],".rk.meta") <- list(label = ghlabels[i])
}
For one variable it would look something like this (adding a label to the first variable in the data.frame):
attr(ghdata[[1]],".rk.meta") <- list(label = "This is a label")
In 0.4.8 I can only add labels in the editor but they disappear when I run this code.
So my question is whether this is the intended behavior in 0.4.8, if so how should I change my code so it will also work in the future.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> My question regards adding labels to a data.frame via R-script.
I am a bit confused here! What is intended difference between "labels" and "columnames" for a data.frame? If what you want is variable names/ column-names then, the standard R function
colnames(ghdata) <- c("Variable1", "Variable2")
should do the job! I am sorry, if I am misunderstanding your question!
Regards
PK
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The point of labels in general is to indicate the real meaning of a variable which can not be contained in the name.
In particular in rkward there is a field in the editor that shows labels.
You can see this if you open a data.frame in the editor (right click the object and chose 'edit'). Write a label in the label field of one of the variabels, then try this in the console:
attributes(data[["varname"]])
If you import an spss dataset with read.spss from the foreign package you get the labels as an attribute:
attr(data,"variable.labels")
Which means that there is an attribute vector for the whole dataset for each extra attribute.
It appears that rkward has created their own attribute which is like this:
attr(data[["varname"]],".rk.meta")
That is, rkward adds an 'attribute-tree' to each individual variable
I have been digging a little deeper.
First: My initial code is wrong, it should probably be:
attr(data,".rk.meta")["label"] <- "This is a label"
Second: I reinstalled 0.4.8 and tested again, and I believe there may be a bug in 0.4.8 regarding labels.
When I add labels the 'official' way writing it in the label field it disappears when I reload the data.
Another thing is that 0.4.8 is _much_ slower than 0.4.2 (from 15 to 20 times slower ie. from 2 sek to over 30 sek for one operation)
This could of course all be because 0.4.8 is not suitable for ubuntu 7.04
So my question still is: is the code above correct in relation to 0.4.8 (even if it does not work on my machine at the moment) or should I change it to make sure it will work in the future?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the best way to read and write labels is using rk.get.label() and rk.set.label(). The internal format for storing the meta-information might change in the future, but these functions will likely remain unchanged. However, rk.set.label() was not added until version 0.4.5.
Viewing labels is broken in rkward 0.4.8, indeed. Thanks for pointing this out. This is now fixed in the current development sources (see http://rkward.sourceforge.net/wiki/index.php?title=RKWard_SVN, if you would like to give it a try). Alternatively, you could use version 0.4.7a for now, which does not have this particular bug.
You write that 0.4.8 is very slow on your system. Is this for all operations, or only for some? Could you perhaps provide some example code?
Thanks!
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi thanks for the answer
> Viewing labels is broken in rkward 0.4.8, indeed.
Ok, good to know that it wasn't me :)
I will look into those functions rk.set.label()/rk.get.label() as soon as possible.
> You write that 0.4.8 is very slow on your system. Is this for all operations, or only for some? Could you perhaps provide some example code?
It is slow for absolutely everything, opening, loading workspace, opening an object for editing. running even the most simple code, the R engine is busy for a long time (ie. red) and the yellow is also often visible for several seconds before it turns green. The package I installed is the one for Debian Etch downloaded from sourceforge. I don't know if this is the correct package for ubuntu 7.04. I tried to add the rkward repository but got a "size mismatch" error. If no one else has such problems it is most likely to do with some kind of package/version mismatch. The version in the ubuntu repository is 0.4.2.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
UPDATE
> This is now fixed in the current development sources...
I just compiled and are now running 0.4.9pre1. It was surprisingly easy, took only a few minutes following the instructions from your link: http://rkward.sourceforge.net/wiki/index.php?title=RKWard_SVN
It appears to be running fine. No obvious problems.
So thanks a lot for the answer.
I am simply amazed that this is possible.
I am now looking into making plugins. I have previously made packages for R for windows, and among other things made menus using the winMenu functions, so I am looking forward to working in this environment.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want to give plugin development a try, that would be great! I suppose you've already found the documentation at http://rkward.sourceforge.net/documents/devel/plugins/index.html . If you have questions (or results), just send us a mail to the rkward-devel mailing list (moderated list due to SPAM problems, but you can still post without being subscribed).
Regards
Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I will develop plugins, that's my nature ;) but I am a bit busy the next month or so. I have already created a new menu but no content yet. So I will definitely be back. I have a some experience with php so I am really looking forward to start.
Regards
Finn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
First off - I am really impressed with what you are doing with rkward - thanks!
I am on
ubuntu 7.04
rkward 0.4.2 (kde 3.5.6)
R 2.4.1.
I breifly tried rkward 0.4.8 but reverted to 0.4.2.
My question regards adding labels to a data.frame via R-script.
I am in the process of moving a large project from SPSS to R/rkward for testing out rkward in a real setting.
I have imported data as data.frame and the labels as a character vector. It has more than 1400 variables so I need to be able to add labels to data.frames via scripts.
I looked into how rkward stores labels and made this loop which apparently works fine in 0.4.2: Labels are added, and recognized by the editor.
for(i in 1:length(ghdata)){
attr(ghdata[[i]],".rk.meta") <- list(label = ghlabels[i])
}
For one variable it would look something like this (adding a label to the first variable in the data.frame):
attr(ghdata[[1]],".rk.meta") <- list(label = "This is a label")
In 0.4.8 I can only add labels in the editor but they disappear when I run this code.
So my question is whether this is the intended behavior in 0.4.8, if so how should I change my code so it will also work in the future.
Hi, fsando,
Thanks for the words of encouragement!
> My question regards adding labels to a data.frame via R-script.
I am a bit confused here! What is intended difference between "labels" and "columnames" for a data.frame? If what you want is variable names/ column-names then, the standard R function
colnames(ghdata) <- c("Variable1", "Variable2")
should do the job! I am sorry, if I am misunderstanding your question!
Regards
PK
Hi Kapatp
Thanks for your quick reply.
The point of labels in general is to indicate the real meaning of a variable which can not be contained in the name.
In particular in rkward there is a field in the editor that shows labels.
You can see this if you open a data.frame in the editor (right click the object and chose 'edit'). Write a label in the label field of one of the variabels, then try this in the console:
attributes(data[["varname"]])
If you import an spss dataset with read.spss from the foreign package you get the labels as an attribute:
attr(data,"variable.labels")
Which means that there is an attribute vector for the whole dataset for each extra attribute.
It appears that rkward has created their own attribute which is like this:
attr(data[["varname"]],".rk.meta")
That is, rkward adds an 'attribute-tree' to each individual variable
I have been digging a little deeper.
First: My initial code is wrong, it should probably be:
attr(data,".rk.meta")["label"] <- "This is a label"
Second: I reinstalled 0.4.8 and tested again, and I believe there may be a bug in 0.4.8 regarding labels.
When I add labels the 'official' way writing it in the label field it disappears when I reload the data.
Another thing is that 0.4.8 is _much_ slower than 0.4.2 (from 15 to 20 times slower ie. from 2 sek to over 30 sek for one operation)
This could of course all be because 0.4.8 is not suitable for ubuntu 7.04
So my question still is: is the code above correct in relation to 0.4.8 (even if it does not work on my machine at the moment) or should I change it to make sure it will work in the future?
Hi,
the best way to read and write labels is using rk.get.label() and rk.set.label(). The internal format for storing the meta-information might change in the future, but these functions will likely remain unchanged. However, rk.set.label() was not added until version 0.4.5.
Viewing labels is broken in rkward 0.4.8, indeed. Thanks for pointing this out. This is now fixed in the current development sources (see http://rkward.sourceforge.net/wiki/index.php?title=RKWard_SVN, if you would like to give it a try). Alternatively, you could use version 0.4.7a for now, which does not have this particular bug.
You write that 0.4.8 is very slow on your system. Is this for all operations, or only for some? Could you perhaps provide some example code?
Thanks!
Thomas
Hi thanks for the answer
> Viewing labels is broken in rkward 0.4.8, indeed.
Ok, good to know that it wasn't me :)
I will look into those functions rk.set.label()/rk.get.label() as soon as possible.
> You write that 0.4.8 is very slow on your system. Is this for all operations, or only for some? Could you perhaps provide some example code?
It is slow for absolutely everything, opening, loading workspace, opening an object for editing. running even the most simple code, the R engine is busy for a long time (ie. red) and the yellow is also often visible for several seconds before it turns green. The package I installed is the one for Debian Etch downloaded from sourceforge. I don't know if this is the correct package for ubuntu 7.04. I tried to add the rkward repository but got a "size mismatch" error. If no one else has such problems it is most likely to do with some kind of package/version mismatch. The version in the ubuntu repository is 0.4.2.
UPDATE
> This is now fixed in the current development sources...
I just compiled and are now running 0.4.9pre1. It was surprisingly easy, took only a few minutes following the instructions from your link:
http://rkward.sourceforge.net/wiki/index.php?title=RKWard_SVN
It appears to be running fine. No obvious problems.
So thanks a lot for the answer.
I am simply amazed that this is possible.
I am now looking into making plugins. I have previously made packages for R for windows, and among other things made menus using the winMenu functions, so I am looking forward to working in this environment.
Thanks for all the kind words.
If you want to give plugin development a try, that would be great! I suppose you've already found the documentation at http://rkward.sourceforge.net/documents/devel/plugins/index.html . If you have questions (or results), just send us a mail to the rkward-devel mailing list (moderated list due to SPAM problems, but you can still post without being subscribed).
Regards
Thomas
I will develop plugins, that's my nature ;) but I am a bit busy the next month or so. I have already created a new menu but no content yet. So I will definitely be back. I have a some experience with php so I am really looking forward to start.
Regards
Finn