Re: [R] Pasting a large chunk of R code in terminals

2015-10-29 Thread Victor Tian
Not a specific problem. Just an issue encountered pasting R codes in
terminals from time to time.

Cheers,

Xu

On Thu, Oct 29, 2015 at 2:46 PM, jim holtman  wrote:

> Another good reason for using "source" instead of copy/paste is that if an
> error occurs, the 'sourced' script will stop at the error, while the
> copy/paste will keep on chugging away, knowing who does what in the rest of
> the script.  Most of the editors I have used on Windows (notepad++, tinn-r)
> support highlighting code and then automatically creating a temporary file
> that is 'sourced' in.
>
>
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
> On Thu, Oct 29, 2015 at 2:13 PM, Victor Tian  wrote:
>
>> Thanks, Marc and Jeff, for the advice of running a file of R code rather
>> than a chunk of R code.
>>
>> Just thought it would be nice to have a feature like this so that there's
>> still a sense of interaction in running R code.
>>
>> It was a random idea and I think using "source" would achieve the same
>> goal.
>>
>> Thanks,
>> Xu
>>
>> On Thu, Oct 29, 2015 at 11:51 AM, Jeff Newmiller <
>> jdnew...@dcn.davis.ca.us>
>> wrote:
>>
>> > I highly recommend ?source.
>> >
>> > You can use source("clipboard") on windows, but creating complete files
>> > that define functions and feeding those complete files to source is a
>> > significant step in developing reproducible analyses. Whenever you find
>> > yourself pasting more than a couple of lines (one or two function calls)
>> > you should be making another function. However, even if you resist
>> making
>> > functions you should be making a habit of sourcing complete files from
>> disk
>> > rather than passing large chunks of code.
>> >
>> ---
>> > Jeff NewmillerThe .   .  Go
>> Live...
>> > DCN:Basics: ##.#.   ##.#.  Live
>> > Go...
>> >   Live:   OO#.. Dead: OO#..  Playing
>> > Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> > /Software/Embedded Controllers)   .OO#.   .OO#.
>> rocks...1k
>> >
>> ---
>> > Sent from my phone. Please excuse my brevity.
>> >
>> > On October 29, 2015 8:16:17 AM MST, Victor Tian 
>> > wrote:
>> > >Hi there,
>> > >
>> > >Often times, I would run R in the terminal when the task is
>> > >computationally
>> > >intensive and a nice-looking UI is less desired.
>> > >
>> > >However, pasting a large chunk of code into the terminal often times
>> > >ends
>> > >up being messed up. In Python, the same problem would happen, however,
>> > >iPython provides a small functionality called magic word such as %paste
>> > >that can help paste the code neatly into the terminal.
>> > >
>> > >I'm wondering if there's a similar functionality in R.
>> > >
>> > >Thanks,
>> >
>> >
>>
>>
>> --
>> *Xu Tian*
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
>


-- 
*Xu Tian*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Pasting a large chunk of R code in terminals

2015-10-29 Thread Victor Tian
Thanks, Marc and Jeff, for the advice of running a file of R code rather
than a chunk of R code.

Just thought it would be nice to have a feature like this so that there's
still a sense of interaction in running R code.

It was a random idea and I think using "source" would achieve the same goal.

Thanks,
Xu

On Thu, Oct 29, 2015 at 11:51 AM, Jeff Newmiller 
wrote:

> I highly recommend ?source.
>
> You can use source("clipboard") on windows, but creating complete files
> that define functions and feeding those complete files to source is a
> significant step in developing reproducible analyses. Whenever you find
> yourself pasting more than a couple of lines (one or two function calls)
> you should be making another function. However, even if you resist making
> functions you should be making a habit of sourcing complete files from disk
> rather than passing large chunks of code.
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live
> Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
>
> On October 29, 2015 8:16:17 AM MST, Victor Tian 
> wrote:
> >Hi there,
> >
> >Often times, I would run R in the terminal when the task is
> >computationally
> >intensive and a nice-looking UI is less desired.
> >
> >However, pasting a large chunk of code into the terminal often times
> >ends
> >up being messed up. In Python, the same problem would happen, however,
> >iPython provides a small functionality called magic word such as %paste
> >that can help paste the code neatly into the terminal.
> >
> >I'm wondering if there's a similar functionality in R.
> >
> >Thanks,
>
>


-- 
*Xu Tian*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Pasting a large chunk of R code in terminals

2015-10-29 Thread Victor Tian
Hi there,

Often times, I would run R in the terminal when the task is computationally
intensive and a nice-looking UI is less desired.

However, pasting a large chunk of code into the terminal often times ends
up being messed up. In Python, the same problem would happen, however,
iPython provides a small functionality called magic word such as %paste
that can help paste the code neatly into the terminal.

I'm wondering if there's a similar functionality in R.

Thanks,

-- 
*Xu Tian*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Linear regression with a rounded response variable

2015-10-21 Thread Victor Tian
Hi Ravi,

Thanks for this interesting question. My thoughts are given below.

If you believe the rounding is indeed uniformly distributed, then the
problem is equivalent with adding a uniform random error between (-0.5,
0.5) for every observation in addition to the standard normal error, which
will make the new error term have a mixture distribution.

Intuitively, the impact of this newly added term depends on the relative
scale of the original normal and the new uniform error terms. To see the
exact impact, you can simulate sets of new response variables by adding
uniform errors from (-0.5, 0.5) to the original response variables and see
the results.

I wish I could have more theoretical answers and hope this helps as well.

Best,
Xu

Xu Tian, Ph.D.
Senior Statistician
Validus Research
New York, NY 10005

On Wed, Oct 21, 2015 at 10:53 AM, Ravi Varadhan 
wrote:

> Hi,
> I am dealing with a regression problem where the response variable, time
> (second) to walk 15 ft, is rounded to the nearest integer.  I do not care
> for the regression coefficients per se, but my main interest is in getting
> the prediction equation for walking speed, given the predictors (age,
> height, sex, etc.), where the predictions will be real numbers, and not
> integers.  The hope is that these predictions should provide unbiased
> estimates of the "unrounded" walking speed. These sounds like a measurement
> error problem, where the measurement error is due to rounding and hence
> would be uniformly distributed (-0.5, 0.5).
>
> Are there any canonical approaches for handling this type of a problem?
> What is wrong with just doing the standard linear regression?
>
> I googled and saw that this question was asked by someone else in a
> stackexchange post, but it was unanswered.  Any suggestions?
>
> Thank you,
> Ravi
>
> Ravi Varadhan, Ph.D. (Biostatistics), Ph.D. (Environmental Engg)
> Associate Professor,  Department of Oncology
> Division of Biostatistics & Bionformatics
> Sidney Kimmel Comprehensive Cancer Center
> Johns Hopkins University
> 550 N. Broadway, Suite -E
> Baltimore, MD 21205
> 410-502-2619
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



-- 
*Xu Tian*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.