Re: [R] Suppress 'x' when appending to a csv file

2007-09-08 Thread John Kane
Thanks Marc. It works.  I had not thought of using
col.names = FALSE as I wanted to keep the colnames. I
see that I will just have to do another write.table
command to do this.  Humm, actually it took a a bit of
juggling to do the names but it's looking fine now.



--- Marc Schwartz <[EMAIL PROTECTED]> wrote:

> On Sat, 2007-09-08 at 11:41 -0400, John Kane wrote:
> > Is there any convenient way to supress the x that
> > appears in csv export files?  I would like to be
> able
> > to export a file and add a comment to it yet still
> be
> > able to read it back into R.  I don't see any way
> to
> > get rid of the x that seperates the different
> appended
> > parts.
> > 
> > Thanks
> > 
> > EXAMPLE
> > 
> > x
> > 1
> > 2
> > 3
> > 4
> > 5
> > x
> > #Results from file SSS.r
> > 
> > R.2.5.1 Windows XP
> 
> John,
> 
> Try this:
> 
> > write.table(head(iris), sep = ",", 
>   row.names = FALSE, col.names = FALSE)
> 5.1,3.5,1.4,0.2,"setosa"
> 4.9,3,1.4,0.2,"setosa"
> 4.7,3.2,1.3,0.2,"setosa"
> 4.6,3.1,1.5,0.2,"setosa"
> 5,3.6,1.4,0.2,"setosa"
> 5.4,3.9,1.7,0.4,"setosa"
> 
> 
> You may need to explicitly adjust other arguments
> that are otherwise set
> to defaults when using write.csv().
> 
> HTH,
> 
> Marc Schwartz
> 
> 
>

__
R-help@stat.math.ethz.ch 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] Suppress 'x' when appending to a csv file

2007-09-08 Thread John Kane
Is there any convenient way to supress the x that
appears in csv export files?  I would like to be able
to export a file and add a comment to it yet still be
able to read it back into R.  I don't see any way to
get rid of the x that seperates the different appended
parts.

Thanks

EXAMPLE

x
1
2
3
4
5
x
#Results from file SSS.r

R.2.5.1 Windows XP

__
R-help@stat.math.ethz.ch 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] negative value for AIC and BIC

2007-09-07 Thread John Sorkin
Oliver,
I am attaching an HTML document in which I have plotted -2Log(x) vs. x. If you 
examine the plot you will see that -2Log(x) can be negative. Since -2Log(x) is 
part of AIC and BIC, AIC and BIC can be negative.
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]

>>> "Hannu Kahra" <[EMAIL PROTECTED]> 09/07/07 4:32 AM >>>
Olivier,

type ?AIC and have a look at the description

Description:

 Generic function calculating the Akaike information criterion for
 one or several fitted model objects for which a log-likelihood
 value can be obtained, according to the formula -2*log-likelihood
 + k*npar, where npar represents the number of parameters in the
 fitted model, and k = 2 for the usual AIC, or k = log(n) (n the
 number of observations) for the so-called BIC or SBC (Schwarz's
 Bayesian criterion).

AIC = -2*log-likelihood + k*npar can be negative as SBC, too.

Hannu

On 9/7/07, Olivier MARTIN <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
>
> I obtained negative values for AIC and BIC criteria for a particular
> model that I have
> developped...
>
> I don't remember to have negative values for these crietria for others
> applications, so I am a
> little suprised... Could anyone tell me if something is wrong or his
> conclusion concerning my model?
>
> Best regards,
> Olivier.
>
> __
> R-help@stat.math.ethz.ch 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]]

__
R-help@stat.math.ethz.ch 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.

Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.  
Any unauthorized use, disclosure or distribution is prohibited.  If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 

   y = -2Log[x]

   Out[20]=

   -2 Log[x]

   In[22]:=

   RowBox[{Plot,  [, RowBox[{y, ,, RowBox[{{, RowBox[{x, ,, 0.01, ,, 4}],
   }}], ,, AxesLabel {x, -2Log[x]}}], ]}]

   [Graphics:HTMLFiles/-2Log_10.gif]

   Out[22]=

   -Graphics-

   __

   Created by [1]Mathematica  (September 7, 2007)

References

   1. http://www.wolfram.com/
__
R-help@stat.math.ethz.ch 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] kendall test

2007-09-06 Thread John Kane
?cor perhaps
--- elyakhlifi mustapha <[EMAIL PROTECTED]>
wrote:

> Hello,
> I thougth that there is a function which does the
> kendall test in R,
> I writed on the console apropos("kendall") and I
> didn't found anything can you tell me how could I do
> to use the kendall test?
> Thanks.
> 
> 
>  
>
_
> 
> 
> l 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Rcmdr scatter3d

2007-09-04 Thread John Fox
Dear chip,

When there is groups variable specified, scatter3d() colours the
regression surface, points, and residuals for each group according to
the colours specified in surface.col. (Setting surface=FALSE suppresses
the regression surfaces and residuals.)

You can save the rgl graph that scatter3d() produces as a bitmapped png
graphic [e.g., via Graphs -> 3D graph -> Save graph to file, which uses
rgl.snapshot()]. There is also an rgl.postscript() command, which
supports some vector-graphics formats, but I've been unable to use it
successfully.

I hope this helps,
 John

On Tue, 4 Sep 2007 13:43:44 -0700 (PDT)
 array chip <[EMAIL PROTECTED]> wrote:
> Hi, I am using the scatter3d function in Rcmdr to plot
> the first 3 principal components, I have a grouping
> variable of 2 groups, and tried to plot points with
> different colors, somehow I couldn't change the
> default colors of the 2 groups (blue and green)by
> using option points.col=c('red','blue'), what's the
> problem here?
> 
> scatter3d(all.pca$x[,2],all.pca$x[,3],all.pca$x[,1],
> surface=FALSE, residuals=TRUE, bg="white",
> axis.scales=F, grid=F, ellipsoid=F, xlab='PCA
> 2',ylab='PCA 3', zlab='PCA
> 1',sphere.size=1.5,groups=as.factor(c(rep(1,100),rep(2,50)))
> ,point.col=c('red','blue'))
> 
> I am also wondering if I can have a copy of the image
> in high resolution, just like copying a regular R plot
> in "Metafile"? 
> 
> Thanks
> 
> 
> 
>
>

> 
> that gives answers, not web links.
> 
> __
> R-help@stat.math.ethz.ch 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.


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
R-help@stat.math.ethz.ch 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] Row-Echelon Form

2007-09-03 Thread John Fox
Dear Peter,

Some time ago, I posted a function RREF to r-help that computes the reduced
row-echelon form of a matrix. Just last week, Scott Hyde posted a revised
version of this function to r-help (see
https://stat.ethz.ch/pipermail/r-help/2007-September/139923.html). My
original function didn't work correctly in some cases, and in response to
Scott's message, I tried to post a newer version to r-help, but it doesn't
seem to have gotten through (perhaps because I attached the function in a
file). I append the function below, along with some other simple
linear-algebra functions.

I hope this helps,
 John

- snip -

# Last modified 9 July 2007 by J. Fox

GaussianElimination <- function(A, B, tol=sqrt(.Machine$double.eps), 
verbose=FALSE, fractions=FALSE){
# A: coefficient matrix
# B: right-hand side vector or matrix
# tol: tolerance for checking for 0 pivot
# verbose: if TRUE, print intermediate steps
# fractions: try to express nonintegers as rational numbers
# If B is absent returns the reduced row-echelon form of A.
# If B is present, reduces A to RREF carrying B along.
if (fractions) {
mass <- require(MASS)
if (!mass) stop("fractions=TRUE needs MASS package")
}
if ((!is.matrix(A)) || (!is.numeric(A)))
stop("argument must be a numeric matrix")
n <- nrow(A)
m <- ncol(A)
if (!missing(B)){
B <- as.matrix(B)
if (!(nrow(B) == nrow(A)) || !is.numeric(B))
  stop("argument must be numeric and must match the number of row of
A")
A <- cbind(A, B)
}
i <- j <- 1
while (i <= n && j <= m){
while (j <= m){
currentColumn <- A[,j]
currentColumn[1:n < i] <- 0
# find maximum pivot in current column at or below current row
which <- which.max(abs(currentColumn))
pivot <- currentColumn[which]
if (abs(pivot) <= tol) { # check for 0 pivot
j <- j + 1
next
} 
if (which > i) A[c(i, which),] <- A[c(which, i),]  # exchange
rows
A[i,] <- A[i,]/pivot# pivot
row <- A[i,]
A <- A - outer(A[,j], row)  # sweep
A[i,] <- row# restore current row
if (verbose) if (fractions) print(fractions(A))
else print(round(A, round(abs(log(tol,10)
j <- j + 1
break
}
i <- i + 1
}
 # 0 rows to bottom
zeros <- which(apply(A[,1:m], 1, function(x) max(abs(x)) <= tol))
if (length(zeros) > 0){
zeroRows <- A[zeros,]
A <- A[-zeros,]
A <- rbind(A, zeroRows)
}
rownames(A) <- NULL
if (fractions) fractions (A) else round(A, round(abs(log(tol, 10
}

matrixInverse <- function(X, tol=sqrt(.Machine$double.eps), ...){
# returns the inverse of nonsingular X
if ((!is.matrix(X)) || (nrow(X) != ncol(X)) || (!is.numeric(X))) 
stop("X must be a square numeric matrix")
n <- nrow(X)
X <- GaussianElimination(X, diag(n), tol=tol, ...) # append identity
matrix
# check for 0 rows in the RREF of X:
if (any(apply(abs(X[,1:n]) <= sqrt(.Machine$double.eps), 1, all)))
stop ("X is numerically singular")
X[,(n + 1):(2*n)]  # return inverse
}

RREF <- function(X, ...) GaussianElimination(X, ...)
# returns the reduced row-echelon form of X

Ginv <- function(A, tol=sqrt(.Machine$double.eps), verbose=FALSE, 
fractions=FALSE){
# return an arbitrary generalized inverse of the matrix A
# A: a matrix
# tol: tolerance for checking for 0 pivot
# verbose: if TRUE, print intermediate steps
# fractions: try to express nonintegers as rational numbers
m <- nrow(A)
n <- ncol(A)
B <- GaussianElimination(A, diag(m), tol=tol, verbose=verbose, 
fractions=fractions)
L <- B[,-(1:n)]
AR <- B[,1:n]
C <- GaussianElimination(t(AR), diag(n), tol=tol, verbose=verbose, 
fractions=fractions)
R <- t(C[,-(1:m)])
AC <- t(C[,1:m])
ginv <- R %*% t(AC) %*% L
if (fractions) fractions (ginv) else round(ginv, round(abs(log(tol,
10
}

cholesky <- function(X, tol=sqrt(.Machine$double.eps)){
# returns the Cholesky square root of the nonsingular, symmetric matrix
X
# tol: tolerance for checking for 0 pivot
# algorithm from Kennedy & Gentle (1980)
if (!is.numeric(X)) stop("argument is not numeric")
if (!is.matrix(X)) stop("argument is not a matrix")
n <- nrow(X)
if (ncol(X) != n) stop("matrix is not square")
if (max(abs(X - t(X))) > tol) stop("matrix is not symm

Re: [R] How to cite the the PDF user's guide for LIMMA

2007-08-29 Thread John Kane
This depends on what style manual you , your
publisher,  or your institution uses.  One common syle
(APA ) recommends this: 
http://library.osu.edu/sites/guides/apagd.php#sid  


--- "Vallejo, Roger" <[EMAIL PROTECTED]>
wrote:

> Dear All,
> How to cite the PDF user's guide for the LIMMA
> package?
> This is not about how to cite the LIMMA package.
> Roger
> 
> 
> Roger L. Vallejo, Ph.D.
> Computational Biologist & Geneticist
> U.S. Department of Agriculture, ARS
> National Center for Cool & Cold Water Aquaculture
> 11861 Leetown Road
> Kearneysville, WV 25430
> Voice:(304) 724-8340 Ext. 2141
> Email:[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Excel

2007-08-29 Thread John Kane

--- Rolf Turner <[EMAIL PROTECTED]> wrote:

> 
> On 28/08/2007, at 7:16 PM, J Dougherty wrote:
> 
>   
> 
> > PS, I quit using Excel for most important work
> after it returned a  
> > negative
> > variance on some data I was collecting descriptive
> statistics on.
> 
> Those of you who have not seen it should have a look
> at Jonathan  
> Cryer's commentary
> on Excel, available at the URL:
> 
>   http://www.stat.uiowa.edu/~jcryer/JSMTalk2001.pdf
> 
> Executive summary:  Friends don't let friends use
> Excel for statistics.
> 
>   cheers,
> 
>   Rolf Turner

And perhaps beware of them at any time?  They're great
tools but all–to–often are miss-used.
http://www.eusprig.org/

__
R-help@stat.math.ethz.ch 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] FAQ 7.x when 7 does not exist. Useability question

2007-08-27 Thread John Kane

--- Duncan Murdoch <[EMAIL PROTECTED]> wrote:

> Deepayan Sarkar wrote:
> > On 8/23/07, Duncan Murdoch <[EMAIL PROTECTED]>
> wrote:
> >   
> >> On 8/23/2007 11:28 AM, Prof Brian Ripley wrote:
> >> 
> >>> On Thu, 23 Aug 2007, John Kane wrote:
> >>>
> >>>   
> >>>> The FAQ Section 7 is a very useful place for
> new users
> >>>> to find out any number of R idiosycracies. 
> However
> >>>> there is no numbering on the FAQ Table of
> Content or
> >>>> on the Sections Tables of Contents.
> >>>> 
> >>> Hmm, doc/FAQ does have a numbered table of
> contents and numbered sections
> >>> and doc/manual/R-FAQ.html does have numbered
> sections and my browser's
> >>> search finds 7.10 straight away.
> >>>   
> >> I think the suggestion is to change the contents
> lists in HTML from 
> >> lists to  lists.  Then one would see
> >>
> >> 1. Introduction
> >> 2. R Basics
> >> 3. R and S
> >> 4. R Web Interfaces
> >> 5. R Add-On Packages
> >> 6. R and Emacs
> >> 7. R Miscellanea
> >> 8. R Programming
> >> 9. R Bugs
> >>10. Acknowledgments
> >>
> >> instead of
> >>
> >>  * Introduction
> >>  * R Basics
> >>  * R and S
> >>  * R Web Interfaces
> >>  * R Add-On Packages
> >>  * R and Emacs
> >>  * R Miscellanea
> >>  * R Programming
> >>  * R Bugs
> >>  * Acknowledgments
> >>
> >> in a browser, and I agree that would be
> preferable (assuming the
> >> numbering is consistent with what we get in the
> other formats).
> >> However, I don't see how to tell makeinfo --html
> to do this.  Adding
> >> --number-sections isn't enough.
> >> 
> >
> > A simple CSS hack is to have
> >
> > ul{
> > list-style-type: decimal;
> > }
> >
> > in the style. The result can be seen in
> >
> > http://dsarkar.fhcrc.org/R/RFAQ-1.png
> >
> > A more sophisticated hack is to have something
> like
> >
> > ---
> > body{
> > counter-reset: chapter;
> > counter-reset: section;
> > }
> > h2.chapter {
> > counter-increment: chapter;
> > counter-reset: section;
> > }
> >
> > ul {
> > list-style-type: none;
> > }
> >
> > li:before {
> > counter-increment: section;
> > content: counter(chapter) "." counter(section)
> " " ;
> > }
> > -
> >
> > which results in
> >
> > http://dsarkar.fhcrc.org/R/RFAQ-2.png
> >
> > The only problem here is that there is no way to
> distinguish between
> > the chapter listing and the section listings (both
> are  > class="menu">). If that could be made to have a
> different class, the
> > chapter listing could be improved.
> 
> I like the first, simple suggestion best; I'll put
> it into R-devel.  
> (With the slight change to use ul.menu instead
> of just ul, because FAQ 2.7 includes a plain ul
> list.)
> 
> Duncan Murdoch
Thanks Deepayan and Duncan.  

It is not a make or break point in using R but it does
seem to make the FAQ a bit more user-friendly.

__
R-help@stat.math.ethz.ch 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] An issue with White's test in Anova

2007-08-24 Thread John Fox
Dear David,

You've found a bug in Anova() for linear models that was introduced some
time ago when the linear.hypothesis() function [which is used by Anova()]
was modified not to report sums of squares for "White-adjusted" tests. I
have to think about should be done in this case.

Sorry,
 John

----
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of David Kaplan
> Sent: Friday, August 24, 2007 3:55 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] An issue with White's test in Anova
> 
> Hi all,
> 
> I'm running White's test to correct for non-constant error 
> variance and I am using the Anova function in the package 
> CAR.  My command structure is
> 
>  > Anova(scireg3, white.adjust="hc3")
> 
> where scireg3 is an object from lm.
> 
> I get the message
> 
> "Error in SS[i] <- SS.term(names[i]) : nothing to replace with"
> 
> What does this mean and how do I fix it.
> 
> Thanks in advance.
> 
> David
> 
> 
> 
> 
> --
> ==
> =
> David Kaplan, Ph.D.
> Professor
> Department of Educational Psychology
> University of Wisconsin - Madison
> Educational Sciences, Room, 1061
> 1025 W. Johnson Street
> Madison, WI 53706
> 
> email: [EMAIL PROTECTED]
> homepage: 
> http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
> Phone: 608-262-0836
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] perception of graphical data

2007-08-24 Thread John Fox
Dear Richard,

Though slightly dated, the following article is a nice summary of the
literature on graphical perception:

Lewandowsky, S & Spence, I. (1989) The perception of statistical
graphs. Sociological Methods and Research, 18, 200-242.

I hope this helps,
 John

On Fri, 24 Aug 2007 13:30:56 -0400
 "Yeh, Richard C" <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I apologize that this is off-topic.  I am seeking information on
> perception of graphical data, in an effort to improve the plots I
> produce.  Would anyone point me to literature reviews in this area?
>  (Or
> keywords to try on google?)  Is this located somewhere near cognitive
> science, psychology, human factors research?
> 
> For example, some specific questions I have are:
> 
> I recall as a child when I first saw a map where the areas of the
> containers (geographical states) were drawn as rectangles,
> proportional
> to a quantity other than land area.  Does anyone know of an algorithm
> for drawing such maps?  Would anyone know of a journal or reference
> where I can find studies on whether subjects reading these maps can
> accurately assess the meaning of the different areas, as [some of us]
> can assess different heights on a bar graph?  (What about areas in
> bar
> graphs with non-uniform widths?)
> 
> Scatter plots of microarray data often attempt to represent thousands
> or
> tens of thousands of points, but all I read from them are density and
> distribution --- the gene names cannot be shown.  At what point,
> would a
> sunflowerplot-like display or a smooth gradient be better?  When two
> data points drawn as 50% gray disks are small and tangent, are they
> perceptually equivalent to a single, 100% black disk?  Or a 50% gray
> disk with twice the area?  What problems are known about plotting
> with
> disks --- do viewers use the area or the diameter (or neither) to
> gauge
> weight?
> 
> 
> As you can tell, I'm a non-expert, mixing issues of data
> interpretation,
> visual perception, graphic representation.  Previously, I didn't have
> the flexibility of R's graphics, so I didn't need to think so much.
> I've read some of Edward S. Tufte's books, but found them more
> qualitative than quantitative.
> 
> Thanks!
> 
> Richard
> 
> 212-933-3305 / [EMAIL PROTECTED]
> 
> __
> R-help@stat.math.ethz.ch 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.


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
R-help@stat.math.ethz.ch 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] Merging two files together in R

2007-08-24 Thread john seers \(IFR\)
 
Try looking at ?merge

If your data is in two dataframes df1 and df2:

merge(df1, df2)

(This will merge on SNPID because that column is common to both
dataframes).



 
---

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Morassa Mohseni
Sent: 24 August 2007 15:41
To: r-help@stat.math.ethz.ch
Subject: [R] Merging two files together in R

Hi,

Thanks in advance for reading this post.

I received some affymetrix genotyping data back recently (250K, Nsp
array)...However, in order for me to do any analysis on this data set, I
need to add append the annotation file to it. Basically I want to do
something that looks like this:



Snpfile(tab delimited):



SNPID  Genotype  X  Y

123   AA13.4 1.2

456   AB   10.1 12.2

789   BB   2.714.4



Annotation file (csv file):



rs#,   SNPID, Chromosome

rs23525,  456, 12

rs78423,  123,  4

rs82342,   789,  9



What I am trying to get is an output file that looks like this:



SNPID  rs#   Chromosome  Genotype  X
Y

123   rs78423  4 AA
13.4
1.2

456   rs23525  12AB
10.1
12.2

789   rs82342   9BB
2.7
14.4





The SNPID is the same in both files so I would like to use that to match
up...but they are not in the same order in both files, so I want to make
sure that I am appending and merging the 2 files correctly. So far all
ive really been able to do is import the files into R...Ive been looking
through the posts, and was wondering if I could use cbind(...) to merge
the files?...not sure though.



Thanks again!!

Morassa Mohseni



PhD Student

Johns Hopkins Dept. of Human Genetics

Baltimore, MD

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] How to shade vertical bands in a graph?

2007-08-24 Thread John Kane

?rect
Something like this should work but I did not take the
time to get the rectangles to fit properly.

aa <- rnorm(25)
yl <- -1.5
yh <- 2.2
xleft <- c(4, 9, 15 ,20)
xright  <-  xleft + 3
plot(aa, ylim= c(yl,yh), type="n")
rect(xleft, yl, xright,yh, col="yellow")
points(aa, col="red")


--- del pes <[EMAIL PROTECTED]> wrote:

> 
> Hello,
> 
> I would like to draw vertical yellow bands in my
> graph, but could not find how to do that in the
> documentation.
> 
> I set up a page to show what I would like to
> achieve: http://rstudent.blogg.de/eintrag.php?id=1
> (the first picture was manually colored with the
> Gimp).
> 
> Any help would be welcome...
> 
> All the best,
> 
> Delfina
>
_
> [[replacing trailing spam]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] FAQ 7.x when 7 does not exist. Useability question

2007-08-23 Thread John Kane

--- Prof Brian Ripley <[EMAIL PROTECTED]> wrote:

> On Thu, 23 Aug 2007, John Kane wrote:
> 
> > The FAQ Section 7 is a very useful place for new
> users
> > to find out any number of R idiosycracies. 
> However
> > there is no numbering on the FAQ Table of Content
> or
> > on the Sections Tables of Contents.
> 
> Hmm, doc/FAQ does have a numbered table of contents
> and numbered sections 

Perhaps we are not talking about the same thing but I
don't see any numbers. My procedure  
- click on FAQ link below documentation, 
- click on R-FAQ link
Result
http://ca.geocities.com/jrkrideau/R/RFAQ.jpg

> and doc/manual/R-FAQ.html does have numbered
sections
 
Click on R-Miscelanea 
Result
http://ca.geocities.com/jrkrideau/R/RFAQ.jpg

The sections themselves are numbered but not the ToC,
at least as displayed in my browser.

Apologies for the poor quality of the screen capture.

As a check, I even found IE and had a look. I am
getting the same display in Firefox and IE so it does
not look like a browser issue.

>and my browser's search finds 7.10 straight away.

As does mine. I just question if this is recommended
as the default approach.  

> 
> > An R-help list reply of "Read FAQ 7.10" in
> response to
> > a question about converting a factor to numeric is
>  a
> > bit cryptic. The only time 7.10 appears is after
> the
> > searcher has found the entry.
> 
> It would help if you told us what you are searching
> that did not contain 
> '7.10'.
> 
> > Would it be a good idea to actually number the
> entries
> > for the FAQ Table of Contents and the Table of
> > Contents for the Sections?
> 
> I think we do.
> 
> -- 
> Brian D. Ripley, 
> [EMAIL PROTECTED]
> Professor of Applied Statistics, 
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865
> 272861 (self)
> 1 South Parks Road, +44 1865
> 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865
> 272595
>

__
R-help@stat.math.ethz.ch 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] FAQ 7.x when 7 does not exist. Useability question

2007-08-23 Thread John Kane
Yes that is it. Thanks
--- "Michael A. Miller" <[EMAIL PROTECTED]> wrote:

> >>>>> "John" == John Kane <[EMAIL PROTECTED]>
> writes:
> 
> > Apologies for the poor quality of the screen
> capture.
> 
> I think the first one is a screen cap of
> http://cran.r-project.org/doc/FAQ/R-FAQ.html.  Is
> that correct?
> 
> The faq that is part of the r-doc-html package from
> Debian also
> has the same "bulleted" table of contents.
> 
> Mike

__
R-help@stat.math.ethz.ch 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] FAQ 7.x when 7 does not exist. Useability question

2007-08-23 Thread John Kane
Thank you Duncan. That is exactly what I meant.  The 
next level (for example, after clicking on R
Miscellanea) should also have numbers.

Whether or not it's possible in html as implimented on
the R website is another matter of course.

--- Duncan Murdoch <[EMAIL PROTECTED]> wrote:

> On 8/23/2007 11:28 AM, Prof Brian Ripley wrote:
> > On Thu, 23 Aug 2007, John Kane wrote:
> > 
> >> The FAQ Section 7 is a very useful place for new
> users
> >> to find out any number of R idiosycracies. 
> However
> >> there is no numbering on the FAQ Table of Content
> or
> >> on the Sections Tables of Contents.
> > 
> > Hmm, doc/FAQ does have a numbered table of
> contents and numbered sections 
> > and doc/manual/R-FAQ.html does have numbered
> sections and my browser's 
> > search finds 7.10 straight away.
> 
> I think the suggestion is to change the contents
> lists in HTML from  
> lists to  lists.  Then one would see
> 
> 1. Introduction
> 2. R Basics
> 3. R and S
> 4. R Web Interfaces
> 5. R Add-On Packages
> 6. R and Emacs
> 7. R Miscellanea
> 8. R Programming
> 9. R Bugs
>10. Acknowledgments
> 
> instead of
> 
>  * Introduction
>  * R Basics
>  * R and S
>  * R Web Interfaces
>  * R Add-On Packages
>  * R and Emacs
>  * R Miscellanea
>  * R Programming
>  * R Bugs
>  * Acknowledgments
> 
> in a browser, and I agree that would be preferable
> (assuming the 
> numbering is consistent with what we get in the
> other formats). 
> However, I don't see how to tell makeinfo --html to
> do this.  Adding 
> --number-sections isn't enough.
> 
> Duncan Murdoch
> 
> > 
> > 
> >> An R-help list reply of "Read FAQ 7.10" in
> response to
> >> a question about converting a factor to numeric
> is  a
> >> bit cryptic. The only time 7.10 appears is after
> the
> >> searcher has found the entry.
> > 
> > It would help if you told us what you are
> searching that did not contain 
> > '7.10'.
> > 
> >> Would it be a good idea to actually number the
> entries
> >> for the FAQ Table of Contents and the Table of
> >> Contents for the Sections?
> > 
> > I think we do.
> > 
> 
>

__
R-help@stat.math.ethz.ch 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] How to fit an linear model withou intercept

2007-08-23 Thread John Sorkin
Michael,
Assuming you want a model with an intercept of zero, I think we need to ask you 
why you want an intercept of zero. When a "normal" regression indicates a 
non-zero intercet, forcing the regression line to have a zero intercept changes 
the meaning of the regression coefficients. If for some reason you want to have 
a zero intercept, but do not want to change the meaning of the regression 
coefficeints, i.e. you still what to minimize the sum of the square deviations 
from the BLUE (Best Leastsquares Unibiased Estimator) of the regression, you 
can center your dependent and indepdent variables re-run the regression. 
Centering means subtracting the mean of each variable from the variable before 
performing the regression. When you do this, the intercept term will be zero 
(or more likely a very, very, very small number that is not statisitclally 
different from zero - it will not be exactly zero due to limits on the 
precision of computer calculations) and the slope term will be the sam!
 e as that you obtained from the "normal" BLUE regression. What you are 
actually doing is transforming your data so it is centered around x=0, y=0, 
i.e. the mean of the x and y terms will be zero. I am not sure this is what you 
want to do, but I am pasting below some R code that will allow you to see the 
affect fourcing the intercept to be zero has on the slope, and how centering 
the data yields a zero intercept without changing the slope.
John



oldpar<-par(ask=T)

# Set up x and y values. Note as defined the slope of the 
# regression should be close to one (save for the "noise"
added to the y values) and the intercept should be close to
four.
x<-0:10
y<-x+4+rnorm(11,0,1)
plot(x,y)
title("Original data")

# Fit a "normal" regression line to the data and display
# the regression line on the scatter plot
fitNormalReg<-lm(y~x)
abline(fitNormalReg)

# Fit a regression line in which the intercept has been
# forced to be zero and display the line on the scattter
# plot.
fitZeroInt<-lm(y~-1+x)
abline(fitZeroInt,lty=2)

# Compare fits. 
summary(fitNormalReg)
summary(fitZeroInt)
# There is a statistically significant difference
# between the models - the model with and intercetpt,
# the "normal" regression is the better fit.
anova(fit1,fit2)

# Center y and x by subtracting their means.
yCentered<-y-mean(y)
xCentered<-x-mean(x)
# Regress the centered y values on the centered x values. This
# will give us a model with an intercept that is very, very
# small. It would be zero save for the precision limits 
# inherent in using a computer. Plot the line. Notice the
# slope of the centered is the same as that obtained from
# the normal regression. 
fitCentered<-lm(yCentered~xCentered)
abline(fitCentered,lty=10)

# Compare the three regressions. Note the slope from the 
# "normal" regression and centered regressions are the same.
# The intercept from the centered regression is very, very small
# and would be zero save for the limits of computer mathematics.
summary(fitNormalReg)
summary(fitZeroInt)
summary(fitCentered)

# Plot the centered data and show that the line goes through zero.
plot(xCentered,yCentered)
abline(fitCentered)
title("Centered data")
oldpar<-par(ask=T)


# Set up x and y values. Note as defined the slope of the 
# regression should be close to one (save for the "noise"
added to the y values) and the intercept should be close to
four.
x<-0:10
y<-x+4+rnorm(11,0,1)
plot(x,y)
title("Original data")

# Fit a "normal" regression line to the data and display
# the regression line on the scatter plot
fitNormalReg<-lm(y~x)
abline(fitNormalReg)

# Fit a regression line in which the intercept has been
# forced to be zero and display the line on the scattter
# plot.
fitZeroInt<-lm(y~-1+x)
abline(fitZeroInt,lty=2)

# Compare fits. 
summary(fitNormalReg)
summary(fitZeroInt)
# There is a statistically significant difference
# between the models - the model with and intercetpt,
# the "normal" regression is the better fit.
anova(fit1,fit2)

# Center y and x by subtracting their means.
yCentered<-y-mean(y)
xCentered<-x-mean(x)
# Regress the centered y values on the centered x values. This
# will give us a model with an intercept that is very, very
# small. It would be zero save for the precision limits 
# inherent in using a computer. Plot the line. Notice the
# slope of the centered is the same as that obtained from
# the normal regression. 
fitCentered<-lm(yCentered~xCentered)
abline(fitCentered,lty=10)

# Compare the three regressions. Note the slope from the 
# "normal" regression and centered regressions are the same.
# The intercept from the centered regression is very, very small
# and would be zero save for the limits of computer mathematics.
summary(fitNormalReg)
summary(fitZeroInt)
summary(fitCentered)

# Plot the centered data and s

Re: [R] FAQ 7.x when 7 does not exist. Useability question

2007-08-23 Thread John Kane

--- Gabor Grothendieck <[EMAIL PROTECTED]>
wrote:

> Note that googling
> 
> R FAQ 7.10
> 
> will get it on the first hit.

True, however this is not exactly a self-contained
solution if one is actually trying to use the FAQ. I
may be old fashioned but when directed to the FAQ I
tend to go to the FAQ rather than Google.  

> 
> On 8/23/07, John Kane <[EMAIL PROTECTED]> wrote:
> > The FAQ Section 7 is a very useful place for new
> users
> > to find out any number of R idiosycracies. 
> However
> > there is no numbering on the FAQ Table of Content
> or
> > on the Sections Tables of Contents.
> >
> > An R-help list reply of "Read FAQ 7.10" in
> response to
> > a question about converting a factor to numeric is
>  a
> > bit cryptic. The only time 7.10 appears is after
> the
> > searcher has found the entry.
> >
> > Would it be a good idea to actually number the
> entries
> > for the FAQ Table of Contents and the Table of
> > Contents for the Sections?
> >
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] FAQ 7.x when 7 does not exist. Useability question

2007-08-23 Thread John Kane
The FAQ Section 7 is a very useful place for new users
to find out any number of R idiosycracies.  However
there is no numbering on the FAQ Table of Content or
on the Sections Tables of Contents. 

An R-help list reply of "Read FAQ 7.10" in response to
a question about converting a factor to numeric is  a
bit cryptic. The only time 7.10 appears is after the
searcher has found the entry. 

Would it be a good idea to actually number the entries
for the FAQ Table of Contents and the Table of
Contents for the Sections?

__
R-help@stat.math.ethz.ch 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] How to fit an linear model withou intercept

2007-08-23 Thread John Kane
?lm

Details
 
"A formula has an implied intercept term. To remove
this use either y ~ x - 1 or y ~ 0 + x. See formula
for more details of allowed formulae. "

Is this what you want?


--- Michal Kneifl <[EMAIL PROTECTED]> wrote:

> Please could anyone help me?
> How can I fit a linear model where an intercept has
> no sense?
>  Thanks in advance..
> 
> Michael
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] summing columns of data frame by group

2007-08-21 Thread John Kane
?by perhaps
--- Daniel O'Shea <[EMAIL PROTECTED]> wrote:

> I have a data frame and one separate vector that is
> a grouping variable for the data frame.  I would
> like to take all rows of the data frame belonging to
> each group and then sum the columns with out using a
> for statement.
> 
> Something like: take all rows of group 1 then
> apply(group1.data,1,sum), but do this without having
> to do it separately for each group.  Any ideas? 
> thank you.
> 
> Dan
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] rv package, rvnorm function

2007-08-20 Thread John P. Burkett
In an attempt to learn to use the rv package, I have been working
through the examples in Jouni Kerman and Andrew Gelman's "Using Random
Variables to Manipulate and Summarize Simulations in R" (July 4, 2007).

I am using a Dell Precision 380n computer running Gentoo Linux and R
2.2.1 (the latest available through Gentoo's portage/emerge system).

Everything worked well until I tried the following command (found on p.
2 of the document):
beta <- rvnorm(mean=beta.hat, var=V.beta*sigma^2)
That command produced the following error message:
Error in .rvmvnorm(n = n, mean = mean, Sigma = var) :
Invalid (non-numeric) covariance matrix Sigma

Any suggestions for interpreting the error message or correcting the
problem would be much appreciated.

Pasted below, in case it is useful, is my R file:

R file begins here **

# This is a file of R commands to test Kerman and Gelman's package rv.
# It is based on their "Using Random Variables to Manipulate and
# Summarize Simulations in R,", July 4, 2007.
testscores <- read.table("rv_data.txt",header=TRUE)  # Extract data.
attach(testscores)  # Put testscores in R search path
testscores[1:2,]# Print first 2 observations
testscores[14:15,]  # Print last 2 observations
x <- testscores[,1] # midterm scores
y <- testscores[,2] # final exam scores
testlm <- lm(y ~ x) # fit linear model by OLS
sigma.hat <- sqrt(deviance(testlm)/df.residual(testlm))
# deviance(testlm) is equivalent to sum(residuals(testlm)^2)
beta.hat <- coefficients(testlm)
V.beta <- vcov(testlm)/(sigma.hat^2)  # unscaled covariance matrix
n <- 10
library(rv)
sigma <- sigma.hat*sqrt((n-2)/rvchisq(df=n-2)) # default number of
simulations
# is 1000
beta <- rvnorm(mean=beta.hat, var=V.beta*sigma^2)

R file ends here *

Best regards,
John

-- 
John P. Burkett
Department of Environmental and Natural Resource Economics
and Department of Economics
University of Rhode Island
Kingston, RI 02881-0808
USA

phone (401) 874-9195

__
R-help@stat.math.ethz.ch 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] recommended combo of apps for new user?

2007-08-20 Thread John Kane

--- hadley wickham <[EMAIL PROTECTED]> wrote:

> On 8/18/07, John Kane <[EMAIL PROTECTED]> wrote:
> > I'm just starting to get a grasp on how R works so
> > don't take my words too seriously but have a look
> at
> > http://addictedtor.free.fr/graphiques/ for some
> idea
> > of what R can do for publication quality graphics.
>  It
> > is always possible that you might need another
> > graphics package as well but I think it unlikely.
> 
> I may be in the minority, but I really don't like
> the R graph gallery.
>  To my eye it largely provides examples of what you
> _shouldn't_ do
> with graphics (and also seems rather unloved at the
> moment, given the
> large number of spam keywords).  It fails to provide
> examples of using
> graphics to gain insight into your data and mainly
> focuses on drawing
> pretty (ugly) pictures.
> 
> Unfortunately there aren't many better resources at
> the moment.
> Deepayan Sarkar is working on a lattice book, and
> hopefully he will
> make the plots available on his website as well. 
> I'm also working on
> a book for my ggplot2 package
> (http://had.co.nz/ggplot2) but that
> won't be finished until next year.  For interactive
> graphics, the
> GGobi book (http://www.ggobi.org/book/) is very
> close to being
> published, and provides details about the R-GGobi
> link as well as many
> techniques for gaining insight into your data
> interactively.  Another
> option is the Graphics of Large Dataset book
> (http://rosuda.org/gold/)
> which provides a wider survey of state of the art in
> interactive
> graphics for large datasets.
> 
> Hadley
> 

I don't disagree in a number of cases but it is a good
example of the myriad of things that one can do with R
graphics even if you may not want to!  And in some
cases, expecially in the business world, jazzing up a
graphic may be needed even if it does not improve the
actual understanding of the data.  

In the context of the OP's question about graphical
capabilites for publication quality output I think the
gallery is not a bad illustration of R's versitility. 


Thanks for the book references. Now just to pry them
loose from wthe library; well the Cook & Swayze one
isn't through cataloging yet.

__
R-help@stat.math.ethz.ch 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] R on a flash drive

2007-08-20 Thread John Kane
Oops meant to send this to the list.
--- John Kane <[EMAIL PROTECTED]> wrote:

> 
> --- Erin Hodgess <[EMAIL PROTECTED]> wrote:
> 
> > Dear R People:
> > 
> > Has anyone run R from a flash drive, please?
> > 
> > If so, how did it work, please?
> 
> Yes I run R, occasionally, on a USB with no problem
> on
> WindowsXP. It works well, albeit a bit more slowly
> than from the hard drive which is as you would
> expect.
> 
> The last time I upgraded the USB (to 2.5.0 ?) I
> simply
> downloaded R and installed it on the USB drive
> rather
> than the C: drive and then installed all my usual
> optional packages using the normal Rgui interface. 
> 
> I usually have R, Tinn-R and portable versions of
> OpenOoffice.org, and Firefox installed on the USB.  
> 
> 
>   Get news delivered with the All new Yahoo!
> Mail.  Enjoy RSS feeds right on your Mail page.
> Start today at
> http://mrd.mail.yahoo.com/try_beta?.intl=ca
>

__
R-help@stat.math.ethz.ch 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] R on a flash drive

2007-08-20 Thread John Kane

--- Erin Hodgess <[EMAIL PROTECTED]> wrote:

> Dear R People:
> 
> Has anyone run R from a flash drive, please?
> 
> If so, how did it work, please?

Yes I run R, occasionally, on a USB with no problem on
WindowsXP. It works well, albeit a bit more slowly
than from the hard drive which is as you would expect.

The last time I upgraded the USB (to 2.5.0 ?) I simply
downloaded R and installed it on the USB drive rather
than the C: drive and then installed all my usual
optional packages using the normal Rgui interface. 

I usually have R, Tinn-R and portable versions of
OpenOoffice.org, and Firefox installed on the USB.

__
R-help@stat.math.ethz.ch 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] SEM for categorical data

2007-08-19 Thread John Fox
Dear Upasna,

I apologize for responding so late, but I was out of town when you posted
your query to r-help.

The sem() function in the sem package can handle dichotomous and ordered
categorical observed variables via tetrachoric, polychoric, biserial, and
polyserial correlations computed by the polycor package. See in particular
the hetcor() function in that package, which can compute "heterogeneous"
correlation matrices. Standard errors for parameter estimates in the SEM can
then be computed by bootstrapping; see ?boot.sem in the sem package for an
example with a confirmatory factor-analysis model for ordinal observed
variables.

I hope that this helps,
 John

--- original message ---

Hi

I am looking for a structural equation modeling package in R which can be
used for categorical data. Is anyone aware of the existence of such a
package? Would appreciate any help on this.

Thank you
Upasna

-- 
-
Upasna Sharma
Research Scholar
Shailesh J. Mehta School of Management,
Indian Institute of Technology, Bombay
Powai, Mumbai - 400076, India

----
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

__
R-help@stat.math.ethz.ch 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] Rcmdr window border lost

2007-08-19 Thread John Fox
Dear Andy and Peter,

My apologies for chiming in so late, but I was out of town and just caught
up with R-help today (and an impressive amount of material accumulates on
R-help in a couple of weeks!).

Although I develop the Rcmdr package on a Windows system, I test it under
Linux as well -- most recently on Ubuntu 7.04 with R 2.5.0. Curiously, the
windows for Rcmdr 1.3-5 look normal to me, as I just verified, so I'm unable
to reproduce the problem, and wonder whether anyone else has seen it.

As well, setting options(Rmcdr=list(suppress.X11.warnings=TRUE)) should
suppress the X11 warnings that appear on some systems, but I thought that
this problem disappeared with R 2.4.0. See ?Commander.

Regards,
 John

--- original messages --

Andy Weller wrote:
> OK, I tried completely removing and reinstalling R, but this has not 
> worked - I am still missing window borders for Rcmdr. I am certain that 
> everything is installed correctly and that all dependencies are met - 
> there must be something trivial I am missing?!
>
> Thanks in advance, Andy
>
> Andy Weller wrote:
>   
>> Dear all,
>>
>> I have recently lost my Rcmdr window borders (all my other programs have 
>> borders)! I am unsure of what I have done, although I have recently 
>> update.packages() in R... How can I reclaim them?
>>
>> I am using:
>> Ubuntu Linux (Feisty)
>> R version 2.5.1
>> R Commander Version 1.3-5
>>
>> 
This sort of behaviour is usually the fault of the window manager, not 
R/Rcmdr/tcltk. It's the WM's job to supply the various window 
decorations on a new window, so either it never got told that there was 
a window, or it somehow got into a confused state. Did you try 
restarting the WM (i.e., log out/in or reboot)? And which WM are we 
talking about?

Same combination works fine on Fedora 7, except for a load of messages 
saying

Warning: X11 protocol error: BadWindow (invalid Window parameter)


>> I have deleted the folder: /usr/local/lib/R/site-library/Rcmdr and 
>> reinstalled Rcmdr with: install.packages("Rcmdr", dep=TRUE)
>>
>> This has not solved my problem though.
>>
>> Maybe I need to reinstall something else as well?
>>
>> Thanks in advance, Andy
>> 


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

__
R-help@stat.math.ethz.ch 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] recommended combo of apps for new user?

2007-08-18 Thread John Kane
I'm just starting to get a grasp on how R works so
don't take my words too seriously but have a look at 
http://addictedtor.free.fr/graphiques/ for some idea
of what R can do for publication quality graphics.  It
is always possible that you might need another
graphics package as well but I think it unlikely.  

About the data bases I don't know really however you
might want to have a look at Frank Harrell's Hmic
package for things like labels. It also includes SAS
and SPSS import funtions as does the foreign package. 

I'd say you definately need a code editor. I'm on
Windows and happy with Tinn-R but for Linux something
like http://ess.r-project.org/ seems to be
recommended.


If you have not already found it 
Bob Muenchen's R for SAS and SPSS Users
http://oit.utk.edu/scc/RforSAS&SPSSusers.pdf may be
very helpful. 

--- Martin Brown <[EMAIL PROTECTED]> wrote:

> Hi there,
> 
> I would like some advice, not so much about how to
> use R, but about software
> that I need to complement R.  I've rooted around in
> the FAQ's and done a few
> searches on this mailing list but haven't quite
> found the perspective I
> need.
> 
> I am an experienced data analyst in my field (forest
> ecology and ecological
> monitoring) but new to R. I am a long time user of
> SPSS and have gotten
> pretty handy with it.  However, I am frustrated with
> SPSS for several
> reasons:  There's the cost (I'm a freelancer; I pay
> for my software
> myself);  the Windows dependence (I use Kubuntu as
> my usual OS now, and
> switching back and forth is a pain); the horrible
> inefficiency when I do
> certain types of file manipulations; and the
> inability to do the kind of
> publication-quality graphs I want... I've usually
> ended up using a
> commercial graphing program (another source of
> expense and limitation).
> 
> I'd like to switch to using R on Kubuntu, for all
> those reasons.  In
> addition I think the mathematical formality that R
> encourages might be good
> for me.
> 
> However, reviewing the FAQ's on the R project web
> site makes me realize that
> I've been using SPSS as three kinds of software
> really:  a DBMS; a
> statistical analysis package; and a graphing
> package.  It looks like moving
> to R might involve learning three kinds of software,
> not just one.  I
> wonder:
> 
> 1) What open-source DBMS works most seamlessly with
> R?  I have seen MySQL
> recommended but wonder if there are alternatives.  I
> sometimes need to
> handle big data files.  In fact a lot of my work
> involves exploratory and
> descriptive analyses of rather large and messy
> databases from ecological
> monitoring, rather than statistical tests per se. 
> In SPSS the data files I
> have been generating have dozens of columns and
> thousands of rows, often
> with value and variable labels helpful for
> documenting my work.
> 2) For the purpose of creating publication-quality
> graphs, do R users
> typically need to go outside of the R system? If so,
> what open-source
> programs would you all recommend?
> 3) Any other software I need to learn that would
> make my work in R more
> productive? (for example, a code editor).
> 
> Thank you for your time,
> 
> Martin J. Brown
> Portland, Oregon
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] multiple colors within same line of text

2007-08-17 Thread John Kane
Correction 
x <- seq(0, 1, length=21)
db <- dbeta(x, 3,1)
plot(db)
colour <- c("red", "blue")
mytext <- c("RED", "BLUE")
mtext( mytext, at= c(2,5), side=1, col=colour)

--- John Kane <[EMAIL PROTECTED]> wrote:

> Hi Andrew,
> 
> This is pretty clumsy but it seems to work.  I
> suspect
> there are many better ways
> 
> x <- seq(0, 1, length=21)
> plot(db)
> colour <- c("red", "blue")
> mytext <- c("RED", "BLUE")
> mtext( mytext, at= c(2,5), side=1, col=colour)
> 
> --- Andrew Yee <[EMAIL PROTECTED]> wrote:
> 
> > Hi, I'm interested in using mtext(), but with the
> > option of having multiple
> > colors in the same line of text.
> > 
> > For example, creating a line of text where:
> > 
> > Red is red and blue is blue
> > 
> > How do you create a text argument that lets you do
> > this within mtext()?
> > 
> > Thanks,
> > Andrew
> > MGH Cancer Center
> > 
> > [[alternative HTML version deleted]]
> > 
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] multiple colors within same line of text

2007-08-17 Thread John Kane
Hi Andrew,

This is pretty clumsy but it seems to work.  I suspect
there are many better ways

x <- seq(0, 1, length=21)
plot(db)
colour <- c("red", "blue")
mytext <- c("RED", "BLUE")
mtext( mytext, at= c(2,5), side=1, col=colour)

--- Andrew Yee <[EMAIL PROTECTED]> wrote:

> Hi, I'm interested in using mtext(), but with the
> option of having multiple
> colors in the same line of text.
> 
> For example, creating a line of text where:
> 
> Red is red and blue is blue
> 
> How do you create a text argument that lets you do
> this within mtext()?
> 
> Thanks,
> Andrew
> MGH Cancer Center
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] residual plots for lmer in lme4 package

2007-08-17 Thread John Maindonald
I am doubtful whether standard residual plots are very useful
in this context.  One wants the theoretical effects Ui to have a
normal distribution.  If there are similar amounts of information
on each patient, maybe it will not be too bad to extract the
estimated effects and check them for normality. I don't think
you can use residuals() to extract them, as glmer() does
not have the notion of levels.  Maybe they can be extracted
using ranef(), but I do not see any examples for use with
glmer() on the help pages.

The issue of checking for normality of effects in multi-level
models has not been very much researched, as far as I can
tell.  The function residuals()  gives residuals that adjust for
all except the "highest" level of random effects.  Depending
on the relative magnitudes of the variance components,
whether or not these "residuals" are anywhere near normal
may not be of much or any consequence.

John Maindonald email: [EMAIL PROTECTED]
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.


On 17 Aug 2007, at 8:00 PM, [EMAIL PROTECTED] wrote:

> From: "Martin Henry H. Stevens" <[EMAIL PROTECTED]>
> Date: 17 August 2007 12:08:15 AM
> To: Margaret Gardiner-Garden <[EMAIL PROTECTED]>
> Cc: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Subject: Re: [R] residual plots for lmer in lme4 package
>
>
> Hi Margaret,
> Have a look at qqmath in the lattice package.
> ?qqmath
> Hank
> On Aug 16, 2007, at 2:45 AM, Margaret Gardiner-Garden wrote:
>
>> Hi,
>>
>>
>>
>> I was wondering if I might be able to ask some advice about doing  
>> residual
>> plots for the lmer function in the lme4 package.
>>
>>
>>
>> Our group's aim is to find if the expression staining of a  
>> particular gene
>> in a sample (or "core")  is related to the pathology of the core.
>>
>> To do this, we used the lmer function to perform a logistic mixed  
>> model
>> below.  I apologise in advance for the lack of subscripts.
>>
>>
>>
>>  logit P(yij=1) = â0 + Ui + â1Patholij where Ui~N(0, óu2),
>>
>> i indexes patient, j indexes measurement, Pathol is an indicator  
>> variable
>> (0,1) for benign
>>
>> epithelium versus cancer and yij is the staining indicator (0,1)  
>> for each
>> core where yij equals 1 if the core stains positive and 0 otherwise.
>>
>>
>>
>> (I have inserted some example R code at the end of this message)
>>
>>
>>
>> I was wondering if you knew how I could test that the errors Ui  
>> are normally
>> distributed in my fit.  I am not familiar with how to do residual  
>> plots for
>> a mixed logistic regression (or even for any logistic regression!).
>>
>>
>>
>> Any advice would be greatly appreciated!
>>
>>
>>
>> Thanks and Regards
>>
>> Marg
>>

__
R-help@stat.math.ethz.ch 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] ADF test

2007-08-16 Thread John C Frain
5, Lag order = 5, p-value = 0.01
> alternative hypothesis: stationary
>
> Warning message:
> p-value smaller than printed p-value in: adf.test(data[, 2])
> >
>
> this explains everything clearly :)
> your NULL hypothesis is "Series is not stationary" - hence hypothesis in
> negative sense
>
> prooved by taking ideal data
>
> > data1<-rnorm(1) #normal data
> > adf.test(data1)
>
>Augmented Dickey-Fuller Test
>
> data:  data1
> Dickey-Fuller = -21.2118, Lag order = 21, p-value = 0.01
> alternative hypothesis: stationary
>
> Warning message:
> p-value smaller than printed p-value in: adf.test(data1)
> >
>
> HTH
>
>
>
>
> Megh Dal <[EMAIL PROTECTED]>
> Sent by: [EMAIL PROTECTED]
> 08/16/2007 04:27 PM
>
> To
> r-help@stat.math.ethz.ch
> cc
>
> Subject
> [R] ADF test
>
>
>
>
>
>
> Hi all,
>
>  Hope you people do not feel irritated for repeatedly sending mail on
> Time series.
>
>  Here I got another problem on the same, and hope I would get some answer
> from you.
>
>  I have following dataset:
>
>  data[,1]
>  [1] 4.96 4.95 4.96 4.96 4.97 4.97 4.97 4.97 4.97 4.98 4.98 4.98 4.98
> 4.98 4.99 4.99 5.00 5.01
>  [19] 5.01 5.00 5.01 5.01 5.01 5.01 5.02 5.01 5.02 5.02 5.03 5.03 5.03
> 5.03 5.03 5.04 5.04 5.04
>  [37] 5.04 5.04 5.04 5.05 5.05 5.06 5.06 5.06 5.07 5.07 5.07 5.07 5.08
> 5.07 5.08 5.08 5.09 5.10
>  [55] 5.10 5.09 5.10 5.10 5.10 5.10 5.10 5.10 5.10 5.10 5.11 5.11 5.11
> 5.11 5.11 5.11 5.11 5.12
>  [73] 5.12 5.12 5.12 5.13 5.14 5.14 5.14 5.14 5.14 5.15 5.15 5.15 5.15
> 5.14 5.15 5.15 5.15 5.16
>  [91] 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.16 5.17 5.17 5.17
> 5.17 5.17 5.18 5.18 5.18
> [109] 5.18 5.18 5.19 5.19 5.20 5.20 5.20 5.20 5.20 5.21 5.21 5.21 5.21
> 5.21 5.21 5.22 5.22 5.23
> [127] 5.23 5.23 5.23 5.24 5.24 5.24 5.25 5.24 5.24 5.25 5.26 5.26 5.26
> 5.26 5.26 5.26 5.26 5.27
> [145] 5.27 5.26 5.27 5.27 5.28 5.29 5.29 5.29 5.29 5.30 5.30 5.30 5.31
> 5.31 5.31 5.32 5.32 5.33
> [163] 5.33
>
>
>  Now I want to conduct a test for stationarity using ADF test :
>
>  > adf.test((data[,1]), "stationary",  0)
>  Augmented Dickey-Fuller Test
>  data:  (data[, 1])
> Dickey-Fuller = -3.7351, Lag order = 0, p-value = 0.02394
> alternative hypothesis: stationary
>
>  But surprisingly it leads towards rejestion of NULL [p-value is less
> than 0.05], i.e. indicates a possible stationary series. However ploting a
> graph of actual data set it doesn't seem so.
>
>  Am I making any mistakes ? Can anyone give me any suggestion?
>
>  Regards,
>  Megh
>
>
> -
>
> [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.
>
>
>
> 
> DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}}
>
> __
> R-help@stat.math.ethz.ch 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.
>


-- 
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] use AnnBuilderSourceUrls with local path insted of ftp adress

2007-08-16 Thread John Zhang

>
>I want to build my own GO package using the function GOPkgBuilder of 
AnnBuilder. It uses AnnBuilderSourceUrls to collect data from different ftp 
sites. These data are not complete for my organism, so I would like to change 
the ftp adresses to a local one. The changing itself is working but when I run 
the script I get the following Error:
>
>Error in loadFromUrl(file.path(sourceURLs[["EG"]], "gene2go.gz")) : 
> URL /path/to/file/gene2go.gz is incorrect or the target site is not 
>responding!


First of all, please post questions about BioConductor packages in BioConductor 
mailing list instead of R.

Is /path/to/file a real local path? If so, you may also need to modify 
GOPkgBuilder a little. Try to change the line

eg = EG(srcUrl = sourceURLs[["EG"]]) to
eg = EG(srcUrl = sourceURLs[["EG"]], fromWeb = FALSE)


>
>The full code of the script is this:
>
>library(AnnBuilder)
>list<-options("AnnBuilderSourceUrls") 
>list$AnnBuilderSourceUrls$EG<-"/path/to/file/"
>options("AnnBuilderSourceUrls"=list$AnnBuilderSourceUrls)
>
>GOPkgBuilder(pkgName = "GO", pkgPath = ".", filename = 
"go_200706-termdb.obo-xml.gz", version = "v.1.0", author = list(author = 
"author", maintainer = "maintainer <[EMAIL PROTECTED]>") )
>
>Thanks in advance for any help.
>
>Daniela Albrecht
>
>
>-- 
>Pt! Schon vom neuen GMX MultiMessenger gehört?
>Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
>
>__
>R-help@stat.math.ethz.ch 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.

Jianhua Zhang
Department of Medical Oncology
Dana-Farber Cancer Institute
44 Binney Street
Boston, MA 02115-6084

__
R-help@stat.math.ethz.ch 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] Convert factor to numeric vector of labels

2007-08-15 Thread John Kane
My reason for setting stringsAsFactors = FALSE is more
that I really dislike having R convert what I "think"
are character variables to factors when I import data.


I suspect that it takes quite a few new users by
surprise that what they had intended to be a character
variable has become a factor. And it can take a long
time to track down the problem if you're a newbie.
-

A quick (overly simple) example where I had intended
the data in the second column to be character. 

Original data found at
http://ca.geocities.com/jrkrideau/R/facts.txt

1, b
1, b
3, b
3, b
4, a
4, a
3, a

options(stringsAsFactors = TRUE)

df  <-
read.csv("http://ca.geocities.com/jrkrideau/R/facts.txt";)
 ; df[,2]
[1]  b  b  b  a  a  a
Levels:  a  b


options(stringsAsFactors = FALSE)

df  <-
read.csv("http://ca.geocities.com/jrkrideau/R/facts.txt";)
 ; df[,2]
[1] " b" " b" " b" " a" " a" " a"
-

There are probably good reasons for setting the
default either way and while currently, I am strongly
of the FALSE persuation I can see some serious
problems changing the default, particularly when most
existing code will assume TRUE.  

It might be that a  "Why are my character variables
turning into factors"  as a compliment to "How do I
convert factors to numeric" in the FAQ would be
sufficient.  As it is the reader knows what seems to
have happened but there is no clue as to why or how
this is happening.

If there are enough problems in importing numeric as
factors a note about the default might be worthwhile
in both FAQ entries  since it seems to indicate that
this is not a rare problem.



--- Matthew Keller <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> If we, the R community, are endeavoring to make R
> user friendly
> (gasp!), I think that one of the first places to
> start would be in
> setting stringsAsFactors = FALSE. Several times I've
> run into
> instances of folks decrying R's "rediculous usage of
> memory" in
> reading data, only to come to find out that these
> folks were
> unknowingly importing certain columns as factors.
> The fix is easy once
> you know it, but it isn't obvious to new users, and
> I'd bet that it
> turns some % of people off of the program. Factors
> are not used often
> enough to justify this default behavior in my
> opinion. When factors
> are used, the user knows to treat the variable as a
> factor, and so it
> can be done on a case-by-case (or should I say
> variable-by-variable?)
> basis.
> 
> Is this a default that should be changed?
> 
> Matt
> 
> 

> > This is one of R's rather _endearing_  little
> > idiosyncrasies. I ran into it a while ago.
> >
>
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/98090.html
> >
> >
> > For some reason, possibly historical, the option
> > "stringAsFactors" is set to TRUE.
> >
> > As Prof Ripley says FAQ 7.10 will tell you
> > as.numeric(as.character(f)) # for a one-off
> conversion
> >
> > >From Gabor Grothendieck  A one-off solution for a
> > complete data.frame
> >
> > DF <- data.frame(let = letters[1:3], num = 1:3,
> >  stringsAsFactors = FALSE)
> >
> > str(DF)  # to see what has happened.
> >
> > You can reset the option globally, see below. 
> However
> > you might want to read Gabor Grothendieck's
> comment
> > about this in the thread referenced above since it
> > could cause problems if you transfer files alot.
> >
> > Personally I went with the global option since I
> don't
> > tend to transfer programs to other people and I
> was
> > getting tired of tracking down errors in my
> programs
> > caused by numeric and character variables suddenly
> > deciding to become factors.
> >
> > >From Steven Tucker:
> >
> > You can also this option globally with
> >  options(stringsAsFactors = TRUE)  # in
> > \library\base\R\Rprofile
> >
> > --- Falk Lieder <[EMAIL PROTECTED]>
> wrote:
> >
> > > Hi,
> > >
> > > I have imported a data file to R. Unfortunately
> R
> > > has interpreted some
> > > numeric variables as factors. Therefore I want
> to
> > > reconvert these to numeric
> > > vectors whose values are the factor levels'
> labels.
> > > I tried
> > > as.numeric(),
> > > but it returns a vector of factor levels (i.e.
> > > 1,2,3,...) instead of labels
> > > (i.e. 0.71, 1.34, 2.61,…).
> > > What can I do instead?
> > >
> > > Best wishes, Falk
> >
> > __
> > R-help@stat.math.ethz.ch 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.
> >
> 
> 
> -- 
> Matthew C Keller
> Postdoctoral Fellow
> Virginia Institute for Psychiatric and Behavioral
> Genetics
>

__
R-help@stat.math.ethz.ch 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 pro

Re: [R] "ung�ltige Versionsspezifikation"

2007-08-15 Thread John Kane
I think we need more information about your system.
Please run
sessionInfo()
and include the information in another posting.


--- "Mag. Ferri Leberl" <[EMAIL PROTECTED]> wrote:

> Dear everybody,
> excuse me if this question ist trivial, however, I
> have now looked for
> an answer for quite a while and therefore dare
> placing it here.
> I want to export .svg-files and got here the advice
> to employ the
> cairo-library.
> I downloaded the *current*-version here and expanded
> it
> to /usr/local/lib/R/site-library.
> library(cairo) returned ungültige
> Versionsspezifikation (INVALID VERSION
> SPECIFICATION).
> I got some answer here (EPM39), but, stupid enough,
> I could not employ
> it as I don't know where to look for the variable
> named there.
> The R-version I employ is 2.3.1.
> Can anybody solve the (probably simple) problem?
> Thank you in advance.
> Yours, Ferri



  

__
R-help@stat.math.ethz.ch 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] Convert factor to numeric vector of labels

2007-08-13 Thread John Kane
This is one of R's rather _endearing_  little 
idiosyncrasies. I ran into it a while ago.
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/98090.html


For some reason, possibly historical, the option
"stringAsFactors" is set to TRUE.  

As Prof Ripley says FAQ 7.10 will tell you
as.numeric(as.character(f)) # for a one-off conversion

>From Gabor Grothendieck  A one-off solution for a
complete data.frame

DF <- data.frame(let = letters[1:3], num = 1:3,
 stringsAsFactors = FALSE)

str(DF)  # to see what has happened.

You can reset the option globally, see below.  However
you might want to read Gabor Grothendieck's comment
about this in the thread referenced above since it
could cause problems if you transfer files alot. 

Personally I went with the global option since I don't
tend to transfer programs to other people and I was
getting tired of tracking down errors in my programs
caused by numeric and character variables suddenly
deciding to become factors.

>From Steven Tucker:

You can also this option globally with
 options(stringsAsFactors = TRUE)  # in
\library\base\R\Rprofile
 
--- Falk Lieder <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I have imported a data file to R. Unfortunately R
> has interpreted some
> numeric variables as factors. Therefore I want to
> reconvert these to numeric
> vectors whose values are the factor levels' labels.
> I tried
> as.numeric(),
> but it returns a vector of factor levels (i.e.
> 1,2,3,...) instead of labels
> (i.e. 0.71, 1.34, 2.61,…).
> What can I do instead?
> 
> Best wishes, Falk

__
R-help@stat.math.ethz.ch 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] Very new - beginners questions

2007-08-13 Thread John Kane
Hi Richard,

No specific answers for your data questions but for
learning R there are any number of resources.

There are links to references for books and a large
number of on-line materials on the R website.  Have a
look at the list on the bottom left of the screen for
"books" and "other" which leads to "contributed
documentation". 

 Books by Dalgaard, Verzani and Crawley all get good
reviews. 

In the contributed documents area "Using R for Data
Analysis and Graphics - Introduction, Examples and
Commentary”  by John Maindonald  and "Kickstarting R"
by Jim Lemon are both very useful.

I have also found that while An Introduction to R is
invaluable it is best to download it and keep it as a
pdf or a hard copy.  Also it is better as a 'second
intro' after you have looked at some of the books or
other supporting documentation.

Don't forget to browse the FAQs.  They answer some of
the more vexing questions about R very well.

(Oh if you want to move a graph from R to Word in
Windows just right click on the graph and copy it.)
--- Richard Price <[EMAIL PROTECTED]> wrote:

> Dear all,
>
>   
> I have 4 sites and want to determine how different
> they are from each other. For this I have decided to
> use R though it seems a bit daunting to learn.
>   I have read data in from a CSV the structure is :
>
>Species1 Species2 Species3
>   
> Site1 4 4  7  
> Site2 3 1  0
> Site3 0 99  6
> Site4 75 3  33
>   
> There are many more species than shown above this is
> just an example. Here are the questions.
>
>   How do I read one row of data so as to load site2
> into a variable called site2?
>   
> Once I plot a graph using ordiplot how do I extract
> it from R so that I can put it into a Word for
> Windows document?
>
>   Once I have the data in varables I hope to use
> designdist and Sørensen to discover diversity
> indices. I had a crack at this once but because I
> had sites as the columns it didn't work. Now that I
> think I have the data correct I can proceed.
>
>   x Input data (this will be the whole data set that
> I read into my variable 'allSites' from a CSV.)?
>   
> The variables for Sørensen will contain terms J for
> shared quantity, A and B for totals, N for the
> number of rows (sites) and P for the number of
> columns (species) and 'Binary' as the term.
>
>   How do I get the shared number of species for each
> row?
>
>   Probably very beginner type questions but I want
> to get on an haven't yet found the answers in my
> trawl throgh the help. Is there a book that I can
> buy to learn R?
>
>   All the best,
> Richard Price
> MSc student University Birmingham.
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> > __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Help wit matrices

2007-08-10 Thread John Kane
Will something like this help?

mm <- matrix(rnorm(100),nrow=10)
mm
nn  <-  mm  >.5
nn

--- Lanre Okusanya <[EMAIL PROTECTED]> wrote:

> Hello all,
> 
> I am working with a 1000x1000 matrix, and I would
> like to return a
> 1000x1000 matrix that tells me which value in the
> matrix is greater
> than a theshold value (1 or 0 indicator).
> i have tried
>   mat2<-as.matrix(as.numeric(mat1>0.25))
> but that returns a 1:10 matrix.
> I have also tried for loops, but they are grossly
> inefficient.
> 
> THanks for all your help in advance.
> 
> Lanre
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] how to include bar values in a barplot?

2007-08-08 Thread John Kane
Do you mean like this?

my.values=10:15
 x <- barplot(my.values, ylim=c(0,11))
  text(x, my.values, labels=my.values, pos=3)


It is very bad practice and OOo should have its
fingers slapped for perpetuating such a form.

--- "Donatas G." <[EMAIL PROTECTED]> wrote:

> How do I include bar values in a barplot (or other R
> graphics, where this 
> could be applicable)? 
> 
> To make sure I am clear I am attaching a barplot
> created with OpenOffice.org 
> which has barplot values written on top of each
> barplot. 
> 
> -- 
> Donatas Glodenis
> http://dg.lapas.info
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Relocating Axis Label/Title

2007-08-08 Thread John Kane
Have a look at "mar" in ?par.  You might want to
try something like mar=c(5, 5, 4, 2) + 0.1 rather than
the default of c(5, 4, 4, 2) + 0.1 .
--- Lorenzo Isella <[EMAIL PROTECTED]> wrote:

> Dear All,
> I am experiencing some problems with relocating an
> axis title.
> I visited the following link before posting:
> 
>
http://tolstoy.newcastle.edu.au/R/help/05/05/5283.html
> 
> But this is not entirely what I would like to do
> Consider the example below:
> 
> rm(list=ls())
> D_mean<-seq(-5,5,length=100)
> y<-exp(-D_mean^2/5)
> pdf("my.pdf")
>
plot(D_mean,y,type="l",yaxt="n",lty=2,lwd=2,col="black",
> ylab = list(expression(paste(dN/dlogD[agg],"
> ["*cm^-3*"]"))),
> xlab = expression(paste(D[agg]," [nm]")),
> cex.lab=1.2
> )
> title(2, mgp=c(0, .3, 0))
> dev.off()
> 
> I have the problem that the "3" in cubic centimeters
> (on the y axis)
> is somehow "cut" in the pdf file I generate.
> Everything would be fine
> if I could shift a bit the title of the y axis.
> It must be trivial, but so far I have not managed to
> do it.
> Any suggestions?
> Many thanks
> 
> Lorenzo
> I tried playing with the mgp parameter, but I
> managed to move the
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Changing font in boxplots

2007-08-08 Thread John Kane

--- Prof Brian Ripley <[EMAIL PROTECTED]> wrote:

> On Wed, 8 Aug 2007, G Iossa, School Biological
> Sciences wrote:
> 
> > Hi John,
> >
> > Thanks so much for such a quick reply.
> > I have tried to set all to Times font running
> >
> > par(font.lab=6) (not 4, maybe this is a local
> setting on my machine?)
> 
> '6' is a setting specific to certain devices on
> Windows.  You should 
> really be using font families (which are quite new
> and so not used in 
> many of the introductions).
> 
>   par(family="serif")
> 
> will change the default for all the text on
> subsequent plots to be in 
> a serif font, which on the windows() device is (by
> default) Times.
> 

Thanks, that works beautifully.  I had seen the
'family=" once but never needed it and forgot about
it.

> The R posting guide does ask you to tell us your OS,
> so that points like 
> this do not have to be guessed at.
> 
> > but now the boxplot shown has the x and y labels
> in Times New Roman and the
> > x and y axis still in Arial. Any idea why R is not
> setting those in Times?
> 
> Because you did not ask it to.  The font of axis
> annotation is set by 
> font.axis, not font.lab (which is controls title()'s
> xlab and ylab and 
> nothing in axis()).  See ?axis and ?par, both of
> which make this clear.
> 
> John Kane has claimed that what inline pars are used
> by boxplot() is 'not 
> clear from ?boxplot', but the lack of clarity is
> his, not in the 
> documentation. ?boxplot refers you to ?bxp, and that
> spells out exactly 
> which inline pars are used.
> 
> >
> > Thanks a lot for your advice,
> > Graziella
> >
> > --On 08 August 2007 09:16 -0400 John Kane
> <[EMAIL PROTECTED]> wrote:
> >
> >> I don't know if boxplot will accept a font
> argument.m
> >> From ?boxplot it is not clear.
> >> You may need to set the par() command before the
> >> boxplot
> >>
> >> Example:
> >> par(font.lab=4)
> >> boxplot(mass ~ family, data=mydata, ylab="mass
> %",
> >> xlab="family",las=1, cex.axis=1)
> >>
> >> --- "G Iossa, School Biological Sciences"
> >> <[EMAIL PROTECTED]> wrote:
> >>
> >>> Hi all,
> >>>
> >>> I am very new to R and this might be a simple
> >>> question but I have looked
> >>> everywhere you suggest before writing to you.
> >>>
> >>> I am trying to change font type from san-serif
> to a
> >>> serif (Times New
> >>> Romans) on all labels and axis of my boxplot. I
> have
> >>> used this function in
> >>> other plots before, e.g.:
> >>>
> >>> plot(residuals~lnlifespan, data=mydata,
> pch=psymb,
> >>> font=6, xlab="ln
> >>> reproductive lifespan", ylab="residuals ln
> mass",
> >>> font.lab=6, cex=1.5,
> >>> cex.axis=1.5, cex.lab=1.5)
> >>>
> >>> and found that font.lab or font.axis=6 gives
> Times
> >>> font. However, when I
> >>> try for boxplot:
> >>>
> >>> boxplot(mass ~ family, data=mydata, ylab="mass
> %",
> >>> xlab="family",
> >>> font.axis=6,  font=6, par(las=1), cex.axis=1)
> >>>
> >>> it does not work (R does not give any warning
> >>> messages). I have also tried
> >>> family="Times" but without success. Any idea of
> why
> >>> is not doing it and
> >>> what I can do to get Times font on my boxplot?
> >>> I run R on Windows.
> >>>
> >>> Thanks a lot,
> >>> Graziella
> >>>
> >>>
> >>
>
*
> >>> Dr. Graziella Iossa
> >>>
> >>> Mammal Research Unit
> >>> School Biological Sciences
> >>> University of Bristol
> >>> Woodland Road
> >>> Bristol BS8 1UG, UK
> >>>
> >>> E-mail: [EMAIL PROTECTED]
> >>> Tel 0044 (0)117 9288918
> >>> Fax 0044 (0)117 3317985
> >>>
> http://www.bio.bris.ac.uk/research/mammal/index.html
> >>> http://www.bio.bris.ac.uk/people/Iossa.htm
> 
> -- 
> Brian D. Ripley, 
> [EMAIL PROTECTED]
> Professor of Applied Statistics, 
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865
> 272861 (self)
> 1 South Parks Road, +44 1865
> 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865
> 272595
>

__
R-help@stat.math.ethz.ch 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] Changing font in boxplots

2007-08-08 Thread John Kane
I don't know if boxplot will accept a font argument.m
>From ?boxplot it is not clear.
You may need to set the par() command before the
boxplot

Example: 
par(font.lab=4)
boxplot(mass ~ family, data=mydata, ylab="mass %",
xlab="family",las=1, cex.axis=1)

--- "G Iossa, School Biological Sciences"
<[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I am very new to R and this might be a simple
> question but I have looked 
> everywhere you suggest before writing to you.
> 
> I am trying to change font type from san-serif to a
> serif (Times New 
> Romans) on all labels and axis of my boxplot. I have
> used this function in 
> other plots before, e.g.:
> 
> plot(residuals~lnlifespan, data=mydata, pch=psymb,
> font=6, xlab="ln 
> reproductive lifespan", ylab="residuals ln mass",
> font.lab=6, cex=1.5, 
> cex.axis=1.5, cex.lab=1.5)
> 
> and found that font.lab or font.axis=6 gives Times
> font. However, when I 
> try for boxplot:
> 
> boxplot(mass ~ family, data=mydata, ylab="mass %",
> xlab="family", 
> font.axis=6,  font=6, par(las=1), cex.axis=1)
> 
> it does not work (R does not give any warning
> messages). I have also tried 
> family="Times" but without success. Any idea of why
> is not doing it and 
> what I can do to get Times font on my boxplot?
> I run R on Windows.
> 
> Thanks a lot,
> Graziella
> 
>
*
> Dr. Graziella Iossa
> 
> Mammal Research Unit
> School Biological Sciences
> University of Bristol
> Woodland Road
> Bristol BS8 1UG, UK
> 
> E-mail: [EMAIL PROTECTED]
> Tel 0044 (0)117 9288918
> Fax 0044 (0)117 3317985
> http://www.bio.bris.ac.uk/research/mammal/index.html
> http://www.bio.bris.ac.uk/people/Iossa.htm
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] rank in decreasing order

2007-08-06 Thread John Logsdon
total_list$field1.rank <- rank(-total_list$field1,ties.method="min")

Marvellous what a negative sign can achieve!  

You may want to put ties.method="max" though depending on what you want...:)

On Monday 06 August 2007 14:13:35 Jiong Zhang, PhD wrote:
> Hi All,
>
> I want to give ranks to elements in a column so I used:
> total_list$field1.rank <- rank(total_list$field1,ties.method="min")
>
> But this gives me the rank in increasing order. How do I get the ranks in
> decreasing order? I know decreasing = FALSE is not a legal argument here.
>
> Thanks.
>
> Jiong
>  The email message (and any attachments) is for the sole use of the
> intended recipient(s) and may contain confidential information.  Any
> unauthorized review, use, disclosure or distribution is prohibited.  If you
> are not the intended recipient, please contact the sender by reply email
> and destroy all copies of the original message (and any attachments). 
> Thank You.
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.



-- 
Best wishes

John

John Logsdon   "Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler"
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch 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] - round() strange behaviour

2007-08-06 Thread John Logsdon
In R you may be tempted to use rounding to index something in an array.  Hence 
my concern and suggestion that there be another argument to round() (and 
signif()) that explicitly sets the rounding mechanism.  

In Fortran IDNINT does as I would expect.  You could do floor(x+0.5) but many 
people, myself included before this conversation, will unwittingly round and 
it will almost always work but the exception is something that may even be 
difficult to reproduce where random numbers are involved without setting the 
seed.  

In this context you cannot leave rounding until the end of course!  Clearly in 
an arithmetic context, rounding should always be left to the end but I don't 
think that is to avoid rounding-to-even but just to avoid unnecessary loss of 
precision in the calculation.  Ask most engineers - and even physicists - and 
I suspect they would not be aware of this debate even though it dates from 
the 1940s.

On Monday 06 August 2007 10:31:22 Jim Lemon wrote:
> (Ted Harding) wrote:
> > ...
> > Thus "always up" or "always down" means that the difference between
> > rounded numbers is always the same as between the unrounded numbers
> > which for other methods the differences can differ by 2.0.
> > This may or may not matter, but it is something to think about
> > when choosing a rounding method.
>
> Ah, but Ted, this is why, as I remarked in a private message to the
> original poster, we were also taught never to round until the final
> result. Had I not had a rather extended debate with an engineer who
> apparently thought that one could get away with successive rounding, I
> would not be so sensitive on the issue.
>
> Jim
>
> __
> R-help@stat.math.ethz.ch 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.



-- 
Best wishes

John

John Logsdon   "Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler"
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch 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] Plot in log scale

2007-08-05 Thread John Kane
What appears to be happening is that you are plotting
all the data sets but all the lines () are being
plotted outside the original plotting frame.  If you
just plot out$a with axes=TRUE you will see what the y
coordinates are.  You need to explicitly set the ylim
values.

There is a mockup of what I think you want to do. 
--

a <- 5:7
b <- c(.005,.009,.01)
c <- c(.05,.08,.12 )
out <- data.frame(a,b,c); out

plot_colors <- c("blue","red","forestgreen","yellow")

plot(out$a, log="y", type="l", col=plot_colors[1], 
ylim=c(.0001, 8),
xlab="tittle_x_axe", ylab="title_y_axe", cex.lab=0.8,
lwd=2, xaxt='n')
axis(1, at=1:3)
lines(out$b, type="l", pch=1, lty=1,
col=plot_colors[2])
lines(out$c, type="l", pch=2, lty=2,
col=plot_colors[3])

-

--- akki <[EMAIL PROTECTED]> wrote:

> Hi,
> Forgive me, because I am new in R.
> I need a graph, where:
> - y axe has log scale
> - graph would have 4 set values: set first (out$a)
> has values over 5.5, set
> second (out$b) and third (out$c) has values over
> 0.005 and the last set
> (out$d) has values over 0.0005 of y axe. For this
> reason, I need have log
> scale on y axe.
> I've look for web, but I can't do the graph that I
> need.
> 
> I try to do something as:
> 
> out <- read.table("/my_path/data.dat", header=T,
> sep="\t")
> plot_colors <-
> c("blue","red","forestgreen","yellow")
> plot(out$a, log="y", type="l", col=plot_colors[1],
> axes=FALSE, ann=T,
> xlab="tittle_x_axe", ylab="title_y_axe",
> cex.lab=0.8, lwd=2)
> axis(1, at=1:200)
> lines(out$b, type="l", pch=1, lty=1,
> col=plot_colors[2])
> lines(out$c, type="l", pch=2, lty=2,
> col=plot_colors[3])
> lines(out$d, type="l", pch=3, lty=3,
> col=plot_colors[4])
> 
> But, I have to only plotted  the first  set  of
> values (out$a). How can I
> draw all my values?
> 
> Thanks in advance.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] - round() strange behaviour

2007-08-04 Thread John Logsdon
I must admit I had never realised this so thanks to Monica for raising it.  

Round-to-even is used for statistical reasons and there is some point as it 
obviously reduces bias.  But why should the decision  be to round to the 
nearest even number?  rounding to the nearest odd number would be equally 
valid.  (signif(x,0) is the same as round(). )

There is a debate and sometimes you need symmetric rounding.  Perhaps there 
should be an option in round that defaults to round-to-even for compatibility 
but includes the various other rounding approaches as seen for example in 
http://en.wikipedia.org/wiki/Rounding

BTW with Fortran the 'nearest integer' approach is used:

  REAL*8 TEST
10CONTINUE
 READ(*,*)TEST
 WRITE(*,*)TEST,IDNINT(TEST)
  GOTO 10
  END

Compiling this under g77 and gfortran gives the result:
~ $ g77 idnint.f -o idnint
~ $ ./idnint
1.5
  1.5 2
2.5
  2.5 3

~ $ gfortran idnint.f -o idnint
~ $ ./idnint
2.5
   2.503
1.5
   1.502

Octave:

octave:1> round(1.5)
ans = 2
octave:2> round(2.5)
ans = 3

On Thursday 02 August 2007 21:46:36 Monica Pisica wrote:
> Hi again,
>
> Mea culpa for not reading help pages before hand - but one would not go
> there when the function syntax is obvious and known  besides other
> programming languages (for example IDL) with same function do not round to
> the next even number  so i do get 3 for round(2.5), and i didn't
> realize that it is "normal" for R to give a 2 instead of 3.> Date: Thu, 2
> Aug 2007 22:38:49 +0200> From: [EMAIL PROTECTED]> To:
> [EMAIL PROTECTED]> CC: r-help@stat.math.ethz.ch> Subject: Re: [R] -
> round() strange behaviour> > On Thu, 2 Aug 2007, Monica Pisica wrote:> > >>
> > Hi,> >> > I am getting some strange results using round - it seems that
> it depends if the number before the decimal point is odd or even > >> >
> For example:> >> > > round(1.5)[1] 2> round(2.5)[1] 2> > While i would
> expect that round(2.5) be 3 and not 2.> >> > Do you have any explanation
> for that?> > Yes: you obviously did not read the man page! Please do.> Z> >
> > I really appreciate your input,> >> > Monica> >> >> >
> _> >
> [[trailing spam removed]]> >> > [[alternative HTML version deleted]]> >> >
> __> > R-help@stat.math.ethz.ch
> 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.> >> >>
> _
> Messenger Caf� � open for fun 24/7. Hot games, cool activities served
> daily. Visit now.
>
>   [[alternative HTML version deleted]]



-- 
Best wishes

John

John Logsdon   "Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler"
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch 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] Invert Likert-Scale Values

2007-08-04 Thread John Kane
Will ?recode in the car package do what you want?
 x <- 1:4
 recode(x, "1='4';2='3' ;3='2'; 4='1'")


--- Alexis Delevett <[EMAIL PROTECTED]> wrote:

> Hi!
> 
> I am using R to process some community survey data.
> Several item responses are recorded via a 7-point
> Likert-Scale. As I have coded the responses, 1
> represents high agreement, and 7 high disagreement.
> This of course impacts the coefficients in a linear
> regression (of example agreement to self-perception
> measures on housing satisfaction). For some
> purposes, in order to make the coefficients more
> accessible to the reader, I would like to invert the
> item values, i.e. to arrive at 1 for high
> disagreement, and 7 for high agreement (such that
> the linear regression would express something like
> "the higher the agreement on A, the greater the B).
> 
> Is there an already existing function for this, or
> do I use a custom replace loop in R?
> 
> Thank you, Alexis
> 
>
> -
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Rmetrics and log returns

2007-08-03 Thread Kerpel, John
Hi all.  How do I compute a Monday Open to Friday Close weekly return in
Rmetrics from daily data?  Thanks!

 

John


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] plot to postscript orientation-update

2007-08-03 Thread John Kane
Follow-up 

I seem to have manged to get the eps file to work
using:
 
postscript("C:/temp/figure.eps", horizontal=F,
paper="special", height=8, width=8, pointsize=12)

Exactly why I'm not sure since I just copied some old
code that I had used a year or so ago.
--- Vorlow Constantinos <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> My vanilla code works fine... 
> 
> See also attached .eps file (seperate email sent
> directly to you)
> 
> > r<-rnorm(100)
> > postscript("figure.eps")
> > plot.ts(r)
> > dev.off()
> 
> Also this works ok as you have been told already:
> 
> > paper="special" in the postscript() call.
> 
> If you see my eps file wrongly then your GSVIEW
> setup is wrong. 
> 
> Choose Orientation "Auto" and under Options (bottom
> half)
> click-select-tick everything except "Ignore DSC".
> 
> That should do the trick...
> 
> Costas
> 
> Miruna Petrescu-Prahova wrote:
> 
> > Hi
> 
> > 
> 
> > I am trying to save some plots in a postscript
> file. When I generate
> the 
> 
> > plots in the main window, they appear correctly -
> their orientation is
> 
> 
> > landscape (i.e., horizontal). However, when I open
> the .ps file with
> GSview, 
> 
> > the whole page appears vertically, and the plot
> appears horizontally,
> which 
> 
> > means that the plot is only partially visible
> (example here 
> 
> >
>
https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
>

>  ). I
> searched 
> 
> > the R-help mailing list archive and found 2
> suggestions: setting the
> width 
> 
> > and height and setting horizontal = FALSE. I have
> tried setting the
> width 
> 
> > and height but it makes no difference. I have also
> tried using
> "horizontal = 
> 
> > FALSE". This rotates and elongates the plot, but
> it is still displayed
> 
> 
> > horizontally on a vertical page, and so only
> partially visible
> (example 
> 
> > here
>
https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
>

> ). I
> 
> 
> > am not sure what is wrong. Plots are created with
> "filled.contour".
> 
>  
> 
> I guess this is a misconfiguration of your GSview.
> The plots are fine 
> 
> for me. Anyway, you might also want to set the
> argument
> 
> paper="special" in the postscript() call.
> 
> Uwe Ligges
> 
>  
> 
> > Thanks
> 
> > Miruna
> 
> > 
> 
> > 
> 
> > 
> 
> > Miruna Petrescu-Prahova
> 
> > Department of Sociology
> 
> > University of California, Irvine
> 
> > [EMAIL PROTECTED]
> 
> > 
> 
> > __
> 
> > R-help@stat.math.ethz.ch 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.
> 
>  
>
---
> Costas Vorlow
> Research Economist
> Eurobank EFG
> Division of Research & Forecasting
> 
>
---
> tel: +30-210-3337273 (ext 17273)
> fax: +30-210-3337687
> 
> 
> 
> 
> P Think before you print.
> 
> Disclaimer:
> This e-mail is confidential. If you are not the
> intended recipient, you should not copy it,
> re-transmit it, use it or disclose its contents, but
> should return it to the sender immediately and
> delete the copy from your system.
> EFG Eurobank Ergasias S.A. is not responsible for,
> nor endorses, any opinion, recommendation,
> conclusion, solicitation, offer or agreement or any
> information contained in this communication.
> EFG Eurobank Ergasias S.A. cannot accept any
> responsibility for the accuracy or completeness of
> this message as it has been transmitted over a
> public network. If you suspect that the message may
> have been intercepted or amended, please call the
> sender.
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] plot to postscript orientation

2007-08-03 Thread John Kane
I don't know about for Miruna but it does not work for
me.

I  tried 
postscript ("figure.eps", paper="letter")

http://ca.geocities.com/jrkrideau/R/eps.figure.pdf
& 
postscript("figure.eps, paper="special", width=5,
height=4)

with similaar same results.

Interstingly enough figure.eps imports completely into
Word but rotated 90 degrees as Miruna noted.  

Where are you finding the Options for Auto? I don't
see them.

john

--- Vorlow Constantinos <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> My vanilla code works fine... 
> 
> See also attached .eps file (seperate email sent
> directly to you)
> 
> > r<-rnorm(100)
> > postscript("figure.eps")
> > plot.ts(r)
> > dev.off()
> 
> Also this works ok as you have been told already:
> 
> > paper="special" in the postscript() call.
> 
> If you see my eps file wrongly then your GSVIEW
> setup is wrong. 
> 
> Choose Orientation "Auto" and under Options (bottom
> half)
> click-select-tick everything except "Ignore DSC".
> 
> That should do the trick...
> 
> Costas
> 
> Miruna Petrescu-Prahova wrote:
> 
> > Hi
> 
> > 
> 
> > I am trying to save some plots in a postscript
> file. When I generate
> the 
> 
> > plots in the main window, they appear correctly -
> their orientation is
> 
> 
> > landscape (i.e., horizontal). However, when I open
> the .ps file with
> GSview, 
> 
> > the whole page appears vertically, and the plot
> appears horizontally,
> which 
> 
> > means that the plot is only partially visible
> (example here 
> 
> >
>
https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
>
<https://webfiles.uci.edu/mpetresc/postscript.files/default.ps>
>  ). I
> searched 
> 
> > the R-help mailing list archive and found 2
> suggestions: setting the
> width 
> 
> > and height and setting horizontal = FALSE. I have
> tried setting the
> width 
> 
> > and height but it makes no difference. I have also
> tried using
> "horizontal = 
> 
> > FALSE". This rotates and elongates the plot, but
> it is still displayed
> 
> 
> > horizontally on a vertical page, and so only
> partially visible
> (example 
> 
> > here
>
https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps
>
<https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps>
> ). I
> 
> 
> > am not sure what is wrong. Plots are created with
> "filled.contour".
> 
>  
> 
> I guess this is a misconfiguration of your GSview.
> The plots are fine 
> 
> for me. Anyway, you might also want to set the
> argument
> 
> paper="special" in the postscript() call.
> 
> Uwe Ligges
> 
>  
> 
> > Thanks
> 
> > Miruna
> 
> > 
> 
> > 
> 
> > 
> 
> > Miruna Petrescu-Prahova
> 
> > Department of Sociology
> 
> > University of California, Irvine
> 
> > [EMAIL PROTECTED]
> 
> > 
> 
> > __
> 
> > R-help@stat.math.ethz.ch 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.
> 
>  
>
---
> Costas Vorlow
> Research Economist
> Eurobank EFG
> Division of Research & Forecasting
> 
>
---
> tel: +30-210-3337273 (ext 17273)
> fax: +30-210-3337687
> 
> 
> 
> 
> P Think before you print.
> 
> Disclaimer:
> This e-mail is confidential. If you are not the
> intended recipient, you should not copy it,
> re-transmit it, use it or disclose its contents, but
> should return it to the sender immediately and
> delete the copy from your system.
> EFG Eurobank Ergasias S.A. is not responsible for,
> nor endorses, any opinion, recommendation,
> conclusion, solicitation, offer or agreement or any
> information contained in this communication.
> EFG Eurobank Ergasias S.A. cannot accept any
> responsibility for the accuracy or completeness of
> this message as it has been transmitted over a
> public network. If you suspect that the message may
> have been intercepted or amended, please call the
> sender.
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] problem with reading data files with different numbers oflines to skip

2007-08-03 Thread john seers \(IFR\)

Hi Tom

It looks as if you are reading in genepix files. I believe the format for the 
start lines includes a second line to say how many lines to skip. Something 
like this, specifying 27 lines to skip:

ATF 1
27  43
Type=GenePix Results 1.4
DateTime=2003/11/14 17:18:30

If so here is a function I use to do what you want to do. If your files have a 
different format then you need to modify how you set the number of lines to 
skip.



# Preprocess the genepix files - strip off first header lines
dopix<-function(genepixfiles, workingdir) {
pre<-"Pre"
# Read in each genepix file, strip unwanted rows and write out again
for (pixfile in genepixfiles) {
pixfileout<-paste(workingdir, pre, basename(pixfile), sep="")
secondline<-read.table(pixfile, skip=1, nrows=1)
skiplines<-as.numeric(secondline[1]) + 2
outdf<-read.table(pixfile, header=T, skip=skiplines, sep="\t")
write.table(outdf, file=pixfileout, sep="\t", row.names=FALSE)
}
}


Regards

John Seers


 -Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Cohen
Sent: 03 August 2007 13:04
To: r-help@stat.math.ethz.ch
Subject: Re: [R] problem with reading data files with different numbers oflines 
to skip

Thanks to Ted and Gabor for your response. 
  I apology for not being clear with my previous description of the problem. I 
tried with  your suggestions using readLines but couldn't make it work. I now 
explain the problem in more details and hope that you can help me out.
   
   I have 30 data files, where some of them have 33 lines and the rests have 31 
lines that I want to skip (examples below with bold text). That is, I only want 
to keep the lines start from 
  Block  Column  Row  Name  ID
   
  I read in the data files with a loop like below, the problem is how do I tell 
the loop to skip 31 lines in some data files and 33 in the rests ?
   
  > for (i in 1:num.files) {
> a<-read.table(file=data[i], 
> ,header=T,skip=31,sep='\t',na.strings="NA")  }
   
  Thanks for your help,
  Tom
   
  # 33 lines to skip
   
Type=GenePix Results 3  DateTime=2006/10/20 
13:35:11Settings=  
GalFile=G:\Avdelningar\viv\translational 
immunologi\Peptide-arrays\Gal-files\742-human-pep2.galPixelSize=10  
  Wavelengths=635
ImageFiles=M:\Peptidearrays\061020\742-2.tif 1  
NormalizationMethod=None  NormalizationFactors=1
  JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
pep,742\742-2.s1.jpgStdDev=Type 1
RatioFormulations=W1/W2 (635/)FeatureType=Circular  
Barcode=  BackgroundSubtraction=LocalFeature
ImageOrigin=560, 1360  JpegOrigin=1940, 3670
  Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B [84948]   
 FocusPosition=0Temperature=30.2
LinesAveraged=1  
  Comment=PMTGain=600
ScanPower=100LaserPower=3.36
Filters=ScanRegion=56,136,2123,6532  
Supplier=Genetix Ltd.  ArrayerSoftwareName=MicroArraying
ArrayerSoftwareVersion=QSoft XP Build 6450 (Revision 131)
Block  Column  Row  Name  ID  X  Y  Dia.  F635 Median  F635 Mean1  1  1  
IgG-human  none  2390  4140  200  301  3171  2  1  >PGDR_HUMAN (P09619)  
AHASDEIYEIMQK  2630  4140  200  254  2501  3  1  >ML1X_HUMAN (Q13585)  
AIAHPVSDDSDLP  2860  4140  200  268  252   
  1000 more rows
   
   
   
  # 31 lines to skip
   
  ATF  1.029  41
Type=GenePix Results 3  DateTime=2006/10/20 13:05:20
Settings=  GalFile=G:\Avdelningar\viv\translational 
immunologi\Peptide-arrays\Gal-files\742-s2.gal  PixelSize=10
Wavelengths=635
ImageFiles=M:\Peptidearrays\061020\742-4.tif 1  
NormalizationMethod=None  NormalizationFactors=1
  JpegImage=C:\Documents and Settings\Shahnaz Mahdavifar\Skrivbord\Human 
pep,742\742-4.s2.jpgStdDev=Type 1
RatioFormulations=W1/W2 (635/)FeatureType=Circular  
Barcode=  BackgroundSubtraction=LocalFeature
ImageOrigin=560, 1360  JpegOrigin=1950, 24310   
   Creator=GenePix Pro 6.0.1.25  Scanner=GenePix 4000B [84948]  
  FocusPosition=0   
 Temperature=28.49LinesAv

Re: [R] plot to postscript orientation

2007-08-03 Thread John Kane

I seem to see the same problem that Miruna gets just
to confirm that it is not just her set-up.  

I'm using GSview4.8 if that helps

--- Uwe Ligges <[EMAIL PROTECTED]>
wrote:


> 
> 
> Miruna Petrescu-Prahova wrote:
> >  Hi
> > 
> >  I am trying to save some plots in a postscript
> file. When I generate the 
> > plots in the main window, they appear correctly -
> their orientation is 
> > landscape (i.e., horizontal). However, when I open
> the .ps file with GSview, 
> > the whole page appears vertically, and the plot
> appears horizontally, which 
> > means that the plot is only partially visible
> (example here 
> >
>
https://webfiles.uci.edu/mpetresc/postscript.files/default.ps
> ). I searched 
> > the R-help mailing list archive and found 2
> suggestions: setting the width 
> > and height and setting horizontal = FALSE. I have
> tried setting the width 
> > and height but it makes no difference. I have also
> tried using "horizontal = 
> > FALSE". This rotates and elongates the plot, but
> it is still displayed 
> > horizontally on a vertical page, and so only
> partially  visible (example 
> > here
>
https://webfiles.uci.edu/mpetresc/postscript.files/horiz.false.ps).
> I 
> > am not sure what is wrong. Plots are created with
> "filled.contour".
> 
> 
> I guess this is a misconfiguration of your GSview.
> The plots are fine 
> for me. Anyway, you might also want to set the
> argument
> paper="special" in the postscript() call.
> 
> Uwe Ligges
> 
> 
> >  Thanks
> >  Miruna
> > 
> > 
> > 
> > Miruna Petrescu-Prahova
> > Department of Sociology
> > University of California, Irvine
> > [EMAIL PROTECTED]
> > 
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] y axix number into horizontal direction

2007-08-02 Thread John Kane
?par  see las
This should work
---
 plot(0,0,xaxt="n", type="n", ylim=c(0,100), las=1, )
 mtext("35",side=2,at=35, line =1, las=1)
---
--- Rebecca Ding <[EMAIL PROTECTED]> wrote:

> Dear R users,
> 
> I used plot() and mtext() functions to draw a plot.
> The numbers: 0,20,35,
> 40,60,80,100 were in the vertical direction. I'd
> like to transfer them into
> the horizontal direction.
> 
> plot(0,0,xaxt="n",type="n", ylim=c(0,100))
> mtext("35",side=2,at=35)
> 
> Any suggestion?
> 
> Thanks.
> 
> Rebecca
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Multivariable correlation

2007-08-02 Thread John Sorkin
Given a square matrix of variables X, is there any way to compute a 
multivariable correlation among all the variables in the array? It is possible 
to calculate the correlation of all pairs of variables in the array, but I want 
to know the correlation of all the variables taken together, i.e. for the matrix

X=x1 x2  x3
x4  x5  x6
x7  x8  x9

I don't want the pair-wise correlations corr(x1,x2), corr(x1,x3), corr(x1,x4) . 
. . etc., but rather
corr(x1,x2,x3,x4,x5,x6,x7,x8,x9).
Thanks,
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]

Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}

__
R-help@stat.math.ethz.ch 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] New user help with plot.default

2007-08-02 Thread John Kane
If I understand the problem then I think that this was
a mistake on my part.  I had it working and then made
a stupid change.

Try

axis(2, at=0:3, labels=c("0","1","2","3"))

# and to make it look pretty

box()

-


--- PaulGaskell <[EMAIL PROTECTED]> wrote:

> 
> I've replied to your email but essentially I just
> have a problem with the
> last line below, the "at" and "labels" arguments are
> different lengths. Also
> the top edge of the ylabel letters are cut off by
> the left hand side of the
> plot frame.
> 
> John Kane-2 wrote:
> > 
> > # Draw the specific axes.
> > axis(1, at=1:8, labels=chems)
> > axis(2, at=0:3, labels=c("1","2","3")
> > 
> >
>
---
> > 
> > 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/New-user-help-with-plot.default-tf4205767.html#a11964917
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] New user help with plot.default

2007-08-02 Thread John Kane
Hi Paul,

I think one of the problems is that xlim is expecting
a numerical vector something like c(1:8) implying a
contiuous variable and yours is categorical.

I have made quite few changes but does this do what
you want?  It may not be the most effient but it runs
:)
-


#set axis label and tick mark label font sizes to be
readable when  pasted into final document

mydata <-
read.table("http://www.nabble.com/file/p11963282/TELrange.csv";,
 sep=",", header=TRUE)
OrderedLevels<-factor(mydata$Chemical,levels=c("Cd",
"Cu", "Zn", "Phen",   "Ant",
"Flu", "Pyr", "Tot"))
chems <-
c("Cd","Cu","Zn","Phe","Ant","Flu","Pyr","Tot")

par(cex.lab=1.2,cex.axis=1.3)
#produce plot with plotting symbols of round black
dots with cex multiplier of 1.5

# remove the default axes in the plot (axes=FALSE)
plot.default(mydata$SQG~OrderedLevels,cex=1.5,pch=16,col=1,
 axes=FALSE,
xlab = "Chemical",ylab = expression(paste("
",Log[10]," metal ("*m*g*~kg^{-1},")
or PAH ("*mu*g*~kg^{-1},") SQG")))

# Draw the specific axes.
axis(1, at=1:8, labels=chems)
axis(2, at=0:3, labels=c("1","2","3")

---



--- PaulGaskell <[EMAIL PROTECTED]> wrote:

> 
> Hi - I'm just starting out with R and have come up
> against a problem with
> what should be a simple operation. I'm plotting a
> range of safety standards
> for 7 different chemicals. I don't want the standard
> box and whisker plot -
> I just a dot for each value. Whilst using
> "plot.default" I get the error
> "invalid xlim value" - which is confusing since
> using the same script with
> "plot" does not produce this error. However, I do
> notice that only alternate
> xlim tick mark labels appear when using "plot".
> Therefore, a question in 2
> parts - firstly what is incompatible about my xlim
> argument with
> plot.default and secondly, how do I suppress the
> "check.overlap" for tick
> mark labels in plot.default?
> 
> Annotated script below (data file also uploaded in
> case its useful) and
> thanks in advance for any help:
> 
> #dataframe is column of numerical values of chemical
> safety guidelines "SQG"
> plus a column identifying the chemicals to which
> each value pertains i.e.
> #SQG Chemical
> #1   0.07918   Cd
> #2  -0.15490   Cd
> #3  -0.15490   Cd
> #4   0.95904   Cd
> #5etc. etc.
> #assign correct plotting order for each chemical
> level 
> OrderedLevels<-factor(Chemical,levels=c("Cd", "Cu",
> "Zn", "Phen", "Ant",
> "Flu", "Pyr", "Tot"))
> #set axis label and tick mark label font sizes to be
> readable when pasted
> into final document
> par(cex.lab=1.2,cex.axis=1.3)
> #produce plot with plotting symbols of round black
> dots with cex multiplier
> of 1.5
>
plot.default(SQG~OrderedLevels,cex=1.5,pch=16,col=1,xlim=c("Cd","Cu","Zn","Phe","Ant","Flu","Pyr","Tot"),xlab
> = "Chemical",ylab = expression(paste(" ",Log[10],"
> metal ("*m*g*~kg^{-1},")
> or PAH ("*mu*g*~kg^{-1},") SQG"))) 
> 
> http://www.nabble.com/file/p11963282/TELrange.csv
> TELrange.csv 
> -- 
> View this message in context:
>
http://www.nabble.com/New-user-help-with-plot.default-tf4205767.html#a11963282
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] "Cut marks" on a plot's y-axis to indicate it is a truncated axis

2007-08-01 Thread John Kane

--- David Lloyd <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I've plotted a Kaplan-Meier curve but the curves
> only range from 0.7 to
> 1 on the y-axis. Therefore I have used: -
> 
> ylim=c(0.7,1)
> 
> [although I think convention dictates that you plot
> 0.5 to 1 to show the
> median? A few papers I've read have done this]??
> 
> BUT, I would like a symbol like // (but rotated 90
> degrees) to indicate
> that the y-axis has been truncated. I'd need to be
> able to specify
> exactly where on the axis to put the symbol as well.
> 
> I couldn't find anything under "par" or "plot" for
> doing this
> 
> Thanks for any help,
> 
> DaveL

I think Jim Lemon's anwsered the question but why do
you need a cut?  There is no need to have a zero on
the plot unless it is some quirky style matter for the
journal.  

Any literate scientific reader should be able to
understand that the y-axis runs from .5 to 1 or
whatever.  Adding a zero point and the || simply is
what Tufte would call chart junk.

__
R-help@stat.math.ethz.ch 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] generating symmetric matrices

2007-07-30 Thread John Logsdon
Since a symmetric matrix must be square, the following code does it:

> X<-5
> MAT<-matrix(rnorm(X*X),X,X)
> MAT<-MAT+t(MAT)
> MAT
   [,1]   [,2]   [,3]   [,4]   [,5]
[1,]  0.1084372 -1.7867366 -0.9620313 -1.0925719 -0.5902326
[2,] -1.7867366 -0.0462097 -1.2707656  0.6112664  1.8673785
[3,] -0.9620313 -1.2707656 -0.3248162  1.5458446  0.7641865
[4,] -1.0925719  0.6112664  1.5458446 -0.1621192 -1.1381366
[5,] -0.5902326  1.8673785  0.7641865 -1.1381366 -2.8668220

If you want to rescale it, for example to make a correlation matrix with the 
diagonal=1, just use cor():

> cor(MAT)
[,1]   [,2][,3]   [,4]   [,5]
[1,]  1. -0.2941807  0.03784626 -0.6431474 -0.5743853
[2,] -0.29418072  1.000  0.65284419 -0.3410521 -0.5921743
[3,]  0.03784626  0.6528442  1. -0.2502129 -0.7101451
[4,] -0.64314741 -0.3410521 -0.25021285  1.000  0.7593021
[5,] -0.57438527 -0.5921743 -0.71014507  0.7593021  1.000

The essential trick is to add matrix to transpose.

On Saturday 28 July 2007 04:28:25 Gregory Gentlemen wrote:
> Greetings,
>
> I have a seemingly simple task which I have not been able to solve today. I
> want to construct a symmetric matrix of arbtriray size w/o using loops. The
> following I thought would do it:
>
> p <- 6
> Rmat <- diag(p)
> dat.cor <- rnorm(p*(p-1)/2)
> Rmat[outer(1:p, 1:p, "<")] <- Rmat[outer(1:p, 1:p, ">")] <- dat.cor
>
> However, the problem is that the matrix is filled by column and so the
> resulting matrix is not symmetric.
>
> I'd be grateful for any adive and/or solutions.
>
> Gregory
>
>
>
>
> -
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@stat.math.ethz.ch 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.



-- 
Best wishes

John

John Logsdon   "Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler"
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch 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] Slightly OT - use of R

2007-07-30 Thread John Logsdon
I am trying to get a measure of how R compares in usage as a statistical 
platform compared to other software.  I would guess it is the most widely 
used among statisticians at least by virtue of it being open source.

But is there any study to which I can refer?  By asking this list I am not 
exactly adopting a rigorous approach!  

Best wishes

John

John Logsdon   "Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler"
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch 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] Constructing bar charts with standard error bars

2007-07-26 Thread John Zabroski
On 7/25/07, Ben Bolker <[EMAIL PROTECTED]> wrote:
> John Zabroski  gmail.com> writes:
>
> > The best clue I have so far is Rtips #5.9:
> > http://pj.freefaculty.org/R/Rtips.html#5.9 which is what I based my present
> > solution off of.
> >
> > However, I do not understand how this works.  It seems like there is no
> > concrete way to determine the arrow drawing parameters x0 and x1 for a
> > barplot.  Moreover, the bars seem to be "cut off".
> >
>
>   barplot() returns the x values you need for x0 and x1.
> barplot(...,ylim=c(0,xbar+se)) will set the upper y limit so
> the bars don't get cut off.
>
>   P.S. I hope you're not hoping to infer a statistically
> significant difference among these groups ...
>
>   cheers
>Ben Bolker

Thanks a lot!  I tried all three and they all seem very dependable.
Also, I appreciate you rewriting my solution and adding elegance.

Is there a way to extend the tick marks to the ylim values, such that
the yscale ymax tickmark is something like max(xbar+se)?  In the
documentation, I thought par(yaxp=c(y0,y1,n)) would do the trick, but
after trying to use it I am not sure I understand what yaxp even does.

P.S. I am not looking for statistically significant differences.  I am
trying to learn how to leverage R's graphing capabilities.  I also
appreciate Frank Harrell referring me to the link about Dynamite Plots
and associated weaknesses.

__
R-help@stat.math.ethz.ch 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] Finding matches in 2 files

2007-07-26 Thread john seers \(IFR\)
 

Something like:

# Sample data
g1<-c("gene1", "gene2", "gene3", "gene4", "gene5", "gene9", "gene10",
"geneA")
g2<-c("gene6", "gene9", "gene1", "gene2", "gene7", "gene8", "gene9",
"gene1", "gene10")
df1<-cbind(gene=g1, expr=runif(length(g1)))
df2<-cbind(gene=g2, expr=runif(length(g2)))

# Merge
mdf<-merge(df1, df2, by="gene", sort=T)
# Unique list
ug<-unique(mdf[,"gene"])


You may find the "match" command useful and/or the "%in%" opertaor.


JS 




 
---
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jenny tan
Sent: 26 July 2007 04:35
To: r-help@stat.math.ethz.ch
Subject: [R] Finding matches in 2 files



I have 2 files containing data analysed by 2 different methods. I would
like to find out which genes appear in both analyses. Can someone show
me how to do this?
_
[[trailing spam removed]]

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Constructing bar charts with standard error bars

2007-07-25 Thread John Zabroski
I am new to R.

I want to graph group data using a "Traditional Bar Chart with Standard
Error Bar", like the kind shown here:
http://samiam.colorado.edu/~mcclella/ftep/twoGroups/twoGroupGraphs.html

Is there a simple way to do this?

So far, I have only figured out how to plot the bars using barplot.

testdata <- scan(, list(group=0,xbar=0,se=0))
400 0.36038 0.02154
200 0.35927 0.02167
100 0.35925 0.02341
50 0.35712 0.01968
25 0.35396 0.01931

barplot(testdata$xbar, names.arg=as.character(testdata$group), main="a=4.0",
xlab="Group", ylab="xbar")
xvalues <- c(0.7, 1.9, 3.1, 4.3, 5.5)
arrows(xvalues, testdata$xbar, xvalues, testdata$xbar+testdata$se, length=
0.4, angle=90, code=3)


The best clue I have so far is Rtips #5.9:
http://pj.freefaculty.org/R/Rtips.html#5.9 which is what I based my present
solution off of.

However, I do not understand how this works.  It seems like there is no
concrete way to determine the arrow drawing parameters x0 and x1 for a
barplot.  Moreover, the bars seem to be "cut off".

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] plots

2007-07-25 Thread John Kane

--- amna khan <[EMAIL PROTECTED]> wrote:

> Hi Sir
> 
> I did not find any function of graph which plot one
> variable on x-axis and 2
> or more than 2 variables on y-axis.
I think
?points
or 
?lines 
may be what you want.

> Moreover, how can I change the labels of L-moments
> diagram obtained by
> plotlmrdia(lmrdia())

Cannot help here.
> 
> Thank you
> 
> -- 
> AMINA SHAHZADI
> Department of Statistics
> GC University Lahore, Pakistan.
> Email:
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Operator > and

2007-07-25 Thread John Kane
mm  <- matrix(1:9, nrow=3) ; mm
subset(mm[,1],mm[,1] <3)  # Note I used 3 not 2 here.

Have a look at some of the introductory documents on 
the R site  ( Contributed documents under OTHER in the
documentation). They should answer a lot of your basic
questions like this.

Documents by Lemon, Maindonald and Verzani are good
places to start.

Also the Introduction to R is useful.


--- Yann Mauon <[EMAIL PROTECTED]> wrote:

> 
> Hello, 
> 
> I'am new to the R world and have a lot of question
> but the first is : How to
> deal with <> opertor in table objects? (Or how to
> deal with <> in
> general...) I explain my problem. 
> 
> I read a file with the read.table expression. I then
> obtain a matrix. I read
> the first line for example with the commande
> data[,1]. Then I would like to
> select only the element in this line that are
> greater than 2. Is there an
> elegant way to achieve that ?
> 
> Thanks by advance...
> -- 
> View this message in context:
>
http://www.nabble.com/Operator-%3E-and-%3C-tf4141869.html#a11781567
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] SOS

2007-07-20 Thread John Kane
?round
x <- 1.2223
round(x,2)
[1] 1.22
--- Fabrice McShort <[EMAIL PROTECTED]>
wrote:

> Hi Julian,
>  
> Thank you very much. Please let me know how to get 2
> numbers after the decim.
>  
> Best regards,
>  
> Fabrice
> 
> 
> 
> > Date: Fri, 20 Jul 2007 08:15:42 -0700> From:
> [EMAIL PROTECTED]> To:
> [EMAIL PROTECTED]> CC:
> r-help@stat.math.ethz.ch> Subject: Re: [R] SOS> >
> Multiply by 100? Add> > R=R*100> > Fabrice McShort
> wrote:> > Dear all, I am a new user of R. I would
> like to know how to get fund's returns in percentage
> (%). For example, I use: R <-
> ts(read.xls("FundData"), frequency = 12, start =
> c(1996, 1)) Whith this program, the returns are like
> 0.0152699. But, I would like to have 1.52%. Please
> advise me about the function. Thanks! Fabrice> >
>
_>
> >> > [[trailing spam removed]]> >> > [[alternative
> HTML version deleted]]> >> >
> __> >
> R-help@stat.math.ethz.ch 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.> >> > > > !
>  -- > Julian M. Burgos> > Fisheries Acoustics
> Research Lab> School of Aquatic and Fishery Science>
> University of Washington> > 1122 NE Boat Street>
> Seattle, WA 98105 > > Phone: 206-221-6864> > 
>
_
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] tapply

2007-07-19 Thread John Kane
I do not understand what you want.  If aps is constant
over each class then the mean for each class is equal
to any value of aps.  

Using your example you can do 

tapply(icu1$aps, icu1$d, mean)

but it does not give you anything new.  Can you
explain the problem a bit more? 


--- sigalit mangut-leiba <[EMAIL PROTECTED]> wrote:

> hello,
> i want to compute the mean of a variable ("aps") for
> every class
> (1,2, and 3).
> every id have a few obs., "aps" and class are
> constant over id.
> like this:
> id   aps class
> 1  11   2
> 1  11   2
> 1  11   2
> 1  11   2
> 1  11   2
> 2   83
> 2   83
> 2   83
> 3  12   2
> 3  12   2
> .
> .
> 
> i tried:
> 
> tapply(icu1$aps_st, icu1$hidclass, function(z)
> mean(unique(z)))
> 
> but it's counting every row and not every id.
> 
> thank you,
> 
> Sigalit.

__
R-help@stat.math.ethz.ch 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] Classification

2007-07-18 Thread John Kane
Have a look at the recode function in the car package

library(car)
?recode
 should give you what you need.


--- "Ing. Michal Kneifl, Ph.D." <[EMAIL PROTECTED]>
wrote:

> Hi,
> I am also a quite new user of R and would like to
> ask you for help:
> I have a data frame where all columns are numeric
> variables. My aim is  
> to convert one columnt in factors.
> Example:
> MD
> 0.2
> 0.1
> 0.8
> 0.3
> 0.7
> 0.6
> 0.01
> 0.2
> 0.5
> 1
> 1
> 
> 
> I want to make classes:
> 0-0.2 A
> 0.21-0.4 B
> 0.41-0.6 C
> . and so on
> 
> So after classification I wil get:
> MD
> A
> A
> D
> B
> .
> .
> .
> and so on
> 
> Please could you give an advice to a newbie?
> Thanks a lot in advance..
> 
> Michael
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] LSD, HSD,...

2007-07-16 Thread John Maindonald
 Stepwise regression variable selection
methods make multiple post hoc comparisons.  The
number of comparisons may be very large, vastly more
than the half-dozen post-hoc comparisons that are
common in an experimental design context.

There is a disconnect here. The multiple testing issue is
noted in pretty much every discussion of analysis of
experimental data, but not commonly mentioned (at least
in older texts) in discussions of stepwise regression, best
subsets and related regression approaches. One reason
for this silence may be that there is no ready HSD-like fix.

The SEs and t-statistics that lm() gives for the finally
selected model can be grossly optimistic. Running the
analysis with the same model matrix, but with y-values
that are noise, can give a useful wake-up call.

John Maindonald email: [EMAIL PROTECTED]
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.


On 16 Jul 2007, at 8:00 PM, Simon Blomberg wrote:

> If you have a priori planned comparisons, you can just test those  
> using
> linear contrasts, with no need to correct for multiple testing. If you
> do not, and you are relying on looking at the data and analysis to  
> tell
> you which treatment means to compare, and you are considering several
> tests, then you should consider correcting for multiple testing. There
> is a large literature on the properties of the various tests.  
> (Tukey HSD
> usually works pretty well for me.)
>
>  Why do people design experiments with a priori hypotheses in
> mind, yet test them using post hoc comparison procedures? It's as if
> they are afraid to admit that they had hypotheses to begin with! Far
> better to test what you had planned to test using the more powerful
> methods for planned comparisons, and leave it at that.
> 
>
>
> On Mon, 2007-07-16 at 09:52 +0200, Adrian J. Montero Calvo wrote:
>> Hi,
>> I'm designing a experiment in order to compare the growing of
>> several clones of a tree specie. It will be a complete randomized  
>> block
>> design. How can I decide what model of mean comparision to choose?  
>> LSD,
>> HSD,TukeyHSD,  Duncan,...?  Thanks in advance
>>
>> __
>> R-help@stat.math.ethz.ch 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.
> -- 
> Simon Blomberg, BSc (Hons), PhD, MAppStat.
> Lecturer and Consultant Statistician
> Faculty of Biological and Chemical Sciences
> The University of Queensland
> St. Lucia Queensland 4072
> Australia
> Room 320 Goddard Building (8)
> T: +61 7 3365 2506
> email: S.Blomberg1_at_uq.edu.au

__
R-help@stat.math.ethz.ch 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] Complex surveys, properly computed SEs and non-parametric analyses

2007-07-15 Thread John Sorkin
Can someone direct me to an R function that properly computes standard errors 
of data obtained from a complex survery design, i.e. perform alnalyses similiar 
to those that can be performed with SUDAAN, particularly for a non-parametric 
one-way ANOVA, e.g. signed rank test?
Thanks,
John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
[EMAIL PROTECTED]
Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}

__
R-help@stat.math.ethz.ch 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] Fwd: THANK YOU: Updating R version

2007-07-14 Thread John C Frain
Everyone using R in Windows should look at these batch files.  Some of
them are pure genius and will speed the process.  Thanks

John

On 14/07/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Note that the batchfiles distribution on CRAN has two batch
> programs:
>
> copydir.bat
> movedir.bat
>
> that simplify the copying portion of the procedure you
> discuss below.  They can copy or move (copying
> preserves the old directory but moving is much faster)
> each package but will not overwrite existing packages
> so the new versions of packages are preserved while the
> old ones are added.  Here is an example using copydir.
> Replace copydir with movedir below to move rather than copy:
>
>  cd \Program Files\R
>  copydir R-2.4.1\library R-2.5.0\library
>
> See the batchfiles' home page at:
>
>  http://code.google.com/p/batchfiles/
>
> The README file contains the instructions given above (and more) and
> also a number of alternative procedures that do not involve the use of
> the batchfiles.
>
> On 7/13/07, John C Frain <[EMAIL PROTECTED]> wrote:
> > -- Forwarded message --
> > From: John C Frain <[EMAIL PROTECTED]>
> > Date: 13-Jul-2007 22:30
> > Subject: Re: [R] THANK YOU: Updating R version
> > To: "Christopher W. Ryan" <[EMAIL PROTECTED]>
> >
> >
> > When I update R the following has worked for me (Windows XP)
> >
> > 1. Install the new version to a new directory (say C:\Program 
> > Files\R\R-2.5.1).
> >
> > 2 Rename the new library subdirectory  to library2.
> >
> > 3 Copy the entire contents of the old library subdirectory (say
> > C:\Program Files\R\R-2.4.0\library\ to the new R root to create
> > C:\Program Files\R\R-2.5.1\library\ .
> >
> > 4 Copy the contents of library2 to library to update your basic library.
> >
> > 5 Now start your new version of R and update packages from the GUI or
> > from the R console.  (You may need to firs check Rprofile .site to
> > ensure that no packages have been loaded)
> >
> > 6. On occasion I have got warning messages when I tried to load
> > packages after this procedure.  This has been cleared by running
> >
> > update.packages(checkBuilt = TRUE)
> >
> > This checks that your packages have been built with the latest
> > version.  When I do this I  agree to install all available updates.
> >
> > 7 You may wish to copy various autoloads etc from your old
> > Rprofile.site to your new Rprofile.site.  I understand that there are
> > some compatibility problems with 2.5.1 and SciViews so be careful.
> >

__
R-help@stat.math.ethz.ch 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] learning the R language (for those strong in Ruby)

2007-07-14 Thread John Kane

--- "David C. James" <[EMAIL PROTECTED]> wrote:

> I feel like I'm not firing at all cylinders with the
> R language,  
> despite reading over the R Language Definition.
> 
> Has anyone seen something like an "R for Rubyists"
> guide (i.e.  
> teaching the R language for those who are more
> familar with Ruby)?
> 
> Alternately, a book with lots of examples about how
> the R language  
> itself works would be fantastic.

Peter Dalgaard's book "Introductory Statistics with R"
or John Verzani's book  "Using R for introductory
statistics" both might be good for a start. Dalgaad's
book has an very handy appendix summarizing a lot of
the basic commands.

There are also quite a few excellent online books and
papers available on the R site (lefthand side at
bottom  you will see books and other)

__
R-help@stat.math.ethz.ch 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] Fwd: THANK YOU: Updating R version

2007-07-13 Thread John C Frain
-- Forwarded message --
From: John C Frain <[EMAIL PROTECTED]>
Date: 13-Jul-2007 22:30
Subject: Re: [R] THANK YOU: Updating R version
To: "Christopher W. Ryan" <[EMAIL PROTECTED]>


When I update R the following has worked for me (Windows XP)

1. Install the new version to a new directory (say C:\Program Files\R\R-2.5.1).

2 Rename the new library subdirectory  to library2.

3 Copy the entire contents of the old library subdirectory (say
C:\Program Files\R\R-2.4.0\library\ to the new R root to create
C:\Program Files\R\R-2.5.1\library\ .

4 Copy the contents of library2 to library to update your basic library.

5 Now start your new version of R and update packages from the GUI or
from the R console.  (You may need to firs check Rprofile .site to
ensure that no packages have been loaded)

6. On occasion I have got warning messages when I tried to load
packages after this procedure.  This has been cleared by running

update.packages(checkBuilt = TRUE)

This checks that your packages have been built with the latest
version.  When I do this I  agree to install all available updates.

7 You may wish to copy various autoloads etc from your old
Rprofile.site to your new Rprofile.site.  I understand that there are
some compatibility problems with 2.5.1 and SciViews so be careful.

Best Regards

John



On 13/07/07, Christopher W. Ryan <[EMAIL PROTECTED]> wrote:
> This sounds like a solution I've been looking for.  With this setup now
> in place, when you download and install some new packages, where will
> they be put?  Into C:\myRlib ?
>
> Thanks.
>
> --Chris
> Christopher W. Ryan, MD
> SUNY Upstate Medical University Clinical Campus at Binghamton
> 40 Arch Street, Johnson City, NY  13790
> cryanatbinghamtondotedu
> PGP public keys available at http://home.stny.rr.com/ryancw/
>
> "If you want to build a ship, don't drum up the men to gather wood,
> divide the work and give orders. Instead, teach them to yearn for the
> vast and endless sea."  [Antoine de St. Exupery]
>
> Raghu Naik wrote:
> > Based on the feedback received, I did the following:
> >
> > a) moved my lib sub-directory from the existing installed R version to
> > c:\myRLib
> > b) installed the updated R version
> > c) created .Renviron file in the home directory (C:\R-2.5.1) with the line
> > R_LIBS=c:/myRLib
> > d) used .libPaths() command to confirm that the new R installation was
> > recognizing the myRLib sub-directory
> > e) deleted my old R installation
> >
> > Things worked fine.
> >
> > Thanks you.
> >
> >
> >
> > -- Forwarded message --
> > From: Raghu Naik <[EMAIL PROTECTED]>
> > Date: Jun 2, 2007 5:13 PM
> > Subject: Updating R version
> > To: r-help@stat.math.ethz.ch
> >
> > A quick question.  I am trying to understand how I could move the installed
> > packages in my R 2.3 version to the newly installed R 2.5 version, without
> > having to install all the packages again. I copied the files under the old
> > library subdirectory to the new library subdirectory. But still the newer
> > version is not recognizing the packages that were copied over.
> >
> > Thanks.
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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.
>


--
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]


-- 
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Saving workspace data

2007-07-13 Thread John Kane

--- Renger van Nieuwkoop <[EMAIL PROTECTED]> wrote:

> Hi
> 
> I imported a lot of text-files with R and saved them
> by using:
> save(list=ls(),file="Grunddaten.Rdata")
> 
> After that I wanted to check my saved data and wrote
> source("Grunddaten.Rdata")
> 
> This gives me an error:
>   Error in parse(file, n = -1, NULL, "?") : Syntax
> error at 1: 
> 
> Can somebody tell me what I am doing wrong (I am
> using R.2.4.1)?
> 
> Renger

source is to load a script or programme.  Try load()

__
R-help@stat.math.ethz.ch 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] Algorythmic Question on Array Filtration

2007-07-13 Thread John Kane
I think we need a bit more information and perhaps a
small example data set to see what you want.  

I am not familiar with term mass window. Is this a
confidence interval around the mass value? 


--- Johannes Graumann <[EMAIL PROTECTED]>
wrote:

> Dear All,
> 
> I have a data frame with the columns "Mass" and
> "Intensity" (this is mass
> spectrometry stuff). Each of the mass values gives
> rise to a mass window of
> 5 ppm around the individual mass (from mass -
> mass/1E6*5 to mass +
> mass/1E5*5). I need to filter the array such that in
> case these mass
> windows overlap I retain the mass/intensity pair
> with the highest
> intensity.
> I apologize for this question, but I have no formal
> IT education and would
> value any nudges toward favorable algorithmic
> solutions highly.
> 
> Thanks for any help,
> 
> Joh
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] how to create matrix in a loop

2007-07-13 Thread John Kane
You don't need to do a loop.  You can do it with an
apply statement I think. See ?apply

If the matrix is "mat" to do the test by column try:

apply(mat, 2, shapiro.test)


--- Tavpritesh Sethi <[EMAIL PROTECTED]> wrote:

> Hi all,
> How does one create a matrix of values in a loop.
> For example, I have 46*70
> matrix with columns giving the values for some blood
> tests performed upon
> the 46 patients(rows). I want to perform a simple
> test of normality
> (shapiro-wilk test) upon each of the biochemical
> tests for the 46
> patients. Can somebody suggest the syntax for such a
> loop. For the data x, I
> wrote the following loop which didnt work:-
> pv<-1:70
> stat<-1:70
> for(i in 1:70)
> {
> pv[i]=shapiro.test(x[,i])$p.value
> stat[i]<-shapiro.test(x[,i])$statistic
> }
> warning msg: items to replace is not a multiple of
> replacement length
> 
> Does it have anything to do with the method of
> importing data as
> read.delimrather than
> read.table?
> Please suggest

__
R-help@stat.math.ethz.ch 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] eMail results out of R

2007-07-12 Thread Scillieri, John
We use a program called Blat (www.blat.net) on Windows to email out
results of overnight runs. If you're on Unix/Linux you can definitely do
a similar thing using one of the hundreds of command line utils.

The R code is similar to below:

sendEmail <- function(from, to, subject, body)
{
  BLAT <- "PATH TO BLAT.EXE"
  MAILSERVER <- "your mail server here";
  
  command <- paste(BLAT, "-", "-to", dQuote(to), "-server", 
MAILSERVER, "-s", dQuote(subject), "-f", dQuote(from))

  system(command, input=body)
}

HTH,

John Scillieri


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, July 12, 2007 9:53 AM
To: r-help@stat.math.ethz.ch
Subject: [R] eMail results out of R

Hi everyone,

I did my homework and read the posting guideline :-)

I want to eMail the results of a computing automatically. So I get the
results (the parameters of a garch process) and I want to eMail them to
another person. How can I do that?

Thx
>>> This e-mail and any attachments are confidential, may contain legal,
professional or other privileged information, and are intended solely for the
addressee.  If you are not the intended recipient, do not use the information
in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP2

__
R-help@stat.math.ethz.ch 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] elementary statistics with R (rkward?)

2007-07-12 Thread John Kane

--- "Donatas G." <[EMAIL PROTECTED]> wrote:

> Hi, I am trying to learn some basic statistics stuff
> but I cannot find any
> elementary statistics exercises using R language.
> Using RKward would be even
> better...
> 
> I need that in analysing sociological data, obtained
> through questionnairres -
> findind corelations between variables, relations
> between different types of
> data, etc.
> 
> Could anyone recommend simple tutorials/exercises,
> available on www for me to
> work on?
> 
> I realize it would be much simple to do this
> introductory stuff with spss, that
> everyone around me is using here in Lithuania, but
> I'd really like to learn to
> do it with R instead...
> 
> -- 
> Donatas G.

http://www.math.ilstu.edu/dhkim/Rstuff/Rtutor.html  is
not a bad place to start.   John Verzani's notes on
Simple R
http://www.math.csi.cuny.edu/Statistics/R/simpleR/ may
also help but his book is better.  

Peter Dalgarrd's book "Introductory Statistics with R"
is also very good.

__
R-help@stat.math.ethz.ch 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] Previously saved workspace restored

2007-07-11 Thread john seers \(IFR\)
 

Hi

If you enter the command "ls()"you will see a list of names that have
come with the .Rdata file you double-clicked.

If you enter one of these names at the command prompt you will see the
data.

So, for example if you have some data called "mydata":



> ls()
[1] "mydata" "repos" 
> mydata
 [,1] [,2] [,3]
[1,]147
[2,]2    58
[3,]369
> 


Regards

John


 
---

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kristi Glover
Sent: 11 July 2007 05:18
To: r-help@stat.math.ethz.ch
Subject: [R] Previously saved workspace restored

hi there,
i an beginner of R. some one have sent me a file (extension is .Rdata).
i have  installed R in my computer and i just double clicked the data.
then it automatically opened R programme and displayed that [previously
saved workspace restored]. the following message was displayed. 
 
Type 'demo()' for some demos, 'help()' for on-line help,
or'help.start()' for an HTML browser interface to help.Type 'q()' to
quit R.
 
[Previously saved workspace restored]
 
but how  can I see the data (table) which is saved (in R format) in R?,

 
i hope you will help me. 
 
Kristi Glover
 
 
 
 
_
Explore the seven wonders of the world

BRE
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Repeated Measure different results to spss

2007-07-10 Thread John Vokey
This should work (with x containing the dataframe):

 > x$Id=factor(x$Id)
 > x$Group=factor(x$Group)
 > x$Task=factor(x$Task)
 > str(x)
'data.frame':   48 obs. of  4 variables:
$ Id   : Factor w/ 24 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9  
10 ...
$ Group: Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
$ Task : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
$ Score: num  0.39 0.48 0.59 0.33 0.38 0.37 0.47 0.2 0.29 0.41 ...
 > out.aov = aov(Score~Group*Task+Error(Id+Id:Task),data=x)
 > summary(out.aov)

Error: Id
   Df  Sum Sq Mean Sq F value Pr(>F)
Group  1 0.03420 0.03420  2.1382 0.1578
Residuals 22 0.35189 0.01600

Error: Id:Task
Df   Sum Sq  Mean Sq F value  Pr(>F)
Task1 0.048133 0.048133  5.2144 0.03242 *
Group:Task  1 0.024687 0.024687  2.6743 0.11621
Residuals  22 0.203080 0.009231
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 >

out.aov = aov(Score~Group*Task+Error(Id),data=x) will work as well,  
but the error-term will be labelled simply as ``Within'', rather than  
as the interaction of Id*Task

>
> Hi,
>
> I have some problems with my repeated measures analysis. When I  
> compute it
> with SPSS I get different results than with R. Probably I am doing  
> something
> wrong in R.
> I have two groups (1,2) both having to solve a task under two  
> conditions
> (1,2). That is one between subject factor (group) and one within  
> subject
> factor (task). I tried the following:
>
>  aov(Score ~factor(Group)*factor(Task)+Error(Id)))
>  aov(Score ~factor(Group)*factor(Task))
> but it leads to different results than my spss. I definitely miss  
> some point
> here .
>
> Thanks for you help.
>
> IdGroup   TaskScore
> 1 1   1   0.39
> 2 1   1   0.48

__
R-help@stat.math.ethz.ch 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] transform excel data into graph

2007-07-09 Thread John Kane
I am not sure exactly what you want but see if this
will work. It will give you a dotchart.  

Assume your data.frame is dat
First give the lessons column a name. See ?names

convert numbers in data.frame to a matrix for dotchart

dmat <- as.matrix(dat[,2:4])

Draw dotchart using dat$lessons as a 
dotchart(dmat, labels = dat[,1])

--- cross123 <[EMAIL PROTECTED]> wrote:

> 
> Hello everyone,
> I have a set of data in the following form, which
> are stored in an Excel
> file:
>  nick   john   peter
> 
> lesson1   0.465 0.498 0.473
> lesson2   0.422  0.44  0.134   
> lesson3   0.45   0.35   0.543   
>   
> lesson4   0.590  0.64  0.11 
> 
> lesson5   0.543  0.50.32
>  
> 
> What I want to do is a 2d-graph plot where I will
> have  the name of the
> student in the X-axis and the name of the lesson in
> the Y-axis and the
> number from each pair will be used to construct the
> plot.
> I am newbie with R and I don't know which package
> shall I use nor the
> commands with which I will import my data in R so
> that the plot will be
> created...
> 
> Any help would be greatly appreciated.

__
R-help@stat.math.ethz.ch 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] problem assigning to indexed data frame element

2007-07-06 Thread John Kane
Check what is happening with current.spec.  It looks
to me as if you are trying to use a factor as an
index.  See below

--- "Drescher, Michael (MNR)"
<[EMAIL PROTECTED]> wrote:

> Hi All,
> 
> Sorry if I ask an obvious thing, I am still new to R
> ...
> 
> I created a data frame of given dimensions to which
> I gave strings as
> column names. I want to write to elements of the
> data frame by indexing
> them with the row number and column name (string).
> The problem is that I
> can read elements from the data frame in this way,
> but I cannot assign
> to elements in this way. Instead, I get the
> following error message:
> 
> Error in Summary.factor(..., na.rm = na.rm) : 
> min not meaningful for factors
> 
> Please find the code I used farther below. It would
> be great if someone
> could help me.
> 
> Best regards, Michael
> 
> PS: Coincidentally, I found this same error message
> mentioned in another
> context (levelplot) as indicating a bug (original
> bug report PR# 6005 on
> Mon, 22 Dec 2003)
> 
> 
> Michael Drescher
> Ontario Forest Research Institute
> Ontario Ministry of Natural Resources
> 1235 Queen St East
> Sault Ste Marie, ON, P6A 2E3
> Tel: (705) 946-7406
> Fax: (705) 946-2030
> 
> 
> 
> Code:
> > sfalls.plot.comp <- matrix(nrow=plot.count,
> ncol=spec.count, byrow=T)
> > colnames(sfalls.plot.comp) <- levels(SPECIES)
> ### SPECIES, SPP_VOL, & PLOT are columns/variables
> in a previously read
> data file
> > sfalls.plot.comp <- data.frame(sfalls.plot.comp)
> > attach(sfalls.plot.comp)
> > sfalls.plot.comp[is.na(sfalls.plot.comp)] <- 0
> 
> > sfalls.plot.comp
>   Bf Bw Pj Po Sb
> 1  0  0  0  0  0
> 2  0  0  0  0  0
> 
> > hh <- 1
> > current.spec <- SPECIES[hh]; current.vol <-
> SPP_VOL[hh]; current.plot
> <- PLOT[hh]
> 
> > current.spec
> [1] Bf
> Levels: Bf Bw Pj Po Sb
> 
> > current.vol
> [1] 2
> 
> > current.plot
> [1] 1
> 
> > sfalls.plot.comp[current.plot,current.spec]
> ### thus, reading from the data frame in this way
> (using the column
> name/string) works fine
> [1] 0
> 
> > sfalls.plot.comp[current.plot,current.spec] <-
> current.vol   ### but
> assigning in this way does not work
> Error in Summary.factor(..., na.rm = na.rm) : 
> min not meaningful for factors

If I am reading this correctly 
current.spec is not a column name or a number. It is a
factor as the levels indicate.  You might be able to
get around this by  

current.spec <- as.character(SPECIES[hh])

R has,what to me is, an annoying tendency to read in
many columns of characters as factors.  This can be
changed by changing something in the startup file.
Exactly what I have forgotten.

> 
> > sfalls.plot.comp[current.plot,1] <- current.vol
> ### assigning by using the column number instead of
> the column name of
> course does work
> > sfalls.plot.comp[current.plot,current.spec]
> [1] 2
> 
> > sfalls.plot.comp[current.plot,"Bw"] <- current.vol
> ### as does assigning when replacing 'current.spec'
> for its assigned
> value in quotes, e.g., "Bw"
> > sfalls.plot.comp[current.plot,"Bw"]
> [1] 2
> 
> > sfalls.plot.comp
>   Bf Bw Pj Po Sb
> 1  2  2  0  0  0
> 2  0  0  0  0  0
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] R Logging Package

2007-07-06 Thread Scillieri, John
> Does anyone know how to print out the current function name and line
> number (similar to how warning(call.=TRUE) operates).  I'd like this
> for a logging package I'm working on, but I can't seem to find a way. 
> 
> Thanks for your help,
> 
> John Scillieri
>>> This e-mail and any attachments are confidential, may contain legal,
professional or other privileged information, and are intended solely for the
addressee.  If you are not the intended recipient, do not use the information
in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP2

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] help with vector construction

2007-07-05 Thread John Kane
Or an alternative to Henrique's if you want to select
all the rows from row 2 up to the  3*n row this may
work.

 n  <- 2
 myvector <- data1[2:(2*n), 3]


--- Juan Pablo Fededa <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
> I want to make a vector with the third column of a
> matrix, but only for the
> 2+3n rows of the matrix, with n being an entire
> number from 0 to a million.
> How can I do that in an easy way?
> Thanks in advance,
> 
> Juan Pablo
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] R Logging Package

2007-07-05 Thread Scillieri, John
Does anyone know how to print out the current function name and line
number (similar to how warning(call.=TRUE) operates).  I'd like this for
a logging package I'm working on, but I can't seem to find a way. 

Thanks for your help,

John Scillieri
>>> This e-mail and any attachments are confidential, may contain legal, 
>>> professional or other privileged information, and are intended solely for 
>>> the addressee.  If you are not the intended recipient, do not use the 
>>> information in this e-mail in any way, delete this e-mail and notify the 
>>> sender. CEG-IP1

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] working with R graphics remotely

2007-07-05 Thread John Logsdon
Better still IMHO - try NX or FreeNX.  That runs an xclient (also of course an 
xserver underneath) on your WIndows desktop.   Windows pop up as required.  
NX compression means that you get very impressive speed, mouse response etc.

A server also needs installing on the Linux box so you may have to negotiate 
with the sysadmins.   I don't think you can install it under an ordinary 
user.

NX: www.nomachine.com
FreeNX: freenx.berlios.de
FreeNX uses core libraries kindly provided by NX

On Monday 02 July 2007 15:52:16 Gabor Grothendieck wrote:
> On your Windows machine you need to run (1) an X server and (2) an ssh
> client. Xming and putty, respectively, are among the free ones.
>
> First start Xming (you can configure it using XLaunch, which is included
> with Xming, or you can run Xming from the Windows command line specifying
> the configuration parameters via command line flags).  Then run
> putty.   Be sure you have X11 forwarding enabled in putty's
>   Connection | SSH | Tunnel
> screen.  Googling will locate much info for these programs.
>
> On 7/1/07, zhihua li <[EMAIL PROTECTED]> wrote:
> > Hi netters,
> >
> > Now I'm connecting from my local windows machine to a remote linux
> > machine and launch R out there using SSH. When I tried to create grahics,
> > like using plot or heatmap, I cannot see the output. Maybe a new R window
> > displaying the graphics has popped out in the remote machine? Or I need
> > to change some settings for the graphics to display? I don't know. I
> > googled it and tried dev.copy but it didn't work. Can anyone help me
> > here? I need to be able to see the output graphics and save it to a file
> > (like jpeg)
> >
> > Thanks a lot!
> >
> > _
> > 享用世界上最大的电子邮件系统— MSN Hotmail。  http://www.hotmail.com
> >
> >
> > __
> > R-help@stat.math.ethz.ch 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.



-- 
Best wishes

John

John Logsdon   "Try to make things as simple
Quantex Research Ltd, Manchester UK as possible but not simpler"
[EMAIL PROTECTED]  [EMAIL PROTECTED]
+44(0)161 445 4951/G:+44(0)7717758675   www.quantex-research.com

__
R-help@stat.math.ethz.ch 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] Loop and cbind

2007-07-04 Thread john seers \(IFR\)



Hi 

In what way does it not work?

My guess is that you have not declared your values outside the for loop.
As they are local they will be lost on exit.

You need to declare them before:

ewma<-vector(length=12)
standard<-vector(length=12)

for ... {
....
}

John Seers
 


 
---

Hi, I would like to apply the following function for i between 1 and 12,
and then construct a list of the return series.

for (i in 1:12){
ewma[i] <- emaTA(calm[[i]]^2,0.03)
standard[i]<- calm[[i]]/sqrt(ewma[i])
standard <- cbind(standard[i])
}

But it does not work. Could anyone give me some advice how can I achieve
this? Many thanks
--
View this message in context:
http://www.nabble.com/Loop-and-cbind-tf4024291.html#a11430500
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] probabilty plot

2007-07-04 Thread John Kane

Is this what you mean ? 

---
mydata <- c(1,2,3,4,5,7,5,4,3)

plot(mydata)
---


--- along zeng <[EMAIL PROTECTED]> wrote:

> Hi all,
>I am a freshman of R,but I am interested  in it!
> Those days,I am
> learning   pages on NIST,with url
>
http://www.itl.nist.gov/div898/handbook/eda/section3/probplot.htm,
> I am meeting  a problem about probability plot and I
> don't know how to
> plot a data set with R.
> Could somebody tell me the answer,and a example is
> the best!  I will
> look forward to your answer.
>  Thank you very much.
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] vertically concatenating data frames

2007-07-03 Thread John Kane
?rbind


--- "Aydemir, Zava (FID)"
<[EMAIL PROTECTED]> wrote:

> Hi,
>  
> what is the recommended way to vertically
> concatenate 2 data frames with
> the same column names but different number of rows?
>  
> My problem is something along these lines:
>  
> df1 <- data.frame(var1=var1,var2=var2,var3=var3)  #
> nrow(df1)=1000
> df2 <- data.frame(var1=var4,var2=var5,var3=var6)  #
> nrow(df2)=2000
>  
> I tried df <- c(df1,df2), no success. stack does not
> seem to be
> appropriate either for my problem.
>  
>  
> Thanks
>  
> Zava
>

> 
> This is not an offer (or solicitation of an offer)
> to buy/se...{{dropped}}
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] select row

2007-07-03 Thread John Kane
 ?which

Use it to find the rows and then extract the rows 

 selection  <- mydata[which(mydata$id=="25-2006"), ]

 should work.

--- Leonardo Lami <[EMAIL PROTECTED]> wrote:

> Hi all,
> I have a little problem selecting some rows from a
> data.frame.
> I'd like to select the rows where a determinated
> column take a
> partivolar value.
> 
> For example:
> tab
>   id   x   y
> 124-2005 1621814 4834991
> 224-2005 1621856 4834907
> 324-2005 1621763 4834956
> 4   25-2006 1622330 4835189
> 5   25-2006 1622533 4834834
> 6   25-2006 1622535 4834909
> 7   25-2006 1622543 4834803
> 8   28-2005 1622798 4835043
> 9   28-2005 1622299 4835129
> 
> I'd like to select the row where id=25-2006
> 
> I searched on the search of the R site but I did'nt
> find anything of simple.
> Can someone help me?
> 
> Thank you very much
> Leonardo
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Homals, PsychoR, Bayesm

2007-07-02 Thread John Kane
You need to tell us what operating system you are
using.


--- faisal afzal siddiqui <[EMAIL PROTECTED]> wrote:

> hi,
> 
> I am working on conjoint analysis, how I can install
> Homals, PsychoR, and Bayesm in my computer, also I
> need some examples in R, would u please help me?
> 
> also advise if there are other programmes/modules in
> R > for conjoint analysis?
> 
> Regds 
> Faisal Afzal Siddiqui
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] basics: changing the directory

2007-07-02 Thread John Kane
RSiteSearch("change directory")  will take you to an
archive site that should help. 

or type
?setwd  to get the relevant man page.  


--- Georg Ehret <[EMAIL PROTECTED]> wrote:

> Dear Ms. R,
>I struggle with a very basic command for most of
> you: How to change the
> working-directory by command-line?
> 
> Thank you!
> Georg.

__
R-help@stat.math.ethz.ch 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] termplot with uniform y-limits

2007-07-02 Thread John Fox
Dear Bill,

Functions in the effects package are somewhat similar to termplot, and
allow you to specify the y-axis limits. For example, modify the last
line of the last example in example(all.effects) to 

plot(eff.pres, ask=FALSE, ylim=c(10, 70))

I hope this helps,
 John

--- original message ---

Does anyone have, or has anyone ever considered making, a version of
'termplot' that allows the user to specify that all plots should have
the same y-limits?

This seems a natural thing to ask for, as the plots share a y-scale.
 If
you don't have the same y-axes you can easily misread the comparative
contributions of the different components. 

Notes: the current version of termplot does not allow the user to
specify ylim.  I checked.

  the plot tools that come with mgcv do this by default.  Thanks
Simon.

----
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
R-help@stat.math.ethz.ch 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] SEM model fit

2007-07-01 Thread John Fox
Dear Frank,

My apologies for the slow response: I'm away from home and checking
r-help infrequently.

To find the confidence interval for the RMSEA it's necessary to compute
two chisquare noncentrality parameters. summary.sem() does this by
one-dimensional optimizations. If the upper bound of the CI is very
large  or the lower bound very close to 0, it might not be possible to
find the values with sufficient precision, and NA is printed.

Looking at the code for summary.sem(), however, I see that the
optimizations could fail spuriously if the sample size is large;
moreover, under these circumstances, both the upper and lower bounds
will be NA, even if the lower bound could have been determined. I've
therefore modified summary.sem() so that it should work more reliably,
and have attached a file with the modified function to this email. Let
me know if it provides more satisfactory results. (Because you didn't
give the input correlation matrix, I can't check myself.) I'll
eventually incorporate the new function is an updated version of the
package.

BTW, I doubt that the RMSEA confidence interval is correct for
polychoric correlations.

Regards,
 John
 
 original message --

 I wonder if someone could explain why, when I perform confirmatory
factor-analysis model using polychoric correlations why I do not get an
estimated confidence interval for the RMSEA.  My experience with these
type
models is that I would obtain a confidence interval estimate.  I did
not get
any warning messages with the output.

RESULTS:

Model Chisquare =  1374   Df =  185 Pr(>Chisq) = 0
 Chisquare (null model) =  12284   Df =  210
 Goodness-of-fit index =  0.903
 Adjusted goodness-of-fit index =  0.88
 RMSEA index =  0.0711   90% CI: (NA, NA)
 Bentler-Bonnett NFI =  0.888
 Tucker-Lewis NNFI =  0.888
 Bentler CFI =  0.902
 SRMR =  0.0682
 BIC =  51.4 


SYNTAX

rm(sem.enf.rq)
mdl.rq <- specify.model()
enf   -> law2,  NA,   1
enf   -> law3,  lam2, 1
enf   -> law4,  lam3, 1
enf   <-> enf,  psi1, 0.6
law2  <-> law2, theta1,   0.3
law3  <-> law3, theta2,   0.3
law4  <-> law4, theta3,   0.5
gender-> enf,   a1,   0.2
incomex   -> enf,   a2,   0.2
oftdrnkr  -> enf,   a3,   0.2
attn  -> nvatt, NA,   1
attn  -> crimatt,   lam4, 1.3
attn  -> asltatt,   lam5, 1.2
attn  <-> attn, psi2, 0.5
nvatt <-> nvatt,theta4,   0.5
crimatt   <-> crimatt,  theta5,   0.1
asltatt   <-> asltatt,  theta6,   0.2
gender-> attn,  a4,   0.2
acon   -> acon1,NA,   1
acon   -> acon2,lam4, 1.5
acon   <-> acon,psi2, 0.1
mcon   -> mvcon1,   NA,   1
mcon   -> mvcon2,   lam5, 1
mcon   <-> mcon,psi3, 0.3
ocon   -> oicon1,   NA,   1
ocon   -> oicon2,   lam6, 1
ocon   <-> ocon,psi4, 0.2
con-> acon, NA,   1
con-> mcon, lam7, 0.8
con-> ocon, lam8, 0.9
con   <-> con, psi5, 0.3
acon1 <-> acon1,   theta7,   0.4
acon2 <-> acon2,   theta8,   0.2
mvcon1<-> mvcon1,  theta9,   0.2
mvcon2<-> mvcon2,  theta10,   0.3
oicon1<-> oicon1,  theta11,   0.2
oicon2<-> oicon2,  theta12,   0.3
gender-> con,  a5,   0.1
incomex   -> con,  a6,   -0.1
oftdrnkr  -> con,  a7,   -0.2
attn  -> con,  gam1, 0.2
sev   -> aophys,   NA,1
sev   -> mvphys,   NA,1
sev   -> oiphys,   NA,1
sev   <-> sev, psi6,  0.5
aophys<-> aophys,  theta13,0.5
mvphys<-> mvphys,  theta14,0.5
oiphys<-> oiphys,  theta14,0.5
con   -> sev,  gam3,   0.8
prev  -> mvpct,NA,1
prev  -> oipct,NA,1
prev  -> alcpct,   NA,1
prev  <-> prev,psi8,  0.4
mvpct <-> mvpct,   theta15,0.5
oipct <-> oipct,   theta15,0.5
alcpct<-> alcpct,  theta15,0.5
con   -> 

Re: [R] Function call within a function.

2007-06-29 Thread John Kane
Thanks very much.  A very nice solution.  The
environment problem was the result of one last
deperate try when the actual problem as Jason pointed
out was that I was not naming my list elements and
thought that I had.  

This looks like it will work quite nicely. I am pretty
sure that there is a cleaner way to do this but it is
likely to mean too much manipulation of data earlier
on.  This is a small attempt to extract data in a new
way from a larger project. 

This is greatly appreciated.

 
--- "Nordlund, Dan (DSHS/RDA)" <[EMAIL PROTECTED]>
wrote:

> > -Original Message-
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On
> Behalf Of John Kane
> > Sent: Thursday, June 28, 2007 12:04 PM
> > To: R R-help
> > Subject: [R] Function call within a function.
> > 
> > I am trying to call a funtion within another
> function
> > and I clearly am misunderstanding what I should
> do. 
> > Below is a simple example.
> > I know lstfun works on its own but I cannot seem
> to
> > figure out how to get it to work within ukn.
> Basically
> > I need to create the variable "nts". I have
> probably
> > missed something simple in the Intro or FAQ.
> > 
> > Any help would be much appreciated.
> > 
> > EXAMPLE
> >
>
--
> > -
> > # create data.frame
> > cata <- c( 1,1,6,1,1,4)
> > catb <- c( 1,2,3,4,5,6)
> > id <- c('a', 'b', 'b', 'a', 'a', 'b')
> > dd1  <-  data.frame(id, cata,catb)
> > 
> > # function to create list from data.frame
> > lstfun  <- function(file, alpha , beta ) {
> > cda  <-  subset(file, file[,1] == alpha)
> > cdb  <-  subset (file, file[,1]== beta)
> > list1 <- list(cda,cdb)
> > }
> > 
> > # funtion to operate on list
> > ukn  <-  function(file, alpha, beta, nam1){
> > aa  <- alpha
> > bb  <- beta
> > myfile  <- file
> > nts <- lstfun(myfile, aa, bb)
> > mysum <- nam1[,3]*5
> > return(mysum)
> > }
> > 
> > results <- ukn(dd1, "a", "b", nts$cda)
> 
> John,
> 
> The first problem I see is one of scope.  nts$cda
> refers to an object called nts which does not exist
> in the calling environment (it is local to the
> function ukn).  So trying to call ukn() with nts
> results in an error.  Second, even if you pass the
> name of the object, you will not be able to use it
> in ukn() in the manner that you are trying.  Your
> ukn() function definition also requires that it know
> the inner workings of function lstfun().  Functions
> generally shouldn't require knowing how other
> functions work, they should only rely on what value
> is returned.
> 
> You can get what you want by redefining ukn in the
> following way
> 
> # funtion to operate on list
> ukn  <-  function(file, alpha, beta, nam1){
> aa  <- alpha
> bb  <- beta
> myfile  <- file
> nts <- lstfun(myfile, aa, bb)
> mysum <- nts[[nam1]][,3]*5
> return(mysum)
> }
> 
> And change the function call to
> 
> results <- ukn(dd1, "a", "b", 1) 
> 
> This still leaves the functions coupled in a way
> that I don't like, but I'm not a good enough R
> programmer to solve that problem at the moment. 
> Maybe someone else will come along with a better
> solution.
> 
> Hope this is helpful,
> 
> Dan
> 
> Daniel J. Nordlund
> Research and Data Analysis
> Washington State Department of Social and Health
> Services
> Olympia, WA  98504-5204
> 
> __
> R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Function call within a function.

2007-06-29 Thread John Kane

--- Jason Barnhart <[EMAIL PROTECTED]> wrote:

> The problem isn't the function call.
> 
> First, list1 returned by lstfun does not name its
> elements so nts$cda 
> won't work. See code change in lstfun.

I missed that entirely.  I was groggier than I
realised yesterday afternoon. I had at least once left
nts in existance in the same environment where ukn is
called, thus getting an intermitant error. In that
environment nts$cda was named!

> 
> Second, specifying nts$cda as the nam1 argument
> tells R to look for 
> the nts object in the environment in which ukn is
> called.  However, 
> the nts object is not created in the parent
> environment, it is created 
> in the ukn's environment.

Yes.  I had already tried calling it within the ukn
environment not realising that I had not named the
elements so this was my last try.  

> 
> Third, nam1[,3] should be nam1[2] as there is no
> third element to this 
> list (although and this doesn't resolve the
> environment issue).

Oops, typo when creating the simple example.  Sorry. 
> 
> I've modified your code below to work, but there are
> better ways to go 
> about this.  Thomas Lumley has a famous quote
> regarding parse.  See 
>
http://tolstoy.newcastle.edu.au/R/e2/help/07/01/8059.html
> among  others.
> 
> I was once referred to Patrick Burns' S Poetry to
> learn about the 
> "eval(parse(text=)))" paradigm which was very
> helpful. You may also 
> want to brush up on environments (see ?environment)
> to learn more 
> about lexical scoping.
> 
> Hope this helps.
> -jason

This has been very helpful though I still do not
understand why one must call nts$cda using the
eval(parse()) command.  Is it because nts is created
within the ukn environment?  

I have had a look at S-Poetry but will need to spend a
lot more time on this.  

I thought that this was not the best way to do things
but I wanted to avoid doing a lot of earlier
manipulations to my data files and so decided to go
with what I had. 


> 
> #MODIFIED CODE
> # create data.frame
> cata <- c( 1,1,6,1,1,4)
> catb <- c( 1,2,3,4,5,6)
> id <- c('a', 'b', 'b', 'a', 'a', 'b')
> dd1 <- data.frame(id, cata,catb)
> 
> # function to create list from data.frame
> lstfun <- function(file, alpha , beta ) {
> cda <- subset(file, file[,1] == alpha)
> cdb <- subset (file, file[,1]== beta)
> ### CODE ADDED HERE
> list1 <- list(cda=cda,cdb=cdb)
> }
> 
> # funtion to operate on list
> ukn <- function(file, alpha, beta, nam1){
> aa <- alpha
> bb <- beta
> myfile <- file
> nts <- lstfun(myfile, aa, bb)
> ### CODE ADDED HERE
> mysum <- eval(parse(text=nam1))
> #mysum <- nam1[,3]*5
> return(mysum)
> }
> 
> results <- ukn(dd1, "a", "b", "nts$cda") ###
> modified how called.
> 
> - Original Message - 
> From: "John Kane" <[EMAIL PROTECTED]>
> To: "R R-help" 
> Sent: Thursday, June 28, 2007 12:03 PM
> Subject: [R] Function call within a function.
> 
> 
> >I am trying to call a funtion within another
> function
> > and I clearly am misunderstanding what I should
> do.
> > Below is a simple example.
> > I know lstfun works on its own but I cannot seem
> to
> > figure out how to get it to work within ukn.
> Basically
> > I need to create the variable "nts". I have
> probably
> > missed something simple in the Intro or FAQ.
> >
> > Any help would be much appreciated.
> >
> > EXAMPLE
> >
>
---
> > # create data.frame
> > cata <- c( 1,1,6,1,1,4)
> > catb <- c( 1,2,3,4,5,6)
> > id <- c('a', 'b', 'b', 'a', 'a', 'b')
> > dd1  <-  data.frame(id, cata,catb)
> >
> > # function to create list from data.frame
> > lstfun  <- function(file, alpha , beta ) {
> > cda  <-  subset(file, file[,1] == alpha)
> > cdb  <-  subset (file, file[,1]== beta)
> > list1 <- list(cda,cdb)
> > }
> >
> > # funtion to operate on list
> > ukn  <-  function(file, alpha, beta, nam1){
> > aa  <- alpha
> > bb  <- beta
> > myfile  <- file
> > nts <- lstfun(myfile, aa, bb)
> > mysum <- nam1[,3]*5
> > return(mysum)
> > }
> >
> > results <- ukn(dd1, "a", "b", nts$cda)
> >
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Function call within a function.

2007-06-29 Thread John Kane

--- Jason Barnhart <[EMAIL PROTECTED]> wrote:

> The problem isn't the function call.
> 
> First, list1 returned by lstfun does not name its
> elements so nts$cda 
> won't work. See code change in lstfun.

Oh, I see. I missed this completely.  I clearly was a
bit groggy yesterday afternoon.  

> 
> Second, specifying nts$cda as the nam1 argument
> tells R to look for 
> the nts object in the environment in which ukn is
> called.  However, 
> the nts object is not created in the parent
> environment, it is created 
> in the ukn's environment.
> 
> Third, nam1[,3] should be nam1[2] as there is no
> third element to this 
> list (although and this doesn't resolve the
> environment issue).
> 
> I've modified your code below to work, but there are
> better ways to go 
> about this.  Thomas Lumley has a famous quote
> regarding parse.  See 
>
http://tolstoy.newcastle.edu.au/R/e2/help/07/01/8059.html
> among 
> others.
> 
> I was once referred to Patrick Burns' S Poetry to
> learn about the 
> "eval(parse(text=)))" paradigm which was very
> helpful. You may also 
> want to brush up on environments (see ?environment)
> to learn more 
> about lexical scoping.
> 
> Hope this helps.
> -jason
> 
> #MODIFIED CODE
> # create data.frame
> cata <- c( 1,1,6,1,1,4)
> catb <- c( 1,2,3,4,5,6)
> id <- c('a', 'b', 'b', 'a', 'a', 'b')
> dd1 <- data.frame(id, cata,catb)
> 
> # function to create list from data.frame
> lstfun <- function(file, alpha , beta ) {
> cda <- subset(file, file[,1] == alpha)
> cdb <- subset (file, file[,1]== beta)
> ### CODE ADDED HERE
> list1 <- list(cda=cda,cdb=cdb)
> }
> 
> # funtion to operate on list
> ukn <- function(file, alpha, beta, nam1){
> aa <- alpha
> bb <- beta
> myfile <- file
> nts <- lstfun(myfile, aa, bb)
> ### CODE ADDED HERE
> mysum <- eval(parse(text=nam1))
> #mysum <- nam1[,3]*5
> return(mysum)
> }
> 
> results <- ukn(dd1, "a", "b", "nts$cda") ###
> modified how called.
> 
> - Original Message - 
> From: "John Kane" <[EMAIL PROTECTED]>
> To: "R R-help" 
> Sent: Thursday, June 28, 2007 12:03 PM
> Subject: [R] Function call within a function.
> 
> 
> >I am trying to call a funtion within another
> function
> > and I clearly am misunderstanding what I should
> do.
> > Below is a simple example.
> > I know lstfun works on its own but I cannot seem
> to
> > figure out how to get it to work within ukn.
> Basically
> > I need to create the variable "nts". I have
> probably
> > missed something simple in the Intro or FAQ.
> >
> > Any help would be much appreciated.
> >
> > EXAMPLE
> >
>
---
> > # create data.frame
> > cata <- c( 1,1,6,1,1,4)
> > catb <- c( 1,2,3,4,5,6)
> > id <- c('a', 'b', 'b', 'a', 'a', 'b')
> > dd1  <-  data.frame(id, cata,catb)
> >
> > # function to create list from data.frame
> > lstfun  <- function(file, alpha , beta ) {
> > cda  <-  subset(file, file[,1] == alpha)
> > cdb  <-  subset (file, file[,1]== beta)
> > list1 <- list(cda,cdb)
> > }
> >
> > # funtion to operate on list
> > ukn  <-  function(file, alpha, beta, nam1){
> > aa  <- alpha
> > bb  <- beta
> > myfile  <- file
> > nts <- lstfun(myfile, aa, bb)
> > mysum <- nam1[,3]*5
> > return(mysum)
> > }
> >
> > results <- ukn(dd1, "a", "b", nts$cda)
> >
> > __
> > R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Function call within a function.

2007-06-29 Thread John Kane

--- Stephen Tucker <[EMAIL PROTECTED]> wrote:

> Dear John,
> 
> Perhaps I am mistaken in what you are trying to
> accomplish but it seems like
> what is required is that you call lstfun() outside
> of ukn(). [and remove the
> call to lstfun() in ukn()].
> 
> nts <- lstfun(myfile, aa, bb)
> results <- ukn(dd1, "a", "b", nts$cda)

Yes this definately will work but seems sloppy.  What
I am doing in 'real' life is trying to sort a set of
data.frames into   a two element list ( lstfun) and
then apply some further subsetting to each data.frame
in the list separately.  
> 
> Alternatively, you can eliminate the fourth argument
> in ukn() and assign (via
> '<-') the results of lstfun() to 'nam1' within ukn()
> instead of saving to
> 'nts'...
Humm, I'll have to think about this. The problem, as I
have set up the program is that nam1 is one of the two
data.frames in the list.  

I may have to reconsider this whole thing.  I have
been trying to use the existing data structures and I
may need to start from scratch.  

Thanks for the help.  You have given me some useful
ideas.

John

> 
> --- John Kane <[EMAIL PROTECTED]> wrote:
> 
> > I am trying to call a funtion within another
> function
> > and I clearly am misunderstanding what I should
> do. 
> > Below is a simple example.
> > I know lstfun works on its own but I cannot seem
> to
> > figure out how to get it to work within ukn.
> Basically
> > I need to create the variable "nts". I have
> probably
> > missed something simple in the Intro or FAQ.
> > 
> > Any help would be much appreciated.
> > 
> > EXAMPLE
> >
>
---
> > # create data.frame
> > cata <- c( 1,1,6,1,1,4)
> > catb <- c( 1,2,3,4,5,6)
> > id <- c('a', 'b', 'b', 'a', 'a', 'b')
> > dd1  <-  data.frame(id, cata,catb)
> > 
> > # function to create list from data.frame
> > lstfun  <- function(file, alpha , beta ) {
> > cda  <-  subset(file, file[,1] == alpha)
> > cdb  <-  subset (file, file[,1]== beta)
> > list1 <- list(cda,cdb)
> > }
> > 
> > # funtion to operate on list
> > ukn  <-  function(file, alpha, beta, nam1){
> > aa  <- alpha
> > bb  <- beta
> > myfile  <- file
> > nts <- lstfun(myfile, aa, bb)
> > mysum <- nam1[,3]*5
> > return(mysum)
> > }
> > 
> > results <- ukn(dd1, "a", "b", nts$cda)
> > 
> > __
> > R-help@stat.math.ethz.ch 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.
> > 
> 
> 
> 
>
>

> Choose the right car based on your needs.  Check out


>

__
R-help@stat.math.ethz.ch 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] Function call within a function.

2007-06-28 Thread John Kane
I am trying to call a funtion within another function
and I clearly am misunderstanding what I should do. 
Below is a simple example.
I know lstfun works on its own but I cannot seem to
figure out how to get it to work within ukn. Basically
I need to create the variable "nts". I have probably
missed something simple in the Intro or FAQ.

Any help would be much appreciated.

EXAMPLE
---
# create data.frame
cata <- c( 1,1,6,1,1,4)
catb <- c( 1,2,3,4,5,6)
id <- c('a', 'b', 'b', 'a', 'a', 'b')
dd1  <-  data.frame(id, cata,catb)

# function to create list from data.frame
lstfun  <- function(file, alpha , beta ) {
cda  <-  subset(file, file[,1] == alpha)
cdb  <-  subset (file, file[,1]== beta)
list1 <- list(cda,cdb)
}

# funtion to operate on list
ukn  <-  function(file, alpha, beta, nam1){
aa  <- alpha
bb  <- beta
myfile  <- file
nts <- lstfun(myfile, aa, bb)
mysum <- nam1[,3]*5
return(mysum)
}

results <- ukn(dd1, "a", "b", nts$cda)

__
R-help@stat.math.ethz.ch 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] Method dispatch in functions?

2007-06-28 Thread John McHenry
Hi,

Could someone point me in the right direction for documentation on the 
following question? 

Let's say I have two objects a and b of classes A and B, respectively.
Now let's say I write a function foo that does something similar to 
objects of type A and B. Basically I want to overload the function
in C++ talk, so if I give foo and object of type A something (and this
is my question) dispatches the call to, say, foo.A, and if I give foo
and object of type B something dispatches the call to, say, foo.B.

I want to write foo.A and foo.B. How to I perform the method 
dispatch? From what I understand there are two ways in R:
S3 and S4. What is the simple S3 way?

Thanks!

Jack.

   
-

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Repeat if

2007-06-28 Thread john seers \(IFR\)
 

Hi Birgit

No, you do not have to write all 85 vectors in the first line. I just did not 
fully appreciate what you were trying to do. 

You could use the "get" option as was suggested somewhere else.

So, if your vectors are V1 to V2 (i.e. 85) say, something like:


V1<-c(1,2,3)
V2<-c(5,2,7)

...

V<-paste("V", 1:2, sep="")
for ( i in 1:length(V) ) { 
print(range (get(V[i]), na.rm = TRUE))
}


Regards

JS

 
---
 
Web sites:

www.ifr.ac.uk   
www.foodandhealthnetwork.com

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
Sent: 28 June 2007 15:12
To: john seers (IFR)
Cc: R Hilfe
Subject: Re: [R] Repeat if

Hello John,

I tried this code. But I got only the ranges of V1 and V2 what is easily 
understandable.
Do I have to write in all 85 vectors in the first line?

V<-list(a=c(V1), b=c(V2))

for ( i in 1:85 ) {  # 2 vectors (replace with 85 ...)
+ print(range (V[i], na.rm = TRUE))
+ }


sapply(1:85, function(i) eval(parse(text=paste("range(V", i, ", na.rm=T)", 
sep=""

But thanks anyway.

Greetings

Birgit


Am 28.06.2007 um 12:23 schrieb john seers ((IFR)):

>
> Hi
>
> I think a for loop would be more what you want.
>
> Something along the lines of:
>
>
> V<-list(a=c(1,2,3), b=c(2,3,4)) # list of 2 vectors
>
> for ( i in 1:2 ) {  # 2 vectors (replace with 85 ...)
> print(range (V[i], na.rm = TRUE))
> }
>
>
> Regards
>
> JS
>
> ---
>
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke
> Sent: 28 June 2007 10:48
> To: R Hilfe
> Subject: [R] Repeat if
>
> Hello,
> (Power Book G4, Mac OS X, R 2.5.0)
>
> I would like to repeat the function range for 85 Vectors (V1-V85).
> I tried with this code:
>
> i<-0
>> repeat {
> + i<-i+1
> + if (i<85) next
> + range (Vi, na.rm = TRUE)
> + if (i==85) break
> + }

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.


  1   2   3   4   5   6   7   8   9   10   >