[R] probit analysis with natural response

2008-06-20 Thread Jinsong Zhao
Dear all,

I have try to use mle() from package stats4 to estimate parameters of
the following model:

p = Pr(Y = 0) = C + (1 - C)F(x'\beta)

a probit model with natural response.

The log-likelihood function is:

fr - function(c, alpha, beta) {
 P - c + (1-c) * pnorm(alpha + beta * x)
 P - pmax(pmin(P,1),0)
 -(sum(log(choose(n,r))) + sum(r * log(P)) + sum((n -r)* log(1-P)))
}

When give the following dataset:

r - c(3,4,4,3,5,4,5,9,8,11,12,13)
n - rep(15,12)
x - c(0, 1.1, 1.3, 2.0, 2.2, 2.8, 3.7, 3.9, 4.4, 4.8, 5.9, 6.8)
x - log10(x)

And then,

fit - mle((fr), start = list(c =0.2, alpha = 0, beta =0), method = BFGS)

It will give the following error message:

Error in optim(start, f, method = method, hessian = TRUE, ...) :
  initial value in 'vmmin' is not finite

However, when I set beta to 0.1, mle() could terminate normally. Set
beta to 0.001 or 5, for example, the above command will give the
following error message:

Error in optim(start, f, method = method, hessian = TRUE, ...) :
  non-finite finite-difference value [3]
 ~~~or [1] when beta set to 5.

What's wrong? And how to improve the above code?

Thanks in advance!

Jinsong Zhao

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Howto reduce number of ticks in X, Y axis while still containing all the data

2008-06-20 Thread Dieter Menne
Gundala Viswanath gundalav at gmail.com writes:

 I am trying to plot 100 x 100 matrix data in a level plot.
 The problem I have is that the x/y -axis label in ticks
 are jumbled together. Thus I want X/Y axis to contain
 10 ticks only, yet still plotting all the 100 data.
 
 Is there a way to do it?
 The code I have below doesn't work.
 

Well, the code did not work because you did not provide example data
and forgot that levelplot is lattice, but when I add these two lines,
it works for me. Scaling is 20,40,..., and all point are shown (hope so, 
I did not count).

Dieter

library(lattice)
mat.data = matrix(rnorm(100*100),nrow=100)

# Corr contains 100x100 matrix
corr - cor(t(mat.data), method =pearson)

# Plot them
levelplot(corr, main=PCC of Top-100 Genes,
xlab=Gene,
ylab=Gene,
scale=list(y=list(tick.number=10)) # Doesn't work
)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Pointwise Confidence Bounds on Logistic Regression

2008-06-20 Thread Prof Brian Ripley

On Thu, 19 Jun 2008, Bryan Hanson wrote:


Thanks so much to all who offered assistance.  I have to say it would have
taken me a long time to figure this out, so I am most grateful.  Plus,
studying your examples greatly improves my understanding.

As a follow up, the fit process gives the following error:

Warning messages:
1: In eval(expr, envir, enclos) :
 non-integer #successes in a binomial glm!

Is this something I should worry about?  It doesn't arise from glm or
glm.fit


It does arise from glm(), which runs the initialization code for the 
family.  Specifically



binomial()$initialize

expression({
if (NCOL(y) == 1) {
if (is.factor(y))
y - y != levels(y)[1]
n - rep.int(1, nobs)
if (any(y  0 | y  1))
stop(y values must be 0 = y = 1)
mustart - (weights * y + 0.5)/(weights + 1)
m - weights * y
if (any(abs(m - round(m))  0.001))
warning(non-integer #successes in a binomial glm!)
}
else if (NCOL(y) == 2) {
if (any(abs(y - round(y))  0.001))
warning(non-integer counts in a binomial glm!)
n - y[, 1] + y[, 2]
y - ifelse(n == 0, 0, y[, 1]/n)
weights - weights * n
mustart - (n * y + 0.5)/(n + 1)
}
else stop(for the binomial family, y must be a vector of 0 and 1's\n,
or a 2 column matrix where col 1 is no. successes and col 2 is 
no. failures)

})

You specified a binomial family with responses 0.1 and 0.9.  That makes no 
sense -- the binomial distribution is for integers.  Perhaps you mean 1/10 
and 9/10, in which case you needed a weight of 10, but I'm forced to 
guess.




Thanks, Bryan

For the record, a final complete working code is appended below.

x - c(1:40)
y1 - c(rep(0.1,10), rep(NA, 10), rep(0.9,20))
y2 - c(rep(0.1,15), rep(NA, 10), rep(0.9,15))
data - as.data.frame(cbind(x,y1,y2))
plot(x, y1, pch = 1, ylim = c(0,1), col = red, main = Logistic Regression
w/Confidence Bounds, ylab = y values,  xlab = x values)
points(x, y2, pch = 3, col = blue)
abline(h = 0.5, col = gray)
fit1 - glm(y1~x, family = binomial(link = logit), data, na.action =
na.omit)
fit2 - glm(y2~x, family = binomial(link = logit), data, na.action =
na.omit)
lines(fit1$model$x, fit1$fitted.values, col = red)
lines(fit2$model$x, fit2$fitted.values, col = blue)

## predictions on scale of link function
pred1 - predict(fit1, se.fit = TRUE)
pred2 - predict(fit2, se.fit = TRUE)

## constant for 95% confidence bands
## getting two t values is redundant here as fit1 and fit2
## have same residual df, but the real world may be different
res.df - c(fit1$df.residual, fit2$df.residual)
## 0.975 because we want 2.5% in upper and lower tail
const - qt(0.975, df = res.df)

## confidence bands on scale of link function
upper1 - pred1$fit + (const[1] * pred1$se.fit)
lower1 - pred1$fit - (const[1] * pred1$se.fit)
upper2 - pred2$fit + (const[2] * pred2$se.fit)
lower2 - pred2$fit - (const[2] * pred2$se.fit)

## bind together into a data frame
bands - data.frame(upper1, lower1, upper2, lower2)

## transform on to scale of response
bands - data.frame(lapply(bands, binomial(link = logit)$linkinv))

## plot confidence bands
lines(fit1$model$x, bands$upper1, col = pink)
lines(fit1$model$x, bands$lower1, col = pink)
lines(fit2$model$x, bands$upper2, col = lightblue)
lines(fit2$model$x, bands$lower2, col = lightblue)



On 6/19/08 12:28 PM, Gavin Simpson [EMAIL PROTECTED] wrote:


On Thu, 2008-06-19 at 10:42 -0400, Bryan Hanson wrote:

[I've ommitted some of the conversation so far...]


E.g. in a logistic model, with (say) eta = beta_0 + beta_1*x one may
find, on the
linear predictor scale, A and B (say) such that P(A = eta = B) = 0.95.

Then P(expit(A) = expit(eta) = expit(B)) = 0.95, which is exactly
what is wanted.


I think I follow the above conceptually, but I don't know how to implement
it, though I fooled around (unsuccessfully) with some of the variations on
predict().

I'm trying to learn this in response to a biology colleague who did
something similar in SigmaPlot. I can already tell that SigmaPlot did a lot
of stuff for him in the background.  The responses are 0/1 of a particular
observation by date.  The following code simulates what's going on (note
that I didn't use 0/1 since this leads to a recognized condition/warning of
fitting 1's and 0's. I've requested Brian's Pattern Recognition book so I
know what the problem is and how to solve it).  My colleague is looking at
two populations in which the LD50 would differ.  I'd like to be able to
put the pointwise confidence bounds on each curve so he can tell if the
populations are really different.

By the way, this code does give a (minor?) error from glm (which you will
see).

Can you make a suggestion about how to get those confidence bounds on
there?

Also, is a probit link more appropriate here?

Thanks,  Bryan

x - c(1:40)
y1 - c(rep(0.1,10), rep(NA, 10), rep(0.9,20))
y2 - c(rep(0.1,15), rep(NA, 10), rep(0.9,15))
data - 

Re: [R] create .exe file with R?

2008-06-20 Thread Prof Brian Ripley

See 'Writing R Extensions'

On Thu, 19 Jun 2008, Hua Li wrote:


Dear all,

I'm writing to check with you whether there is a way to create .exe 
file(or something like that) with R. Now working on creating a program 
to take inputs from users (with tcl/tk), I would appreciate any idea to 
make the program run on its own rather than every time having to run my 
source code in R.


Thanks!

Hua

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to write symbol (nabla) in R graph

2008-06-20 Thread Dieter Menne
Nuno Prista nmprista at fc.ul.pt writes:

 
 Can anyone of you tell me how to write a nabla symbol in an R graph?
 


I have not tested it, but according to

http://www.gnu.org/software/plotutils/manual/html_chapter/plotutils_10.html


nabla is Unicode [0321]

Check documentation on plothmath how to use it.

Note: the documents cited in plotmath are huge, and it would be nice to have
something like the gnu-reference I google for a short list.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Wacek Kusnierczyk
Simon Blomberg wrote:
 I try to use a functional programming style. I define functions within
 functions when it is helpful in terms of information hiding. I avoid
 writing functions with side-effects as much as possible, so the only
 communication of the called function with the caller function is through
 the arguments and the returned value. I try to keep the code as simple
 and clear as possible (this is one of the things I fail at most). An
 appropriate amount of comments is also useful, especially when returning
 to old code after a long break. OOP is useful for really big projects,
 but I find OOP unnecessarily complicated for small jobs.

 I found Code Complete, by McConnell (http://www.cc2e.com/) to be very
 helpful. I'm sure there are other books around with similar tips. Before
 I switched to R, I used XLisp-Stat. I found learning Lisp to be a really
 good way to learn good programming practices. Good Lisp code is the
 closest thing you can get to poetry in computer programming. Lisp Style
  Design, by Miller and Benson was helpful. I'd like to see an S Style
  Design.
   

i support this view.  i found sicp (structure and interpretation of
computer programs, by abelson  sussman, a real classic in the field)
particularly enlightening, although it certainly is a bit outdated in
many respects -- but just a bit.  functional programming style is great,
but beware -- r will create (afaik, experts please correct me if this is
wrong) a deep copy of about any object you send as an argument to a
function (if only when it is actually used inside the function), and the
result may be that the more beautiful the code, the more the performance
sucks. 

in pure functional programming, a function cannot change any part of the
object passed to it as an argument, so there's no need for making a
local copy.  in r everything can happen as you can deparse the call to a
function inside the function body, and you can never tell whether the
object you pass to a function will be changed or not, given only the
function's signature.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R web site-Useability finding varous bits of documentation

2008-06-20 Thread Dieter Menne
hadley wickham h.wickham at gmail.com writes:

 
  Note that the R-project page (www.r-project.org)
  and  CRAN  are two things,  albeit closely related.
  CRAN is for DOWNLOADing, including free contributed docs.
  So that is the main reason, contrib.docs are not there in 
 the  www.r-project.org sidebar.
 
 Why does there need to be two sites?
 
I agree. I never  understood this division, and it adds a lot of 
confusion because parts are repeated.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] YAPMQ - Yet Another PlotMath Question

2008-06-20 Thread Dieter Menne
Peter Dalgaard p.dalgaard at biostat.ku.dk writes:

 Notice that paste()ing two expressions does not yield an expression 
 result. Instead, it deparses both arguments and gives a character string.

May I suggest to add this sentence to the expression documentation? That section
is VERY terse.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Howto reduce number of ticks in X, Y axis while still containing all the data

2008-06-20 Thread Gundala Viswanath
Hi Dieter,

I'm aware of the need to include lattice library.
I just didn't show it.

However my code still cant' produce the same results
as yours.

My data.mat contain this form of output
 print(data.matrix)

  11145  3545  8951 11097 16599 11100
8566 .. (upto 100 more)
11145 1.000 0.9979445 0.9966705 0.9855180 0.9775806 0.9949439 0.9579916
3545  0.9979445 1.000 0.9973328 0.9910627 0.9847413 0.9947414 0.9521648
8951  0.9966705 0.9973328 1.000 0.9882817 0.9829629 0.9938390 0.9558376
11097 0.9855180 0.9910627 0.9882817 1.000 0.9969120 0.9846531 0.9490246
16599 0.9775806 0.9847413 0.9829629 0.9969120 1.000 0.9785536 0.9383424

(up to 100 more)

Which is different from yours, that gives:

   [,1]  [,2]  [,3]  [,4]  [,5]
  [1,]  1.00  0.1348954834  0.0751601237  0.0348865551 -0.2111789755
  [2,]  0.1348954834  1.00  0.0543903623 -0.0183413605 -0.1684300250
  [3,]  0.0751601237  0.0543903623  1.00  0.1070384198 -0.0598198329
  [4,]  0.0348865551 -0.0183413605  0.1070384198  1.00  0.0632082205
  [5,] -0.2111789755 -0.1684300250 -0.0598198329  0.0632082205  1.00

Can you suggest how can I over come this problem?

- Gundala Viswanath
Jakarta - Indonesia


On Fri, Jun 20, 2008 at 3:38 PM, Dieter Menne
[EMAIL PROTECTED] wrote:
 Gundala Viswanath gundalav at gmail.com writes:

 I am trying to plot 100 x 100 matrix data in a level plot.
 The problem I have is that the x/y -axis label in ticks
 are jumbled together. Thus I want X/Y axis to contain
 10 ticks only, yet still plotting all the 100 data.

 Is there a way to do it?
 The code I have below doesn't work.


 Well, the code did not work because you did not provide example data
 and forgot that levelplot is lattice, but when I add these two lines,
 it works for me. Scaling is 20,40,..., and all point are shown (hope so,
 I did not count).

 Dieter

 library(lattice)
 mat.data = matrix(rnorm(100*100),nrow=100)

 # Corr contains 100x100 matrix
 corr - cor(t(mat.data), method =pearson)

 # Plot them
 levelplot(corr, main=PCC of Top-100 Genes,
xlab=Gene,
ylab=Gene,
scale=list(y=list(tick.number=10)) # Doesn't work
)

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] colnames of a column

2008-06-20 Thread Alfredo Alessandrini
 have you read the docs?

Yes, I'm reading the manual An Introduction to R..


 start with ?`[`

Ok...I haven't read it.

Thanks.

Alfredo

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] plot function

2008-06-20 Thread Norbert NEUWIRTH
dear userRs, 

I am deeply ashamed asking you this very basic question, but I did neither get 
it online nor by the S/R-literature I have. 

I simply want to plot the values of a COUPLE of vectors within one graph - in 
concrete a couple of time series, a couple of distributions and some stacked 
area graphs. I am higly convinced, that there are dozens of solutions. Could 
you please recommend me one?

All the best,
  Norbert

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to write symbol (nabla) in R graph

2008-06-20 Thread Prof Brian Ripley

On Fri, 20 Jun 2008, Dieter Menne wrote:


Nuno Prista nmprista at fc.ul.pt writes:


Can anyone of you tell me how to write a nabla symbol in an R graph?


We need to know what is meant by 'nabla': 
http://en.wikipedia.org/wiki/Nabla_symbol tries to disambiguate.



I have not tested it,


so others are left to find your errors for you.


but according to

http://www.gnu.org/software/plotutils/manual/html_chapter/plotutils_10.html


nabla is Unicode [0321]


U+0321 is COMBINING PALATALIZED HOOK BELOW !  You have misread that 
document, which is about Hershey encodings not Unicode.



Check documentation on plothmath how to use it.


Perhaps you meant ?Hershey ?


Note: the documents cited in plotmath are huge, and it would be nice to have
something like the gnu-reference I google for a short list.


Like the reference

http://www.stat.auckland.ac.nz/~paul/R/CM/AdobeSym.html

?  The Gnuplot reference you cite does qualify as 'huge' and you have 
demonstrated how unclear it is.  ?plotmath has both the definitive 
documentation and a reference to a short table (added by Paul Murrell at 
my suggestion).


Steve Ellison's answer is Unicode U+2207 via the symbol font.  That is 
'Nabla' (capitalized) according to


http://www.alanwood.net/unicode/mathematical_operators.html

although the Adobe glyph name is 'gradient'.


To summarize, do one of

Use \xd1 in font = 5

Use plotmath with symbol(\xd1) (or equivalent)

Use \u2207 on systems that support UTF-8 (and with a font and graphics 
device that supports this).


E.g.

plot(1:5, type=n)
text(1,1, \xd1, font=5)
text(2,2, expression(symbol(\xd1)))
text(3,3, \u2207)

Depending on the locale and graphics device (and version of R) each of 
these may or may not work -- the first is probably the most reliable.


--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Some help with dates.

2008-06-20 Thread Paul Fisch
Hey,

I'm new to R but familiar with other programming languages.

Basically, I want to store an array of dates.  For each of these dates I
want to store only the day of the week and the hour.  So for example:
Monday 12 would be Monday at 12 o'clock and Tuesday 20 would be Tuesday
at 8 p.m.

Alternatively it could be stored as 0-6 for Sunday to Saturday.  So Tuesday
at 11 a.m. would be something like 2 11.

These dates don't need to be stored exactly like I have written.  I just
would like to know how R would store a day of the week combined with an hour
in a variable.


Thanks,
Paul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plot function

2008-06-20 Thread Dieter Menne
Norbert NEUWIRTH norbert.s.neuwirth at univie.ac.at writes:

 
 I am deeply ashamed asking you this very basic question, but I did neither get
it online nor by the
 S/R-literature I have. 
 
 I simply want to plot the values of a COUPLE of vectors within one graph - in
concrete a couple of time series, a
 couple of distributions and some stacked area graphs. I am higly convinced,
that there are dozens of
 solutions. Could you please recommend me one?

It would be good if you provide a data set and an example that comes close to
what you want. With standard graphic, check the use of lines instead of plot.
And for lattice, have a look at

http://dsarkar.fhcrc.org/lattice/book/figures.html

for example Fig 15.12 is a bit similar to your request.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How/When to use :: and :::?

2008-06-20 Thread ctu

Hi Dear R users,

I check help(Syntax) but I still don't know how to use :: and ::: and  
when I should use it.  Can anyone give me a answer?


Thanks in advance

Chunhao Tu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How/When to use :: and :::?

2008-06-20 Thread Wacek Kusnierczyk
[EMAIL PROTECTED] wrote:
 Hi Dear R users,

 I check help(Syntax) but I still don't know how to use :: and ::: and
 when I should use it.  Can anyone give me a answer?

 Thanks in advance

?`::`

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plotting barplot and scatterplot on same device - x-axis problem

2008-06-20 Thread Thomas Pedersen

Hi R-users

I'm a relative newbie and uses R mostly for graphical purpose. I have a
layout problem when plotting a scatterplot and a barplot using
par(new=TRUE). The baseline of the x-axis is not positioned equal for the
two plotting functions (see picture) and I have been unable to find out how
this is changed. 

http://www.nabble.com/file/p18025066/pic.jpeg 

I have added the script if this is of interrest:

par(mar = c(7, 4, 4, 2) + 0.1)

barplot(rbind(data$Asn,data$Glu,data$NH3),
 beside=T,
 axes=TRUE,
 xlim=c(0,57),
 ylim=c(0,10))

par(new=TRUE)

plot(1:14,data$Acidification.time,
 axes=FALSE,
 type=b,
 xlab=,
 ylab=,
 xlim=c(0.3,14.7),
 ylim=c(6,8))

axis(1,pos=6,
 labels=FALSE,
 at=c(0.3,1:14,14.7))

text(1:14, par(usr)[3], srt = 90, adj = 1,
 labels = data$Month, xpd = TRUE)

axis(4,pos=14.7)

All help will be greatly appreciated
-- 
View this message in context: 
http://www.nabble.com/Plotting-barplot-and-scatterplot-on-same-device---x-axis-problem-tp18025066p18025066.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Some help with dates.

2008-06-20 Thread jim holtman
Check out 'POSIXlt'.  This should provide a hint as to how you can do it:

 ?as.POSIXlt
 x - as.POSIXlt('2008-03-04 11:00')
 x
[1] 2008-03-04 11:00:00 GMT
 unlist(x)
  sec   min  hour  mday   mon  year  wday  yday isdst
0 011 4 2   108 263 0
 ?POSIXlt
 myDate - paste(x$wday, x$hour)
 myDate
[1] 2 11



On Fri, Jun 20, 2008 at 4:35 AM, Paul Fisch [EMAIL PROTECTED] wrote:
 Hey,

 I'm new to R but familiar with other programming languages.

 Basically, I want to store an array of dates.  For each of these dates I
 want to store only the day of the week and the hour.  So for example:
 Monday 12 would be Monday at 12 o'clock and Tuesday 20 would be Tuesday
 at 8 p.m.

 Alternatively it could be stored as 0-6 for Sunday to Saturday.  So Tuesday
 at 11 a.m. would be something like 2 11.

 These dates don't need to be stored exactly like I have written.  I just
 would like to know how R would store a day of the week combined with an hour
 in a variable.


 Thanks,
 Paul

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problems with basic loop

2008-06-20 Thread Michael Pearmain
I'm having trouble creating a looping variable and i can't see wher ethe
problem arises from any hep gratfully appreciated

First create a table

x-table(SURVEY$n_0,exposed)
 x
  exposed
   False True
  Under 16241
  16-19   689
  20-24  190   37
  25-34  555  204
  35-44  330   87
  45-54  198   65
  55-64   67   35
  65+ 108

Now ectors to store counts and column proportions

 xT-x[,True]
 xF-x[,False]
 yT-x[,True]/colSums(x)
 yF-x[,False]/colSums(x)

check length for dynamic looping
 length(yT)
[1] 8

now create loop
 for(i in 1:length(yT)){
+ pwr.2p2n.test(2*(asin(sqrt(yT[i]))-asin(sqrt(yF[i]))),n1=xT[i],n2=xF[i])
+ }
Error in pwr.2p2n.test(2 * (asin(sqrt(yT[i])) - asin(sqrt(yF[i]))), n1 =
xT[i],  :
  number of observations in the first group must be at least 2

this confuses me as if i enter the data as values the procedure works?

Thanks in advance

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Using metric units in plots

2008-06-20 Thread Philip Rhoades

People,

It appears that one has to use Imperial measurements in plot parameters? 
 I can't find any info on using metric units . .


Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW  2001
Australia
E-mail:  [EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problem with date-x-axis in lattice

2008-06-20 Thread Henning Wildhagen
Hello list,

i am trying to plot a continous variable y against a date variable, both 
in one dataframe named df, using a code like this

library(lattice)
plot1-xyplot(y~date, data=df, type=b)

date is of class Date, of course, format=%d.%m.%Y, and spans two 
calendar years. The problem is that the x-axis is labeled with only one 
tick mark corresponding to the year with century (%Y) of the second 
calendar year.

Is there a way to define the increment of the x-axis tick marks?

Cheers

Henning
-- 



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Jan T. Kim
On Fri, Jun 20, 2008 at 09:06:24AM +0200, Wacek Kusnierczyk wrote:
 Simon Blomberg wrote:
  I try to use a functional programming style. I define functions within
  functions when it is helpful in terms of information hiding. I avoid
  writing functions with side-effects as much as possible, so the only
  communication of the called function with the caller function is through
  the arguments and the returned value. I try to keep the code as simple
  and clear as possible (this is one of the things I fail at most). An
  appropriate amount of comments is also useful, especially when returning
  to old code after a long break. OOP is useful for really big projects,
  but I find OOP unnecessarily complicated for small jobs.
 
  I found Code Complete, by McConnell (http://www.cc2e.com/) to be very
  helpful. I'm sure there are other books around with similar tips. Before
  I switched to R, I used XLisp-Stat. I found learning Lisp to be a really
  good way to learn good programming practices. Good Lisp code is the
  closest thing you can get to poetry in computer programming. Lisp Style
   Design, by Miller and Benson was helpful. I'd like to see an S Style
   Design.

 
 i support this view.  i found sicp (structure and interpretation of
 computer programs, by abelson  sussman, a real classic in the field)
 particularly enlightening, although it certainly is a bit outdated in
 many respects -- but just a bit.  functional programming style is great,
 but beware -- r will create (afaik, experts please correct me if this is
 wrong) a deep copy of about any object you send as an argument to a
 function (if only when it is actually used inside the function), and the
 result may be that the more beautiful the code, the more the performance
 sucks. 

Not necessarily -- R's promise mechanism quite reasonably ensures
that copies of parameter objects are only made upon modifying these
objects.

However, on a more fundamental programming philosophy note, the fact
that R does not allow multiple references to one object is a limitation.
One of the fundamental principles of good programming is that there
should be a one-to-one correspondence between instances in the program
and objects in the real world (problem domain etc.), and having no
references makes achieving this difficult (and quite impossible for
more complex systems).

Best regards, Jan
-- 
 +- Jan T. Kim ---+
 | email: [EMAIL PROTECTED]   |
 | WWW:   http://www.cmp.uea.ac.uk/people/jtk |
 *-=  hierarchical systems are for files, not for humans  =-*

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with basic loop

2008-06-20 Thread Peter Dalgaard
Michael Pearmain wrote:
 I'm having trouble creating a looping variable and i can't see wher ethe
 problem arises from any hep gratfully appreciated

 First create a table

 x-table(SURVEY$n_0,exposed)
   
 x
 
   exposed
False True
   Under 16241
   16-19   689
   20-24  190   37
   25-34  555  204
   35-44  330   87
   45-54  198   65
   55-64   67   35
   65+ 108

 Now ectors to store counts and column proportions

   
 xT-x[,True]
 xF-x[,False]
 yT-x[,True]/colSums(x)
 yF-x[,False]/colSums(x)
 

 check length for dynamic looping
   
 length(yT)
 
 [1] 8

 now create loop
   
 for(i in 1:length(yT)){
 
 + pwr.2p2n.test(2*(asin(sqrt(yT[i]))-asin(sqrt(yF[i]))),n1=xT[i],n2=xF[i])
 + }
 Error in pwr.2p2n.test(2 * (asin(sqrt(yT[i])) - asin(sqrt(yF[i]))), n1 =
 xT[i],  :
   number of observations in the first group must be at least 2

 this confuses me as if i enter the data as values the procedure works?

 Thanks in advance
   
Er, the first row under 16 has a count of 1 in the True column and
it confuses you that you get an error saying that you need at least 2??

But what looks _really_ confused is what you are trying to do in the
first place: The p's you are passing to pwr.2p2n are the empirical
relative frequencies of the individual age groups. This sort of reverses
cause and effect (presumably the exposure does not cause middle age) and
it is pretty odd to compare a particular  row in a table with everything
else jumbled together but worse, it is post-hoc power calculation, which
is just a plain Bad Idea (as several people have pointed out before).

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] playwith 0.8-55

2008-06-20 Thread Felix Andrews
playwith package version 0.8-55 is now on CRAN.
It provides a GTK+ interface for interacting with R plots.

Screenshots of some examples are online at:
http://code.google.com/p/playwith/wiki/Screenshots

Changes in Version 0.8-55

  o argument `parameters`: automatically constructs
widgets to control parameter values appearing in the call.

  o default action when dragging on the plot is zoom.
default action on right-click is zoomout.

  o whether to start in time.mode is determined by looking at
the data: TRUE if the x data has a 'ts' or 'zoo' class.

  o restrict zooming to x axis in time.mode
only if a time.vector was not specified.

  o concept of the main function which accepts typical plot
arguments (xlim, ylim, main, etc) -- not necessarily the
top-level call. By default, a depth-first search is used
to find a function that accepts `xlim` or `...`.

  o callArg() now uses standard evaluation by default, rather than
quoting its argument. Old code will need to be changed!

  o use RGtk2 rather than gWidgets for edit.call and edit.annotations
because gWidgets is very slow.

  o reasonable guess for data points and labels with ggplot::qplot()

  o enabled pretty ggplot2 plots (print.ggplot with pretty=TRUE)
if using grid package version = 2.7
(older versions had a problem with viewports being popped).

  o code reorganisation: split tools into separate files; ESS style.


The predecessor to this package, plotAndPlayGTK, has been moved to the
CRAN archive.

-- 
Felix Andrews / 安福立
PhD candidate
Integrated Catchment Assessment and Management Centre
The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
http://www.neurofractal.org/felix/
3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Prof Brian Ripley

On Fri, 20 Jun 2008, Philip Rhoades wrote:


People,

It appears that one has to use Imperial measurements in plot parameters?  I 
can't find any info on using metric units . .


In package grid you can use several different units.

In base graphics there are a very few par()s that use inches (and I am 
pretty sure that comes from the US unit as used in S, not the 'Imperial' 
one -- see e.g. Wikipedia).  But those are rarely used.


Also most graphics devices are dimensioned in inches with resolutions in 
dpi.


Function cm() might help you.



Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW  2001
Australia
E-mail:  [EMAIL PROTECTED]


--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Philip Rhoades

Prof Brian Ripley,


Prof Brian Ripley wrote:

On Fri, 20 Jun 2008, Philip Rhoades wrote:


People,

It appears that one has to use Imperial measurements in plot 
parameters?  I can't find any info on using metric units . .


In package grid you can use several different units.



When I search the R site for grid I get:

Package ‘grid’ was removed from the CRAN repository


In base graphics there are a very few par()s that use inches (and I am 
pretty sure that comes from the US unit as used in S, not the 'Imperial' 
one -- see e.g. Wikipedia).  But those are rarely used.



This is a bit confusing - as far as I can see, ALL the pars use inches? 
I understand the US effect but shouldn't Metric units be supported directly?



Also most graphics devices are dimensioned in inches with resolutions in 
dpi.


Function cm() might help you.



Thanks,

Phil.
--
Philip Rhoades

Pricom Pty Limited  (ACN 003 252 275  ABN 91 003 252 275)
GPO Box 3411
Sydney NSW  2001
Australia
E-mail:  [EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with basic loop

2008-06-20 Thread Michael Pearmain
Thanks for the reply Peter,

 I did just see that i had put the first error message,(agreed rather an
 obvious error) in and not the second i received

 Warning message:
 In asin(sqrt(yF[i])) : NaNs produced

 The reason i'm looking at this is advert exposure True and False.

 I'm inspecting age to asses weather or not to weight data in order to
 normalise groups for later questions,
 The questions that i am looking at later on are not scale based questions
 so i cannot perform t-tests on these, so i thought the only viable way was
 to look at z-tests for proportions to check for post-hoc differences

 Any advise on other methods would be gratefully taken



 On Fri, Jun 20, 2008 at 11:14 AM, Peter Dalgaard [EMAIL PROTECTED]
 wrote:

 Michael Pearmain wrote:
  I'm having trouble creating a looping variable and i can't see wher ethe
  problem arises from any hep gratfully appreciated
 
  First create a table
 
  x-table(SURVEY$n_0,exposed)
 
  x
 
exposed
 False True
Under 16241
16-19   689
20-24  190   37
25-34  555  204
35-44  330   87
45-54  198   65
55-64   67   35
65+ 108
 
  Now ectors to store counts and column proportions
 
 
  xT-x[,True]
  xF-x[,False]
  yT-x[,True]/colSums(x)
  yF-x[,False]/colSums(x)
 
 
  check length for dynamic looping
 
  length(yT)
 
  [1] 8
 
  now create loop
 
  for(i in 1:length(yT)){
 
  +
 pwr.2p2n.test(2*(asin(sqrt(yT[i]))-asin(sqrt(yF[i]))),n1=xT[i],n2=xF[i])
  + }
  Error in pwr.2p2n.test(2 * (asin(sqrt(yT[i])) - asin(sqrt(yF[i]))), n1 =
  xT[i],  :
number of observations in the first group must be at least 2
 
  this confuses me as if i enter the data as values the procedure works?
 
  Thanks in advance
 
 Er, the first row under 16 has a count of 1 in the True column and
 it confuses you that you get an error saying that you need at least 2??

 But what looks _really_ confused is what you are trying to do in the
 first place: The p's you are passing to pwr.2p2n are the empirical
 relative frequencies of the individual age groups. This sort of reverses
 cause and effect (presumably the exposure does not cause middle age) and
 it is pretty odd to compare a particular  row in a table with everything
 else jumbled together but worse, it is post-hoc power calculation, which
 is just a plain Bad Idea (as several people have pointed out before).

 --
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907





 --
 Michael Pearmain
 Senior Statistical Analyst


 1st Floor, 180 Great Portland St. London W1W 5QZ
 t +44 (0) 2032191684
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]


 Doubleclick is a part of the Google group of companies

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Duncan Murdoch

On 20/06/2008 6:41 AM, Philip Rhoades wrote:

Prof Brian Ripley,


Prof Brian Ripley wrote:

On Fri, 20 Jun 2008, Philip Rhoades wrote:


People,

It appears that one has to use Imperial measurements in plot 
parameters?  I can't find any info on using metric units . .

In package grid you can use several different units.



When I search the R site for grid I get:

Package ‘grid’ was removed from the CRAN repository


That's because it became a base package.  It's distributed with R, not 
as a separate package on CRAN.



In base graphics there are a very few par()s that use inches (and I am 
pretty sure that comes from the US unit as used in S, not the 'Imperial' 
one -- see e.g. Wikipedia).  But those are rarely used.



This is a bit confusing - as far as I can see, ALL the pars use inches? 
I understand the US effect but shouldn't Metric units be supported directly?


I believe only inches are used as physical units, but many of the par() 
values don't use physical units.  There are lines, user coordinates, 
etc.  And plot() makes almost no use of physical units.


Duncan Murdoch




Also most graphics devices are dimensioned in inches with resolutions in 
dpi.


Function cm() might help you.



Thanks,

Phil.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plot function

2008-06-20 Thread Duncan Murdoch

On 20/06/2008 4:09 AM, Norbert NEUWIRTH wrote:
dear userRs, 

I am deeply ashamed asking you this very basic question, but I did neither get it online nor by the S/R-literature I have. 


I simply want to plot the values of a COUPLE of vectors within one graph - in 
concrete a couple of time series, a couple of distributions and some stacked 
area graphs. I am higly convinced, that there are dozens of solutions. Could 
you please recommend me one?



x - 1:1000
y1 - rnorm(1000)
y2 - rexp(1000)
ylim - range(c(y1,y2))
plot(x, y1, col=blue, ylim = ylim)
points(x, y2, col=red)

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Alberto Monteiro
Philip Rhoades wrote:
 
 This is a bit confusing - as far as I can see, ALL the pars use 
 inches? I understand the US effect but shouldn't Metric units be 
 supported directly?
 
That's one of my complains, but it seems that this will take time.
I don't believe it would be too hard to implement metric parameters
in every function.

Maybe Humanity must lose a few more people in airplane crashes
or nuclear plant meltdowns before we ban those unscientific units
from use.

Alberto Monteiro

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problems with basic loop

2008-06-20 Thread Peter Dalgaard
Michael Pearmain wrote:
 Thanks for the reply Peter,

   
 I did just see that i had put the first error message,(agreed rather an
 obvious error) in and not the second i received

 Warning message:
 In asin(sqrt(yF[i])) : NaNs produced
 
Ah. Notwithstanding other remarks, that one would be due to

yT-x[,True]/colSums(x)

The divisor here is a vector of length two!! So every 2nd time you are dividing 
with the wrong thing and in one case that gets you a relative frequency bigger 
than 1...


 The reason i'm looking at this is advert exposure True and False.

 I'm inspecting age to asses weather or not to weight data in order to
 normalise groups for later questions,
 The questions that i am looking at later on are not scale based questions
 so i cannot perform t-tests on these, so i thought the only viable way was
 to look at z-tests for proportions to check for post-hoc differences

 Any advise on other methods would be gratefully taken

 
I still don't see where the notion of power needs to come in. Shouldn't
the effect size for  The questions that I am looking at later enter
somehow? If you just want to know whether there is age-dependent
exposure, how about

chisq.test(SURVEY$n_0,exposed)

(or wilcox.test if you want something that takes the group ordering into
account, or prop.trend.test). If, for better or worse, you want to test
single rows, you could use

chisq.test(SURVEY$n_0 == 35-44,exposed)

etc.


 On Fri, Jun 20, 2008 at 11:14 AM, Peter Dalgaard [EMAIL PROTECTED]
 wrote:

 
 Michael Pearmain wrote:
   
 I'm having trouble creating a looping variable and i can't see wher ethe
 problem arises from any hep gratfully appreciated

 First create a table

 x-table(SURVEY$n_0,exposed)

 
 x

   
   exposed
False True
   Under 16241
   16-19   689
   20-24  190   37
   25-34  555  204
   35-44  330   87
   45-54  198   65
   55-64   67   35
   65+ 108

 Now ectors to store counts and column proportions


 
 xT-x[,True]
 xF-x[,False]
 yT-x[,True]/colSums(x)
 yF-x[,False]/colSums(x)

   
 check length for dynamic looping

 
 length(yT)

   
 [1] 8

 now create loop

 
 for(i in 1:length(yT)){

   
 +
 
 pwr.2p2n.test(2*(asin(sqrt(yT[i]))-asin(sqrt(yF[i]))),n1=xT[i],n2=xF[i])
   
 + }
 Error in pwr.2p2n.test(2 * (asin(sqrt(yT[i])) - asin(sqrt(yF[i]))), n1 =
 xT[i],  :
   number of observations in the first group must be at least 2

 this confuses me as if i enter the data as values the procedure works?

 Thanks in advance

 
 Er, the first row under 16 has a count of 1 in the True column and
 it confuses you that you get an error saying that you need at least 2??

 But what looks _really_ confused is what you are trying to do in the
 first place: The p's you are passing to pwr.2p2n are the empirical
 relative frequencies of the individual age groups. This sort of reverses
 cause and effect (presumably the exposure does not cause middle age) and
 it is pretty odd to compare a particular  row in a table with everything
 else jumbled together but worse, it is post-hoc power calculation, which
 is just a plain Bad Idea (as several people have pointed out before).

 --
   O__   Peter Dalgaard �ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
 ~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907



   
 --
 Michael Pearmain
 Senior Statistical Analyst


 1st Floor, 180 Great Portland St. London W1W 5QZ
 t +44 (0) 2032191684
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]


 Doubleclick is a part of the Google group of companies
 

   [[alternative HTML version deleted]]

   
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
   


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] print one character on several lines

2008-06-20 Thread jim holtman
?strwrap

 cat(strwrap(This is a very long character and I want to print it on several 
 lines. This is a very long character and I want to print it on several 
 lines., width=40),sep=\n)
This is a very long character and I
want to print it on several lines. This
is a very long character and I want to
print it on several lines.


On Thu, Jun 19, 2008 at 5:33 PM, Hua Li [EMAIL PROTECTED] wrote:
 Hi All,

 I'm wondering how I can print one large/long character on several lines so 
 that the output will not overflow a page. Setting fill be TRUE or even 
 numbers does not help. An example is below:


 ipuFile - file(input.txt, w)

 cat(This is a very long character and I want to print it on several lines. 
 This is a very long character and I want to print it on several lines.,fill 
 = TRUE,file = ipuFile)

 close(ipuFile)

 Thanks!

 Hua

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting barplot and scatterplot on same device - x-axis problem

2008-06-20 Thread stephen sefick
Is there anyway you could include the data so we can see what the problem
is- I am getting better at this code reading stuff, but it reduces my time
if I can just copy it into my R session and then fiddle.
thanks

Stephen

On Fri, Jun 20, 2008 at 4:39 AM, Thomas Pedersen [EMAIL PROTECTED] wrote:


 Hi R-users

 I'm a relative newbie and uses R mostly for graphical purpose. I have a
 layout problem when plotting a scatterplot and a barplot using
 par(new=TRUE). The baseline of the x-axis is not positioned equal for the
 two plotting functions (see picture) and I have been unable to find out how
 this is changed.

 http://www.nabble.com/file/p18025066/pic.jpeg

 I have added the script if this is of interrest:

 par(mar = c(7, 4, 4, 2) + 0.1)

 barplot(rbind(data$Asn,data$Glu,data$NH3),
  beside=T,
  axes=TRUE,
  xlim=c(0,57),
  ylim=c(0,10))

 par(new=TRUE)

 plot(1:14,data$Acidification.time,
  axes=FALSE,
  type=b,
  xlab=,
  ylab=,
  xlim=c(0.3,14.7),
  ylim=c(6,8))

 axis(1,pos=6,
  labels=FALSE,
  at=c(0.3,1:14,14.7))

 text(1:14, par(usr)[3], srt = 90, adj = 1,
  labels = data$Month, xpd = TRUE)

 axis(4,pos=14.7)

 All help will be greatly appreciated
 --
 View this message in context:
 http://www.nabble.com/Plotting-barplot-and-scatterplot-on-same-device---x-axis-problem-tp18025066p18025066.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Gavin Simpson
On Fri, 2008-06-20 at 09:09 -0200, Alberto Monteiro wrote:
 Philip Rhoades wrote:
  
  This is a bit confusing - as far as I can see, ALL the pars use 
  inches? I understand the US effect but shouldn't Metric units be 
  supported directly?
  
 That's one of my complains, but it seems that this will take time.
 I don't believe it would be too hard to implement metric parameters
 in every function.

But it is not too difficult to do this yourself:

in2cm - function(x) return(x * 2.54)

cm2in - function(x) return(x * 0.3937008)

then use in2cm() or cm2in() depending on what you want to achieve. If
you want a margin of 4cm all round the plot:

op - par(mai = cm2in(rep(4, 4)))
plot(1:10)
par(op)

HTH

G

 
 Maybe Humanity must lose a few more people in airplane crashes
 or nuclear plant meltdowns before we ban those unscientific units
 from use.
 
 Alberto Monteiro
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Draw curve for histogram

2008-06-20 Thread Kenn Konstabel
On Fri, Jun 20, 2008 at 2:47 AM, Anh Tran [EMAIL PROTECTED] wrote:

 Thanks. I think I've got it. However, the density is plotted, not the
 frequency. Is there a way to convert the density back to frequency.
 Thanks a bunch.


an easy answer is that hist returns an object which you plot in any way you
like. for example,

x - rnorm(100)
foo - hist(x, plot=FALSE)
foo
plot(foo$mids, foo$counts, type=l)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread hadley wickham
 However, on a more fundamental programming philosophy note, the fact
 that R does not allow multiple references to one object is a limitation.
 One of the fundamental principles of good programming is that there
 should be a one-to-one correspondence between instances in the program
 and objects in the real world (problem domain etc.), and having no
 references makes achieving this difficult (and quite impossible for
 more complex systems).

This is a principle of object oriented programming, not good
programming in general!

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] replacing segments of vector by their averages

2008-06-20 Thread jim holtman
Does this give you the results you are expecting:

 m - c(0.3,0.3,0.3,0.1,0.1,0.5,0.5,0.5,0.5,0.15,0.15,0.3,0.5,0.8)
 m  0.2
 [1]  TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE
 TRUE  TRUE  TRUE
 m.rle - rle(m  0.2)
 offsets - 1 + c(0, head(cumsum(m.rle$lengths), -1))
 # initialize the output results
 results - numeric(length(m.rle$values))
 results[] - NA

 for (i in seq_along(m.rle$values)){
+ if (m.rle$values[i]){  #numbers  0.2
+ results[i] - mean(m[seq(offsets[i], length=m.rle$lengths[i])])
+ }
+ }
 results
[1] 0.300NA 0.500NA 0.533



On Thu, Jun 19, 2008 at 4:55 AM, Daren Tan [EMAIL PROTECTED] wrote:

 Given a vector of numeric of length n, I need to find segments that are = 
 0.2, compute the average of individual segments, and replace the original 
 values in each segment by their corresponding averages.

 For example, there are three segments that are = 0.2, the average of 1st 
 segment is 0.3, 2nd is 0.5, and the 3rd is 0.533

 c(0.3,0.3,0.3,0.1,0.1,0.5,0.5,0.5,0.5,0.15,0.15,0.3,0.5,0.8) [1] 0.30 0.30 
 0.30 0.10 0.10 0.50 0.50 0.50 0.50 0.15 0.15 0.30 0.50 0.80 m = 0.2 [1]  
 TRUE  TRUE  TRUE FALSE FALSE  TRUE  TRUE  TRUE  TRUE FALSE FALSE  TRUE[13]  
 TRUE  TRUE

 _


[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 3D histogram

2008-06-20 Thread sumit gupta
Hii..

Could anyone please tell me how to draw 3D histogram in R

I have a 20X3 matirx. Now I want 2 of the variable on X and Y axis .And
Height of the bar should denote the value of third variable.

Thanx


Sumit

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 3D histogram

2008-06-20 Thread Richardson, Patrick
Try

?hist

-and-

?plot.histogram

You should find what you need there.

Cheers,

Patrick

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of sumit gupta
Sent: Friday, June 20, 2008 8:46 AM
To: r-help@r-project.org
Subject: [R] 3D histogram

Hii..

Could anyone please tell me how to draw 3D histogram in R

I have a 20X3 matirx. Now I want 2 of the variable on X and Y axis .And
Height of the bar should denote the value of third variable.

Thanx


Sumit

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Howto access V-base only column in a data frame

2008-06-20 Thread Marc Schwartz

on 06/19/2008 11:28 PM Rolf Turner wrote:


On 20/06/2008, at 4:07 PM, Moshe Olshansky wrote:


If you know the value of k then you could do the following:

goodNames - paste(V,1:k,sep=)
ind - which(colnames(df) %in% goodNames)
df[,ind]

(where df is your dataframe).

P.S. I won't be surprised if df[,goodNames] is all right too (have not 
checked).


What about df[,grep(^V,names(df))] ?  (Leave off the ``^'' if you want 
any

column whose name contains ``V'' (r.t. begins with ``V'').



Unless I missed something in the original request, such that the only 
column to remove is 'var', why not:


  subset(df, select = -var)

?

See ?subset

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Spencer Graves
 Maybe I missed it, but I haven't seen in this tread mention of 
Venables and Ripley (2000) S Programming (Springer).  I found it 
interesting and useful, though I have not used it as much as MASS -- 
partly because it is more specialized and it's coverage is not as broad. 


 Spencer

hadley wickham wrote:

However, on a more fundamental programming philosophy note, the fact
that R does not allow multiple references to one object is a limitation.
One of the fundamental principles of good programming is that there
should be a one-to-one correspondence between instances in the program
and objects in the real world (problem domain etc.), and having no
references makes achieving this difficult (and quite impossible for
more complex systems).



This is a principle of object oriented programming, not good
programming in general!

Hadley




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 3D histogram

2008-06-20 Thread Richardson, Patrick
Actually, have a look at the rgl package and this link 
http://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/r/3d_bar_chart/

It points to bar charts, but there is some valuable info on 3D histograms as 
well.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of sumit gupta
Sent: Friday, June 20, 2008 8:46 AM
To: r-help@r-project.org
Subject: [R] 3D histogram

Hii..

Could anyone please tell me how to draw 3D histogram in R

I have a 20X3 matirx. Now I want 2 of the variable on X and Y axis .And
Height of the bar should denote the value of third variable.

Thanx


Sumit

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Simon Blomberg
I read the Wizard Book too. Absolutely classic! I agree about paying attention 
to performance, of course. Lisp programmers bend over backwards to write 
tail-recursive functions for similar performance reasons. So you have to pay 
attention to the language's idiosyncracies. But the time spent coding is 
usually much longer than the eventual run time. Learning to write well-designed 
code can do more to save time, even if the run time is slightly longer than 
optimal. If run time is an issue, then switching to C or Fortran etc. might be 
the best bet. But even in that case, using R for prototyping code can provide 
valueable insights.

Cheers,

Simon.

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 
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.



-Original Message-
From: Wacek Kusnierczyk [mailto:[EMAIL PROTECTED]
Sent: Fri 20/06/2008 5:06 PM
To: R help
Cc: Simon Blomberg
Subject: Re: [R] Programming Concepts and Philosophy
 
Simon Blomberg wrote:
 I try to use a functional programming style. I define functions within
 functions when it is helpful in terms of information hiding. I avoid
 writing functions with side-effects as much as possible, so the only
 communication of the called function with the caller function is through
 the arguments and the returned value. I try to keep the code as simple
 and clear as possible (this is one of the things I fail at most). An
 appropriate amount of comments is also useful, especially when returning
 to old code after a long break. OOP is useful for really big projects,
 but I find OOP unnecessarily complicated for small jobs.

 I found Code Complete, by McConnell (http://www.cc2e.com/) to be very
 helpful. I'm sure there are other books around with similar tips. Before
 I switched to R, I used XLisp-Stat. I found learning Lisp to be a really
 good way to learn good programming practices. Good Lisp code is the
 closest thing you can get to poetry in computer programming. Lisp Style
  Design, by Miller and Benson was helpful. I'd like to see an S Style
  Design.
   

i support this view.  i found sicp (structure and interpretation of
computer programs, by abelson  sussman, a real classic in the field)
particularly enlightening, although it certainly is a bit outdated in
many respects -- but just a bit.  functional programming style is great,
but beware -- r will create (afaik, experts please correct me if this is
wrong) a deep copy of about any object you send as an argument to a
function (if only when it is actually used inside the function), and the
result may be that the more beautiful the code, the more the performance
sucks. 

in pure functional programming, a function cannot change any part of the
object passed to it as an argument, so there's no need for making a
local copy.  in r everything can happen as you can deparse the call to a
function inside the function body, and you can never tell whether the
object you pass to a function will be changed or not, given only the
function's signature.

vQ


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 3D histogram

2008-06-20 Thread Gabor Csardi
Maybe I'm missing something, but where is the 3D here?

My tip is hist3d in package rgl. But there might be others, 
it might worth to search the archive, I remember seeing this 
question once.

Gabor

On Fri, Jun 20, 2008 at 08:55:36AM -0400, Richardson, Patrick wrote:
 Try
 
 ?hist
 
 -and-
 
 ?plot.histogram
 
 You should find what you need there.
 
 Cheers,
 
 Patrick
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of sumit gupta
 Sent: Friday, June 20, 2008 8:46 AM
 To: r-help@r-project.org
 Subject: [R] 3D histogram
 
 Hii..
 
 Could anyone please tell me how to draw 3D histogram in R
 
 I have a 20X3 matirx. Now I want 2 of the variable on X and Y axis .And
 Height of the bar should denote the value of third variable.
 
 Thanx
 
 
 Sumit
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 This email message, including any attachments, is for ...{{dropped:11}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem in Binning of a data set

2008-06-20 Thread Petr PIKAL
sumit gupta [EMAIL PROTECTED] napsal dne 20.06.2008 14:44:52:

 Hii..
 
 Could you please tell me how to draw 3D histogram in R
 
 I have a 20X3 matirx. Now I want 2 of the variable on X and Y axis .And 
Height
 of the bar should denote the value of third variable.

See scatterplot3d, image, contour, persp and maybe some others. However I 
am not sure if 3D hist like in Excel can be plotted directly in R. 
For various graphing options see

http://addictedtor.free.fr/graphiques/thumbs.php

Regards
Petr



 
 Thanx
 
 Sumit
 


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Optim() violates constraints

2008-06-20 Thread Ben Bolker
Zornitsa Luleva zornitsa.luleva at gmail.com writes:

 
  Hi,
 
 I am using the mle2 method of the package 'bbmle'. The method is calling as
 far as I understood it the optim method L-BFGS-B (this is the method I
 use). The latter one allows the user to impose box constraints on the
 variables, i.e. to give lower and upper bounds. It is important that the
 initial values satisfy the constraints. In my problem, it is the case. I do
 not know if there is something else to watch for, but the algorithm violates
 the constraints that I have given and therefore, my algorithm is not
 working. Do you have any idea what I can do about it?
 
 Thank you very much in advance!
 
 Zoe

  Well, bbmle is my package so technically you should be
writing to me (bolker at ufl.edu) and not the list about it, but ...
it's actually an optim() issue. Various people have hit this kind of problem
in rare circumstances.

http://bugs.r-project.org/cgi-bin/R/Analyses?id=3325;user=guest
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/13004.html
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/124619.html
http://finzi.psych.upenn.edu/R/Rhelp01/archive/15859.html

  The usual advice is (1) to use the parscale option within
the control argument to make sure the problem is scaled properly 
(this will usually fix most L-BFGS-B problems), (2) if necessary
set the bounds just a little bit inside the true constraints.

  If this doesn't fix the problem, please post (as suggested
in the posting guide) a minimal, self-contained, reproducible
example ...

   Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Multiple assign()

2008-06-20 Thread Crispin Miller
Hi,

Apologies in advance if this has been asked before, but I couldn't find
quite the same question

I'm trying to assign multiple values from a list into an environment. At the
moment, I'm doing this using 'mapply' but finding it slower than I would
like. 

Is there a (quicker) function that will assign multiple values in a single
go (I guess, the analogue to 'mget')?


Crispin 

This email is confidential and intended solely for the u...{{dropped:12}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] reformatting R scripts for htmlize()

2008-06-20 Thread Jim Lemon
On Wed, 2008-06-18 at 11:49 +0200, Agustin Lobo wrote:
 Hi!
 
 I have a bunch of (mainly class) R scripts that I would
 like to convert into html pages (although if someone
 thinks that what I want to do is easier with latex or pdf,
 please tell me).
 
 Considering the format of my files, htmlize() seems the best
 option. The only problem is that I would need
 to write graphics to a file, thus
 converting parts like:
 
 plot(sel$hora, sel$COD_SP_C)
 #and check the time intervals
 plot(mishdift(sel$hora))
 
 into:
 
 png(1.png);plot(sel$hora, sel$COD_SP_C);dev.off()
 #and check the time intervals
 png(2.png);plot(mishdift(sel$hora));dev.off()
 
 Any ideas on how to write an script (could be done
 in R itself?) that would automatically modify
 the current script into a htmlize-friendly script?
 
 One problem is that while R accepts png()
 providing a default name for the png file,
 htmlize() fails unless a name is provided.
 
Hi Agustin,
htmlize was intended to provide a simple way to produce output from R
scripts that:

1) Looked familiar to the average stats consumer.

2) Required minimal modification from the R script that the average R
user would write.

The R2html function in the prettyR package, generously contributed by
Phillipe Grosjean, goes some way toward integrating graphics into the
output, whereas htmlize requires the user to add the graphic device
commands. Because more complex commands are hard to anticipate:

barpos-barplot(heights,...)
dispbars(barpos,heights,...)
es-emptyspace(...)
legend(...)

just writing a function that looks up the names of plotting functions
and tries to add graphic device commands would only serve for very basic
plots. One can't even hold the dev.off() until a non-plotting command
appears, for these can easily occur within a group of plotting commands
as in the above example. I tend to write the graphic device commands
into the script, but leave them commented out until I am ready to run
htmlize. I'm always happy to listen to suggestions on how the functions
in the packages I maintain could be improved, however.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting barplot and scatterplot on same device - x-axis problem

2008-06-20 Thread Jim Lemon
On Fri, 2008-06-20 at 01:39 -0700, Thomas Pedersen wrote:
 Hi R-users
 
 I'm a relative newbie and uses R mostly for graphical purpose. I have a
 layout problem when plotting a scatterplot and a barplot using
 par(new=TRUE). The baseline of the x-axis is not positioned equal for the
 two plotting functions (see picture) and I have been unable to find out how
 this is changed. 

Hi Thomas,
You might find that barp in the plotrix package will do what you want
as it centers the bars on integral values.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Jim Lemon
On Fri, 2008-06-20 at 11:26 +0100, Prof Brian Ripley wrote:
 ...
 In base graphics there are a very few par()s that use inches (and I am 
 pretty sure that comes from the US unit as used in S, not the 'Imperial' 
 one -- see e.g. Wikipedia).  But those are rarely used.
 
My recollection of the Imperial and US units was that inches were the
same and only volumetric measures differed (despite the fact that the
USA officially adopted decimal measures long ago but didn't get around
to using them). Given the fairly rubbery definition of the inch, that
coincidence was pretty surprising.

And if you think inches are bad, check out points.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using metric units in plots

2008-06-20 Thread Peter Dalgaard

 And if you think inches are bad, check out points.
   
Not to mention pints

Cheers,
-p

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Howto reduce number of ticks in X, Y axis while still containing all the data

2008-06-20 Thread Dieter Menne
Gundala Viswanath gundalav at gmail.com writes:

 I'm aware of the need to include lattice library.
 I just didn't show it.
Examples should be complete and self-running, as the posting guide says.
 
 However my code still cant' produce the same results
 as yours.
 
 My data.mat contain this form of output
  print(data.matrix)
 
   11145  3545  8951 11097 16599 11100
 8566 .. (upto 100 more)
 11145 1.000 0.9979445 0.9966705 0.9855180 0.9775806 0.9949439 0.9579916
 3545  0.9979445 1.000 0.9973328 0.9910627 0.9847413 0.9947414 0.9521648
 8951  0.9966705 0.9973328 1.000 0.9882817 0.9829629 0.9938390 0.9558376
 11097 0.9855180 0.9910627 0.9882817 1.000 0.9969120 0.9846531 0.9490246
 16599 0.9775806 0.9847413 0.9829629 0.9969120 1.000 0.9785536 0.9383424
 
 (up to 100 more)
 

Send me the output of str(data.matrix). Or, much better, try to reproduce your
problem with a simulated data set similar to the one I gave you.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread [EMAIL PROTECTED]
On 20 июн, 11:06, Wacek Kusnierczyk
[EMAIL PROTECTED] wrote:
 the result may be that the more beautiful the code, the more the performance
 sucks.

Sad but true.

Andrey

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting barplot and scatterplot on same device - x-axis problem

2008-06-20 Thread Thomas Pedersen

Of course :) - here you go...

http://www.nabble.com/file/p18028420/Data.txt Data.txt 

The data is tab-separated

Thanks for the reply
-- 
View this message in context: 
http://www.nabble.com/Plotting-barplot-and-scatterplot-on-same-device---x-axis-problem-tp18025066p18028420.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to write symbol (nabla) in R graph

2008-06-20 Thread Nuno Prista

Dear all, 

I still need help (I am a newbie to R). 

I looked on the plotmath help and could not find how Unicode can be used.
And I am in a Windows platform which I don't know if it is relevant. Can
anyone help? Here is a simple example

plot(1:10,1:10)

can anyone provide the code to insert a nabla anywhere on it?

thanks


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dieter Menne
Sent: Friday, June 20, 2008 3:03 AM
To: [EMAIL PROTECTED]
Subject: Re: [R] how to write symbol (nabla) in R graph

Nuno Prista nmprista at fc.ul.pt writes:

 
 Can anyone of you tell me how to write a nabla symbol in an R graph?
 


I have not tested it, but according to

http://www.gnu.org/software/plotutils/manual/html_chapter/plotutils_10.html


nabla is Unicode [0321]

Check documentation on plothmath how to use it.

Note: the documents cited in plotmath are huge, and it would be nice to have
something like the gnu-reference I google for a short list.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] fligner.test

2008-06-20 Thread Stefan Th. Gries
Hi all

I have a question regarding the Fligner-Killeen test. I am using

- a PC with Windows XP (Build 20600.xpsp080413-2111 (Service Pack 3);
- the following R version:
 sessionInfo()
R version 2.7.0 (2008-04-22)
i386-pc-mingw32


I have a vector LENGTH and a factor RELATION that are distributed like this:

 table(LENGTH, RELATION)
 RELATION
LENGTH object subject
   1   9  51
   2  25  18
   3  36  23
   4  23  14
   5  17  13
   6  12   7
   7  10   5
   8   3   7
   9   4   3
   10  3   5
   11  4   2
   12  2   0
   13  0   2
   16  2   1
   22  0   1
   49  1   0
   53  1   0

I wanted to run a Fligner test to see whether the lengths for the two
relations differ in terms of their variance. This is what I found,
though:

#
 fligner.test(LENGTH[RELATION==subject], LENGTH[RELATION==object])
   Fligner-Killeen test of homogeneity of variances
data:  LENGTH[RELATION == subject] and LENGTH[RELATION == object]
Fligner-Killeen:med chi-squared = 18.3552, df = 14, p-value = 0.1911

 fligner.test(LENGTH[RELATION==object], LENGTH[RELATION==subject])
   Fligner-Killeen test of homogeneity of variances
data:  LENGTH[RELATION == object] and LENGTH[RELATION == subject]
Fligner-Killeen:med chi-squared = 16.8838, df = 13, p-value = 0.2047

 fligner.test(LENGTH~RELATION)
   Fligner-Killeen test of homogeneity of variances
data:  LENGTH by RELATION
Fligner-Killeen:med chi-squared = 0.626, df = 1, p-value = 0.4288
#

The order of the vectors etc. changes the results??? Needless to say
this does not happen with var.test or ... Is this normal; if so, which
one is the one to report?

Thx,
STG

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to write symbol (nabla) in R graph

2008-06-20 Thread Prof Brian Ripley

You appear to have missed

https://stat.ethz.ch/pipermail/r-help/2008-June/165435.html


On Fri, 20 Jun 2008, Nuno Prista wrote:



Dear all,

I still need help (I am a newbie to R).

I looked on the plotmath help and could not find how Unicode can be used.
And I am in a Windows platform which I don't know if it is relevant. Can
anyone help? Here is a simple example

plot(1:10,1:10)

can anyone provide the code to insert a nabla anywhere on it?

thanks


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dieter Menne
Sent: Friday, June 20, 2008 3:03 AM
To: [EMAIL PROTECTED]
Subject: Re: [R] how to write symbol (nabla) in R graph

Nuno Prista nmprista at fc.ul.pt writes:



Can anyone of you tell me how to write a nabla symbol in an R graph?




I have not tested it, but according to

http://www.gnu.org/software/plotutils/manual/html_chapter/plotutils_10.html


nabla is Unicode [0321]

Check documentation on plothmath how to use it.

Note: the documents cited in plotmath are huge, and it would be nice to have
something like the gnu-reference I google for a short list.

Dieter

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Marc Schwartz

on 06/20/2008 10:04 AM hadley wickham wrote:


If you do nothing to your code, in 18 months time its performance will
have doubled because computers will have become faster.  Your code
will not get easier to understand by itself.


I suspect a good fortunes candidate...

:-)

Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Ramon Diaz-Uriarte
2008/6/20 hadley wickham [EMAIL PROTECTED]:
 2008/6/20 [EMAIL PROTECTED] [EMAIL PROTECTED]:
 On 20 июн, 11:06, Wacek Kusnierczyk
 [EMAIL PROTECTED] wrote:
 the result may be that the more beautiful the code, the more the performance
 sucks.

 Sad but true.

 If you do nothing to your code, in 18 months time its performance will
 have doubled because computers will have become faster.  Your code

But that doesn't seem to be true anymore (if we are talking single
CPU), and it seems not to have been true for at least a few years
(e.g.,
http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-183.html
for instance, their figure 2 in p. 6).

 will not get easier to understand by itself.


No it won't.

Best,

R.

 Hadley


 --
 http://had.co.nz/
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Ramon Diaz-Uriarte
Statistical Computing Team
Structural Biology and Biocomputing Programme
Spanish National Cancer Centre (CNIO)
http://ligarto.org/rdiaz
Phone: +34-91-224-6900 ext. 3019
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] The Green Book and its relevance to R

2008-06-20 Thread Ben Fairbank
I bogged down about half way through reading the Green Book, in part
because it became increasingly difficult to understand how some of the
ideas related to R, as opposed to S (which I have not used).  Does any
reader know whether there is a document that points out differences
between S and R that would be helpful in reading the Green Book?
Ideally, perhaps, I need a crib sheet to help relate Programming with
data to R, as opposed to S.  And, incidentally, in the opinion of those
who have read all three, which of the books, blue, green, or white (or
maybe V  R S programming?), would be most recommended as the next
book for one who would move beyond advanced beginner status?
(Programming experience in Fortran, APL, Python, small-system assembly
language, but not C).

 

Ben Fairbank

San Antonio, Texas

[EMAIL PROTECTED]

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] fligner.test

2008-06-20 Thread Ben Bolker
Stefan Th. Gries stgries at gmail.com writes:

 
 Hi all
 
 I have a question regarding the Fligner-Killeen test. I am using
 
 - a PC with Windows XP (Build 20600.xpsp080413-2111 (Service Pack 3);
 - the following R version:
  sessionInfo()
 R version 2.7.0 (2008-04-22)
 i386-pc-mingw32
 
 I have a vector LENGTH and a factor RELATION that are distributed like this:
 
  table(LENGTH, RELATION)
  RELATION
 LENGTH object subject
[snip]
  fligner.test(LENGTH[RELATION==subject], LENGTH[RELATION==object])
Fligner-Killeen test of homogeneity of variances
 data:  LENGTH[RELATION == subject] and LENGTH[RELATION == object]
 Fligner-Killeen:med chi-squared = 18.3552, df = 14, p-value = 0.1911
 
  fligner.test(LENGTH[RELATION==object], LENGTH[RELATION==subject])
Fligner-Killeen test of homogeneity of variances
 data:  LENGTH[RELATION == object] and LENGTH[RELATION == subject]
 Fligner-Killeen:med chi-squared = 16.8838, df = 13, p-value = 0.2047
 
  fligner.test(LENGTH~RELATION)
Fligner-Killeen test of homogeneity of variances
 data:  LENGTH by RELATION
 Fligner-Killeen:med chi-squared = 0.626, df = 1, p-value = 0.4288
 #
 
 The order of the vectors etc. changes the results??? Needless to say
 this does not happen with var.test or ... Is this normal; if so, which
 one is the one to report?


  I think you misunderstood the manual page for fligner.test.
I believe that all of the following should give identical
results (corresponding to the last test in your examples):

fligner.test(list(LENGTH[RELATION==subject], LENGTH[RELATION==object]))
fligner.test(list(LENGTH[RELATION==object], LENGTH[RELATION==subject]))
fligner.test(LENGTH,RELATION)
fligner.test(LENGTH~RELATION)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The Green Book and its relevance to R

2008-06-20 Thread Douglas Bates
On Fri, Jun 20, 2008 at 11:33 AM, Ben Fairbank [EMAIL PROTECTED] wrote:
 I bogged down about half way through reading the Green Book, in part
 because it became increasingly difficult to understand how some of the
 ideas related to R, as opposed to S (which I have not used).  Does any
 reader know whether there is a document that points out differences
 between S and R that would be helpful in reading the Green Book?
 Ideally, perhaps, I need a crib sheet to help relate Programming with
 data to R, as opposed to S.  And, incidentally, in the opinion of those
 who have read all three, which of the books, blue, green, or white (or
 maybe V  R S programming?), would be most recommended as the next
 book for one who would move beyond advanced beginner status?
 (Programming experience in Fortran, APL, Python, small-system assembly
 language, but not C).

You may want instead to wait for John's forthcoming book Software for
Data Analysis: Programming with R.  It was supposed to be out by now
but there apparently have been delays (John says the delays have not
been from his side) and Amazon.com now lists it as being available on
Jul. 18




 Ben Fairbank

 San Antonio, Texas

 [EMAIL PROTECTED]




[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparison between R and MATLAB

2008-06-20 Thread Earl F. Glynn
Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Can I get a comparison between R and MATLAB? How is R efficient than MATLAB? 
Or what are the weaknesses of R compared to MATLAB?


Don't forget to compare licenses and cost.  Matlab's rigid and unreasonable 
license is the main reason I use R now.

Several years ago the Mathworks refused to let a post doc and me share a 
MatLab license -- they wanted all single-user licenses to be named users 
even if each of us only needed MatLab a few hours a month.  I asked if they 
had a math model for what we got for a license, but they didn't care that 
there was a huge disconnect between what they wanted to sell and our usage 
needs.  I quit using MatLab, converted my project from MatLab to R, and now 
steer as many people to R as possible.

The Mathworks refuses to acknowledge that life-science users of math tools 
are not like physical science users.  Biologists can spend weeks or months 
on experiments and then occasionally need high-end math tools  for analysis.

A single shared network MatLab license outside of academia is outrageously 
expensive.  A single network concurrent license for Matlab and the Image 
processing, Signal Processing and PDE toolboxes costs $18,800 -- I received 
that quote just yesterday since we still have a few people that use existing 
MatLab code.

MatLab may be a good product, but the Mathworks is unreasonable in how they 
license it.  We are a non-profit, basic life scientific research institute 
and the Mathworks sells us the same license as for-profit businesses.  Only 
degree-granting universities are eligible for academic pricing apparently.

efg
Earl F Glynn
Bioinformatics
Stowers Institute for Medical Research

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparison between R and MATLAB

2008-06-20 Thread Clint Bowman
The easy way around that is to create an account, Mathworks, with a
common group that all who will use MatLab belong, then su - Mathworks
should satisfy the license manager.

Clint BowmanINTERNET:   [EMAIL PROTECTED]
Air Dispersion Modeler  INTERNET:   [EMAIL PROTECTED]
Air Quality Program VOICE:  (360) 407-6815
Department of Ecology   FAX:(360) 407-7534

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 20 Jun 2008, Earl F. Glynn wrote:

 Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Can I get a comparison between R and MATLAB? How is R efficient than MATLAB?
 Or what are the weaknesses of R compared to MATLAB?


 Don't forget to compare licenses and cost.  Matlab's rigid and unreasonable
 license is the main reason I use R now.

 Several years ago the Mathworks refused to let a post doc and me share a
 MatLab license -- they wanted all single-user licenses to be named users
 even if each of us only needed MatLab a few hours a month.  I asked if they
 had a math model for what we got for a license, but they didn't care that
 there was a huge disconnect between what they wanted to sell and our usage
 needs.  I quit using MatLab, converted my project from MatLab to R, and now
 steer as many people to R as possible.

 The Mathworks refuses to acknowledge that life-science users of math tools
 are not like physical science users.  Biologists can spend weeks or months
 on experiments and then occasionally need high-end math tools  for analysis.

 A single shared network MatLab license outside of academia is outrageously
 expensive.  A single network concurrent license for Matlab and the Image
 processing, Signal Processing and PDE toolboxes costs $18,800 -- I received
 that quote just yesterday since we still have a few people that use existing
 MatLab code.

 MatLab may be a good product, but the Mathworks is unreasonable in how they
 license it.  We are a non-profit, basic life scientific research institute
 and the Mathworks sells us the same license as for-profit businesses.  Only
 degree-granting universities are eligible for academic pricing apparently.

 efg
 Earl F Glynn
 Bioinformatics
 Stowers Institute for Medical Research

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Combine colors and shading lines

2008-06-20 Thread HBaize


Josh, 
Check into add=TRUE :-)

All you need to do is insert add=TRUE to the second 
chart to superimpose it on the first chart. You might also 
consider making the second bar a different shade of color 
rather than using shadding lines, then it would only be one 
plot. 

data(HairEyeColor)
a - as.table( apply(HairEyeColor, c(1,2), sum) )
a1-a[1:2,]

barplot(a1,
type=n,
col=c(red,red,blue,blue,purple,purple,green,green),
beside = TRUE )

barplot(a1,
col=1,
density=c(0,7,0,7,0,7,0,7),
beside = TRUE, add=TRUE )



Josh Roofchop wrote:
 
 Hi, basically I am trying to create a grouped bar graph with each group a
 different color and a bar in each group to have shading lines.  Basically
 combine the 2 graphs created below.
 Thanks,
 Josh
 
 data(HairEyeColor)
 a - as.table( apply(HairEyeColor, c(1,2), sum) )
 a1-a[1:2,]
 
 par(mfcol=c(1,2), bg=white)
 
 barplot(a1, 
   type=n,
   col=c(2,2,4,4,6,6,3,3),
 beside = TRUE, )
 
 barplot(a1, 
 col=1,
 density=c(0,7,0,7,0,7,0,7),
 beside = TRUE, )
 
  http://www.nabble.com/file/p18033630/graph.JPG graph.JPG 
 

-- 
View this message in context: 
http://www.nabble.com/Combine-colors-and-shading-lines-tp18033630p18035111.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparison between R and MATLAB

2008-06-20 Thread Wacek Kusnierczyk
for many tasks, gnu octave (a 'matlab clone', no offense to gnu folks
intended) is quite sufficient, and *free* (+ open source).  you can run
some of matlab code in octave.

you should also check if sage (http://www.sagemath.org/) can do the job
for you, it's stuffed with all sorts of maths utilities, with friendly
python frontend, etc.
and once you're at python's, check numpy, scipy, and matplotlib, which
do lots of good work too.  all open source, of course.

vQ


Clint Bowman wrote:
 The easy way around that is to create an account, Mathworks, with a
 common group that all who will use MatLab belong, then su - Mathworks
 should satisfy the license manager.

 Clint Bowman  INTERNET:   [EMAIL PROTECTED]
 Air Dispersion ModelerINTERNET:   [EMAIL PROTECTED]
 Air Quality Program   VOICE:  (360) 407-6815
 Department of Ecology FAX:(360) 407-7534

   USPS:   PO Box 47600, Olympia, WA 98504-7600
   Parcels:300 Desmond Drive, Lacey, WA 98503-1274

 On Fri, 20 Jun 2008, Earl F. Glynn wrote:

   
 Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Can I get a comparison between R and MATLAB? How is R efficient than MATLAB?
 Or what are the weaknesses of R compared to MATLAB?


 Don't forget to compare licenses and cost.  Matlab's rigid and unreasonable
 license is the main reason I use R now.

 Several years ago the Mathworks refused to let a post doc and me share a
 MatLab license -- they wanted all single-user licenses to be named users
 even if each of us only needed MatLab a few hours a month.  I asked if they
 had a math model for what we got for a license, but they didn't care that
 there was a huge disconnect between what they wanted to sell and our usage
 needs.  I quit using MatLab, converted my project from MatLab to R, and now
 steer as many people to R as possible.

 The Mathworks refuses to acknowledge that life-science users of math tools
 are not like physical science users.  Biologists can spend weeks or months
 on experiments and then occasionally need high-end math tools  for analysis.

 A single shared network MatLab license outside of academia is outrageously
 expensive.  A single network concurrent license for Matlab and the Image
 processing, Signal Processing and PDE toolboxes costs $18,800 -- I received
 that quote just yesterday since we still have a few people that use existing
 MatLab code.

 MatLab may be a good product, but the Mathworks is unreasonable in how they
 license it.  We are a non-profit, basic life scientific research institute
 and the Mathworks sells us the same license as for-profit businesses.  Only
 degree-granting universities are eligible for academic pricing apparently.

 efg
 Earl F Glynn
 Bioinformatics
 Stowers Institute for Medical Research

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
   


-- 
---
Wacek Kusnierczyk, MD PhD

Email: [EMAIL PROTECTED]
Phone: +47 73591875, +47 72574609

Department of Computer and Information Science (IDI)
Faculty of Information Technology, Mathematics and Electrical Engineering (IME)
Norwegian University of Science and Technology (NTNU)
Sem Saelands vei 7, 7491 Trondheim, Norway
Room itv303

Bioinformatics  Gene Regulation Group
Department of Cancer Research and Molecular Medicine (IKM)
Faculty of Medicine (DMF)
Norwegian University of Science and Technology (NTNU)
Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
Room 231.05.060

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Unexpected Behavior (potentially) in t.test

2008-06-20 Thread Russell Pierce
Greetings,

I have stumbled across some unexpected behavior (potential a bug) in, what I
suspect to be R's (2.6.2 on Ubuntu Linux) t.test function; then again the
problem may exist in my code. I have shutdown R and started it back up,
re-run the code and re-experienced the error. I have searched on Google for
the abnormal termination error message (stderr  10 * .Machine$double.eps *
max(abs(mx), abs(my))) stop(data are essentially constant) but only found
one instance, http://tolstoy.newcastle.edu.au/R/e2/help/07/06/18179.html,
but the discussion there did not seem particularly helpful.

I've included all of my code, amateurish though it may be. I have not
isolated the faulty part, and to me it all looks pretty simple, so I'm not
sure where I'm going wrong. For background, the goal of this code is to run
a simulation to explore the problem space of inflation of Type I error when
decisions to run or not to run more participants are made by preliminary
looks at the data (as in Wagenmakers, 2007). This code is meant to examine
the problem space given that there is no true difference between the groups
(as is the case when both a generated from random draws from the normal
distribution). I run an initial number of subjects in two groups (t1N) then,
if p is  .25 on the t-test I add t2N more subjects to each group. Then I
perform the t.test again. If the p was  .25 at time 1 I stop. Plainp is
simply storing the p-values from t2 (if it was performed) or from t1 (if t2
was not performed). In the code I provide t1 starts at 16 since this is
about when the problem becomes more frequent. Please note that it takes
quite a long while to fail, and depending on what the true cause is it may
not fail at all. On my system it is failing before t1N advances to 17.

Any suggestions as to how to avoid the error and instructions as to the
cause of it would be appreciated. Thank you for your input and patience.

logit - function(p)

{

# compute and return logit of p;

# if p=.5 then logit==0 else sign(logit)==(p.5)

return( log(p/(1-p)) )

}


 antilogit - function(x)

{

# compute and return antilogit of x;

# this returns a proportion p for which logit(p)==x;

return( exp(x)/(1+exp(x)) )

}


 plainp - c() #Clear the plainp value

t1Nsim - (100/5) * 1000 * 10 # random chance should provide 1 cases at
t1

contthreshold - .25 #p value below which we run more subjects

t1pvals - rep(NA,t1Nsim) #clear the pvalues

t2pvals - rep(NA,t1Nsim) #clear the pvalues

t1N - 10 #for debugging

t2N - 5 #for debugging


 for (t1N in 16:50) #Outer loop testing possible values for t1N

for (t2N in 1:50) #Inner loop testing possible values for t2N

{

print(paste(Checking with ,t1N, initial samples and ,t2N, extra
samples,sep=)) #feedback

for (lcv in 1:t1Nsim) #Run simulation t1Nsim times...

{

if (lcv %% 2 == 0) {print(paste((lcv/t1Nsim)*100,%,sep=))} #feedback

Cgroup - rnorm(t1N) #Initial random draw for Group1

Tgroup - rnorm(t1N) #Initial random draw for Group 2

currentp - t.test(Cgroup,Tgroup)[[p.value]] #Get t1 p value

t1pvals[lcv] - currentp #Store t1 p value

#If p = .05 or = continue threshold then run more subjects

if ((currentp = contthreshold)  (currentp = .05)) {

Cgroup - c(Cgroup,rnorm(t2N)) #Add t2N subjects to group 1

Tgroup - c(Tgroup,rnorm(t2N)) #Add t2N subjects to group 2

currentp - t.test(Cgroup,Tgroup)[[p.value]] #Get t2 p value

t2pvals[lcv] - currentp #store t2 p value

}

}

plainp - ifelse(!is.na(t2pvals),{t2pvals},{t1pvals}) #Make sure we are
looking at the right ps

table(t1pvals = .05); round(summary(t1pvals),4) #debugging

hist(t1pvals) #debugging

table(plainp = .05); round(summary(plainp),4) #debugging

hist(plainp, probability=TRUE,main=paste(t1N,then,t2N)) #Histogram of
interest

abline(a=1.00,b=0) #Baseline probability

dev.copy(jpeg,filename=paste(Sim with ,t1N, start samples and ,t2N,
extra samples.jpg,sep=),height=600,width=800,bg=white) # Create the
image

dev.off() #Save the image

chi - rbind(table(t1pvals = .05),table(plainp = .05)) #debugging

chisq.test(chi) #debugging

explore - data.frame(t1=t1pvals,t2=t2pvals,picked=plainp) #debugging

t.test(explore$picked,explore$t1) #debugging

t.test(logit(explore$picked),logit(explore$t1)) #debugging

}

---
Russell Pierce
Psychology Department
Graduate Student - Cognitive
(951) 827-2553
University of California, Riverside, 92521

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with date-x-axis in lattice

2008-06-20 Thread Deepayan Sarkar
On 6/20/08, Henning Wildhagen [EMAIL PROTECTED] wrote:
 Hello list,

  i am trying to plot a continous variable y against a date variable, both
  in one dataframe named df, using a code like this

  library(lattice)
  plot1-xyplot(y~date, data=df, type=b)

  date is of class Date, of course, format=%d.%m.%Y, and spans two
  calendar years. The problem is that the x-axis is labeled with only one
  tick mark corresponding to the year with century (%Y) of the second
  calendar year.

  Is there a way to define the increment of the x-axis tick marks?

Could you provide a reproducible example?

In general, the algorithm that computes tick locations for date-time
scales often performs inadequately. Presumably the algorithm could be
improved, but I don't know how (the current code is ripped off from
traditional graphics, which has similar problems). It may be simpler
to just specify 'at' locations manually in the 'scales' argument (see
?xyplot).

-Deepayan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparison between R and MATLAB

2008-06-20 Thread Kevin J. Thompson
hi,
 
  my 0.2$ the rpy python module is excellent, in addition to those Wacek 
mentioned. 

  another free alternative, particularly for graphics  is scilab:
http://www.scilab.org/ 

thanks,
kevin

- Original Message -
From: Wacek Kusnierczyk [EMAIL PROTECTED]
Date: Friday, June 20, 2008 2:47 pm
Subject: Re: [R] Comparison between R and MATLAB

 for many tasks, gnu octave (a 'matlab clone', no offense to gnu folks
 intended) is quite sufficient, and *free* (+ open source).  you 
 can run
 some of matlab code in octave.
 
 you should also check if sage (http://www.sagemath.org/) can do 
 the job
 for you, it's stuffed with all sorts of maths utilities, with friendly
 python frontend, etc.
 and once you're at python's, check numpy, scipy, and matplotlib, which
 do lots of good work too.  all open source, of course.
 
 vQ
 
 
 Clint Bowman wrote:
  The easy way around that is to create an account, Mathworks, 
 with a
  common group that all who will use MatLab belong, then su - 
 Mathworks should satisfy the license manager.
 
  Clint BowmanINTERNET:   [EMAIL PROTECTED]
  Air Dispersion Modeler  INTERNET:   [EMAIL PROTECTED]
  Air Quality Program VOICE:  (360) 407-6815
  Department of Ecology   FAX:(360) 407-7534
 
  USPS:   PO Box 47600, Olympia, WA 98504-7600
  Parcels:300 Desmond Drive, Lacey, WA 98503-1274
 
  On Fri, 20 Jun 2008, Earl F. Glynn wrote:
 

  Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote in 
 message news:[EMAIL PROTECTED]
 MAILSRV02.Amba.com... Can I get a comparison between R and 
 MATLAB? How is R efficient than MATLAB?
  Or what are the weaknesses of R compared to MATLAB?
 
 
  Don't forget to compare licenses and cost.  Matlab's rigid and 
 unreasonable license is the main reason I use R now.
 
  Several years ago the Mathworks refused to let a post doc and 
 me share a
  MatLab license -- they wanted all single-user licenses to be 
 named users
  even if each of us only needed MatLab a few hours a month.  I 
 asked if they
  had a math model for what we got for a license, but they 
 didn't care that
  there was a huge disconnect between what they wanted to sell 
 and our usage
  needs.  I quit using MatLab, converted my project from MatLab 
 to R, and now
  steer as many people to R as possible.
 
  The Mathworks refuses to acknowledge that life-science users of 
 math tools
  are not like physical science users.  Biologists can spend 
 weeks or months
  on experiments and then occasionally need high-end math tools  
 for analysis.
 
  A single shared network MatLab license outside of academia is 
 outrageously expensive.  A single network concurrent license for 
 Matlab and the Image
  processing, Signal Processing and PDE toolboxes costs $18,800 --
 I received
  that quote just yesterday since we still have a few people that 
 use existing
  MatLab code.
 
  MatLab may be a good product, but the Mathworks is unreasonable 
 in how they
  license it.  We are a non-profit, basic life scientific 
 research institute
  and the Mathworks sells us the same license as for-profit 
 businesses.  Only
  degree-granting universities are eligible for academic pricing 
 apparently.
  efg
  Earl F Glynn
  Bioinformatics
  Stowers Institute for Medical Research
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-
 project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-
 project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 
 
 -- 
 ---
 
 Wacek Kusnierczyk, MD PhD
 
 Email: [EMAIL PROTECTED]
 Phone: +47 73591875, +47 72574609
 
 Department of Computer and Information Science (IDI)
 Faculty of Information Technology, Mathematics and Electrical 
 Engineering (IME)
 Norwegian University of Science and Technology (NTNU)
 Sem Saelands vei 7, 7491 Trondheim, Norway
 Room itv303
 
 Bioinformatics  Gene Regulation Group
 Department of Cancer Research and Molecular Medicine (IKM)
 Faculty of Medicine (DMF)
 Norwegian University of Science and Technology (NTNU)
 Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
 Room 231.05.060
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.htmland provide commented, minimal, self-contained, 
 reproducible code.


__
R-help@r-project.org mailing 

Re: [R] Problem with date-x-axis in lattice

2008-06-20 Thread Gabor Grothendieck
There is an example in the examples section of ?xyplot.zoo in the
zoo package of using panel.axis.  It works largely the same way even if
you don't use zoo.

On Fri, Jun 20, 2008 at 6:06 AM, Henning Wildhagen [EMAIL PROTECTED] wrote:
 Hello list,

 i am trying to plot a continous variable y against a date variable, both
 in one dataframe named df, using a code like this

 library(lattice)
 plot1-xyplot(y~date, data=df, type=b)

 date is of class Date, of course, format=%d.%m.%Y, and spans two
 calendar years. The problem is that the x-axis is labeled with only one
 tick mark corresponding to the year with century (%Y) of the second
 calendar year.

 Is there a way to define the increment of the x-axis tick marks?

 Cheers

 Henning
 --



[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Programming Concepts and Philosophy

2008-06-20 Thread Esmail Bonakdarian

hadley wickham wrote:

2008/6/20 [EMAIL PROTECTED] [EMAIL PROTECTED]:

If you do nothing to your code, in 18 months time its performance will
have doubled because computers will have become faster.  Your code
will not get easier to understand by itself.


Very nicely put .. and true too!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about nlmer

2008-06-20 Thread ctu

Hi R user,
I have a question about nlmer. Can I specify the multilevel random  
effects in the the nlmer? For example, level 1 is hospital and level  
2 is patient, so


nlmer(response~SSfol(Dose,Time,lke,lka,lcl)~(lke+lka+lcl|hospital)~(lke+lka+lcl|patient%in%hospital), data=health,  
start=c(lke=-2.5,lka=0.5,lcl=-3),verb=1))


I can do it in the nlme but I still don't know how to get it in nlmer!

many thanks in advance

Chunhao

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] World Ocean Database files

2008-06-20 Thread Franz J Mueter

Has anyone written a script or function to read data from NODC’s World
Ocean Database files?

(I know there are simple Fortran and C programs to read these files, but
the output is not suitable for easy analysis)

Thanks, Franz

_

Dr. Franz J. Mueter
School of Fisheries and Ocean Sciences, Juneau Center
University of Alaska Fairbanks
11120 Glacier Highway
Juneau, Alaska 99801-8677

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting barplot and scatterplot on same device - x-axis problem

2008-06-20 Thread Carl Witthoft

As an alternative to the other suggestions,
I've found it just as easy to make the bar plot using plot() .

Assuming I've run hist()-sudh,  then do

plot(sudh$breaks[1:length(sudh$breaks)-1],sudh$counts,type='h',lwd={pick_a_width_you_like))

Then it's easy to drop some scatterplot points or lines on top of that.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Combine colors and shading lines

2008-06-20 Thread HBaize


Well perhaps we can take the mystery of why it work for me, but not you, off
line :-)
I'm using R 2.6.1 on a WinXP platform. 

You could try just using shades of color like this:

data(HairEyeColor)
a - as.table( apply(HairEyeColor, c(1,2), sum) )
a1-a[1:2,]

barplot(a1,
type=n,
col=c(red,pink,blue,lightblue,purple,
  lavender,green,lightgreen),
beside = TRUE )




-- 
View this message in context: 
http://www.nabble.com/Combine-colors-and-shading-lines-tp18033630p18036907.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparison between R and MATLAB

2008-06-20 Thread Wacek Kusnierczyk
Kevin J. Thompson wrote:
 hi,
  
   my 0.2$ the rpy python module is excellent, in addition to those Wacek 
 mentioned. 

   another free alternative, particularly for graphics  is scilab:
 http://www.scilab.org/ 

   

for scilab there is the rscilab module, so that we are with r again.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] World Ocean Database files

2008-06-20 Thread Roy Mendelssohn

Hi Franz:

we have a web service that will get you the Pacific.  Look at http:// 
coastwatch.pfel.noaa.gov/erddap/tabledap/pmelWOD5np.html  it will  
show you how to use  form the URL request, and by changing the file  
ender you can change the format.


To use in R, you would so something like  (say for a csv file):

download.file(url=http://coastwatch.pfel.noaa.gov/erddap/tabledap/ 
WOD5np.csv?SOME CONSTRAINTS, destfile=/users/frans/wodb.csv)

wodb-read.csv(file=wodb.csv)


There are a variety of different format available.  We are  
essentially reserving in a different way the service provide by the  
PMEL Dapper service.


HTH,

-Roy

PS - I believe ODV also has access to the WODB, but not directly into R.

On Jun 20, 2008, at 1:25 PM, Franz J Mueter wrote:



Has anyone written a script or function to read data from NODC’s World
Ocean Database files?

(I know there are simple Fortran and C programs to read these  
files, but

the output is not suitable for easy analysis)

Thanks, Franz

_

Dr. Franz J. Mueter
School of Fisheries and Ocean Sciences, Juneau Center
University of Alaska Fairbanks
11120 Glacier Highway
Juneau, Alaska 99801-8677

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

and provide commented, minimal, self-contained, reproducible code.


**
The contents of this message do not reflect any position of the U.S.  
Government or NOAA.

**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: [EMAIL PROTECTED] (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.
From those who have been given much, much will be expected

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting barplot and scatterplot on same device - x-axis problem

2008-06-20 Thread Francisco J. Zagmutt
You could try using the arguments type, lwd and lend in the call to 
plot().  For example:


plot(1:10, type=h, lend=2, lwd=10)
points((1:10)*1.1, type=b)

type=h creates vertical lines under each observation, lwd controls the 
thickness of the lines, and lend=2 draws square ends on the lines.


I hope this helps,

Francisco




Thomas Pedersen wrote:

Hi R-users

I'm a relative newbie and uses R mostly for graphical purpose. I have a
layout problem when plotting a scatterplot and a barplot using
par(new=TRUE). The baseline of the x-axis is not positioned equal for the
two plotting functions (see picture) and I have been unable to find out how
this is changed. 

http://www.nabble.com/file/p18025066/pic.jpeg 


I have added the script if this is of interrest:

par(mar = c(7, 4, 4, 2) + 0.1)

barplot(rbind(data$Asn,data$Glu,data$NH3),
 beside=T,
 axes=TRUE,
 xlim=c(0,57),
 ylim=c(0,10))

par(new=TRUE)

plot(1:14,data$Acidification.time,
 axes=FALSE,
 type=b,
 xlab=,
 ylab=,
 xlim=c(0.3,14.7),
 ylim=c(6,8))

axis(1,pos=6,
 labels=FALSE,
 at=c(0.3,1:14,14.7))

text(1:14, par(usr)[3], srt = 90, adj = 1,
 labels = data$Month, xpd = TRUE)

axis(4,pos=14.7)

All help will be greatly appreciated


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] handling the output of strsplit

2008-06-20 Thread Denis Chabot

Hi,

Simple question, but I did not figure out how to find the answer on my  
own (wrong choice of keywords on my part).


I have a character variable for time of day that has entries looking  
like 6h30, 7h40, 12h25, 23h, etc. For the sake of this  
message, say


h = c(3h30,  6h30,  9h40,  11h25, 14h00,  
15h55,  23h)


I could not figure out how to use chron to import this into times, so  
I tried to extract the hours and minutes on my own.


I used strsplit and got a list:

h2 = strsplit(h, h)
 h2
[[1]]
[1] 3  30

[[2]]
[1] 6  30

[[3]]
[1] 9  40

[[4]]
[1] 11 25

[[5]]
[1] 14 00

[[6]]
[1] 15 55

[[7]]
[1] 23

It is where I am stuck. I would have like to extract a vector of  
hours from this list, and a vector of minutes, to reconstruct a  
time of day.


But the only command I know, unlist, makes a long vector of h, min, h,  
min, h, min.


For this in particular, but lists in general, how can one extract the  
first item of each element in the list, then the second item of each  
element, etc.?


Thanks in advance,

Denis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] handling the output of strsplit

2008-06-20 Thread Wacek Kusnierczyk
Denis Chabot wrote:
 Hi,

 Simple question, but I did not figure out how to find the answer on my
 own (wrong choice of keywords on my part).

 I have a character variable for time of day that has entries looking
 like 6h30, 7h40, 12h25, 23h, etc. For the sake of this
 message, say

 h = c(3h30,  6h30,  9h40,  11h25, 14h00,
 15h55,  23h)

 I could not figure out how to use chron to import this into times, so
 I tried to extract the hours and minutes on my own.

 I used strsplit and got a list:

 h2 = strsplit(h, h)
  h2
 [[1]]
 [1] 3  30

 [[2]]
 [1] 6  30

 [[3]]
 [1] 9  40

 [[4]]
 [1] 11 25

 [[5]]
 [1] 14 00

 [[6]]
 [1] 15 55

 [[7]]
 [1] 23

 It is where I am stuck. I would have like to extract a vector of
 hours from this list, and a vector of minutes, to reconstruct a
 time of day.

 But the only command I know, unlist, makes a long vector of h, min, h,
 min, h, min.

 For this in particular, but lists in general, how can one extract the
 first item of each element in the list, then the second item of each
 element, etc.?


sapply(h2, `[`, 1)
[1] 3 6 9 etc.

sapply(h2, `[`, 2)
[1] 30 30 40 etc.

? `[`

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] omnibus LR in multinomial model

2008-06-20 Thread markleeds
If one estimates a model using multinom, is it possible to perform the 
omnibus LR test ( the analogue to omnibus F in linear models )  using 
the output
from multinom ? The residual deviance is there but I was hoping I could 
somehow pull out the deviance based on just using an intercept ?
Sample code  is below from the CAR book but I wasn't sure how to do it 
based on that example. Thanks for any insights.



library(car)
library(nnet)

attach(Womenlf)

participation - ordered(partic, levels=c('not.work', 'parttime', 
'fulltime'))

print(participation)

mod.multinom - multinom(participation ~ hincome + children)
print(mod.multinom)
print(str(mod.multinom))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] handling the output of strsplit

2008-06-20 Thread Wacek Kusnierczyk
Denis Chabot wrote:
 Hi,

 Simple question, but I did not figure out how to find the answer on my
 own (wrong choice of keywords on my part).

 I have a character variable for time of day that has entries looking
 like 6h30, 7h40, 12h25, 23h, etc. For the sake of this
 message, say

 h = c(3h30,  6h30,  9h40,  11h25, 14h00,
 15h55,  23h)

 I could not figure out how to use chron to import this into times, so
 I tried to extract the hours and minutes on my own.

 I used strsplit and got a list:

 h2 = strsplit(h, h)
  h2
 [[1]]
 [1] 3  30

 [[2]]
 [1] 6  30

 [[3]]
 [1] 9  40

 [[4]]
 [1] 11 25

 [[5]]
 [1] 14 00

 [[6]]
 [1] 15 55

 [[7]]
 [1] 23

 It is where I am stuck. I would have like to extract a vector of
 hours from this list, and a vector of minutes, to reconstruct a
 time of day.

 But the only command I know, unlist, makes a long vector of h, min, h,
 min, h, min.

 For this in particular, but lists in general, how can one extract the
 first item of each element in the list, then the second item of each
 element, etc.?



you can also want to convert this representation to something cron-readable:

times(gsub(([0-9]+)h([0-9]*), \\1:0\\2:0, h))
[1] 03:30:00 06:30:00 etc.

(the first 0 in the replacement accommodates for missing minutes digits,
the second for seconds)

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] handling the output of strsplit

2008-06-20 Thread Gabor Grothendieck
We construct a times object by replacing the letter h with
a : and then pasting a :00 on the end.  Then replace any occurrence
of :: with :00: .  Its now in the format that times recognizes so we can
just convert that to times and apply hours() and minutes() to get
the components:

 library(chron)
 h2 - times(sub(::, :00:, paste(sub(h, :, h), 00, sep = :)))
 hours(h2)
[1]  3  6  9 11 14 15 23
 minutes(h2)
[1] 30 30 40 25  0 55  0\

Another possibility is to use gsubfn in package gsubfn.  It matches the
string such that it captures the hour and minutes in the two backreferences
and then pastes them together with a :00 at the end.   It then replaces
:: with :00: and converts that to times.   hours() and minutes() could be used,
as before, to get the components.

 library(gsubfn)
 times(gsubfn(([^h]+)h(.*), ~ sub(::, :00:, paste(..., 00, sep = 
 :)), h, backref = -2))
[1] 03:30:00 06:30:00 09:40:00 11:25:00 14:00:00 15:55:00 23:00:00

Here is another approach using strapply in the gsubfn package.  We use the
same pattern but this time convert each component to numeric:

 times(strapply(h, ([^h]+)h(.*), ~ as.numeric(x) / 24 + sum(as.numeric(y), 
 na.rm = TRUE)/(24*60), backref = -2, simplify = c))
[1] 03:30:00 06:30:00 09:40:00 11:25:00 14:00:00 15:55:00 23:00:00



On Fri, Jun 20, 2008 at 6:14 PM, Denis Chabot [EMAIL PROTECTED] wrote:
 Hi,

 Simple question, but I did not figure out how to find the answer on my own
 (wrong choice of keywords on my part).

 I have a character variable for time of day that has entries looking like
 6h30, 7h40, 12h25, 23h, etc. For the sake of this message, say

 h = c(3h30,  6h30,  9h40,  11h25, 14h00,
 15h55,  23h)

 I could not figure out how to use chron to import this into times, so I
 tried to extract the hours and minutes on my own.

 I used strsplit and got a list:

 h2 = strsplit(h, h)
 h2
 [[1]]
 [1] 3  30

 [[2]]
 [1] 6  30

 [[3]]
 [1] 9  40

 [[4]]
 [1] 11 25

 [[5]]
 [1] 14 00

 [[6]]
 [1] 15 55

 [[7]]
 [1] 23

 It is where I am stuck. I would have like to extract a vector of hours
 from this list, and a vector of minutes, to reconstruct a time of day.

 But the only command I know, unlist, makes a long vector of h, min, h, min,
 h, min.

 For this in particular, but lists in general, how can one extract the first
 item of each element in the list, then the second item of each element,
 etc.?

 Thanks in advance,

 Denis

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] handling the output of strsplit

2008-06-20 Thread Denis Chabot

Most helpful Gabor,

Many thanks,

Denis
Le 08-06-20 à 18:58, Gabor Grothendieck a écrit :


We construct a times object by replacing the letter h with
a : and then pasting a :00 on the end.  Then replace any occurrence
of :: with :00: .  Its now in the format that times recognizes so we  
can

just convert that to times and apply hours() and minutes() to get
the components:


library(chron)
h2 - times(sub(::, :00:, paste(sub(h, :, h), 00, sep =  
:)))

hours(h2)

[1]  3  6  9 11 14 15 23

minutes(h2)

[1] 30 30 40 25  0 55  0\

Another possibility is to use gsubfn in package gsubfn.  It matches  
the
string such that it captures the hour and minutes in the two  
backreferences
and then pastes them together with a :00 at the end.   It then  
replaces
:: with :00: and converts that to times.   hours() and minutes()  
could be used,

as before, to get the components.


library(gsubfn)
times(gsubfn(([^h]+)h(.*), ~ sub(::, :00:, paste(..., 00,  
sep = :)), h, backref = -2))

[1] 03:30:00 06:30:00 09:40:00 11:25:00 14:00:00 15:55:00 23:00:00

Here is another approach using strapply in the gsubfn package.  We  
use the

same pattern but this time convert each component to numeric:

times(strapply(h, ([^h]+)h(.*), ~ as.numeric(x) / 24 +  
sum(as.numeric(y), na.rm = TRUE)/(24*60), backref = -2, simplify =  
c))

[1] 03:30:00 06:30:00 09:40:00 11:25:00 14:00:00 15:55:00 23:00:00



On Fri, Jun 20, 2008 at 6:14 PM, Denis Chabot [EMAIL PROTECTED] 
 wrote:

Hi,

Simple question, but I did not figure out how to find the answer on  
my own

(wrong choice of keywords on my part).

I have a character variable for time of day that has entries  
looking like
6h30, 7h40, 12h25, 23h, etc. For the sake of this message,  
say


h = c(3h30,  6h30,  9h40,  11h25, 14h00,
15h55,  23h)

I could not figure out how to use chron to import this into times,  
so I

tried to extract the hours and minutes on my own.

I used strsplit and got a list:

h2 = strsplit(h, h)

h2

[[1]]
[1] 3  30

[[2]]
[1] 6  30

[[3]]
[1] 9  40

[[4]]
[1] 11 25

[[5]]
[1] 14 00

[[6]]
[1] 15 55

[[7]]
[1] 23

It is where I am stuck. I would have like to extract a vector of  
hours
from this list, and a vector of minutes, to reconstruct a time of  
day.


But the only command I know, unlist, makes a long vector of h, min,  
h, min,

h, min.

For this in particular, but lists in general, how can one extract  
the first
item of each element in the list, then the second item of each  
element,

etc.?

Thanks in advance,

Denis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Scatter plot transparency

2008-06-20 Thread Anh Tran
Hi all,
I'm putting a few plots together and wondering what format would be best to
export a few scatter plots to Illustrator to make a figure. I'm thinking
about overlaying some plot in Illustrator, so the export file type has to be
transparent for Illustrator (version 10).
I tried PNG and TIFF, but it does not seems to have transparency that is
recognized by Illustrator (or Photoshop for that matter).

EMF (meta data file) on the other hand is very good. The only problem is
that every dot on the plot becomes a vector, which slows the program down
considerably (I have about 200k dots on a graph).

So, is there a good way to import these plot in as picture so I can use them
as layer for Illustrator (Photoshop would be fine too).

Thank you all.

-- 
Regards,
Anh Tran

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Scatter plot transparency

2008-06-20 Thread milton ruser
Hi Anh,

I don´t know if I understood your point fine.
I generate a scatterplot, and open it on adobe photoshop 7.0 with tranparent
background.

setwd(c:\\temp)

x-runif(100)
y-rnorm(100)

png(transparent_scatterplot.png, 800, 600, bg=transparent)
plot(y~x)
dev.off()

I hope this help,

miltinho
Brazil

On 6/20/08, Anh Tran [EMAIL PROTECTED] wrote:

 Hi all,
 I'm putting a few plots together and wondering what format would be best to
 export a few scatter plots to Illustrator to make a figure. I'm thinking
 about overlaying some plot in Illustrator, so the export file type has to
 be
 transparent for Illustrator (version 10).
 I tried PNG and TIFF, but it does not seems to have transparency that is
 recognized by Illustrator (or Photoshop for that matter).

 EMF (meta data file) on the other hand is very good. The only problem is
 that every dot on the plot becomes a vector, which slows the program down
 considerably (I have about 200k dots on a graph).

 So, is there a good way to import these plot in as picture so I can use
 them
 as layer for Illustrator (Photoshop would be fine too).

 Thank you all.

 --
 Regards,
 Anh Tran

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] omnibus LR in multinomial model

2008-06-20 Thread Steven McKinney
Is this what you were trying to do?
See intercept model and anova below.

HTH

Steve McKinney


 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
 On Behalf Of [EMAIL PROTECTED]
 Sent: Friday, June 20, 2008 3:47 PM
 To: [EMAIL PROTECTED]
 Subject: [R] omnibus LR in multinomial model
 
 If one estimates a model using multinom, is it possible to perform the
 omnibus LR test ( the analogue to omnibus F in linear models )  using
 the output
 from multinom ? The residual deviance is there but I was hoping I
could
 somehow pull out the deviance based on just using an intercept ?
 Sample code  is below from the CAR book but I wasn't sure how to do it
 based on that example. Thanks for any insights.
 
 
 library(car)
 library(nnet)
 
 attach(Womenlf)
 
 participation - ordered(partic, levels=c('not.work', 'parttime',
 'fulltime'))
 print(participation)
 
 mod.multinom - multinom(participation ~ hincome + children)
 print(mod.multinom)
 print(str(mod.multinom))

 mod.multinom0 - multinom(participation ~ 1)
# weights:  6 (2 variable)
initial  value 288.935032 
final  value 250.246281 
converged
 anova(mod.multinom, mod.multinom0)
   Model Resid. df Resid. Dev   TestDf LR stat.
Pr(Chi)
1  1   524   500.4926   NA   NA
NA
2 hincome + children   520   422.8819 1 vs 2 4 77.61064
5.551115e-16



 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] clicking on plot and recording XY coords

2008-06-20 Thread milton ruser
Dear all,

I need to run a interactive procedure where the user
will need click on the screen (over a XY plot)
and I need to record the XY coordinate which the
user clicked. Roughly I wrote a short code below.
You see that I suppose that the user will choose
four coordinates inside the region of intersection
between three segmentes. On each click, I would like to
record the position clicked in a vector.
Any help are welcome.

Miltinho
-
number.clicks-4
for (i in 1:number.clicks)
 {
 plot(0,0, type=n)
 seg1-arrows(-0.5,-1,0.5,0, col=1)
 seg2-arrows(0,-1,-0.3,0.3, col=2)
 seg3-arrows(0.2,-0.7,-0.5,0, col=4)
 # here I would like click on PLOT
 # and record de XY position
 # before go to next aquisition
 }

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] clicking on plot and recording XY coords

2008-06-20 Thread jim holtman
?locator

On Fri, Jun 20, 2008 at 11:25 PM, milton ruser [EMAIL PROTECTED] wrote:
 Dear all,

 I need to run a interactive procedure where the user
 will need click on the screen (over a XY plot)
 and I need to record the XY coordinate which the
 user clicked. Roughly I wrote a short code below.
 You see that I suppose that the user will choose
 four coordinates inside the region of intersection
 between three segmentes. On each click, I would like to
 record the position clicked in a vector.
 Any help are welcome.

 Miltinho
 -
 number.clicks-4
 for (i in 1:number.clicks)
  {
  plot(0,0, type=n)
  seg1-arrows(-0.5,-1,0.5,0, col=1)
  seg2-arrows(0,-1,-0.3,0.3, col=2)
  seg3-arrows(0.2,-0.7,-0.5,0, col=4)
  # here I would like click on PLOT
  # and record de XY position
  # before go to next aquisition
  }

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] clicking on plot and recording XY coords

2008-06-20 Thread milton ruser
Thanks Jim.

I included your suggestion on the script and run fine.
But how can I skip (record X and Y as NULL) on some steps?
On this example it don´t occour, but when working with real data I will need
bypass some acquisitions. Is there a way of do it on a for() looping? I
noticed that if I click on right button of mouse the locator() ask for
continue or stop. But some times I just want to record NULL for the
position.

Thanks a lot,

Miltinho



number.clicks-4
my.coords-NULL
for (i in 1:number.clicks)
 {
 plot(0,0, type=n)
 seg1-arrows(-0.5,-1,0.5,0, col=1)
 seg2-arrows(0,-1,-0.3,0.3, col=2)
 seg3-arrows(0.2,-0.7,-0.5,0, col=4)

 coord-locator(1, type=p)
 my.coords-rbind(my.coords, cbind(x=coord$x, y=coord$y))
 }

my.coords

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] clicking on plot and recording XY coords

2008-06-20 Thread milton ruser
Jim,

In fact, if I click stop the for() looping and stop, and I need to
continue on the for().
By other side, is there a way of I ask for the user acquire point (with a
dialog box with Yes or No options), and if the user anwer Yes I collect the
points, otherwise I go for the next step of for() looping?

sorry for do it so trouble.
Kind regards


miltinho


On 6/21/08, jim holtman [EMAIL PROTECTED] wrote:

 I am not sure how you would record a NULL.  I assume that if you click
 'stop', then the result returned is a NULL and you can test for that.
 Once you start collecting points, you should not have a NULL in the
 series.

 On Fri, Jun 20, 2008 at 11:56 PM, milton ruser [EMAIL PROTECTED]
 wrote:
  Thanks Jim.
 
  I included your suggestion on the script and run fine.
  But how can I skip (record X and Y as NULL) on some steps?
  On this example it don´t occour, but when working with real data I will
 need
  bypass some acquisitions. Is there a way of do it on a for() looping? I
  noticed that if I click on right button of mouse the locator() ask for
  continue or stop. But some times I just want to record NULL for the
  position.
 
  Thanks a lot,
 
  Miltinho
  
 
  number.clicks-4
  my.coords-NULL
 
  for (i in 1:number.clicks)
   {
   plot(0,0, type=n)
   seg1-arrows(-0.5,-1,0.5,0, col=1)
   seg2-arrows(0,-1,-0.3,0.3, col=2)
   seg3-arrows(0.2,-0.7,-0.5,0, col=4)
 
   coord-locator(1, type=p)
   my.coords-rbind(my.coords, cbind(x=coord$x, y=coord$y))
   }
 
  my.coords
 
 



 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem you are trying to solve?


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] cutting out numbers from vectors

2008-06-20 Thread calundergrad

i have a vector with a string of number 
e.g

[1] 0113001 001130011000 001130012000 001130013000 001130016000
[6] 001130018000

i want a vector with the same numbers except with the last three digits  of
every factor cut off.  
e.g

[1] 01130010 001130011 001130012 001130013 001130016
[6] 001130018

how do i accomplish this?
-- 
View this message in context: 
http://www.nabble.com/cutting-out-numbers-from-vectors-tp18034157p18034157.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Combine colors and shading lines

2008-06-20 Thread Josh Roofchop

Hi, basically I am trying to create a grouped bar graph with each group a
different color and a bar in each group to have shading lines.  Basically
combine the 2 graphs created below.
Thanks,
Josh

data(HairEyeColor)
a - as.table( apply(HairEyeColor, c(1,2), sum) )
a1-a[1:2,]

par(mfcol=c(1,2), bg=white)

barplot(a1, 
type=n,
col=c(2,2,4,4,6,6,3,3),
beside = TRUE, )

barplot(a1, 
col=1,
density=c(0,7,0,7,0,7,0,7),
beside = TRUE, )

http://www.nabble.com/file/p18033630/graph.JPG graph.JPG 
-- 
View this message in context: 
http://www.nabble.com/Combine-colors-and-shading-lines-tp18033630p18033630.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Combine colors and shading lines

2008-06-20 Thread Josh Roofchop

I tried the add=TRUE but get
Warning messages: 1: parameter add could not be set in high-level plot()
function

Josh


HBaize wrote:
 
 
 Josh, 
 Check into add=TRUE :-)
 
 All you need to do is insert add=TRUE to the second 
 chart to superimpose it on the first chart. You might also 
 consider making the second bar a different shade of color 
 rather than using shadding lines, then it would only be one 
 plot. 
 
 data(HairEyeColor)
 a - as.table( apply(HairEyeColor, c(1,2), sum) )
 a1-a[1:2,]
 
 barplot(a1,
 type=n,

 col=c(red,red,blue,blue,purple,purple,green,green),
 beside = TRUE )
 
 barplot(a1,
 col=1,
 density=c(0,7,0,7,0,7,0,7),
 beside = TRUE, add=TRUE )
 
 
 
 Josh Roofchop wrote:
 
 Hi, basically I am trying to create a grouped bar graph with each group a
 different color and a bar in each group to have shading lines.  Basically
 combine the 2 graphs created below.
 Thanks,
 Josh
 
 data(HairEyeColor)
 a - as.table( apply(HairEyeColor, c(1,2), sum) )
 a1-a[1:2,]
 
 par(mfcol=c(1,2), bg=white)
 
 barplot(a1, 
  type=n,
  col=c(2,2,4,4,6,6,3,3),
 beside = TRUE, )
 
 barplot(a1, 
 col=1,
 density=c(0,7,0,7,0,7,0,7),
 beside = TRUE, )
 
  http://www.nabble.com/file/p18033630/graph.JPG graph.JPG 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Combine-colors-and-shading-lines-tp18033630p18036266.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about copula-GARCH model

2008-06-20 Thread Jonas Malmros
Hello everyone,

I am learning about copulas and also do some MATLAB/R coding to get
better understanding of how copulas work.
Recently I have started coding simple copula-GARCH models, that is I
fit say AR(1)-GARCH(1,1)-normal models to univariate time series, and
then I want to fit the copula (two-stage procedure).

What I have problem with is connecting these two estimation stages.
After I have estimated AR-GARCH univariate models, what do I take from
these models and put into log-likelihood estimation of the copula? Do
I take residuals from AR-GARCH models, or do I use estimated
parameters of these models to produce samples that I then use in
copula estimation stage?

I read a few papers that use copula-GARCH models, but it is not clear
from them how to estimate copula model.
In one of the papers it says: Let u=F(x; theta(x)) and v=F(y;
theta(y)), where theta(x) and theta(y) are the vectors of parameters
of each marginal distribution... and then one uses u and v in copula
log-likelihood minimization.
I am so embarassed, but I still do not get it.  If I estimated the
GARCH model parameters, how do I get these F(x; theta(x)) and F(y;
theta(y))?
Probably very simple and totally obvious thing, but I just do not get it. :-(
Could you please help me understand? How do I do it in MATLAB or R?

THanks in advance!

-- 
Jonas Malmros

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Convert character string to number

2008-06-20 Thread Ken Liu
Hi,

I would like to convert a character vector

xxx - c(1/2, 1/4)

to 

yyy - c(0.5, 0.25)


, but as.numeric didn't work for me.  Could anyone give me a hint please?

Thanks,
Ken

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Adding columns of Aggregates to existing dataframe

2008-06-20 Thread tonyxv

Hello,
I have a dataframe 


ID1   ID2
A1B3
A1B4
A1B3
A1B3
A2B1
A2B1
A2B4
A3B2
A3B2
A5B1
A5B1
A5B6
A5B4
A6B2



I want to add extra columns to the dataframe CountID1 and CountID2 which is
the actual count of values such as A1 etc
ie



ID1   ID2CountID1CountID2
A1B3 4   3
A1B4 4   4
A1B3 4   3
A1B3 4   3
A2B1 3   4
A2B1 3   4
A2B4 3   3
A3B2 2   3
A3B2 2   3
A5B1 4   4
A5B1 4   4
A5B6 4   1
A5B4 4   4
A6B2 1   3


I know this can be done by first creating temporary aggregate dataframes
then merging with the original.
Is there an easier way if i want to calculate many aggregates without having
to merge many temp tables.


Thanks.
-- 
View this message in context: 
http://www.nabble.com/Adding-columns-of-Aggregates-to-existing-dataframe-tp18039838p18039838.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] unable to update the matrix values within a function

2008-06-20 Thread Ken Liu
Hi,

I don't understand why this doesn't work:

matTest - matrix(nrow=3, ncol=3)
testMove - function(I, J){
for(i in 1:I){
for(j in 1:J){
matTest[i, j] - i+j
}
}
}
testMove(2, 3)
matTest

Why the elements of the matrix matTest are still NA?  How could I fix it?

Thanks,
Ken

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] stepAIC {MASS}

2008-06-20 Thread Nathan Leon Pace, MD, MStat
In a generalized linear model with k covariates, there are 2(kth power) - 1
possible models (excluding interactions).

Awhile ago a posting to R-help suggested Model Selection and Multimodel
Inference, 2nd ed, by Burnham and Anderson as a good source for
understanding model selection. They recommend (page 71) computing AIC
differences over all candidate models in the set of possible models.

After looking at the help page for stepAIC and checking MASS, I am not
certain which AICs are estimated by stepAIC.

Comments will be appreciated.

Nathan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.