[R] Simple plot question

2007-04-26 Thread David Kaplan
Hi,

I have been searching and can't seem to find a simple command that will 
allow me to sample from a multivariate normal distribution with known 
covariance matrix.  I am likely missing something.

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.


Re: [R] Simple plot question

2007-04-26 Thread Ravi Varadhan
Check out the function mvrnorm in package MASS.

library(MASS)
?mvrnorm

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Kaplan
Sent: Thursday, April 26, 2007 2:49 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Simple plot question

Hi,

I have been searching and can't seem to find a simple command that will 
allow me to sample from a multivariate normal distribution with known 
covariance matrix.  I am likely missing something.

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.


[R] Simple plot() question

2004-11-16 Thread michael watson (IAH-C)
Hi

First a simple question to do with plot().  How do I change the x-axis
labels on a plot?

For example, I am plotting each row of a matrix, and I want each row to
be a line on my graph.  Simple really.  Eg:

plot(sg[1,], type=l)

When I do this, the x-axis is labelled 1:38, as I have 38 columns in my
matrix.  When I do:

plot(sg[1,order(sg[1,])], type=l)

Ideally I would like the x-axis labels to reflect the new order of the
columns, but they're still numbered 1:38... I've read the plot() docs
and the par() docs and can't figure it out - I know I'm missing
something obvious, but what?

Cheers

Mick

Michael Watson
Head of Informatics
Institute for Animal Health,
Compton Laboratory,
Compton,
Newbury,
Berkshire RG20 7NN
UK

Phone : +44 (0)1635 578411 ext. 2535
Mobile: +44 (0)7990 827831
E-mail: [EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Simple plot() question

2004-11-16 Thread James W. MacDonald
michael watson (IAH-C) wrote:
Hi
First a simple question to do with plot().  How do I change the x-axis
labels on a plot?
For example, I am plotting each row of a matrix, and I want each row to
be a line on my graph.  Simple really.  Eg:
plot(sg[1,], type=l)
When I do this, the x-axis is labelled 1:38, as I have 38 columns in my
matrix.  When I do:
plot(sg[1,order(sg[1,])], type=l)
Ideally I would like the x-axis labels to reflect the new order of the
columns, but they're still numbered 1:38... I've read the plot() docs
and the par() docs and can't figure it out - I know I'm missing
something obvious, but what?
You want to add xaxt=n so the x-axis labels are not printed. Then add 
your new labels using axis(1, at=1:38, labels=some vector of label names)

HTH,
Jim

Cheers
Mick
Michael Watson
Head of Informatics
Institute for Animal Health,
Compton Laboratory,
Compton,
Newbury,
Berkshire RG20 7NN
UK
Phone : +44 (0)1635 578411 ext. 2535
Mobile: +44 (0)7990 827831
E-mail: [EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

--
James W. MacDonald
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Simple plot() question

2004-11-16 Thread Dimitris Rizopoulos
try something like
plot(..., axes=FALSE)
axis(2); axis(1, labels=c(your labels))
Best,
Dimitris

Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
- Original Message - 
From: michael watson (IAH-C) [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, November 16, 2004 3:45 PM
Subject: [R] Simple plot() question


Hi
First a simple question to do with plot().  How do I change the 
x-axis
labels on a plot?

For example, I am plotting each row of a matrix, and I want each row 
to
be a line on my graph.  Simple really.  Eg:

plot(sg[1,], type=l)
When I do this, the x-axis is labelled 1:38, as I have 38 columns in 
my
matrix.  When I do:

plot(sg[1,order(sg[1,])], type=l)
Ideally I would like the x-axis labels to reflect the new order of 
the
columns, but they're still numbered 1:38... I've read the plot() 
docs
and the par() docs and can't figure it out - I know I'm missing
something obvious, but what?

Cheers
Mick
Michael Watson
Head of Informatics
Institute for Animal Health,
Compton Laboratory,
Compton,
Newbury,
Berkshire RG20 7NN
UK
Phone : +44 (0)1635 578411 ext. 2535
Mobile: +44 (0)7990 827831
E-mail: [EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Simple plot() question

2004-11-16 Thread Andy Bunn
Hi Mick:

I'm a little unsure if this is what you are after but does this do it?

foo.mat - matrix(rnorm(100), nrow = 10, ncol = 10)
plot(foo.mat[1,], type=l, xlab = Crud, ylab = More Crud)
plot(foo.mat[1,order(foo.mat[1,])], type=l, xaxt = n, xlab = Crud,
ylab = More Crud)
axis(1, at=1:length(foo.mat[1,]), labels= order(foo.mat[1,]))


Seems like a barplot might be a nice way to go too:
barplot(foo.mat[1,order(foo.mat[1,])], names.arg = order(foo.mat[1,]))


A reproducible example would help the list see what you are after as I might
be totally off on this.
HTH, Andy


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of michael watson
 (IAH-C)
 Sent: Tuesday, November 16, 2004 9:45 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Simple plot() question


 Hi

 First a simple question to do with plot().  How do I change the x-axis
 labels on a plot?

 For example, I am plotting each row of a matrix, and I want each row to
 be a line on my graph.  Simple really.  Eg:

 plot(sg[1,], type=l)

 When I do this, the x-axis is labelled 1:38, as I have 38 columns in my
 matrix.  When I do:

 plot(sg[1,order(sg[1,])], type=l)

 Ideally I would like the x-axis labels to reflect the new order of the
 columns, but they're still numbered 1:38... I've read the plot() docs
 and the par() docs and can't figure it out - I know I'm missing
 something obvious, but what?

 Cheers

 Mick

 Michael Watson
 Head of Informatics
 Institute for Animal Health,
 Compton Laboratory,
 Compton,
 Newbury,
 Berkshire RG20 7NN
 UK

 Phone : +44 (0)1635 578411 ext. 2535
 Mobile: +44 (0)7990 827831
 E-mail: [EMAIL PROTECTED]

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html