Bug 380762 - FIXED IN SVN: data corruption after changing var to factor
Summary: FIXED IN SVN: data corruption after changing var to factor
Status: RESOLVED FIXED
Alias: None
Product: rkward
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: RKWard Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-23 07:27 UTC by RKWard Team
Modified: 2011-03-20 11:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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
> 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:
> df
a    b c
1  first <NA> 4
2 second <NA> 2
3  third <NA> 2
4 fourth <NA> 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