(no subject)

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

(no subject)

Jonathan P Daily
I was wondering if there is a way to get read in a single keystroke at a
time in R as a string, akin to ncurses-style interfaces. I looked into
readLines, readChar, etc. using stdin, but these all require the use of an
end of line. Has anyone ever had need to do this or have any ideas on how
to do this?

Thanks,
Jon

PS I apologize if this double-sends, but I am having mail client issues.
--------------------------------------
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
     - Jubal Early, Firefly

______________________________________________
[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: (no subject)

Bert Gunter
?strsplit

x <- "ThisIsaString"
y<- strsplit(x,"")

This gives a list, which you can convert to a vector by unlist(y)

Incidentally, you could have found out about strsplit via R's
help.search("character string") (or similar) or even googling "R
string function" . Please use R's native Help capabilities before
posting to the list.

(I will grant that the unlist()  trick may not be that easy to find).

Also, it's often worthwhile searching the Help archives first. Peter
Dalgaard answered this same question here a day or two ago.

Cheers,
Bert



On Tue, Mar 15, 2011 at 6:35 AM, Jonathan P Daily <[hidden email]> wrote:

> I was wondering if there is a way to get read in a single keystroke at a
> time in R as a string, akin to ncurses-style interfaces. I looked into
> readLines, readChar, etc. using stdin, but these all require the use of an
> end of line. Has anyone ever had need to do this or have any ideas on how
> to do this?
>
> Thanks,
> Jon
>
> PS I apologize if this double-sends, but I am having mail client issues.
> --------------------------------------
> Jonathan P. Daily
> Technician - USGS Leetown Science Center
> 11649 Leetown Road
> Kearneysville WV, 25430
> (304) 724-4480
> "Is the room still a room when its empty? Does the room,
>  the thing itself have purpose? Or do we, what's the word... imbue it."
>     - Jubal Early, Firefly
>
> ______________________________________________
> [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.
>



--
Bert Gunter
Genentech Nonclinical Biostatistics

______________________________________________
[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: Keyboard Input

Jonathan P Daily
I apologize for being unclear in my original post. What I am trying to
achieve is to capture the stdin() connection and read in a single
keystroke - including arrow keys and the like - without having to have to
use the return key each time. My goal is to create a small UI for rapidly
looking through the results of a large simulation. As I think about it
more, though, it is probably going to be easier to dump the data into
files and look through it outside of R.

Thanks anyways,

Jon
--------------------------------------
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
     - Jubal Early, Firefly

Bert Gunter <[hidden email]> wrote on 03/15/2011 10:08:51 AM:

> [image removed]
>
> Re: [R] (no subject)
>
> Bert Gunter
>
> to:
>
> Jonathan P Daily
>
> 03/15/2011 10:08 AM
>
> Cc:
>
> r-help
>
> ?strsplit
>
> x <- "ThisIsaString"
> y<- strsplit(x,"")
>
> This gives a list, which you can convert to a vector by unlist(y)
>
> Incidentally, you could have found out about strsplit via R's
> help.search("character string") (or similar) or even googling "R
> string function" . Please use R's native Help capabilities before
> posting to the list.
>
> (I will grant that the unlist()  trick may not be that easy to find).
>
> Also, it's often worthwhile searching the Help archives first. Peter
> Dalgaard answered this same question here a day or two ago.
>
> Cheers,
> Bert
>
>
>
> On Tue, Mar 15, 2011 at 6:35 AM, Jonathan P Daily <[hidden email]>
wrote:
> > I was wondering if there is a way to get read in a single keystroke at
a
> > time in R as a string, akin to ncurses-style interfaces. I looked into
> > readLines, readChar, etc. using stdin, but these all require the use
of an
> > end of line. Has anyone ever had need to do this or have any ideas on
how
> > to do this?
> >
> > Thanks,
> > Jon
> >
> > PS I apologize if this double-sends, but I am having mail client
issues.
> > --------------------------------------
> > Jonathan P. Daily
> > Technician - USGS Leetown Science Center
> > 11649 Leetown Road
> > Kearneysville WV, 25430
> > (304) 724-4480
> > "Is the room still a room when its empty? Does the room,
> >  the thing itself have purpose? Or do we, what's the word... imbue
it."
> >     - Jubal Early, Firefly
> >
> > ______________________________________________
> > [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.
> >
>
>
>
> --
> Bert Gunter
> Genentech Nonclinical Biostatistics

______________________________________________
[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: Keyboard Input

Gabor Grothendieck
On Tue, Mar 15, 2011 at 10:29 AM, Jonathan P Daily <[hidden email]> wrote:
> I apologize for being unclear in my original post. What I am trying to
> achieve is to capture the stdin() connection and read in a single
> keystroke - including arrow keys and the like - without having to have to
> use the return key each time. My goal is to create a small UI for rapidly
> looking through the results of a large simulation. As I think about it
> more, though, it is probably going to be easier to dump the data into
> files and look through it outside of R.
>

See:
http://r.789695.n4.nabble.com/detecting-a-key-press-td2324938.html

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[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: Keyboard Input

Jonathan P Daily
Solved. Thanks.
--------------------------------------
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
     - Jubal Early, Firefly

Gabor Grothendieck <[hidden email]> wrote on 03/15/2011 10:38:34
AM:

> [image removed]
>
> Re: [R] Keyboard Input
>
> Gabor Grothendieck
>
> to:
>
> Jonathan P Daily
>
> 03/15/2011 10:38 AM
>
> Cc:
>
> Bert Gunter, r-help
>
> On Tue, Mar 15, 2011 at 10:29 AM, Jonathan P Daily <[hidden email]>
wrote:
> > I apologize for being unclear in my original post. What I am trying to
> > achieve is to capture the stdin() connection and read in a single
> > keystroke - including arrow keys and the like - without having to have
to
> > use the return key each time. My goal is to create a small UI for
rapidly

> > looking through the results of a large simulation. As I think about it
> > more, though, it is probably going to be easier to dump the data into
> > files and look through it outside of R.
> >
>
> See:
> http://r.789695.n4.nabble.com/detecting-a-key-press-td2324938.html
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com

______________________________________________
[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: (no subject)

rex.dwyer
In reply to this post by Bert Gunter
Hi Jon,  I read your question differently.  Is the answer?  - Rex

> ch=scan(stdin(),what=character(0),n=1)
1: f
Read 1 item
> ch
[1] "f"
>

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Bert Gunter
Sent: Tuesday, March 15, 2011 10:09 AM
To: Jonathan P Daily
Cc: [hidden email]
Subject: Re: [R] (no subject)

?strsplit

x <- "ThisIsaString"
y<- strsplit(x,"")

This gives a list, which you can convert to a vector by unlist(y)

Incidentally, you could have found out about strsplit via R's
help.search("character string") (or similar) or even googling "R
string function" . Please use R's native Help capabilities before
posting to the list.

(I will grant that the unlist()  trick may not be that easy to find).

Also, it's often worthwhile searching the Help archives first. Peter
Dalgaard answered this same question here a day or two ago.

Cheers,
Bert



On Tue, Mar 15, 2011 at 6:35 AM, Jonathan P Daily <[hidden email]> wrote:

> I was wondering if there is a way to get read in a single keystroke at a
> time in R as a string, akin to ncurses-style interfaces. I looked into
> readLines, readChar, etc. using stdin, but these all require the use of an
> end of line. Has anyone ever had need to do this or have any ideas on how
> to do this?
>
> Thanks,
> Jon
>
> PS I apologize if this double-sends, but I am having mail client issues.
> --------------------------------------
> Jonathan P. Daily
> Technician - USGS Leetown Science Center
> 11649 Leetown Road
> Kearneysville WV, 25430
> (304) 724-4480
> "Is the room still a room when its empty? Does the room,
>  the thing itself have purpose? Or do we, what's the word... imbue it."
>     - Jubal Early, Firefly
>
> ______________________________________________
> [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.
>



--
Bert Gunter
Genentech Nonclinical Biostatistics

______________________________________________
[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.




message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited.
______________________________________________
[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.