Line numbers of scan(0

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Line numbers of scan(0

Lisa
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
Reply | Threaded
Open this post in threaded view
|

Re: Line numbers of scan(0

David Winsemius

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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Line numbers of scan(0

Lisa
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.
Reply | Threaded
Open this post in threaded view
|

Re: Line numbers of scan(0

Rolf Turner-3
In reply to this post by Lisa
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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Line numbers of scan(0

David Winsemius
In reply to this post by Lisa

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

______________________________________________
[hidden email] 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.