Recommendation for website to format R code

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

Recommendation for website to format R code

tmrsg11
Hi list,

Could anyone recommend some good website for formatting R code?  For
example, when you copy paste R code to gmail and back to R, it loses its
format, the dash symbol causes errors.

I've had someone used it to format my code here on the list, but can't find
it anymore.

Mike

        [[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: Recommendation for website to format R code

Mark Lamias
Are you only interested in formatting code from copy and pasting to/from email?  If you are interested in formatting your code in Latex/PDF/HTML take a look at the knitr package:

http://yihui.name/knitr/

Also, you could check out the formatR package:
http://cran.r-project.org/web/packages/formatR/formatR.pdf

--Mark Lamias




________________________________
 From: C W <[hidden email]>
To: r-help <[hidden email]>
Sent: Wednesday, January 23, 2013 9:27 PM
Subject: [R] Recommendation for website to format R code

Hi list,

Could anyone recommend some good website for formatting R code?  For
example, when you copy paste R code to gmail and back to R, it loses its
format, the dash symbol causes errors.

I've had someone used it to format my code here on the list, but can't find
it anymore.

Mike

    [[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.
        [[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: Recommendation for website to format R code

tmrsg11
Hey Mark,
I am aware of this package.  The situation is,
1. I am emailing my code from my machine to a public machine.  Installation
is a hassle.
2. Copy pasting for a website.

I know there are websites for formatting Java and C code.  So, I am looking
for a website in particular, and I have seen it before but don't remember
the site.

Mike

On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias <[hidden email]> wrote:

> Are you only interested in formatting code from copy and pasting to/from
> email?  If you are interested in formatting your code in Latex/PDF/HTML
> take a look at the knitr package:
>
> http://yihui.name/knitr/
>
> Also, you could check out the formatR package:
> http://cran.r-project.org/web/packages/formatR/formatR.pdf
>
> --Mark Lamias
>
>
>   ------------------------------
> *From:* C W <[hidden email]>
> *To:* r-help <[hidden email]>
> *Sent:* Wednesday, January 23, 2013 9:27 PM
> *Subject:* [R] Recommendation for website to format R code
>
> Hi list,
>
> Could anyone recommend some good website for formatting R code?  For
> example, when you copy paste R code to gmail and back to R, it loses its
> format, the dash symbol causes errors.
>
> I've had someone used it to format my code here on the list, but can't find
> it anymore.
>
> Mike
>
>     [[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.
>
>
>

        [[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: Recommendation for website to format R code

Brian Diggs
On 1/23/2013 6:40 PM, C W wrote:
> Hey Mark,
> I am aware of this package.  The situation is,
> 1. I am emailing my code from my machine to a public machine.  Installation
> is a hassle.
> 2. Copy pasting for a website.

For your second use case, there is the Pretty R syntax highlighter at
http://www.inside-r.org/pretty-r

It doesn't reformat code (you would need to use the functions in formatR
to do that first), but it does make HTML version of code for display on
a website.

> I know there are websites for formatting Java and C code.  So, I am looking
> for a website in particular, and I have seen it before but don't remember
> the site.
>
> Mike
>
> On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias <[hidden email]> wrote:
>
>> Are you only interested in formatting code from copy and pasting to/from
>> email?  If you are interested in formatting your code in Latex/PDF/HTML
>> take a look at the knitr package:
>>
>> http://yihui.name/knitr/
>>
>> Also, you could check out the formatR package:
>> http://cran.r-project.org/web/packages/formatR/formatR.pdf
>>
>> --Mark Lamias
>>
>>
>>    ------------------------------
>> *From:* C W <[hidden email]>
>> *To:* r-help <[hidden email]>
>> *Sent:* Wednesday, January 23, 2013 9:27 PM
>> *Subject:* [R] Recommendation for website to format R code
>>
>> Hi list,
>>
>> Could anyone recommend some good website for formatting R code?  For
>> example, when you copy paste R code to gmail and back to R, it loses its
>> format, the dash symbol causes errors.
>>
>> I've had someone used it to format my code here on the list, but can't find
>> it anymore.
>>
>> Mike
>>
>>      [[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.
>>
>>
>>
>
> [[alternative HTML version deleted]]
>


--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

______________________________________________
[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: Recommendation for website to format R code

tmrsg11
thanks, Brian.  I remember sending code to the R list, it was about the
lattice package some time around June 2012.  And someone else reformatted,
and it my surprise it was eye-opening.

Anyways, I will dig around on this list.
Thanks,
Mike

On Thu, Jan 24, 2013 at 2:42 PM, Brian Diggs <[hidden email]> wrote:

> On 1/23/2013 6:40 PM, C W wrote:
>
>> Hey Mark,
>> I am aware of this package.  The situation is,
>> 1. I am emailing my code from my machine to a public machine.
>>  Installation
>> is a hassle.
>> 2. Copy pasting for a website.
>>
>
> For your second use case, there is the Pretty R syntax highlighter at
> http://www.inside-r.org/**pretty-r <http://www.inside-r.org/pretty-r>
>
> It doesn't reformat code (you would need to use the functions in formatR
> to do that first), but it does make HTML version of code for display on a
> website.
>
>  I know there are websites for formatting Java and C code.  So, I am
>> looking
>> for a website in particular, and I have seen it before but don't remember
>> the site.
>>
>> Mike
>>
>> On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias <[hidden email]> wrote:
>>
>>  Are you only interested in formatting code from copy and pasting to/from
>>> email?  If you are interested in formatting your code in Latex/PDF/HTML
>>> take a look at the knitr package:
>>>
>>> http://yihui.name/knitr/
>>>
>>> Also, you could check out the formatR package:
>>> http://cran.r-project.org/web/**packages/formatR/formatR.pdf<http://cran.r-project.org/web/packages/formatR/formatR.pdf>
>>>
>>> --Mark Lamias
>>>
>>>
>>>    ------------------------------
>>> *From:* C W <[hidden email]>
>>> *To:* r-help <[hidden email]>
>>> *Sent:* Wednesday, January 23, 2013 9:27 PM
>>> *Subject:* [R] Recommendation for website to format R code
>>>
>>>
>>> Hi list,
>>>
>>> Could anyone recommend some good website for formatting R code?  For
>>> example, when you copy paste R code to gmail and back to R, it loses its
>>> format, the dash symbol causes errors.
>>>
>>> I've had someone used it to format my code here on the list, but can't
>>> find
>>> it anymore.
>>>
>>> Mike
>>>
>>>      [[alternative HTML version deleted]]
>>>
>>> ______________________________**________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/**posting-guide.html<http://www.R-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>>>
>>>
>>         [[alternative HTML version deleted]]
>>
>>
>
> --
> Brian S. Diggs, PhD
> Senior Research Associate, Department of Surgery
> Oregon Health & Science University
>

        [[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: Recommendation for website to format R code

jverzaniNWBKZ
This post has NOT been accepted by the mailing list yet.
It isn't an answer, but if you want to host such a website (http://www.r-bloggers.com/shiny-server-now-available/), here is a simple shiny application to do what you want:

## ui.R
shinyUI(bootstrapPage(
                      width <- 800 ## pixes
                      msg <- "
Paste R code here then click the button to get formatted text
"
                     
                      tags$h1("Format some R code with formatR"),
                      tags$textarea(id="foo", rows=15, required=TRUE, cols=500, width=800, style=sprintf("width: %spx", width),
                                    placeholder=msg),
                      submitButton(text="Format text"),
                      tags$hr(),
                      verbatimTextOutput("formatted_code")
))



## server.R
shinyServer(function(input, output) {
  require(formatR)
 
  output$formatted_code <- reactiveText(function() {
    out <- tidy.source(text = input$foo, output=FALSE)$text.tidy
    paste(out, collapse="\n")
  })
})
Reply | Threaded
Open this post in threaded view
|

Re: Recommendation for website to format R code

tmrsg11
In reply to this post by Mark Lamias
I ran across this page for C, Java, etc.  No R.

http://pastebin.com/
It looks similar and more than what I was looking for, just saying.

Mike


On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias <[hidden email]> wrote:

> Are you only interested in formatting code from copy and pasting to/from
> email?  If you are interested in formatting your code in Latex/PDF/HTML
> take a look at the knitr package:
>
> http://yihui.name/knitr/
>
> Also, you could check out the formatR package:
> http://cran.r-project.org/web/packages/formatR/formatR.pdf
>
> --Mark Lamias
>
>
>   ------------------------------
> *From:* C W <[hidden email]>
> *To:* r-help <[hidden email]>
> *Sent:* Wednesday, January 23, 2013 9:27 PM
> *Subject:* [R] Recommendation for website to format R code
>
> Hi list,
>
> Could anyone recommend some good website for formatting R code?  For
> example, when you copy paste R code to gmail and back to R, it loses its
> format, the dash symbol causes errors.
>
> I've had someone used it to format my code here on the list, but can't find
> it anymore.
>
> Mike
>
>     [[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.
>
>
>

        [[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: Recommendation for website to format R code

Suzen, Mehmet
Probably formatR/knitr is more robust but this one has an option for S
http://hilite.me/

-m

On 25 January 2013 02:37, C W <[hidden email]> wrote:

> I ran across this page for C, Java, etc.  No R.
>
> http://pastebin.com/
> It looks similar and more than what I was looking for, just saying.
>
> Mike
>
>
> On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias <[hidden email]> wrote:
>
>> Are you only interested in formatting code from copy and pasting to/from
>> email?  If you are interested in formatting your code in Latex/PDF/HTML
>> take a look at the knitr package:
>>
>> http://yihui.name/knitr/
>>
>> Also, you could check out the formatR package:
>> http://cran.r-project.org/web/packages/formatR/formatR.pdf
>>
>> --Mark Lamias
>>
>>
>>   ------------------------------
>> *From:* C W <[hidden email]>
>> *To:* r-help <[hidden email]>
>> *Sent:* Wednesday, January 23, 2013 9:27 PM
>> *Subject:* [R] Recommendation for website to format R code
>>
>> Hi list,
>>
>> Could anyone recommend some good website for formatting R code?  For
>> example, when you copy paste R code to gmail and back to R, it loses its
>> format, the dash symbol causes errors.
>>
>> I've had someone used it to format my code here on the list, but can't find
>> it anymore.
>>
>> Mike
>>
>>     [[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.
>>
>>
>>
>
>         [[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: Recommendation for website to format R code

Ista Zahn
In reply to this post by tmrsg11
I still don't understand what you are looking for, but
https://gist.github.com/ is similar to pastebin, and it does have R
syntax highlighting.

Best,
Ista

On Thu, Jan 24, 2013 at 8:37 PM, C W <[hidden email]> wrote:

> I ran across this page for C, Java, etc.  No R.
>
> http://pastebin.com/
> It looks similar and more than what I was looking for, just saying.
>
> Mike
>
>
> On Wed, Jan 23, 2013 at 9:34 PM, Mark Lamias <[hidden email]> wrote:
>
>> Are you only interested in formatting code from copy and pasting to/from
>> email?  If you are interested in formatting your code in Latex/PDF/HTML
>> take a look at the knitr package:
>>
>> http://yihui.name/knitr/
>>
>> Also, you could check out the formatR package:
>> http://cran.r-project.org/web/packages/formatR/formatR.pdf
>>
>> --Mark Lamias
>>
>>
>>   ------------------------------
>> *From:* C W <[hidden email]>
>> *To:* r-help <[hidden email]>
>> *Sent:* Wednesday, January 23, 2013 9:27 PM
>> *Subject:* [R] Recommendation for website to format R code
>>
>> Hi list,
>>
>> Could anyone recommend some good website for formatting R code?  For
>> example, when you copy paste R code to gmail and back to R, it loses its
>> format, the dash symbol causes errors.
>>
>> I've had someone used it to format my code here on the list, but can't find
>> it anymore.
>>
>> Mike
>>
>>     [[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.
>>
>>
>>
>
>         [[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.