return output to console for copying as input

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

return output to console for copying as input

Nevil Amos
I want to print a vector of strings to the console formatted as if it were
input

X<-c("a","b","c")
> X
[1] "a" "b" "c"

what I would like to get is

the.function(X)
>"a","b","c"

what is the function?

cheers

Nevil amos

        [[alternative HTML version deleted]]

______________________________________________
[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: return output to console for copying as input

Rui Barradas
Hello,

Maybe ?cat

cat(X, "\n")

(But it doesn't put the vector elements between quotes.)

Hope this helps,

Rui Barradas

Em 25-06-2013 08:14, nevil amos escreveu:

> I want to print a vector of strings to the console formatted as if it were
> input
>
> X<-c("a","b","c")
>> X
> [1] "a" "b" "c"
>
> what I would like to get is
>
> the.function(X)
>> "a","b","c"
>
> what is the function?
>
> cheers
>
> Nevil amos
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [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.
>

______________________________________________
[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: return output to console for copying as input

Enrico Schumann-2
In reply to this post by Nevil Amos
On Tue, 25 Jun 2013, nevil amos <[hidden email]> writes:

> I want to print a vector of strings to the console formatted as if it were
> input
>
> X<-c("a","b","c")
>> X
> [1] "a" "b" "c"
>
> what I would like to get is
>
> the.function(X)
>>"a","b","c"
>
> what is the function?
>

the.function <- function(x)
    cat(paste0("\"", x, "\"", collapse = ", "), "\n")



--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

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