Bug 380762

Summary: FIXED IN SVN: data corruption after changing var to factor
Product: [Applications] rkward Reporter: RKWard Team <rkward-devel>
Component: generalAssignee: RKWard Team <rkward-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: All   
Latest Commit: Version Fixed In:

Description RKWard Team 2010-12-23 07:27:43 UTC
-- Originally posted by (AT sourceforge.net): ziogelis77 --

-- This ticket was imported from http://sourceforge.net/p/rkward/bugs/80 on 2017-05-30 15:26:51 +0100 --
In data frame editor I sometimes need to change data type from numeric to factor and then add levels. If I do it in this order, everything is ok. But if I add levels first, and only then do I change the variable type to factor, the data in the variable column gets lost. This happens every time you do it. Before you close the editor, you still see the variable in the editor window, but if you print the data frame column in console, all you see is NA's. The data disappears right after the second action - changing the data type. If you leave the data type „number“, is.numeric\(df$b\) still reports TRUE, although the number is displayed. A workaround is: after doing it the wrong way you need to copy the column content to a csv file, and then copy it from there and paste it back. 

Tested in both linux \(ubuntu\) and windows version of rkward 0.5.4
KDE windows: KDE 4.4.1 \(rkward bundle\)
KDE on linux – current stable 4.5.4
&gt; R.version
\_                            
platform       i386-pc-mingw32              
arch           i386                         
os             mingw32                      
system         i386, mingw32                
status                                      
major          2                            
minor          11.1                         
year           2010                         
month          05                           
day            31                           
svn rev        52157                        
language       R                            
version.string R version 2.11.1 \(2010-05-31\)




To reproduce:

a=c\(1,2,3,4\)
b=c\(1,1,2,4\)
c=c\(4,2,2,1\)
df=data.frame\(a,b,c\)

Then open and edit the data set changing data type and then adding levels, column a – in the correct order, column b – in the incorrect order.

close df

run df:
&gt; df
a    b c
1  first &lt;NA&gt; 4
2 second &lt;NA&gt; 2
3  third &lt;NA&gt; 2
4 fourth &lt;NA&gt; 1-- Labels: data handling --
Comment 1 RKWard Team 2010-12-23 07:28:46 UTC
-- Originally posted by (AT sourceforge.net): ziogelis77 --
- **summary**: editing levels for numeric data destroys data --> editing levels for numeric data,then changing type ruin data
Comment 2 Thomas Friedrichsmeier 2010-12-23 10:48:40 UTC
Hi\!

Embarrassing. Thanks for reporting this issue.

The problem should now be fixed in the development version \(http://p.sf.net/rkward/svn\). For Ubuntu, a fixed version should be available from our daily build archive tomorrow \(https://launchpad.net/~rkward-devel/+archive/rkward-dailys\).

Regards
Thomas
Comment 3 Thomas Friedrichsmeier 2010-12-23 10:48:40 UTC
- **assigned_to**: nobody --> tfry
- **summary**: editing levels for numeric data,then changing type ruin data --> FIXED IN SVN: data corruption after changing var to factor
- **status**: open --> open-fixed
Comment 4 RKWard Team 2010-12-23 11:44:06 UTC
-- Originally posted by (AT sourceforge.net): ziogelis77 --
Man you are quick\! Thank you though, even when you know the right order, mixing things up happens too often.

Donatas
Comment 5 Thomas Friedrichsmeier 2011-03-20 11:27:50 UTC
- **status**: open-fixed --> closed-fixed