Hello-- I am a relatively new user to R and I cannot find the information I need. Please help. I have a very large data set with values including letters, numbers, and symbols (sometimes within the same vector value [ie X9-]. I've imported the data using read.fwp and it arrives in list format. I'd like to change the letters and symbols to numbers (ie X9- -> 00911) in every entry. How would you recommend I try to do so? Thank you!
Exactly how is the translation of "X9-" -> 00911 done? Are there unique mappings of character sequences to numbers? How many different ones might there be? Why do you have leading zeros on the result? If they are changed to numeric, then the default printing results in '911'. Can you provide an idea of what you data looks like - e.g., str(yourData). Is this to be done on all, or selected, columns? You need to provide a bit more background so that we can understand the problem you are trying to solve. On Sun, Aug 3, 2008 at 4:54 PM, Andrew Ramsey <aramsey at schoolph.umass.edu> wrote:> Hello-- > > I am a relatively new user to R and I cannot find the information I need. > Please help. > > I have a very large data set with values including letters, numbers, and > symbols (sometimes within the same vector value [ie X9-]. > > I've imported the data using read.fwp and it arrives in list format. > > I'd like to change the letters and symbols to numbers (ie X9- -> 00911) in > every entry. > > How would you recommend I try to do so? > > Thank you! > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
On Sunday 03 August 2008 01:54:43 pm Andrew Ramsey wrote:> Hello-- > > I am a relatively new user to R and I cannot find the information I > need. Please help. > > I have a very large data set with values including letters, numbers, > and symbols (sometimes within the same vector value [ie X9-]. > > I've imported the data using read.fwp and it arrives in list format. > > I'd like to change the letters and symbols to numbers (ie X9- -> > 00911) in every entry. > > How would you recommend I try to do so? > > Thank you! >Andrew, Your information is a little sparse, which limits how helpful list members can be. What is the purpose to recoding the values? By "read.fwp" did you mean "read.fwf" as in fixed-wdith format? Looking at your "before" and "after" example, the leading zeros in the "after" example value would seem to mean the value is STILL an alphanumeric string rather than a "number" per se. It might order more neatly in a printout than common ascii, but it is really no different and should still be a list. As a rule, I would recommend handling tasks related to data coding in a dbms such as PostgreSQL or Access. It is afterall what they are for. John
Reasonably Related Threads
- Virtual mailboxes do not look into subfolders
- P values in non linear regression and singular gradients using nls
- Aarch64: unaligned access despite -mstrict-align
- sem package fails when no of factors increase from 3 to 4
- How to pass a list of parameters into a function