Re: [R] convert into numeric variable

2008-10-21 Thread Gabor Grothendieck
Use readLines to read your data into Lines.in. Then delete percentages and right parens followed by replacing left parens followed by zero or more spaces with a minus. Then re-read using read.table. Lines <- "4.61%( 4.11%) 29.85% ( 1.27%) 16.04% 21.31% 14.09% 39.71% 4.61%( 4.11%) 29

[R] convert into numeric variable

2008-10-21 Thread Young Cho
Hi, I have an accounting data with "%" at the end and "()" for negative. E.g. if I read in with read.table, then R reads in as a factor: [11625] 4.61%( 4.11%) 29.85% ( 1.27%) 16.04% 21.31% 14.09% 39.71% [11633] 3.03%17.39% 80.13% 6648 Levels: ( 0.00%) ( 0.03%) ( 0.04%) ( 0.05%)