[R] .Rprofile: "contains invalid line(s)"

2014-06-05 Thread Stephen Davies

At some point in the recent past, my local .Rprofile has ceased to be
executed on startup. I've upgraded R several times in the last few months, and
am unsure which version caused this problem. Currently I'm running version
3.1.0 (2014-04-10) "Spring Dance" on 64-bit Ubuntu.

My symptoms and fix attempts:

1) Changes I make to .Rprofile are no longer automatically recognized by R
on startup.

2) After some Googling, I was led to believe that I need to set the
environment variable R_ENVIRON to "/home/stephen/.Rprofile." But after doing
so, when I start R, I get an error message: "File /home/stephen/.Rprofile
contains invalid line(s)". Then it lists the contents of .Rprofile, which are
now simply:

.First <- function() { 
joe <<- function(x) x*2
}

This file is perfectly valid, however, which I know because when I
explicitly source() it, it loads .First just fine, and if I run ".First()", I
can then successfully run "joe(3)".

Why does R say this .Rprofile is invalid on startup? Is setting R_ENVIRON,
as described, the correct procedure? And why did this suddenly become
necessary?

- Stephen Davies, Ph.D.
  (step...@umw.edu)

__
R-help@r-project.org 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.


[R] "verbose source" command?

2011-10-13 Thread Stephen Davies
(Apologies for the n00b question.)

Hello, I'm teaching R in an introductory programming course and am walking
the students through the baby steps. One thing I'd like to be able to do is
have them copy the commands they type at the R console into a text file,
and then execute the text file to see the results. For instance, if their 
session looks like this:

3+4
[1] 7
factorial(10)
[1] 3628800

I'd like for them to create a text file called "myCommands.R" with contents:

3+4
factorial(10)

and then run it at the R console using source("myCommands.R"), and see this 
output:

[1] 7
[1] 3628800

This would help with many things, including my grading their lab work.

Unfortunately, if I/they do this using the source() command as it stands,
the result is of course no output at all, because nothing is being
explicitly printed (with print() or cat() command, for example).

My question is: is there a command to do what I'm trying to do here? Is
there some kind of "verbose source" command (or mode) that will run a .R
script/program/file and print all the results from it exactly as if those
commands had been entered at the console?

__
R-help@r-project.org 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.


Re: [R] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-20 Thread Stephen Davies

> >>> I'm using chisq.test() on a matrix of categorical data, and I see  
> >>> that the
> >>> "residuals" attribute of the returned object will give me the  
> >>> Pearson residuals.
> 
> Actually they are not an attribute in the R sense, but rather a list  
> value.

Oh. I was just going by:

> attributes(my.chisq.test)
$names
[1] "statistic" "parameter" "p.value"   "method""data.name" "observed" 
[7] "expected"  "residuals"

$class
[1] "htest"

which I interpreted as "this object has 8 attributes, called 'statistic',
'parameter', ..., 'residuals'." Is that not the right terminology?


> >>> That's cool. However, what I'd really like is the standardized  
> >>> (adjusted)
> >>> Pearson residuals, which have a N(0,1) distribution. Is there a  
> >>> way to do that
> >>> in R (other than by me programming it myself?)
> >>
> >> ?scale
> >
> > chisq.test(...)$stdres, more likely.

"scale" is not what I want. As for "$stdres," that would be wonderful, but
as you can see from the above list of attributes, it's not one of the 8
returned. What am I missing?

- Stephen

__
R-help@r-project.org 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.


[R] chisq.test(): standardized (adjusted) Pearson residuals

2011-08-19 Thread Stephen Davies
I'm using chisq.test() on a matrix of categorical data, and I see that the
"residuals" attribute of the returned object will give me the Pearson residuals.
That's cool. However, what I'd really like is the standardized (adjusted)
Pearson residuals, which have a N(0,1) distribution. Is there a way to do that
in R (other than by me programming it myself?)

__
R-help@r-project.org 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.