Dear all, Does everyone know how to change the line numbers of scan()? For example,> scan(n = 3)1: 4 2: 6 3: 9 Read 3 items [1] 4 6 9 I just want to change the line numbers 1, 2, and 3 to, say a, b, and c that look like this:> scan(n = 3)a: 4 b: 6 c: 9 Read 3 items [1] 4 6 9 Any help will be appreciated. Lisa -- View this message in context: http://r.789695.n4.nabble.com/Line-numbers-of-scan-0-tp3482314p3482314.html Sent from the R help mailing list archive at Nabble.com.
On Apr 28, 2011, at 5:40 PM, Lisa wrote:> Dear all, > > Does everyone know how to change the line numbers of scan()? For > example, > >> scan(n = 3) > 1: 4 > 2: 6 > 3: 9 > Read 3 items > [1] 4 6 9 > > I just want to change the line numbers 1, 2, and 3 to, say a, b, and > c that > look like this: > >> scan(n = 3) > a: 4 > b: 6 > c: 9 > Read 3 items > [1] 4 6 9 > > Any help will be appreciated.If I were an actor I would be asking: "So what is my motivation?" -- David Winsemius, MD West Hartford, CT
I am trying to write a function to check unusual values in my datasets and correct them. As some R users suggested, I try to use readline() and scan() in my function. Suppose there are several unusual values in a dataset. I want to change the line numbers in scan() to something like: unusual value 1, unusual value 2 and so on. I think this can make the correction much easier. -- View this message in context: http://r.789695.n4.nabble.com/Line-numbers-of-scan-0-tp3482314p3482802.html Sent from the R help mailing list archive at Nabble.com.
On 29/04/11 09:40, Lisa wrote:> Dear all, > > Does everyone know how to change the line numbers of scan()? For example, > >> scan(n = 3) > 1: 4 > 2: 6 > 3: 9 > Read 3 items > [1] 4 6 9 > > I just want to change the line numbers 1, 2, and 3 to, say a, b, and c that > look like this: > >> scan(n = 3) > a: 4 > b: 6 > c: 9 > Read 3 items > [1] 4 6 9 > > Any help will be appreciated.Are you suffering from the delusion that the line numbers "1", "2", and "3" are part of/permanently affixed to the object returned by scan()? They're not. cheers, Rolf Turner
On Apr 28, 2011, at 11:07 PM, Lisa wrote:> I am trying to write a function to check unusual values in my > datasets and > correct them. As some R users suggested, I try to use readline() and > scan() > in my function. Suppose there are several unusual values in a > dataset. I > want to change the line numbers in scan() to something like: unusual > value > 1, unusual value 2 and so on. I think this can make the correction > much > easier. >Read the data in and process them. scan() is not the right tool for that. It is a low level function on which read.table and its kin are based. (Also ... do read the Posting Guide and learn to include context in your questions.) -- David Winsemius, MD West Hartford, CT