Re: [R] significance for a random effect in Mixed Model ANOVA

2007-10-15 Thread joris . dewolf


Nathaniel,

If you are interested in the particular subject, you should consider them
as a fixed effect, which wil give you what you want.

If your subjects are really random, the only thing you could be interested
in, is whether considering the subjects as a grouping is helping you in
improving your model. The logical way is to compare two models, one with
and one without Subject, and compare their loglikelihood with the usual
anova() function.

Joris






   
 "Nathaniel
 Street"   
   cc 
 Sent by:  
 [EMAIL PROTECTED] Subject 
 project.org   [R] significance for a random   
   effect in Mixed Model ANOVA 
   
 14/10/2007 23:48  
   
   
 Please respond to 
 nathaniel.street@ 
 plantphys.umu.se  
   
   




In a number of cases I want to use mixed-model ANOVA tests where I am
interested in whether both the fixed and random effects (and their
interactions) are significant.

If I use this example

>library(nlme)
>data(Orthodont)
>anova(lme(distance ~ age + Sex, data = Orthodont, random = ~ 1))

I get the result

 numDF denDF  F-value p-value
(Intercept) 180 4123.156  <.0001
age 180  114.838  <.0001
Sex 1259.292  0.0054

How do I also get a significance value for the random factor (Subject)?

Incidentally, why does it seem that people are not generally interested in
whether the random variables are different from each other? In the case of
the Orthodont data (if there was replication at the Subject level i.e. if
you could clone humans [as you can plants]), would it not be interesting
to know if subjects (nested within sex) are different to each other as
well as
if there is an age effect (so to know if underlying genotype is also an
important factor)?

Thanks

Nat Street
--
Nathaniel Street
Umeå Plant Science Centre
Department of Plant Physiology
University of Umeå
SE-901 87 Umeå
SWEDEN

email: [EMAIL PROTECTED]
tel: +46-90-786 5477
fax:  +46-90-786 6676
www.upsc.se
http://www.citeulike.org/user/natstreet

__
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] iwidgets not found in r on windows

2007-10-15 Thread Heddema@ NXP
Hello,

I have a problem with using Iwidgets in R while i'm able to use BWiget and 
Tktable. If I let tcl list the names of
packages, Iwidgets seems available. I use R 2.6.0; in addition 
addTclPath("C:/Tcl/lib") has been used (in which iwidets is present)

> try(tcl("package", "names"))
 http opt tcltest ::Utility::expand Widget ::Utility::number BWidget 
msgcat Tktable Hierarchy ::Utility Iwidgets registry ::Utility::dump 
::Utility::tk ::Utility::string Tcl dde Tk 
> tclRequire("BWidget")
 1.8 
> tclRequire("Tktable")
 2.9 
> tclRequire("Iwidgets")
[1] FALSE
Warning message:
In tclRequire("Iwidgets") : Tcl package 'Iwidgets' not found

With regards,

Roelof Heddema


[[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] Data manipulation

2007-10-15 Thread Stephen Tucker
Hi Klaus,

I am not exactly sure what you are asking for, but something like this? This
would be option (2) from your list - I don't know that it would be too
difficult in R that you would want to use another tool.

filt <- function(x)
  with(x,which(Hole > 1))

normalize <- function(x,y)
{
  x$Feature <- x$Feature - with(y,Nominel[match(x$Hole,Hole)])
  return(x)
}

# from CSV import
mydata <- read.csv(...)

# answer
normalizedData <- normalize(filt(mydata))




--- Klaus Friis Østergaard <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I have a data set which is like this I write as the CSV I import:
> 
> Sample;Hole;Feature;Value
> 1;5;x;4,2334
> 1;5;y;3,3434
> 1;5;r;0,1080
> 1;10;x;5,2526
> 1;10;y;4,3434
> 1;10;r;0,1080
> 
> 
> with 98 sample and 10 different holes. These are measured values.
> 
> Now I also have a list of nominel values:
> 
> Hole;Feature;Nominel;LSL;USL
> 5;x;4,25,4,20;4,30
> 5;y;3,35;3,30;3,40
> 5;r;0,10;0,07;0,13
> 10;x;5,25;5,20;5,30
> ...
> 
> If I want to "normalize" the measured values. The results are to be used in
> a Sweave file that I plan to reuse for several similar data sets in the
> furture.
> 
> I have been looking at different approache:
> 1. do it in a script out side R
> 2. do it the long and hard way by filtering out all the single holes and
> Feature, the on this list subtract the nominel values, and then combine it
> back.
> 3. ?
> 
> Any help and guidence apriciated
> -- 
> Klaus F. Østergaard, 
> 
>   [[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] Make playwith a default graphic device

2007-10-15 Thread Felix Andrews
My previous suggestion was inconsistent with the Trellis/Lattice idea
of creating a trellis object without necessarily creating a plot. And
it also interfered with attempts to plot to a file device. So here is
a better solution, based on replacing `print.trellis`, though it is
still basically a hack.

library(lattice)
library(plotAndPlayGTK)

setAutoPlaywith <- function(on=TRUE) {
if (on == FALSE) {
return(rm(print.trellis, envir=.GlobalEnv))
}
assign("print.trellis",
function(x, position = NULL, split = NULL, more = FALSE, newpage = TRUE,
packet.panel = packet.panel.default, draw.in = NULL, ...)
{
dev.interactive2 <- function(orNone) dev.interactive(orNone) ||
(interactive() && .Device == "null device" &&
getOption("device") == "Cairo")
playing <- 'plotAndPlayUpdate' %in% sapply(sys.calls(), 
function(x)
ifelse(is.symbol(x[[1]]), toString(x[[1]]), ""))
new <- newpage && is.null(draw.in) &&
!lattice:::lattice.getStatus("print.more")
if (require(plotAndPlayGTK, quietly=TRUE) &&
dev.interactive2(TRUE) && !playing && new) {
# starting a new plot on an interactive device
eval.parent(call("playwith", x$call), n=2)
return(invisible())
}
# call the real `print.trellis`, from lattice package
ocall <- sys.call()
ocall[[1]] <- quote(lattice:::print.trellis)
eval.parent(ocall)
}, envir=.GlobalEnv)
invisible()
}

setAutoPlaywith(TRUE)
xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)
setAutoPlaywith(FALSE)
xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)

Deepayan, what do you think -- would it be appropriate to make a
Lattice option for something like this?

Felix

On 10/14/07, Felix Andrews <[EMAIL PROTECTED]> wrote:
> Hi Ronaldo,
>
> As Professor Ripley explained, playwith is a function, not a device.
> It uses a Cairo-based device from the cairoDevice package. I too would
> like to have `playwith` as the default behavior for some plots, but
> there is no standard way to do that. It can not be implemented as a
> device because it needs to know what the high-level plot call is.
>
> The only way I can think of is to redefine the generic plot
> function(s). But that is an ugly hack, and can never cover all cases.
> You could do it with the standard Lattice high-level plot functions,
> as follows:
>
> library(lattice)
>
> latticePlay <- function(x, data, ...) {
> playing <- 'plotAndPlayUpdate' %in%
> sapply(sys.calls(), function(x) toString(x[[1]]))
> if (require(plotAndPlayGTK, quietly=TRUE) && !playing)
> return(playwith(plot.call=sys.call()))
> eval(sys.call(), as.environment("package:lattice"))
> }
>
> latticeFns <- c("barchart", "bwplot", "cloud", "contourplot",
> "densityplot", "dotplot", "histogram", "levelplot",
> "parallel", "qq", "qqmath", "splom", "stripplot",
> "wireframe", "xyplot")
>
> ## this will mask all the high-level Lattice generics
> invisible(lapply(latticeFns, assign, latticePlay, env=.GlobalEnv))
>
> ## now `playwith` is called automatically:
> xyplot(Murder ~ Population, data.frame(state.x77))
>
> ## to revert (remove definitions from the Global Env)
> rm(list=latticeFns)
>
> Note that this approach does not allow you to specify any of the
> optional arguments to playwith().
>
> I would be much more reluctant to try the same thing with base
> graphics (`plot`, etc) because it would cause problems with
> multi-figure layouts.
>
> I have had several reports of the "figure margins too large" error,
> but have not experienced it myself. It seems to happen on unix-like
> systems (macOS / linux) and not on windows. The default window size is
> supposed to be 640x480 pixels, which should be large enough...
>
> Best,
> Felix
>
>
> On 10/14/07, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> > You seem to be under the misapprehension that playwith() is a graphics
> > device: it is not.
> >
> > To set a graphics device as the default, use options(device=).  I am not
> > sure what 'more functionalities' you are looking for: the playwith() uses
> > the cairoDevice package for its graphics device, and there is also the
> > Cairo package.
> >
> > On Sat, 13 Oct 2007, Ronaldo Reis Junior wrote:
> >
> > > Hi,
> > >
> > > I looking for a graphic device on Linux with more functionalities than 
> > > the X11
> > > (). I find the plotAndPlayGTK package and the playwith function. It is a 
> > > good
> > > device. It is possible to make it default in my system.
> >
> > Did you mean that to be a question?
> >
> > > Now I need:
> > >
> > >> library(plotAndPlayGTK )
> > > Loading required package: RGtk2
> > > Loa

Re: [R] ggplot2: ordering categorial data

2007-10-15 Thread Christoph Krammer
I got some further with this issue by myself, using a temporary rank number
to get the bars sortet:

data_rb <- read.csv("c421_recipient_country.txt", header=TRUE, nrows=10)
data_rb$i <- factor(seq(1,10))
levels(data_rb$i) <- data_rb$tld

ggplot(data_rb) + geom_bar(aes(x=i, y=spam), colour="navy", fill="navy") +
geom_bar(aes(x=i, y=stockspam), fill="maroon")


But the problem is that both bars got stacked up. The lower part is blue and
the upper one is red. I did not get how to use position_dodge() to separate
them.

With the following idea, I get an error:

> ggplot(data_rb) + geom_bar(aes(x=i, y=spam), fill="navy",
position="dodge") + geom_bar(aes(x=i, y=stockspam), fill="maroon",
position="dodge")
Fehler in as.vector(x, "double") : kann nicht nach Vektor umwandeln

In english: "Error in as.vector(x, "double") : can not convert to vector"

Can anybody help here?

Thanks and regards,
 Christoph

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Christoph Krammer
Sent: Sunday, October 14, 2007 11:30 AM
To: r-help@r-project.org
Subject: [R] ggplot2: ordering categorial data

Hello again,

everytime I think I got something to work, the next issue comes up...

I have the following data.frame, I want to visualize:

> data_rb
   tld  spam1 spam2 share
1   ca 826436 73452 0.0889
2  org 470550 25740 0.0547
3   de 156042 15531 0.0995
4  com 140753  7527 0.0535
5  edu  34845  2507 0.0719
6  net  12781   382 0.0299
7   ru   764818 0.0024
8   tw   2290 2 0.0009
9   uk   228322 0.0096
10  kr971 7 0.0072

The perfect version of the final plot would look like this:
TLD is the X axis, ordered by the spam1 values
spam1 and spam2 are on the same Y axis, both as line plots share is on a
second Y axis, again as line plots the three lines should appear in
different colours

I first tried to do a bar plot with the following command:
qplot(tld, spam, data=data_rb, geom="bar", position="dodge") +
geom_bar(aes(y=data_rb$stockspam), position="dodge")

But this seems to stack spam1 and spam2 values.

When I try to do a lineplot, I get the following error message:
> qplot(tld, spam, data=data_rb, geom="line")
Error in unit(x0, default.units) : 'x' and 'units' must have length > 0

Can anyone help me with this?

Thanks and regards,
 Christoph

__
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] Save variable with loop part

2007-10-15 Thread marcg
Hello

does anyone know how to save in a variable with a loop part.

Im reading several csv files with read.table and would like to save with a loop:

for (i in 0:9){
}

should give read0, read1, read2, read3, read4, read5, read6, read7, read8, read9

st. like read(i)<-read.table("myfile.csv".)

I tried with paste("read", i, sep"") or to save as a vector with my names, but 
it doesn't work

suggestions?

thanks

marc
-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

__
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] oanda and yahoo get.hist.quote

2007-10-15 Thread Adrian Trapletti
Hello Alexander

I doubt that such an analyis is very useful as the data is not sampled 
synchronously (equity close in the US for ^gspc and even that is not 
always at the same time, some average price from Oanda data). Also fx 
data from others sources as suggested in another mail on this list would 
not really help with this unless it is really sampled at exactly the 
same times as the equity close of ^gspc. The only way to get clean data 
for such an analysis is to use intraday data.

Best regards
Adrian

>Message: 1
>Date: Sun, 14 Oct 2007 15:00:15 -0500
>From: Alexander Moreno <[EMAIL PROTECTED]>
>Subject: [R-SIG-Finance] oanda and yahoo get.hist.quote
>To: [EMAIL PROTECTED]
>Message-ID: <[EMAIL PROTECTED]>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>Hi,
>
>I have S&P index data (^gspc) that I got from get.hist.quote from yahoo, 
>and fx data from the same function from Oanda.  The Oanda data has 
>7-days, and the S&P data has 5.  Anyone know how to get them to match up 
>for the same time period?
>
>Best,
>Alex
>
>
>
>  
>

-- 
Adrian Trapletti
Wildsbergstrasse 31
8610 Uster
Switzerland

Phone :   +41 (0) 44 9945630
Mobile :  +41 (0) 76 3705631

Email :   [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] Odp: Save variable with loop part

2007-10-15 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 15.10.2007 11:12:57:

> Hello
> 
> does anyone know how to save in a variable with a loop part.
> 
> Im reading several csv files with read.table and would like to save with 
a loop:
> 
> for (i in 0:9){
> }
> 
> should give read0, read1, read2, read3, read4, read5, read6, read7, 
read8, read9
> 
> st. like read(i)<-read.table("myfile.csv".)

Well this is not an answer to your question but did you consider to use 
list? If your data are similar and you want to do some analysis with it 
list  seems to me as a better option than several objects.

read <- rep(vector("list", 1),9)

gives you an empty list

and
read[[1]] <- read.table(
reads specified file to first position of list.

Be aware also that in R indexing starts at 1 not at 0.

Regards
Petr

> 
> I tried with paste("read", i, sep"") or to save as a vector with my 
names, but
> it doesn't work
> 
> suggestions?
> 
> thanks
> 
> marc
> -- 
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
> 
> __
> 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] how to generate and evaluate a design using Algdesign

2007-10-15 Thread sun
Thanks Steve,

Now it is a bit clear to me, thanks very much. 


- Original Message - 
From: "S Ellison" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "sun" <[EMAIL PROTECTED]>
Sent: Friday, October 12, 2007 12:59 PM
Subject: Re: [R] how to generate and evaluate a design using Algdesign


> If you do something like length(coef(lm(y~.+v3:v4 + v5:v6, data=dat)))
> to get a quick empirical estimate of required number of coefficients,
> you will find that you have 35 coefficients, so 32 observations cannot
> provide a solution at all. And indeed, nTrials=35 is the first size at
> which optFederov even tries to find a design.
> 
> After that,many possible trial designs will be singular because (I
> think) most subsets of the data will miss out support points for the
> design. You need a lot of repeats to find a design at all with so few
> points, or optfederov won't find a viable design at all. 
> 
> If you're prepared to wait a while, run with at least nTrials=45 with
> plenty of repeats and you have a chance of something useful, though the
> efficiency (judged by Ge) looked pretty poor. 
> 
> Steve E
 "sun" <[EMAIL PROTECTED]> 10/10/2007 14:59:59 >>>
> Hi,
> 
>  I have some problems when using AlgDesign->optFederov() generating 
> designs.
> 
> I have 6 variables, all factors. 3^2 and 4^4, I want to have a design
> that 
> can take care of  main effects and two interactions within 2 pair of 
> variables v3-v4 and v5-v6, the following is the code
> 
> 
> require(AlgDesign)
> set.seed(1)
> levels = c(v1=3,v2=3, v3=4,v4=4,v5=4,v6=4)
> 
> dat<-gen.factorial(levels,center=FALSE,varNames=names(levels),factors=
> c(1,2,3,4,5,6))
> 
> model = ~.+v3:v4+v5:v6
> 
> optDgn<-optFederov(model,dat,nRepeat=5,nTrials = 32,criterion = "D",
> approximate = F)
> 
> 
> this lead to a error msg " nTrials must be greater than or equal to
> the
> number of columns in expanded X" . I thought I do not have that many
> columns. if I change approximate to T, this error has gone.
> 
> if I remove nTrials argument in function call:
>> optDgn<-optFederov(~.+v3:v4+v5:v6,dat,nRepeat=5,criterion = 
>> "D",approximate = F)
> I got a error : "Singular design."
> 
> what would be the cause and what is the sullotion?
> 
> another question is, how do I measure or evaluate a design to see if it
> is 
> able to handle which effects(main effects/which intercations)? I got
> some 
> other designs generated by other packages, so I 'd like to check their
> 
> characteristics.
> 
> Thanks in advance,
> 
> Sun
> 
> __
> R-help@r-project.org mailing list

__
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] iplots question

2007-10-15 Thread Erich Neuwirth
Are there parameters to set position and size of the windows created by
the commands in iplots? I could not find them.

__
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] Download old R-2.5.1 version?

2007-10-15 Thread Hans-Peter
Is it possible to download somewhere the former 2.5.1 windows bin version of
R? (Need it for testing).

Thanks,
Hans-Peter

[[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] Download old R-2.5.1 version?

2007-10-15 Thread Henrique Dallazuanna
For Windows:
http://cran.r-project.org/bin/windows/base/old/

For Linux:
http://cran.r-project.org/bin/linux/

On 15/10/2007, Hans-Peter <[EMAIL PROTECTED]> wrote:
>
> Is it possible to download somewhere the former 2.5.1 windows bin version
> of
> R? (Need it for testing).
>
> Thanks,
> Hans-Peter
>
>[[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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[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] Need help ploting time series

2007-10-15 Thread gsmkb86

Hi:
I been having a lot of trouble trying to plot multiple time series on the
same plot. What I want to do is the following:
I have a table with sales per day on different states and what i would like
to do is plot time series for all the diferents states in the same plot
(divided in small squares, not all the time series together) so I can
visualize the data; but I do not know how to do this, im kind of new on R,
so any help is greatly appreciated. Thanks in advance.

__
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 "condition has length > 1" issue for lists

2007-10-15 Thread Svempa

I have the following code:

list1 <- list()
for (i in list.files(pattern="filename1")){
x <- read.table(i)
list1[[i]] <- x
}

list2 <- list()
for (i in list.files(pattern="filename2*")){
x <- read.table(i)
list2[[i]] <- x
}

anslist <- vector('list', length(list1)) 
for(i in 1:length(list1)) 
if (list1[[i]] & list2[[i]] >1)
anslist[[i]] <- list1[[i]] - list2[[i]]

That, if at least one element in either of the lists is below 1, nothing
happens. I now get the warning message "the condition has length >1..." etc.
I would guess this is because list1 and list2 aren't really real matrices,
more references to files. How do I get around this?

-- 
View this message in context: 
http://www.nabble.com/The-%22condition-has-length-%3E-1%22-issue-for-lists-tf4625785.html#a13209531
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] cumulative frequency plots for factors

2007-10-15 Thread Dieter Vanderelst
Dear list,

I have a data frame with a number of events (factor) and the times at which 
they occurred (continuous variable):

event time
A 10
A 12
B 15
A 17
C 13
...

Is it possible in R to make a plot against time of the cumulative frequency of 
occurrence of each event? This would be, a raising line for each factor.

Regards,
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] [R-pkgs] new package 'nnls'

2007-10-15 Thread Katharine Mullen
A new package 'nnls' is now available on CRAN.

The package provides an R interface to the Lawson-Hanson NNLS algorithm
for non-negative least squares that solves the least squares problem A x =
b with the constraint x >= 0.

The Lawson-Hanson NNLS algorithm was published in

Lawson CL, Hanson RJ (1974). Solving Least Squares Problems. Prentice
Hall, Englewood Cliffs, NJ.

Lawson CL, Hanson RJ (1995). Solving Least Squares Problems. Classics in
Applied Mathematics. SIAM, Philadelphia.

and is available as Fortran77 code on Netlib (file lawson-hanson/all). The
'nnls' package interfaces to this code.

Included in the examples section of the function 'nnls' is a test problem
comparing NNLS to the L-BFGS-B method of 'optim' and to the 'solve.QP'
function of the package 'quadprog'.  NNLS is shown to be faster and
slightly more accurate than these more general purpose algorithms for the
test problem examined.

I do not have access to S-PLUS or the S-PLUS source, but the help page for
the S-SPLUS function 'nnls.fit' references Lawson and Hanson (1974), and
is probably close to the port here.  I have not written any methods for
printing or summaries, and only return the solution x. On request, I can
modify this behavior.

I would be interested in suggestions, bug reports, and other comments.

Kate Mullen


Katharine Mullen
mail: Department of Physics and Astronomy, Faculty of Sciences
Vrije Universiteit Amsterdam, de Boelelaan 1081
1081 HV Amsterdam, The Netherlands
room: T.1.06
tel: +31 205987870
fax: +31 205987992
e-mail: [EMAIL PROTECTED]
homepage: http://www.nat.vu.nl/~kate/

___
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] cumulative frequency plots for factors

2007-10-15 Thread Henrique Dallazuanna
Perhaps:

par(mfrow=c(3,1))
lapply(tapply(df$time, df$events, ecdf), plot)


On 15/10/2007, Dieter Vanderelst <[EMAIL PROTECTED]> wrote:
>
> Dear list,
>
> I have a data frame with a number of events (factor) and the times at
> which they occurred (continuous variable):
>
> event time
> A 10
> A 12
> B 15
> A 17
> C 13
> ...
>
> Is it possible in R to make a plot against time of the cumulative
> frequency of occurrence of each event? This would be, a raising line for
> each factor.
>
> Regards,
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[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] Data manipulation

2007-10-15 Thread Klaus Friis Østergaard
2007/10/15, Stephen Tucker <[EMAIL PROTECTED]>:
>
> Hi Klaus,
>
> I am not exactly sure what you are asking for, but something like this?
> This
> would be option (2) from your list - I don't know that it would be too
> difficult in R that you would want to use another tool.
>
> filt <- function(x)
>   with(x,which(Hole > 1))
>
> normalize <- function(x,y)
> {
>   x$Feature <- x$Feature - with(y,Nominel[match(x$Hole,Hole)])
>   return(x)
> }
>
> # from CSV import
> mydata <- read.csv(...)
>
> # answer
> normalizedData <- normalize(filt(mydata))


I have not tried your solution yet, I was maybe more looking for somewhat
like this

rawdate$nomalized <- rawdata$Value - nom$Nominel[nom$Hole == rawdata$Hole &&
nom$Feature == rawdata$Feature]

maybe it should be like this

nominel.value <- function(hole, feature, nominel.array)
{
 n <- nominel.array$nominel[nominel.array$Hole == hole &
 nominel.array$Feature == feature]
 return(n)
}

rawdata$normalised <- rawdata$Value - nominel.value(rawdata$Hole,
rawdata$Feature, nom)

But it does not seem to work, the problem is that I expect nominel.value to
return a single value but it returns a vector, but not as expected.

I think that adding a new column to the data frame is better.

The rawdata is actually hole position and radius (x,y, r), Hole is the index
number of a hole on a singel sample, and I have measured on 98 different
samples. As a part of a process capability analysis I would like to compare
the measured values for each holes by subtracting the target/should be/
nominel value, so i look at deviation from the "true" value. I hope this
explains this better.


/Klaus






--- Klaus Friis Østergaard <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > I have a data set which is like this I write as the CSV I import:
> >
> > Sample;Hole;Feature;Value
> > 1;5;x;4,2334
> > 1;5;y;3,3434
> > 1;5;r;0,1080
> > 1;10;x;5,2526
> > 1;10;y;4,3434
> > 1;10;r;0,1080
> > 
> >
> > with 98 sample and 10 different holes. These are measured values.
> >
> > Now I also have a list of nominel values:
> >
> > Hole;Feature;Nominel;LSL;USL
> > 5;x;4,25,4,20;4,30
> > 5;y;3,35;3,30;3,40
> > 5;r;0,10;0,07;0,13
> > 10;x;5,25;5,20;5,30
> > ...
> >
> > If I want to "normalize" the measured values. The results are to be used
> in
> > a Sweave file that I plan to reuse for several similar data sets in the
> > furture.
> >
> > I have been looking at different approache:
> > 1. do it in a script out side R
> > 2. do it the long and hard way by filtering out all the single holes and
> > Feature, the on this list subtract the nominel values, and then combine
> it
> > back.
> > 3. ?
> >
> > Any help and guidence apriciated
> > --
> > Klaus F. Østergaard, 
> >
> >   [[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.
> >
>
>
>
>
> 
>
> Looking for a deal? Find great prices on flights and hotels with Yahoo!
> FareChase.
> http://farechase.yahoo.com/
>



-- 
Klaus F. Østergaard, 

[[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] Fonts do not display properly in R 2.5.1 on Red Hat Enterprise Linux 4

2007-10-15 Thread michael watson (IAH-C)
Dear All

I posted a similar question quite some time ago, but that was on an old
OS and an old version of R.  This time I have RHEL 4, which is still
supported as an OS, and R 2.5.1 which is not *that* old.

My sessionInfo() gives:

> sessionInfo()
R version 2.5.1 (2007-06-27) 
i686-redhat-linux-gnu 

locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
ENTIFICATION=C

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"
"methods"  
[7] "base" 

other attached packages:
DetectiV 
   "1.1" 

> plot(1:10,1:10)

Results can be seen here:
http://detectiv.sourceforge.net/out.jpg

I suspect I do not have the right fonts installed that R uses by
default

Any ideas?

Thanks
Mick

The information contained in this message may be confide...{{dropped:14}}

__
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] Fonts do not display properly in R 2.5.1 on Red Hat Enterprise Linux 4

2007-10-15 Thread Prof Brian Ripley
This looks like what happens when you use a UTF-8 locale and don't have 
Unicode X11 (meta-)fonts installed.  Try running in LC_CTYPE=en_GB: if 
that works you will both have a workaround and know where to look for a 
solution.

On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:

> Dear All
>
> I posted a similar question quite some time ago, but that was on an old
> OS and an old version of R.  This time I have RHEL 4, which is still
> supported as an OS, and R 2.5.1 which is not *that* old.
>
> My sessionInfo() gives:
>
>> sessionInfo()
> R version 2.5.1 (2007-06-27)
> i686-redhat-linux-gnu
>
> locale:
> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
> TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> ENTIFICATION=C
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"
> [7] "base"
>
> other attached packages:
> DetectiV
>   "1.1"
>
>> plot(1:10,1:10)
>
> Results can be seen here:
> http://detectiv.sourceforge.net/out.jpg
>
> I suspect I do not have the right fonts installed that R uses by
> default
>
> Any ideas?
>
> Thanks
> Mick
>
> The information contained in this message may be confi...{{dropped: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.


Re: [R] Need help ploting time series

2007-10-15 Thread Gabor Grothendieck
In the zoo package plot.zoo and xyplot.zoo can do this.

library(zoo)
vignette("zoo")
vignette("zoo-quickref")
?plot.zoo
?xyplot.zoo

On 10/14/07, gsmkb86 <[EMAIL PROTECTED]> wrote:
>
> Hi:
> I been having a lot of trouble trying to plot multiple time series on the
> same plot. What I want to do is the following:
> I have a table with sales per day on different states and what i would like
> to do is plot time series for all the diferents states in the same plot
> (divided in small squares, not all the time series together) so I can
> visualize the data; but I do not know how to do this, im kind of new on R,
> so any help is greatly appreciated. Thanks in advance.
>
> __
> 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] Variable which has the maximum value of DF

2007-10-15 Thread Lauri Nikkinen
Hi,

Suppose I have a data.frame like this

Lines <- "var1 var2 var3 var4 var5 var6

  0  2  1 2  0  0
  2  3  7 6  0  1
  1.54  9 9  6  0
  1.06  1022 3  3
"
DF <- read.table(textConnection(Lines), skip=1)
names(DF) <- scan(textConnection(Lines), what = "", nlines = 1)

How do I find the name of the variable which has the maximum value of
the data.frame? In this example the answer is "var3" (22).

Best regards,
Lauri

__
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] Variable which has the maximum value of DF

2007-10-15 Thread Henrique Dallazuanna
Perhaps,

names(which.max(sapply(DF, max)))


On 15/10/2007, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Suppose I have a data.frame like this
>
> Lines <- "var1 var2 var3 var4 var5 var6
>
> 0  2  1 2  0  0
> 2  3  7 6  0  1
> 1.54  9 9  6  0
> 1.06  1022 3  3
> "
> DF <- read.table(textConnection(Lines), skip=1)
> names(DF) <- scan(textConnection(Lines), what = "", nlines = 1)
>
> How do I find the name of the variable which has the maximum value of
> the data.frame? In this example the answer is "var3" (22).
>
> Best regards,
> Lauri
>
> __
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[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] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread michael watson (IAH-C)
Dear All

Another one I have touched on before with a much older OS and version.

My sessionInfo() is:
> sessionInfo()
R version 2.5.1 (2007-06-27) 
i686-redhat-linux-gnu 

locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
ENTIFICATION=C

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"
"methods"  
[7] "base" 

other attached packages:
DetectiV 
   "1.1" 

I'm getting the following error message when plotting a quite complex
graph:

Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
NA,  : 
Error: X11 cannot allocate additional graphics colours.
Consider using X11 with colortype="pseudo.cube" or "gray".

The problem is I only get it under certain circumstances.  I have some
quite convoluted test code:

n <- 82
mat <- matrix(rnorm(n*10), ncol=n)
fcolors <- terrain.colors(n)
image(z=mat, axes=FALSE)
oneis <- 1 / ncol(mat)
sptl <- oneis / 3
max <- 1:n * oneis
min <- c(0, max[1:length(max)-1])
for (i in 1:n) {
axis(side=2, at=c(min[i]-sptl,max[i]+sptl), labels=NA, line=0.9,
lwd=3, lty=1, tick=TRUE, tck=0, col=fcolors[i],lend=2)
}

Now, this code works without error on values of n up to and including
81, but produces the error when it is 82:

Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
NA,  : 
Error: X11 cannot allocate additional graphics colours.
Consider using X11 with colortype="pseudo.cube" or "gray".

The issue I have with it is that if I do a normal plot operation, I
don't get the error!

n <- 82
fcolors <- terrain.colors(n)
plot(1:n,1:n, col=fcolors)

Here the plot works, there are no errors and the colours come out fine.
But when I use the axis command, in the more complex code above, I get
an error.

The real question I want to know is how can I enable R (or my OS) to
plot a greater number of colours?  I can plot 820 colours on R under
windows, probably more, I just plucked 820 out of the air.  I'm guessing
this is because my windows graphics card can produce that many colours,
whereas on linux I am limited by what x-windows can produce, but there
must be some way of increasing the number of colours I can plot using R
under linux...?

Many thanks
Mick

The information contained in this message may be confide...{{dropped:14}}

__
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] Fonts do not display properly in R 2.5.1 on Red Hat Enterprise Linux 4

2007-10-15 Thread michael watson (IAH-C)
Thank you Brian, setting the locale using.

Sys.setlocale("LC_CTYPE","en_GB")

Meant that my test plot command worked fine.

Will now install Unicode X11 fonts 

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: 15 October 2007 14:12
To: michael watson (IAH-C)
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Fonts do not display properly in R 2.5.1 on Red Hat
Enterprise Linux 4

This looks like what happens when you use a UTF-8 locale and don't have 
Unicode X11 (meta-)fonts installed.  Try running in LC_CTYPE=en_GB: if 
that works you will both have a workaround and know where to look for a 
solution.

On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:

> Dear All
>
> I posted a similar question quite some time ago, but that was on an
old
> OS and an old version of R.  This time I have RHEL 4, which is still
> supported as an OS, and R 2.5.1 which is not *that* old.
>
> My sessionInfo() gives:
>
>> sessionInfo()
> R version 2.5.1 (2007-06-27)
> i686-redhat-linux-gnu
>
> locale:
>
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
>
TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
>
8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> ENTIFICATION=C
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"
> [7] "base"
>
> other attached packages:
> DetectiV
>   "1.1"
>
>> plot(1:10,1:10)
>
> Results can be seen here:
> http://detectiv.sourceforge.net/out.jpg
>
> I suspect I do not have the right fonts installed that R uses by
> default
>
> Any ideas?
>
> Thanks
> Mick
>
> The information contained in this message may be
confide...{{dropped:14}}
>
> __
> 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] Fonts do not display properly in R 2.5.1 on Red HatEnterprise Linux 4

2007-10-15 Thread michael watson (IAH-C)
OK, tried google, got very, very lost.  There are lots of different
packages out there.

Can anyone tell me where I can download the "Unicode X11 (meta-)fonts"
for Red Hat that R needs?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of michael watson (IAH-C)
Sent: 15 October 2007 14:43
To: Prof Brian Ripley
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Fonts do not display properly in R 2.5.1 on Red
HatEnterprise Linux 4

Thank you Brian, setting the locale using.

Sys.setlocale("LC_CTYPE","en_GB")

Meant that my test plot command worked fine.

Will now install Unicode X11 fonts 

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: 15 October 2007 14:12
To: michael watson (IAH-C)
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Fonts do not display properly in R 2.5.1 on Red Hat
Enterprise Linux 4

This looks like what happens when you use a UTF-8 locale and don't have 
Unicode X11 (meta-)fonts installed.  Try running in LC_CTYPE=en_GB: if 
that works you will both have a workaround and know where to look for a 
solution.

On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:

> Dear All
>
> I posted a similar question quite some time ago, but that was on an
old
> OS and an old version of R.  This time I have RHEL 4, which is still
> supported as an OS, and R 2.5.1 which is not *that* old.
>
> My sessionInfo() gives:
>
>> sessionInfo()
> R version 2.5.1 (2007-06-27)
> i686-redhat-linux-gnu
>
> locale:
>
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
>
TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
>
8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> ENTIFICATION=C
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"
> [7] "base"
>
> other attached packages:
> DetectiV
>   "1.1"
>
>> plot(1:10,1:10)
>
> Results can be seen here:
> http://detectiv.sourceforge.net/out.jpg
>
> I suspect I do not have the right fonts installed that R uses by
> default
>
> Any ideas?
>
> Thanks
> Mick
>
> The information contained in this message may be
confide...{{dropped:14}}
>
> __
> 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.

__
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] Data manipulation

2007-10-15 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 15.10.2007 14:36:59:

> 2007/10/15, Stephen Tucker <[EMAIL PROTECTED]>:
> >
> > Hi Klaus,
> >
> > I am not exactly sure what you are asking for, but something like 
this?
> > This
> > would be option (2) from your list - I don't know that it would be too
> > difficult in R that you would want to use another tool.
> >
> > filt <- function(x)
> >   with(x,which(Hole > 1))
> >
> > normalize <- function(x,y)
> > {
> >   x$Feature <- x$Feature - with(y,Nominel[match(x$Hole,Hole)])
> >   return(x)
> > }
> >
> > # from CSV import
> > mydata <- read.csv(...)
> >
> > # answer
> > normalizedData <- normalize(filt(mydata))
> 
> 
> I have not tried your solution yet, I was maybe more looking for 
somewhat
> like this
> 
> rawdate$nomalized <- rawdata$Value - nom$Nominel[nom$Hole == 
rawdata$Hole &&
> nom$Feature == rawdata$Feature]

Well, let us put it another way. Do you want for each unique combination 
of Hole and Feature to subtract a value from one data frame, let us call 
it nom from another data frame, let us call it raw? If yes I assume you 
have exactly same number of unique combinations of Hole and Feature values 
in both datasets.

In that case you can use such for cycle (although there can be other finer 
solutions)

for (i in 1:no.of.unique.levels) {
selection <- interaction(raw$hole, raw$feature) %in% interaction(nom$hole, 
nom$feature)[1]
raw[selection,"value"] <- raw[selection,"value"]-nom[i,"value"]
}






> 
> maybe it should be like this
> 
> nominel.value <- function(hole, feature, nominel.array)
> {
>  n <- nominel.array$nominel[nominel.array$Hole == hole &
>  nominel.array$Feature == 
feature]
>  return(n)
> }
> 
> rawdata$normalised <- rawdata$Value - nominel.value(rawdata$Hole,
> rawdata$Feature, nom)
> 
> But it does not seem to work, the problem is that I expect nominel.value 
to
> return a single value but it returns a vector, but not as expected.
> 
> I think that adding a new column to the data frame is better.
> 
> The rawdata is actually hole position and radius (x,y, r), Hole is the 
index
> number of a hole on a singel sample, and I have measured on 98 different
> samples. As a part of a process capability analysis I would like to 
compare
> the measured values for each holes by subtracting the target/should be/
> nominel value, so i look at deviation from the "true" value. I hope this
> explains this better.
> 
> 
> /Klaus
> 
> 
> 
> 
> 
> 
> --- Klaus Friis Řstergaard <[EMAIL PROTECTED]> wrote:
> >
> > > Hi,
> > >
> > > I have a data set which is like this I write as the CSV I import:
> > >
> > > Sample;Hole;Feature;Value
> > > 1;5;x;4,2334
> > > 1;5;y;3,3434
> > > 1;5;r;0,1080
> > > 1;10;x;5,2526
> > > 1;10;y;4,3434
> > > 1;10;r;0,1080
> > > 
> > >
> > > with 98 sample and 10 different holes. These are measured values.
> > >
> > > Now I also have a list of nominel values:
> > >
> > > Hole;Feature;Nominel;LSL;USL
> > > 5;x;4,25,4,20;4,30
> > > 5;y;3,35;3,30;3,40
> > > 5;r;0,10;0,07;0,13
> > > 10;x;5,25;5,20;5,30
> > > ...
> > >
> > > If I want to "normalize" the measured values. The results are to be 
used
> > in
> > > a Sweave file that I plan to reuse for several similar data sets in 
the
> > > furture.
> > >
> > > I have been looking at different approache:
> > > 1. do it in a script out side R
> > > 2. do it the long and hard way by filtering out all the single holes 
and
> > > Feature, the on this list subtract the nominel values, and then 
combine
> > it
> > > back.
> > > 3. ?
> > >
> > > Any help and guidence apriciated
> > > --
> > > Klaus F. Řstergaard, 
> > >
> > >   [[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.
> > >
> >
> >
> >
> >
> > 

> >
> > Looking for a deal? Find great prices on flights and hotels with 
Yahoo!
> > FareChase.
> > http://farechase.yahoo.com/
> >
> 
> 
> 
> -- 
> Klaus F. Řstergaard, 
> 
>[[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.


[R] for loop if else conditional

2007-10-15 Thread Vishal Belsare
date <- as.POSIXlt(Sys.time())  #present date
for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
if (date$wday != 0 & date$wday != 6) {print(date);assign("date",
(date-86400))} else (assign("date", (date-86400)))


I am trying to print dates from present day to a day in the past, but
omitting weekends. I am not doing something right, but can't figure
out what. Help appreciated!


Vishal Belsare

__
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] for loop if else conditional

2007-10-15 Thread Vishal Belsare
date <- as.POSIXlt(Sys.time())  #present date

for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
if (date$wday != 0 & date$wday != 6) {print(date);assign("date",
(date-86400))} else (assign("date", (date-86400)))


I am trying to print dates from present day to a day in the past, but
omitting weekends. I am not doing something right, but can't figure
out what. Help appreciated!


Vishal Belsare

__
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] Need some help

2007-10-15 Thread azzza


Quite helpful indeed. Greatly appreciated.
Another problem I had was trying to simulate an example from my book.
Simulating 1000 coin tosses, and finding the frequency of sign changes. So
how will we plot this using R? (frequency of sign changes in Y axis)




Daniel Nordlund wrote:
> 
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> On Behalf
>> Of azzza
>> Sent: Sunday, October 14, 2007 10:21 PM
>> To: r-help@r-project.org
>> Subject: [R] Need some help
>> 
>> 
>> Hi!
>> I'm taking a course that requires some programming background, but I'm a
>> complete novice in the field.
>> 
>> when asked to generate a list of 20 uniform random numbers, is it alright
>> if
>> I put in >randu, and just copy-paste the first 20 numbers?? Or is there,
>> as
>> I suspect, a better way of calling out exactly 20 uniform random
>> numbers??
>> 
> See ?runif
> 
> rand_nums <- runif(20)
> 
>> I'm also unable to solve the following problem:
>> We know that on average 30% of the customers who enter a store make a
>> purchase. Suppose 200
>> people enter the store today. Run a simulation to see how many purchases
>> we
>> will have today.
>> 
> see ?sample
>> number_of_purchases <- sum(sample(c(0,1), 200, prob=c(.70, .30),
>> replace=TRUE))
> 
> Hope this is helpful,
> 
> Dan 
> 
> Daniel Nordlund
> Bothell, WA USA
> 
> __
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Need-some-help-tf4624513.html#a13214128
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] for loop if else conditional

2007-10-15 Thread Vishal Belsare
date <- as.POSIXlt(Sys.time())  #present date

for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
if (date$wday != 0 & date$wday != 6)
{print(date);assign("date", (date-86400))} else (assign("date", (date-86400)))


I am trying to print dates from present day to a day in the past, but
omitting weekends. I am not doing something right, but can't figure
out what. Help appreciated!


Vishal Belsare


-- 
"A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects."
~ Robert Heinlein

__
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] for loop if else conditional

2007-10-15 Thread Gabor Grothendieck
See ?seq.Date, e.g.

   now <- Sys.Date()
   dd <- seq(now - 20, now, by = "day")
   dd[as.POSIXlt(dd)$wday %% 6 != 0]

and have a look at R News 4/1.

On 10/15/07, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> date <- as.POSIXlt(Sys.time())  #present date
> for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
>if (date$wday != 0 & date$wday != 6) {print(date);assign("date",
> (date-86400))} else (assign("date", (date-86400)))
>
>
> I am trying to print dates from present day to a day in the past, but
> omitting weekends. I am not doing something right, but can't figure
> out what. Help appreciated!
>
>
> Vishal Belsare
>
> __
> 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] a question on impulse responses

2007-10-15 Thread Joerg van den Hoff
On Sat, Oct 13, 2007 at 03:08:58PM +0300, Martin Ivanov wrote:
> 
> Dear R users,
> 
> I am using the vars package to calculate the impulse response functions and 
> the forecast error variance decomposition of a VAR model. Unfortunately I do 
> not know whether these functions assume unit or one standard deviation 
> shocks. I tried to look into the code of these functions, but in vain: 
> neither irf, nor vars::irf, nor vars:::irf output the code of the functions. 
> Does someone know whether irf and fevd assume one standard deviation or a 
> unit shock? How can I see the code of these functions?

?getAnywhere

should do it
> 
> Regards,
> Martin Ivanov
> 
> -
> ?? ??? - ?? ???! www.survivor.btv.bg
> 
> __
> 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] some question about partial prediction in survival

2007-10-15 Thread Thomas Lumley
On Sun, 14 Oct 2007, coldeyes.Rhelp wrote:

> Hi there:
> i got a problem to get the prediction from a model recently.  for
> example if i use a survival analysis to predict the risk. i use the code
> like below: i found the the prediction is not equal to (coef * x + coef
> * sex) , could someone help me with why this happened?

The intercept is not identifiable in a Cox model, and the code takes 
advantage of this to center the variables.  The predicted values are the 
values you expected, minus the mean.

For the example in ?predict.coxph
R> fit<-coxph(Surv(time,status)~x,data=aml)
R> predict(fit)
  1  2  3  4  5  6  7
-0.4776692 -0.4776692 -0.4776692 -0.4776692 -0.4776692 -0.4776692 -0.4776692
  8  9 10 11 12 13 14
-0.4776692 -0.4776692 -0.4776692 -0.4776692  0.4378634  0.4378634  0.4378634
 15 16 17 18 19 20 21
  0.4378634  0.4378634  0.4378634  0.4378634  0.4378634  0.4378634  0.4378634
 22 23
  0.4378634  0.4378634
R> sum(predict(fit))
[1] 7.21645e-16
R> a<-coef(fit)*(aml$x=="Nonmaintained")
R> a-mean(a)
  [1] -0.4776692 -0.4776692 -0.4776692 -0.4776692 -0.4776692 -0.4776692
  [7] -0.4776692 -0.4776692 -0.4776692 -0.4776692 -0.4776692  0.4378634
[13]  0.4378634  0.4378634  0.4378634  0.4378634  0.4378634  0.4378634
[19]  0.4378634  0.4378634  0.4378634  0.4378634  0.4378634


>and  can someone
> explain to me how this command "predict(f, type="terms")" works? is
> every partial prediction equal to coef*x=predict(f,type="terms")[,1] and
> coef*sex=predict(f,type="terms")[,2]?  it looks like they did not match.
> however
> "predict(f)=predict(f,type="terms")[,1]+predict(f,type="terms")[,2]"

The same thing happens here. Each column of predict(,type="terms") sums to 
zero.  In this case it is the same behaviour as  lm() and glm().

-thomas

__
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] Variable which has the maximum value of DF

2007-10-15 Thread Peter Dalgaard
Henrique Dallazuanna wrote:
> Perhaps,
>
> names(which.max(sapply(DF, max)))
>   
Nice.

I was thinking along the lines of

M <- as.matrix(DF)
colnames(M)[col(M)[which.max(M)]]
>
> On 15/10/2007, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
>   
>> Hi,
>>
>> Suppose I have a data.frame like this
>>
>> Lines <- "var1 var2 var3 var4 var5 var6
>>
>> 0  2  1 2  0  0
>> 2  3  7 6  0  1
>> 1.54  9 9  6  0
>> 1.06  1022 3  3
>> "
>> DF <- read.table(textConnection(Lines), skip=1)
>> names(DF) <- scan(textConnection(Lines), what = "", nlines = 1)
>>
>> How do I find the name of the variable which has the maximum value of
>> the data.frame? In this example the answer is "var3" (22).
>>
>> Best regards,
>> Lauri
>>
>> __
>> 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.
>   


-- 
   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] Bad EMF export

2007-10-15 Thread Poirier Clement
Hello dear useRs,

I'm trying to export a barplot into an emf file. My problem is that  
the plot is properly printed into the file, except the bars that do  
not appear :(
I've experienced some problems also with simple points plots, in which  
points did not appear (same problem).

Can you help me please ?
Thanks in advance !

Clement Poirier

__
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 "condition has length > 1" issue for lists

2007-10-15 Thread jim holtman
Your logic test is not correct.  Here is what I think you want.  See
if it makes sense.

> x <- list()  # create some test data
> x[[1]] <- read.table(textConnection("1 2 3 4
+ 5 6 7 8
+ 4 3 2 1
+ 8 7 6 5"))
> # create another list element
> x[[2]] <- t(x[[1]])
> str(x[[1]])
'data.frame':   4 obs. of  4 variables:
 $ V1: int  1 5 4 8
 $ V2: int  2 6 3 7
 $ V3: int  3 7 2 6
 $ V4: int  4 8 1 5
> x[[1]]
  V1 V2 V3 V4
1  1  2  3  4
2  5  6  7  8
3  4  3  2  1
4  8  7  6  5
> # assume all numeric -- test if any less than 3
> # case 1
> x[[1]] < 3  # you get multiple values back
V1V2V3V4
[1,]  TRUE  TRUE FALSE FALSE
[2,] FALSE FALSE FALSE FALSE
[3,] FALSE FALSE  TRUE  TRUE
[4,] FALSE FALSE FALSE FALSE
> # really want a single value
> any(x[[1]] < 3)
[1] TRUE
> # I think this is what you want
> newlist <- list()
> if (any(x[[1]] > 1) & any(x[[2]] > 1)){
+ newlist[[1]] <- x[[1]] - x[[2]]
+ }
> newlist
[[1]]
  V1 V2 V3 V4
1  0 -3 -1 -4
2  3  0  4  1
3  1 -4  0 -5
4  4 -1  5  0



On 10/15/07, Svempa <[EMAIL PROTECTED]> wrote:
>
> I have the following code:
>
> list1 <- list()
> for (i in list.files(pattern="filename1")){
>x <- read.table(i)
>list1[[i]] <- x
> }
>
> list2 <- list()
> for (i in list.files(pattern="filename2*")){
>x <- read.table(i)
>list2[[i]] <- x
> }
>
> anslist <- vector('list', length(list1))
> for(i in 1:length(list1))
> if (list1[[i]] & list2[[i]] >1)
> anslist[[i]] <- list1[[i]] - list2[[i]]
>
> That, if at least one element in either of the lists is below 1, nothing
> happens. I now get the warning message "the condition has length >1..." etc.
> I would guess this is because list1 and list2 aren't really real matrices,
> more references to files. How do I get around this?
>
> --
> View this message in context: 
> http://www.nabble.com/The-%22condition-has-length-%3E-1%22-issue-for-lists-tf4625785.html#a13209531
> 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.
>


-- 
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] Bad EMF export

2007-10-15 Thread Peter Dalgaard
Poirier Clement wrote:
> Hello dear useRs,
>
> I'm trying to export a barplot into an emf file. My problem is that  
> the plot is properly printed into the file, except the bars that do  
> not appear :(
> I've experienced some problems also with simple points plots, in which  
> points did not appear (same problem).
>
> Can you help me please ?
> Thanks in advance !
>
>   
Did you close the device with dev.off() before using the EMF?

-- 
   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] Bad EMF export

2007-10-15 Thread Marc Schwartz
On Mon, 2007-10-15 at 17:36 +0200, Poirier Clement wrote:
> Hello dear useRs,
> 
> I'm trying to export a barplot into an emf file. My problem is that  
> the plot is properly printed into the file, except the bars that do  
> not appear :(
> I've experienced some problems also with simple points plots, in which  
> points did not appear (same problem).
> 
> Can you help me please ?
> Thanks in advance !
> 
> Clement Poirier

How are you doing this? Via code?

If so, more than likely you forgot to add:

  dev.off()

after the code that generates the plot.  If you don't close the device,
then parts of the plot are not "flushed" from the cache to the disk file
and you are left with an incomplete plot in the file.

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] Need some help

2007-10-15 Thread jim holtman
You might want to check out 'rle'.  This will give you the 'lengths'
of runs of the same value and therefore when the value changes (sign
change?) you can see how often:

> x <- sample(c(-1,1), 1000, TRUE)
> rle(x)
Run Length Encoding
  lengths: int [1:483] 2 2 1 4 3 1 1 1 1 2 ...
  values : num [1:483] -1 1 -1 1 -1 1 -1 1 -1 1 ...

Here was a sample of 1000, and there were 483 changes between the
samples.  Is this what you are looking for?

On 10/15/07, azzza <[EMAIL PROTECTED]> wrote:
>
>
> Quite helpful indeed. Greatly appreciated.
> Another problem I had was trying to simulate an example from my book.
> Simulating 1000 coin tosses, and finding the frequency of sign changes. So
> how will we plot this using R? (frequency of sign changes in Y axis)
>
>
>
>
> Daniel Nordlund wrote:
> >
> >> -Original Message-
> >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> >> On Behalf
> >> Of azzza
> >> Sent: Sunday, October 14, 2007 10:21 PM
> >> To: r-help@r-project.org
> >> Subject: [R] Need some help
> >>
> >>
> >> Hi!
> >> I'm taking a course that requires some programming background, but I'm a
> >> complete novice in the field.
> >>
> >> when asked to generate a list of 20 uniform random numbers, is it alright
> >> if
> >> I put in >randu, and just copy-paste the first 20 numbers?? Or is there,
> >> as
> >> I suspect, a better way of calling out exactly 20 uniform random
> >> numbers??
> >>
> > See ?runif
> >
> > rand_nums <- runif(20)
> >
> >> I'm also unable to solve the following problem:
> >> We know that on average 30% of the customers who enter a store make a
> >> purchase. Suppose 200
> >> people enter the store today. Run a simulation to see how many purchases
> >> we
> >> will have today.
> >>
> > see ?sample
> >> number_of_purchases <- sum(sample(c(0,1), 200, prob=c(.70, .30),
> >> replace=TRUE))
> >
> > Hope this is helpful,
> >
> > Dan
> >
> > Daniel Nordlund
> > Bothell, WA USA
> >
> > __
> > 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.
> >
> >
>
> --
> View this message in context: 
> http://www.nabble.com/Need-some-help-tf4624513.html#a13214128
> 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.
>


-- 
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] Variable which has the maximum value of DF

2007-10-15 Thread jim holtman
You can also use arr.ind=TRUE to get the indices of the maximum value:

> Lines <- "var1 var2 var3 var4 var5 var6
+
+  0  2  1 2  0  0
+  2  3  7 6  0  1
+  1.54  9 9  6  0
+  1.06  1022 3  3
+ "
> DF <- read.table(textConnection(Lines), header=TRUE)
> DF
  var1 var2 var3 var4 var5 var6
1  0.021200
2  2.037601
3  1.549960
4  1.06   10   2233
> which(DF == max(DF), arr.ind=TRUE)
 row col
[1,]   4   4
>


On 10/15/07, Lauri Nikkinen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Suppose I have a data.frame like this
>
> Lines <- "var1 var2 var3 var4 var5 var6
>
>  0  2  1 2  0  0
>  2  3  7 6  0  1
>  1.54  9 9  6  0
>  1.06  1022 3  3
> "
> DF <- read.table(textConnection(Lines), skip=1)
> names(DF) <- scan(textConnection(Lines), what = "", nlines = 1)
>
> How do I find the name of the variable which has the maximum value of
> the data.frame? In this example the answer is "var3" (22).
>
> Best regards,
> Lauri
>
> __
> 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] Rmpi building

2007-10-15 Thread Sean Davis
I am trying to build Rmpi on Suse 10.2 linux.  While I would like to use
the RPM version of liblam-7.1.2, I have not been able to do so.  It
seems that Rmpi makes some pretty strong assumptions when trying to
guess the MPI version.  Has anyone successfully built Rmpi against
lam-7.1.2 recently using R-2.6.0?  If so, can you give some pointers
about where the libraries and header files need to be to have Rmpi "do
the right thing"?  I have perused the configure file in the Rmpi
distribution without much success.

Thanks,
Sean

__
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] glmmML vs. lmer - fitting overdispersed Poisson outcome.

2007-10-15 Thread Sam Field
Group,

I have count data with one observation per subject.  I would like to fit 
a glmm to these data in order to account for overdispersion in the 
outcome. The lmer() function does not appear to be able to handle data 
that have only one observation per-cluster id, even though separate 
variance components for the count and normal portions of the outcome are 
identifiable.  The glmmML() function does not seem to have problems with 
this (as the code below illustrates).

library(lme4)
library(glmmML)
u <- rnorm(100)
y <- rpois(100,exp(u))
id <- seq(1:100)
summary(glmmML(y~1,cluster=as.factor(id),family =poisson))
summary(lmer(y~1+(1|id),family='poisson'))  

I would like to use lmer() rather then glmmML(). Does anybody know of a 
way of getting the lmer() function to work with these kinds of data? 

Sam


-- 
Samuel H. Field
Division of Internal Medicine - University of Pennsylvania
CHERP - Philadelphia VA Medical Center
3900 Woodland Ave (9 East)
Philadelphia, PA 19104
(215) 823-5800 EXT. 6155 (Office)
(215) 823-6330 (Fax)

__
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] clipping off words inside a vector of strings

2007-10-15 Thread Gonçalo Ferraz
Hi,

I have a vector of strings (class character) with 6 elements (length  
6). I call it 'names'.

"Graham Chapman"
"John Cleese"
"Terry Gilliam"
"Eric Idle"
"Terry Jones"
"Michael Palin"

And I want to turn it into another vector of strings called  
'shortnames' with the same length.
The new vector should look like:

"Gra Cha"
"Joh Cle"
"Ter Gil"
"Eri Idl"
"Ter Jon"
"Mic Pal"

I just want to clip the first three characters of each word inside  
each string.

Would anyone know how to do this quickly?

Thanks!

Gonçalo





[[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] clipping off words inside a vector of strings

2007-10-15 Thread Romain Francois
Lemon Curry ?

sapply( strsplit( monty, " " ), function(x) {
   paste( substring(x,1,3), collapse = " " )
})

is a way to do it, ...
There is probably a better way to do that using the gsubfn package

Gonçalo Ferraz wrote:
> Hi,
>
> I have a vector of strings (class character) with 6 elements (length  
> 6). I call it 'names'.
>
> "Graham Chapman"
> "John Cleese"
> "Terry Gilliam"
> "Eric Idle"
> "Terry Jones"
> "Michael Palin"
>
> And I want to turn it into another vector of strings called  
> 'shortnames' with the same length.
> The new vector should look like:
>
> "Gra Cha"
> "Joh Cle"
> "Ter Gil"
> "Eri Idl"
> "Ter Jon"
> "Mic Pal"
>
> I just want to clip the first three characters of each word inside  
> each string.
>
> Would anyone know how to do this quickly?
>
> Thanks!
>
> Gonçalo
>
>
>
>
>
>   [[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.
>   


-- 
Mango Solutions
data analysis that delivers

Tel:  +44(0) 1249 467 467
Fax:  +44(0) 1249 467 468
Mob:  +44(0) 7813 526 123

__
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] Need some help

2007-10-15 Thread azzza

Umm, yes, what you had makes a lot of sense. How would I represent that in a
plot of the number of sign changes in the to  Y axis, and the toss number
(from 0 to 1000) in the x-axis? 




jholtman wrote:
> 
> You might want to check out 'rle'.  This will give you the 'lengths'
> of runs of the same value and therefore when the value changes (sign
> change?) you can see how often:
> 
>> x <- sample(c(-1,1), 1000, TRUE)
>> rle(x)
> Run Length Encoding
>   lengths: int [1:483] 2 2 1 4 3 1 1 1 1 2 ...
>   values : num [1:483] -1 1 -1 1 -1 1 -1 1 -1 1 ...
> 
> Here was a sample of 1000, and there were 483 changes between the
> samples.  Is this what you are looking for?
> 
> On 10/15/07, azzza <[EMAIL PROTECTED]> wrote:
>>
>>
>> Quite helpful indeed. Greatly appreciated.
>> Another problem I had was trying to simulate an example from my book.
>> Simulating 1000 coin tosses, and finding the frequency of sign changes.
>> So
>> how will we plot this using R? (frequency of sign changes in Y axis)
>>
>>
>>
>>
>> Daniel Nordlund wrote:
>> >
>> >> -Original Message-
>> >> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED]
>> >> On Behalf
>> >> Of azzza
>> >> Sent: Sunday, October 14, 2007 10:21 PM
>> >> To: r-help@r-project.org
>> >> Subject: [R] Need some help
>> >>
>> >>
>> >> Hi!
>> >> I'm taking a course that requires some programming background, but I'm
>> a
>> >> complete novice in the field.
>> >>
>> >> when asked to generate a list of 20 uniform random numbers, is it
>> alright
>> >> if
>> >> I put in >randu, and just copy-paste the first 20 numbers?? Or is
>> there,
>> >> as
>> >> I suspect, a better way of calling out exactly 20 uniform random
>> >> numbers??
>> >>
>> > See ?runif
>> >
>> > rand_nums <- runif(20)
>> >
>> >> I'm also unable to solve the following problem:
>> >> We know that on average 30% of the customers who enter a store make a
>> >> purchase. Suppose 200
>> >> people enter the store today. Run a simulation to see how many
>> purchases
>> >> we
>> >> will have today.
>> >>
>> > see ?sample
>> >> number_of_purchases <- sum(sample(c(0,1), 200, prob=c(.70, .30),
>> >> replace=TRUE))
>> >
>> > Hope this is helpful,
>> >
>> > Dan
>> >
>> > Daniel Nordlund
>> > Bothell, WA USA
>> >
>> > __
>> > 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.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Need-some-help-tf4624513.html#a13214128
>> 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.
>>
> 
> 
> -- 
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Need-some-help-tf4624513.html#a13216156
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] clipping off words inside a vector of strings

2007-10-15 Thread Marc Schwartz
On Mon, 2007-10-15 at 12:04 -0400, Gonçalo Ferraz wrote:
> Hi,
> 
> I have a vector of strings (class character) with 6 elements (length  
> 6). I call it 'names'.
> 
> "Graham Chapman"
> "John Cleese"
> "Terry Gilliam"
> "Eric Idle"
> "Terry Jones"
> "Michael Palin"
> 
> And I want to turn it into another vector of strings called  
> 'shortnames' with the same length.
> The new vector should look like:
> 
> "Gra Cha"
> "Joh Cle"
> "Ter Gil"
> "Eri Idl"
> "Ter Jon"
> "Mic Pal"
> 
> I just want to clip the first three characters of each word inside  
> each string.
> 
> Would anyone know how to do this quickly?
> 
> Thanks!
> 
> Gonalo

How about this:

> HolyGrail
[1] "Graham Chapman" "John Cleese""Terry Gilliam"  "Eric Idle" 
[5] "Terry Jones""Michael Palin"

> gsub("^(.{3}).+ (.{3}).+", "\\1 \\2", HolyGrail)
[1] "Gra Cha" "Joh Cle" "Ter Gil" "Eri Idl" "Ter Jon" "Mic Pal"

See ?gsub and ?regex

HTH,

Marc Schwartz


A reading from the Book of Armaments, Chapter 4, Verses 16 to 20:

Then did he raise on high the Holy Hand Grenade of Antioch, saying,
"Bless this, O Lord, that with it thou mayst blow thine enemies to tiny
bits, in thy mercy." And the people did rejoice and did feast upon the
lambs and toads and tree-sloths and fruit-bats and orangutans and
breakfast cereals ... Now did the Lord say, "First thou pullest the Holy
Pin. Then thou must count to three. Three shall be the number of the
counting and the number of the counting shall be three. Four shalt thou
not count, neither shalt thou count two, excepting that thou then
proceedeth to three. Five is right out. Once the number three, being the
number of the counting, be reached, then lobbest thou the Holy Hand
Grenade in the direction of thine foe, who, being naughty in my sight,
shall snuff it."

-- Monty Python, "Monty Python and the Holy Grail"

__
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] Bad EMF export

2007-10-15 Thread Poirier Clement
> How are you doing this? Via code?

I just type saveCopy(file, type="emf", etc) after the barplot()  
function ; but using windows commands (file, save as) do the same.

> If so, more than likely you forgot to add:
>
>   dev.off()
>
> after the code that generates the plot.  If you don't close the device,
> then parts of the plot are not "flushed" from the cache to the disk file
> and you are left with an incomplete plot in the file.

Ok but where has the line dev.off() to be placed ? If after the  
barplot() function, the plot disappears and there's nothing to save  
anymore ?

Thank you !

> 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.


[R] String concatenation, File Path Handling to pass to download.file( ) [backslash in DOS paths]

2007-10-15 Thread Vishal Belsare
Gabor,

Thanks much. Your solution is elegant. My overall scheme is to take
present date, and check whether it is a weekend, if not, then create a
string based on the date, to concatenate into a url link for
download.file( ). The files I need to download have a part which is in
the format: mmddyy. I am working to make myself a system to connect to
exchanges, and download end of day files from their servers. Knowing
that there won't be any files for weekends, I want to omit making
those requests (later I'd add something to skip a list of given
exchange holidays).

So I am making this string from the date, if it isn't a weekend,
concatenating to make the URL, downloading the file, unzipping it and
decrementing the date by a day to repeat the test for weekday and
following action. If to begin with the date is of a weekend, then
'else' should take over and decrement the date. I also have problem

My crude solution is this (I am just 4-day old into learning/using R):

#begin script

date <- as.POSIXlt(Sys.time())  #present date

for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))

if (date$wday != 0 & date$wday != 6)#check whether 
weekday
{
datestr <- as.character(date, "%d%m%y")#make date
character string ddmmyy
url <- 
paste("http://www.bseindia.com/bhavcopy/eq",datestr,"_csv.zip",sep="";)
file <- paste("C:\\Program
Files\\R\\R-2.5.0\\data"\",datestr,"_csv.zip",sep="")
download.file(url, destfile = file, mode = "wb")
zip.unpack(file, cat("C:\\Program Files\\R\\R-2.5.0\\data\\"))
date <- date - 86400
}
 else (date <- date-86400)

#end script

The above URLs would point to Bombay Stock Exchange's data files (if
the script works). Thanks again. The code you already suggested would
help me make the date sequence, but I am not sure how I could extract
the mmddyy string from it. Also, I might end up making a list for
dates extending to about 10 years in the past (~2600 working days), so
I was more keen on not creating one long list.


Vishal Belsare


On 10/15/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> See ?seq.Date, e.g.
>
>now <- Sys.Date()
>dd <- seq(now - 20, now, by = "day")
>dd[as.POSIXlt(dd)$wday %% 6 != 0]
>
> and have a look at R News 4/1.
>
> On 10/15/07, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> > date <- as.POSIXlt(Sys.time())  #present date
> > for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
> >if (date$wday != 0 & date$wday != 6) {print(date);assign("date",
> > (date-86400))} else (assign("date", (date-86400)))
> >
> >
> > I am trying to print dates from present day to a day in the past, but
> > omitting weekends. I am not doing something right, but can't figure
> > out what. Help appreciated!
> >
> >
> > Vishal Belsare
> >

__
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] String concatenation, File Path Handling to pass to download.file( ) [backslash in DOS paths]

2007-10-15 Thread Vishal Belsare
Gabor,

Thanks much. Your solution is elegant. My overall scheme is to take
present date, and check whether it is a weekend, if not, then create a
string based on the date, to concatenate into a url link for
download.file( ). The files I need to download have a part which is in
the format: mmddyy. I am working to make myself a system to connect to
exchanges, and download end of day files from their servers. Knowing
that there won't be any files for weekends, I want to omit making
those requests (later I'd add something to skip a list of given
exchange holidays).

So I am making this string from the date, if it isn't a weekend,
concatenating to make the URL, downloading the file, unzipping it and
decrementing the date by a day to repeat the test for weekday and
following action. If to begin with the date is of a weekend, then
'else' should take over and decrement the date. I also have problem
with backslashes in creating the file path.

My crude solution is this (I am just 4-day old into learning/using R):

#begin script

date <- as.POSIXlt(Sys.time())  #present date

for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))

if (date$wday != 0 & date$wday != 6)#check
whether weekday
{
datestr <- as.character(date, "%d%m%y")   #make date
character string
url <- 
paste("http://www.bseindia.com/bhavcopy/eq",datestr,"_csv.zip",sep="";)
file <- paste("C:\\Program
Files\\R\\R-2.5.0\\data"\",datestr,"_csv.zip",sep="")
download.file(url, destfile = file, mode = "wb")
zip.unpack(file, cat("C:\\Program Files\\R\\R-2.5.0\\data\\"))
date <- date - 86400
}
 else (date <- date-86400)

#end script

The above URLs would point to Bombay Stock Exchange's data files (if
the script works). Thanks again. The code you already suggested would
help me make the date sequence, but I am not sure how I could extract
the mmddyy string from it. Also, I might end up making a list for
dates extending to about 10 years in the past (~2600 working days), so
I was more keen on not creating one long list.


Vishal Belsare


On 10/15/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> See ?seq.Date, e.g.
>
>now <- Sys.Date()
>dd <- seq(now - 20, now, by = "day")
>dd[as.POSIXlt(dd)$wday %% 6 != 0]
>
> and have a look at R News 4/1.
>
> On 10/15/07, Vishal Belsare <[EMAIL PROTECTED]> wrote:
> > date <- as.POSIXlt(Sys.time())  #present date
> > for (i in 1:difftime(as.POSIXlt(Sys.Date()),"2007-10-01"))
> >if (date$wday != 0 & date$wday != 6) {print(date);assign("date",
> > (date-86400))} else (assign("date", (date-86400)))
> >
> >
> > I am trying to print dates from present day to a day in the past, but
> > omitting weekends. I am not doing something right, but can't figure
> > out what. Help appreciated!
> >
> >
> > Vishal Belsare
> >


-- 
"A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects."
~ Robert Heinlein

__
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] ERROR while importing data

2007-10-15 Thread pintinho

Hi everyone, 

When I try to import data do R, the following message appears: "\U
sequences are not supported on Windows".

I tried lots of methods to import (read.csv, read.table, RODBC, read.delim)
and the same message appears for all these methods. I think it is a bigger
problem. 

Can anyone help me solving this issue? 

Thanks a lot. 



-- 
View this message in context: 
http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
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] Bad EMF export

2007-10-15 Thread Marc Schwartz
On Mon, 2007-10-15 at 18:21 +0200, Poirier Clement wrote:
> > How are you doing this? Via code?
> 
> I just type saveCopy(file, type="emf", etc) after the barplot()  
> function ; but using windows commands (file, save as) do the same.
> 
> > If so, more than likely you forgot to add:
> >
> >   dev.off()
> >
> > after the code that generates the plot.  If you don't close the device,
> > then parts of the plot are not "flushed" from the cache to the disk file
> > and you are left with an incomplete plot in the file.
> 
> Ok but where has the line dev.off() to be placed ? If after the  
> barplot() function, the plot disappears and there's nothing to save  
> anymore ?
> 
> Thank you !

I can't seem to locate anything on saveCopy() for some reason. I presume
that it is Windows specific, but I have searched the R Reference manual,
the list archives and the source code tree for more information.

We may need somebody with a Windows install to provide more guidance
here and to confirm my transient blindness.

Normally, the dev.off() line would follow a call to emf() where you are
going directly to the file and not to the display first. You would open
the emf() device, then your plotting code follows, finally ending with
dev.off().

You might want to review ?saveCopy to get a feel for any examples in the
help file and any Details that would point to potential gotchas in its
use.

Sorry that I can't be more specific.

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] ERROR while importing data

2007-10-15 Thread Stefan Grosse
On Monday 15 October 2007 06:43:52 pm pintinho wrote:
pi> I tried lots of methods to import (read.csv, read.table, RODBC,
 read.delim) 
pi> and the same message appears for all these methods. I think
 it is a bigger 
pi> problem.
pi>
pi> Can anyone help me solving this issue?


A little bit more information (how does your data looke like, which program 
was used to create them) would be helpfull for us to help you ...

Stefan


signature.asc
Description: This is a digitally signed message part.
__
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] Need some help

2007-10-15 Thread jim holtman
I really depends on what you want to plot.  You can plot the
cumulative count of the sign changes with:

x <- sample(c(0,1), 1000, TRUE)
plot(cumsum(x), type='l')

There are other things you can do.  You can get a rough histogram of
the length of the run by:

> stem(rle(x)$length)

  The decimal point is at the |

  1 | +201
  1 |
  2 | +60
  2 |
  3 | 0
  3 |
  4 | 00
  4 |
  5 | 0
  5 |
  6 | 
  6 |
  7 | 0

With R, almost anything is possible.

On 10/15/07, azzza <[EMAIL PROTECTED]> wrote:
>
> Umm, yes, what you had makes a lot of sense. How would I represent that in a
> plot of the number of sign changes in the to  Y axis, and the toss number
> (from 0 to 1000) in the x-axis?
>
>
>
>
> jholtman wrote:
> >
> > You might want to check out 'rle'.  This will give you the 'lengths'
> > of runs of the same value and therefore when the value changes (sign
> > change?) you can see how often:
> >
> >> x <- sample(c(-1,1), 1000, TRUE)
> >> rle(x)
> > Run Length Encoding
> >   lengths: int [1:483] 2 2 1 4 3 1 1 1 1 2 ...
> >   values : num [1:483] -1 1 -1 1 -1 1 -1 1 -1 1 ...
> >
> > Here was a sample of 1000, and there were 483 changes between the
> > samples.  Is this what you are looking for?
> >
> > On 10/15/07, azzza <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >> Quite helpful indeed. Greatly appreciated.
> >> Another problem I had was trying to simulate an example from my book.
> >> Simulating 1000 coin tosses, and finding the frequency of sign changes.
> >> So
> >> how will we plot this using R? (frequency of sign changes in Y axis)
> >>
> >>
> >>
> >>
> >> Daniel Nordlund wrote:
> >> >
> >> >> -Original Message-
> >> >> From: [EMAIL PROTECTED]
> >> [mailto:[EMAIL PROTECTED]
> >> >> On Behalf
> >> >> Of azzza
> >> >> Sent: Sunday, October 14, 2007 10:21 PM
> >> >> To: r-help@r-project.org
> >> >> Subject: [R] Need some help
> >> >>
> >> >>
> >> >> Hi!
> >> >> I'm taking a course that requires some programming background, but I'm
> >> a
> >> >> complete novice in the field.
> >> >>
> >> >> when asked to generate a list of 20 uniform random numbers, is it
> >> alright
> >> >> if
> >> >> I put in >randu, and just copy-paste the first 20 numbers?? Or is
> >> there,
> >> >> as
> >> >> I suspect, a better way of calling out exactly 20 uniform random
> >> >> numbers??
> >> >>
> >> > See ?runif
> >> >
> >> > rand_nums <- runif(20)
> >> >
> >> >> I'm also unable to solve the following problem:
> >> >> We know that on average 30% of the customers who enter a store make a
> >> >> purchase. Suppose 200
> >> >> people enter the store today. Run a simulation to see how many
> >> purchases
> >> >> we
> >> >> will have today.
> >> >>
> >> > see ?sample
> >> >> number_of_purchases <- sum(sample(c(0,1), 200, prob=c(.70, .30),
> >> >> replace=TRUE))
> >> >
> >> > Hope this is helpful,
> >> >
> >> > Dan
> >> >
> >> > Daniel Nordlund
> >> > Bothell, WA USA
> >> >
> >> > __
> >> > 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.
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Need-some-help-tf4624513.html#a13214128
> >> 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.
> >>
> >
> >
> > --
> > 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.
> >
> >
>
> --
> View this message in context: 
> http://www.nabble.com/Need-some-help-tf4624513.html#a13216156
> 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.
>


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

What is the problem you are trying to solve?

__
R-help@r-project.org mail

[R] residual s.e. by group in mixed model

2007-10-15 Thread Irene Mantzouni
Hi all!
 
I would like to extract the residual standard error by group in a lme() model...
Is there a direct method?
Also, a rather statistical question;
I need to estimate the standard error of the mean(residuals) in a model..is 
this the same as the residual s.e.?
 
Thank you!!
 
Irene

__
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] ERROR while importing data

2007-10-15 Thread pintinho

Stefan, I found what was wrong. Thank you very much anyway!


Stefan Grosse-2 wrote:
> 
> On Monday 15 October 2007 06:43:52 pm pintinho wrote:
> pi> I tried lots of methods to import (read.csv, read.table, RODBC,
>  read.delim) 
> pi> and the same message appears for all these methods. I think
>  it is a bigger 
> pi> problem.
> pi>
> pi> Can anyone help me solving this issue?
> 
> 
> A little bit more information (how does your data looke like, which
> program 
> was used to create them) would be helpfull for us to help you ...
> 
> Stefan
> 
>  
> __
> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13217556
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] Get the last 3 chars of a string

2007-10-15 Thread Sergio Correia
I want to extract the last 3 letters of a string.

So far, I've done this:

> symbol = 'XYZ.VX"
> substr(symbol,nchar(symbol)-2,nchar(symbol))
[1] ".VX"

It works, but the code looks UGLY as hell. Am I missing something? Or
is this the way it's supposed to be?

Thanks,
Sergio

On 10/15/07, pintinho <[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
>
> When I try to import data do R, the following message appears: "\U
> sequences are not supported on Windows".
>
> I tried lots of methods to import (read.csv, read.table, RODBC, read.delim)
> and the same message appears for all these methods. I think it is a bigger
> problem.
>
> Can anyone help me solving this issue?
>
> Thanks a lot.
>
>
>
> --
> View this message in context: 
> http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
> 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-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] Get the last 3 chars of a string

2007-10-15 Thread Gabor Grothendieck
Here is an alternative:

sub(".*(..)$", "\\1", x)

and using strapply in gsubfn its even shorter:

library(gsubfn)
strapply(x, "..$")

On 10/15/07, Sergio Correia <[EMAIL PROTECTED]> wrote:
> I want to extract the last 3 letters of a string.
>
> So far, I've done this:
>
> > symbol = 'XYZ.VX"
> > substr(symbol,nchar(symbol)-2,nchar(symbol))
> [1] ".VX"
>
> It works, but the code looks UGLY as hell. Am I missing something? Or
> is this the way it's supposed to be?
>
> Thanks,
> Sergio
>
> On 10/15/07, pintinho <[EMAIL PROTECTED]> wrote:
> >
> > Hi everyone,
> >
> > When I try to import data do R, the following message appears: "\U
> > sequences are not supported on Windows".
> >
> > I tried lots of methods to import (read.csv, read.table, RODBC, read.delim)
> > and the same message appears for all these methods. I think it is a bigger
> > problem.
> >
> > Can anyone help me solving this issue?
> >
> > Thanks a lot.
> >
> >
> >
> > --
> > View this message in context: 
> > http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
> > 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-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] Get the last 3 chars of a string

2007-10-15 Thread jim holtman
Looks fine by me.  There are lots of other ways of doing it.  Does
this look any nicer?

> x <- c('asdfghk', 'qwerrey')
> gsub(".*(...)$", '\\1', x)
[1] "ghk" "rey"
>


On 10/15/07, Sergio Correia <[EMAIL PROTECTED]> wrote:
> I want to extract the last 3 letters of a string.
>
> So far, I've done this:
>
> > symbol = 'XYZ.VX"
> > substr(symbol,nchar(symbol)-2,nchar(symbol))
> [1] ".VX"
>
> It works, but the code looks UGLY as hell. Am I missing something? Or
> is this the way it's supposed to be?
>
> Thanks,
> Sergio
>
> On 10/15/07, pintinho <[EMAIL PROTECTED]> wrote:
> >
> > Hi everyone,
> >
> > When I try to import data do R, the following message appears: "\U
> > sequences are not supported on Windows".
> >
> > I tried lots of methods to import (read.csv, read.table, RODBC, read.delim)
> > and the same message appears for all these methods. I think it is a bigger
> > problem.
> >
> > Can anyone help me solving this issue?
> >
> > Thanks a lot.
> >
> >
> >
> > --
> > View this message in context: 
> > http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
> > 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-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] Get data from matrix

2007-10-15 Thread pintinho

Hi,

I have a matrix that has a variable number of columns. I do not know, a
priori,  the number of columns.

How can I get a sub matrix, for example, from row 10 to the end of the
columns?

In MatLab I would use something like this: SubMatrix = Matrix[10, 1:end]

Thanks a lot.
-- 
View this message in context: 
http://www.nabble.com/Get-data-from-matrix-tf4629336.html#a13218653
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] Get the last 3 chars of a string

2007-10-15 Thread Sergio Correia
I was hoping to avoid using regex except when necessary (u know what
they say), but I'm beginning to think that's the way things are done
in R.

Thanks

On 10/15/07, jim holtman <[EMAIL PROTECTED]> wrote:
> Looks fine by me.  There are lots of other ways of doing it.  Does
> this look any nicer?
>
> > x <- c('asdfghk', 'qwerrey')
> > gsub(".*(...)$", '\\1', x)
> [1] "ghk" "rey"
> >
>
>
> On 10/15/07, Sergio Correia <[EMAIL PROTECTED]> wrote:
> > I want to extract the last 3 letters of a string.
> >
> > So far, I've done this:
> >
> > > symbol = 'XYZ.VX"
> > > substr(symbol,nchar(symbol)-2,nchar(symbol))
> > [1] ".VX"
> >
> > It works, but the code looks UGLY as hell. Am I missing something? Or
> > is this the way it's supposed to be?
> >
> > Thanks,
> > Sergio
> >
> > On 10/15/07, pintinho <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi everyone,
> > >
> > > When I try to import data do R, the following message appears: "\U
> > > sequences are not supported on Windows".
> > >
> > > I tried lots of methods to import (read.csv, read.table, RODBC, 
> > > read.delim)
> > > and the same message appears for all these methods. I think it is a bigger
> > > problem.
> > >
> > > Can anyone help me solving this issue?
> > >
> > > Thanks a lot.
> > >
> > >
> > >
> > > --
> > > View this message in context: 
> > > http://www.nabble.com/ERROR-while-importing-data-tf4628752.html#a13216707
> > > 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-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] avoiding a loop?

2007-10-15 Thread Tom Sgouros

Hi All:

I feel like there must be a slick R-native no-loop way to get the counts
for the entries in a factor, but I'm unable to see how.  Right now I'm
doing this:

hn.ent<-data.frame(rep(0,length(levels(hnf))), row.names=levels(hnf))
colnames(hn.ent)<-c("count")
for (lev in levels(hnf)) {
  hn.ent[lev,"count"] <- sum(lev == hnf)
}

I'm sure there's a better way, but I don't know it.  Can anyone help?

Also, why does hn.ent[lev,"count"] work and hn.ent$count[lev] does not?

In a related problem, I have a vector of strings, and want a vector of
the strings combined.  That is, I have c("a", "b", "c", "d") and I want
c("ab", "bc", "cd").  I see this is easy with numbers, but paste() is
the only way I see to stick strings together, and I don't get how I'd
use them without a loop.

Many thanks,

 -tom

-- 
 
 tomfool at as220 dot org
 http://sgouros.com  
 http://whatcheer.net

__
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] Bad EMF export

2007-10-15 Thread Prof Brian Ripley
I think you mean savePlot: I have never heard of saveCopy.

We have seen this before, and the problem was the EMF viewer, not the EMF 
file.  So how is this being viewed?

And as ever

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

applies.


On Mon, 15 Oct 2007, Poirier Clement wrote:

>> How are you doing this? Via code?
>
> I just type saveCopy(file, type="emf", etc) after the barplot()
> function ; but using windows commands (file, save as) do the same.
>
>> If so, more than likely you forgot to add:
>>
>>   dev.off()
>>
>> after the code that generates the plot.  If you don't close the device,
>> then parts of the plot are not "flushed" from the cache to the disk file
>> and you are left with an incomplete plot in the file.
>
> Ok but where has the line dev.off() to be placed ? If after the
> barplot() function, the plot disappears and there's nothing to save
> anymore ?
>
> Thank you !
>
>> 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.
>

-- 
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] Rmpi building

2007-10-15 Thread Dirk Eddelbuettel

Sean,

On 15 October 2007 at 12:03, Sean Davis wrote:
| I am trying to build Rmpi on Suse 10.2 linux.  While I would like to use
| the RPM version of liblam-7.1.2, I have not been able to do so.  It
| seems that Rmpi makes some pretty strong assumptions when trying to
| guess the MPI version.  Has anyone successfully built Rmpi against
| lam-7.1.2 recently using R-2.6.0?  If so, can you give some pointers
| about where the libraries and header files need to be to have Rmpi "do
| the right thing"?  I have perused the configure file in the Rmpi
| distribution without much success.

On Debian/Ubuntu, I had to 'freeze' LAM at 7.1.1. It failed with the newer
ones, incl 7.1.4.  I never really looked too hard why ... as the plan was to
migrate to Open MPI as soon as feasible.  And I am happy to report that the
newest Rmpi, with one small additional change that should appear on CRAN
soon, builds fine against Open MPI.  If you can, consider migrating from LAM
to Open MPI.

Hth, Dirk

-- 
Three out of two people have difficulties with fractions.

__
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] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread Charles C. Berry

You knew this?

http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0640.html

I cannot replicate your error. I use n <- 1000 on R-2.6.0, and it still 
works.


Only a guess, but maybe your X setup is out of date. Maybe an update would 
help?

As for why axis triggers this, axis uses all the colors, but image only 
uses (something like) those that fall into the bins shown here:

hist( mat, breaks=n )

As you see there are usually some empty bins and those colors do not get 
rendered till axis() does its thing.

Chuck

On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:

> Dear All
>
> Another one I have touched on before with a much older OS and version.
>
> My sessionInfo() is:
>> sessionInfo()
> R version 2.5.1 (2007-06-27)
> i686-redhat-linux-gnu
>
> locale:
> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
> TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> ENTIFICATION=C
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"
> [7] "base"
>
> other attached packages:
> DetectiV
>   "1.1"
>
> I'm getting the following error message when plotting a quite complex
> graph:
>
> Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> NA,  :
>Error: X11 cannot allocate additional graphics colours.
> Consider using X11 with colortype="pseudo.cube" or "gray".
>
> The problem is I only get it under certain circumstances.  I have some
> quite convoluted test code:
>
> n <- 82
> mat <- matrix(rnorm(n*10), ncol=n)
> fcolors <- terrain.colors(n)
> image(z=mat, axes=FALSE)
> oneis <- 1 / ncol(mat)
> sptl <- oneis / 3
> max <- 1:n * oneis
> min <- c(0, max[1:length(max)-1])
> for (i in 1:n) {
>   axis(side=2, at=c(min[i]-sptl,max[i]+sptl), labels=NA, line=0.9,
> lwd=3, lty=1, tick=TRUE, tck=0, col=fcolors[i],lend=2)
> }
>
> Now, this code works without error on values of n up to and including
> 81, but produces the error when it is 82:
>
> Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> NA,  :
>Error: X11 cannot allocate additional graphics colours.
> Consider using X11 with colortype="pseudo.cube" or "gray".
>
> The issue I have with it is that if I do a normal plot operation, I
> don't get the error!
>
> n <- 82
> fcolors <- terrain.colors(n)
> plot(1:n,1:n, col=fcolors)
>
> Here the plot works, there are no errors and the colours come out fine.
> But when I use the axis command, in the more complex code above, I get
> an error.
>
> The real question I want to know is how can I enable R (or my OS) to
> plot a greater number of colours?  I can plot 820 colours on R under
> windows, probably more, I just plucked 820 out of the air.  I'm guessing
> this is because my windows graphics card can produce that many colours,
> whereas on linux I am limited by what x-windows can produce, but there
> must be some way of increasing the number of colours I can plot using R
> under linux...?
>
> Many thanks
> Mick
>
> The information contained in this message may be confi...{{dropped:15}}

__
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] Get data from matrix

2007-10-15 Thread Henrique Dallazuanna
Hi,

mat[,10:ncol(mat)]

On 15/10/2007, pintinho <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I have a matrix that has a variable number of columns. I do not know, a
> priori,  the number of columns.
>
> How can I get a sub matrix, for example, from row 10 to the end of the
> columns?
>
> In MatLab I would use something like this: SubMatrix = Matrix[10, 1:end]
>
> Thanks a lot.
> --
> View this message in context:
> http://www.nabble.com/Get-data-from-matrix-tf4629336.html#a13218653
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[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] grouping modalities

2007-10-15 Thread Jorge Manuel de Almeida Magalhães

> Dear  Sirs:
>
> Is there a way to group  multiple responses in variables sets. SPSS 
> have this feature: this is possible to group a set of variables by 
> their common categories. I would like to do the same in R.

Example:

my.df = data.frame(var1=c(1,2,2,1,2,2,1,2), var2=c(2,2,1,1,2,2,1,1), 
var3=c(1,2,2,1,1,1,1,2), var4=c(1,1,1,1,2,1,2,1))

I'm looking for a way compute set1 and set2?

set1 = c(5,4) % (var1, var2) modality = 2
set2=c(3,2) % (var3, var4) modality = 2

Thanks a lot

jorge

__
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] Wildcards

2007-10-15 Thread subura

Care to explain how i can use a wildcard expression to "source" all files
ending with .R in a subdirectory ? I've tried something like this
'source(glob2rx("*.R"))' without success.

Thank you
-- 
View this message in context: 
http://www.nabble.com/Wildcards-tf4627981.html#a13214214
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] avoiding a loop?

2007-10-15 Thread jim holtman
?table   to count the factors

> x
[1] "a" "b" "c" "d" "e"
> paste(head(x, -1), tail(x, -1), sep='')
[1] "ab" "bc" "cd" "de"


On 10/15/07, Tom Sgouros <[EMAIL PROTECTED]> wrote:
>
> Hi All:
>
> I feel like there must be a slick R-native no-loop way to get the counts
> for the entries in a factor, but I'm unable to see how.  Right now I'm
> doing this:
>
> hn.ent<-data.frame(rep(0,length(levels(hnf))), row.names=levels(hnf))
> colnames(hn.ent)<-c("count")
> for (lev in levels(hnf)) {
>  hn.ent[lev,"count"] <- sum(lev == hnf)
> }
>
> I'm sure there's a better way, but I don't know it.  Can anyone help?
>
> Also, why does hn.ent[lev,"count"] work and hn.ent$count[lev] does not?
>
> In a related problem, I have a vector of strings, and want a vector of
> the strings combined.  That is, I have c("a", "b", "c", "d") and I want
> c("ab", "bc", "cd").  I see this is easy with numbers, but paste() is
> the only way I see to stick strings together, and I don't get how I'd
> use them without a loop.
>
> Many thanks,
>
>  -tom
>
> --
>  
>  tomfool at as220 dot org
>  http://sgouros.com
>  http://whatcheer.net
>
> __
> 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] Wildcards

2007-10-15 Thread jim holtman
for (i in list.files(pattern=".*\\.R$")) source(i)

On 10/15/07, subura <[EMAIL PROTECTED]> wrote:
>
> Care to explain how i can use a wildcard expression to "source" all files
> ending with .R in a subdirectory ? I've tried something like this
> 'source(glob2rx("*.R"))' without success.
>
> Thank you
> --
> View this message in context: 
> http://www.nabble.com/Wildcards-tf4627981.html#a13214214
> 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.
>


-- 
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] Wildcards

2007-10-15 Thread Sundar Dorai-Raj


subura said the following on 10/15/2007 12:04 PM:
> Care to explain how i can use a wildcard expression to "source" all files
> ending with .R in a subdirectory ? I've tried something like this
> 'source(glob2rx("*.R"))' without success.
> 
> Thank you

Try

R.files <- list.files(my.path, pattern = glob2rx("*.R"), full = TRUE)
invisible(sapply(R.files, source))

HTH,

--sundar

__
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] avoiding a loop?

2007-10-15 Thread tom sgouros

I knew it was simple.  Thanks very much.

 -tom


jim holtman <[EMAIL PROTECTED]> wrote:

> ?table   to count the factors
> 
> > x
> [1] "a" "b" "c" "d" "e"
> > paste(head(x, -1), tail(x, -1), sep='')
> [1] "ab" "bc" "cd" "de"
> 
> 
> On 10/15/07, Tom Sgouros <[EMAIL PROTECTED]> wrote:
> >
> > Hi All:
> >
> > I feel like there must be a slick R-native no-loop way to get the counts
> > for the entries in a factor, but I'm unable to see how.  Right now I'm
> > doing this:
> >
> > hn.ent<-data.frame(rep(0,length(levels(hnf))), row.names=levels(hnf))
> > colnames(hn.ent)<-c("count")
> > for (lev in levels(hnf)) {
> >  hn.ent[lev,"count"] <- sum(lev == hnf)
> > }
> >
> > I'm sure there's a better way, but I don't know it.  Can anyone help?
> >
> > Also, why does hn.ent[lev,"count"] work and hn.ent$count[lev] does not?
> >
> > In a related problem, I have a vector of strings, and want a vector of
> > the strings combined.  That is, I have c("a", "b", "c", "d") and I want
> > c("ab", "bc", "cd").  I see this is easy with numbers, but paste() is
> > the only way I see to stick strings together, and I don't get how I'd
> > use them without a loop.
> >
> > Many thanks,
> >
> >  -tom
> >
> > --
> >  
> >  tomfool at as220 dot org
> >  http://sgouros.com
> >  http://whatcheer.net
> >
> > __
> > 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?
> 


-- 
 
 tomfool at as220 dot org
 http://sgouros.com  
 http://whatcheer.net

__
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] coef se in lme

2007-10-15 Thread Irene Mantzouni
Hi all!
 
How is it possible to estimate  standard errors for coef obtained from lme?
Is there sth like se.coef() for lmer or what is the anaytical solution?
 
Thank you!

__
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] partitioning data

2007-10-15 Thread stephenc
I am trying to train on part of my data and test on another part:

> glm.model = glm(as.factor(h_finished) ~ . , family=binomial,
data=form[1:15,])
> pred =  predict(glm.model, data=form[150001:20,-1], type="response")
> t = table(pred, form[150001:20,1])
Error in table(pred, form[150001:2e+05, 1]) :
all arguments must have the same length

but try as I might my pred has too many lines:

> length(pred)
[1] 15
> length(form[15:20, 1])
[1] 5

[15:20, 1] works in the table function and indeed immediately
above. How can I make the [15:20, 1] work the predict function?

__
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] Rmpi building

2007-10-15 Thread Sean Davis
Dirk Eddelbuettel wrote:
> Sean,
> 
> On 15 October 2007 at 12:03, Sean Davis wrote:
> | I am trying to build Rmpi on Suse 10.2 linux.  While I would like to use
> | the RPM version of liblam-7.1.2, I have not been able to do so.  It
> | seems that Rmpi makes some pretty strong assumptions when trying to
> | guess the MPI version.  Has anyone successfully built Rmpi against
> | lam-7.1.2 recently using R-2.6.0?  If so, can you give some pointers
> | about where the libraries and header files need to be to have Rmpi "do
> | the right thing"?  I have perused the configure file in the Rmpi
> | distribution without much success.
> 
> On Debian/Ubuntu, I had to 'freeze' LAM at 7.1.1. It failed with the newer
> ones, incl 7.1.4.  I never really looked too hard why ... as the plan was to
> migrate to Open MPI as soon as feasible.  And I am happy to report that the
> newest Rmpi, with one small additional change that should appear on CRAN
> soon, builds fine against Open MPI.  If you can, consider migrating from LAM
> to Open MPI.

It does.  I would like to move over to OpenMPI but have been a bit
hesitant because of the support from most third-party softwares with LAM
and because of lack of documentation for OpenMPI.  However, I have to
admit that I haven't looked hard at this option yet.

After some playing around, I got lam-7.1.3 compiled from source into
default locations (after assuring that -fPIC was used) to work with
Rmpi_0.5-4 by doing:

CC=mpicc R CMD INSTALL --clean Rmpi_0.5-4.tar.gz

Thanks for Martin Morgan for a reply off-list to use mpicc, which
removed the headache of trying to line up the directory locations correctly.

Sean

__
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] Strange results converting string to number

2007-10-15 Thread pintinho

Hi,

I am getting a strange result while converting a string vector into numeric
vector:

> Datas[1]
[1] 37315

> as.numeric(Datas[1])
[1] 2

Can anyone help me??
-- 
View this message in context: 
http://www.nabble.com/Strange-results-converting-string-to-number-tf4629811.html#a13220089
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] Strange results converting string to number

2007-10-15 Thread Rolf Turner

On 16/10/2007, at 8:30 AM, pintinho wrote:

>
> Hi,
>
> I am getting a strange result while converting a string vector into  
> numeric
> vector:
>
>> Datas[1]
> [1] 37315
>
>> as.numeric(Datas[1])
> [1] 2
>
> Can anyone help me??

It would seem that ``Datas'' is a ***factor*** and NOT a ``string  
vector''
(i.e. not a vector of mode character).  There is much (repetitive)  
discussion
on this list of how to convert a factor to a numeric vector.  See FAQ  
7.10.

cheers,

Rolf Turner


##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
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] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread michael watson (IAH-C)
Thanks for the response...

My confusion about plot stems from the fact I am plotting 82 points with 82 
colours, so surely all colours get plotted?

As for updating X, I recently installed the latest version of XFree86 for my 
version of linux, RHEL 4.

As for Brian's e-mail you quoted, I do try and look at things like that, but I 
don't know what arguments he refers to:

"Run the X11 device with the arguments stated"

Which arguments, and how do I run my X11 device with them?

I've pretty much had this problem with every version of R on linux, all the way 
from SuSe 8.2 to SuSe 9.2, through to RHEL3 and now RHEL4 - I always have this 
problem.

Perhaps you could tell me which version of X you use to generate 1000 colours 
without getting the error message?  I'm sorry, but what i would really love is 
someone to say "RHEL4?  Aha , you need to install X version foo, available from 
http://www.foo.com/bar.rpm...)

-Original Message-
From: Charles C. Berry [mailto:[EMAIL PROTECTED]
Sent: Mon 15/10/2007 7:54 PM
To: michael watson (IAH-C)
Cc: r-help@r-project.org
Subject: Re: [R] Error: X11 cannot allocate additional graphics colours.
 

You knew this?

http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0640.html

I cannot replicate your error. I use n <- 1000 on R-2.6.0, and it still 
works.


Only a guess, but maybe your X setup is out of date. Maybe an update would 
help?

As for why axis triggers this, axis uses all the colors, but image only 
uses (something like) those that fall into the bins shown here:

hist( mat, breaks=n )



As you see there are usually some empty bins and those colors do not get 
rendered till axis() does its thing.

Chuck

On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:

> Dear All
>
> Another one I have touched on before with a much older OS and version.
>
> My sessionInfo() is:
>> sessionInfo()
> R version 2.5.1 (2007-06-27)
> i686-redhat-linux-gnu
>
> locale:
> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
> TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> ENTIFICATION=C
>
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"
> [7] "base"
>
> other attached packages:
> DetectiV
>   "1.1"
>
> I'm getting the following error message when plotting a quite complex
> graph:
>
> Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> NA,  :
>Error: X11 cannot allocate additional graphics colours.
> Consider using X11 with colortype="pseudo.cube" or "gray".
>
> The problem is I only get it under certain circumstances.  I have some
> quite convoluted test code:
>
> n <- 82
> mat <- matrix(rnorm(n*10), ncol=n)
> fcolors <- terrain.colors(n)
> image(z=mat, axes=FALSE)
> oneis <- 1 / ncol(mat)
> sptl <- oneis / 3
> max <- 1:n * oneis
> min <- c(0, max[1:length(max)-1])
> for (i in 1:n) {
>   axis(side=2, at=c(min[i]-sptl,max[i]+sptl), labels=NA, line=0.9,
> lwd=3, lty=1, tick=TRUE, tck=0, col=fcolors[i],lend=2)
> }
>
> Now, this code works without error on values of n up to and including
> 81, but produces the error when it is 82:
>
> Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> NA,  :
>Error: X11 cannot allocate additional graphics colours.
> Consider using X11 with colortype="pseudo.cube" or "gray".
>
> The issue I have with it is that if I do a normal plot operation, I
> don't get the error!
>
> n <- 82
> fcolors <- terrain.colors(n)
> plot(1:n,1:n, col=fcolors)
>
> Here the plot works, there are no errors and the colours come out fine.
> But when I use the axis command, in the more complex code above, I get
> an error.
>
> The real question I want to know is how can I enable R (or my OS) to
> plot a greater number of colours?  I can plot 820 colours on R under
> windows, probably more, I just plucked 820 out of the air.  I'm guessing
> this is because my windows graphics card can produce that many colours,
> whereas on linux I am limited by what x-windows can produce, but there
> must be some way of increasing the number of colours I can plot using R
> under linux...?
>
> Many thanks
> Mick
>
> The information contained in this message may be =\ co...{{dropped:20}}

__
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] Get data from matrix

2007-10-15 Thread Jorge Ivan Velez Valbuena

SubMatrix = Matrix[10,]


Cheers, 

Jorge 

- Original Message -
From: pintinho <[EMAIL PROTECTED]>
Date: Monday, October 15, 2007 2:17 pm
Subject: [R]  Get data from matrix

> 
> Hi,
> 
> I have a matrix that has a variable number of columns. I do not 
> know, a
> priori,  the number of columns.
> 
> How can I get a sub matrix, for example, from row 10 to the end of the
> columns?
> 
> In MatLab I would use something like this: SubMatrix = Matrix[10, 
> 1:end]
> Thanks a lot.
> -- 
> View this message in context: http://www.nabble.com/Get-data-from-
> matrix-tf4629336.html#a13218653
> 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.htmland 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] help with simple goodness of fit test

2007-10-15 Thread jgant

Hello,
I've read the other posts with regard to "chisq.test" and "goodness of fit"
and am still missing something.
1. I create a simple vector of randomly generated lognormal values with
mean=0 and sd=1;
>d1 <- rlnorm(100,meanlog=0,sdlog=1);
2. I also create a vector of probabilities that are expected for a lognormal
distribution. I suspect this is the culprit.
>pr <- dlnorm(d1,meanlog=0,sdlog=1);
3. I perform the chi-square test on the random data and expected
probabilities.
>c <- chisq.test(d1,p=pr,rescale.p=TRUE);

The output is as follows:
Warning message:
Chi-squared approximation may be incorrect in: chisq.test(d1, p = pr,
rescale.p = TRUE) 
> c;

Chi-squared test for given probabilities

data:  d1 
X-squared = 156992.7, df = 99, p-value < 2.2e-16

I'd expect the "goodness of fit" test to pass, with a high p value. Can
someone tell me why things seem incorrect. Again I apologize for the
simpleton request.

Thanks,
John
-- 
View this message in context: 
http://www.nabble.com/help-with-simple-goodness-of-fit-test-tf4630125.html#a13221078
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] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread Marc Schwartz
This is not a X server version issue.

There are Linux system (not R) display settings that will dictate the
number of simultaneous colors that can be displayed. This will be
dependent upon the display resolution defined and the amount of video
RAM on the graphics card. The higher the display resolution the more
video memory it takes since you have more pixels. The more colors you
want to display simultaneously, the more memory per pixel it takes.

Those concepts, BTW, are the same on Windows and OS X.

So if you are running directly on the RHEL system, check the display
setting to be sure that it is set for a sufficient number of colors.
This would be an administrative task requiring root privilege. Ideally,
you want so-called TrueColor or "Millions of Colors" to be set. This
requires a pixel depth of 24 bpp or 32 bpp, depending upon VRAM
available.

On the other hand, if you are connected remotely to the RHEL server,
using ssh and Xvfb on a server that is not running X, then you will need
to adjust (or have the SysAdmin adjust) the -pixdepths setting on the
RHEL server. This controls the 'bpp' available on the server. 

See 'man Xvfb' for more information for the latter scenario.

HTH,

Marc Schwartz

On Mon, 2007-10-15 at 20:53 +0100, michael watson (IAH-C) wrote:
> Thanks for the response...
> 
> My confusion about plot stems from the fact I am plotting 82 points
> with 82 colours, so surely all colours get plotted?
> 
> As for updating X, I recently installed the latest version of XFree86
> for my version of linux, RHEL 4.
> 
> As for Brian's e-mail you quoted, I do try and look at things like
> that, but I don't know what arguments he refers to:
> 
> "Run the X11 device with the arguments stated"
> 
> Which arguments, and how do I run my X11 device with them?
> 
> I've pretty much had this problem with every version of R on linux,
> all the way from SuSe 8.2 to SuSe 9.2, through to RHEL3 and now RHEL4
> - I always have this problem.
> 
> Perhaps you could tell me which version of X you use to generate 1000
> colours without getting the error message?  I'm sorry, but what i
> would really love is someone to say "RHEL4?  Aha , you need to install
> X version foo, available from http://www.foo.com/bar.rpm...)
> 
> -Original Message-
> From: Charles C. Berry [mailto:[EMAIL PROTECTED]
> Sent: Mon 15/10/2007 7:54 PM
> To: michael watson (IAH-C)
> Cc: r-help@r-project.org
> Subject: Re: [R] Error: X11 cannot allocate additional graphics colours.
>  
> 
> You knew this?
> 
>   http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0640.html
> 
> I cannot replicate your error. I use n <- 1000 on R-2.6.0, and it still 
> works.
> 
> 
> Only a guess, but maybe your X setup is out of date. Maybe an update would 
> help?
> 
> As for why axis triggers this, axis uses all the colors, but image only 
> uses (something like) those that fall into the bins shown here:
> 
>   hist( mat, breaks=n )
> 
> 
> 
> As you see there are usually some empty bins and those colors do not get 
> rendered till axis() does its thing.
> 
> Chuck
> 
> On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:
> 
> > Dear All
> >
> > Another one I have touched on before with a much older OS and version.
> >
> > My sessionInfo() is:
> >> sessionInfo()
> > R version 2.5.1 (2007-06-27)
> > i686-redhat-linux-gnu
> >
> > locale:
> > LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
> > TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
> > 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
> > ENTIFICATION=C
> >
> > attached base packages:
> > [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> > "methods"
> > [7] "base"
> >
> > other attached packages:
> > DetectiV
> >   "1.1"
> >
> > I'm getting the following error message when plotting a quite complex
> > graph:
> >
> > Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> > NA,  :
> >Error: X11 cannot allocate additional graphics colours.
> > Consider using X11 with colortype="pseudo.cube" or "gray".
> >
> > The problem is I only get it under certain circumstances.  I have some
> > quite convoluted test code:
> >
> > n <- 82
> > mat <- matrix(rnorm(n*10), ncol=n)
> > fcolors <- terrain.colors(n)
> > image(z=mat, axes=FALSE)
> > oneis <- 1 / ncol(mat)
> > sptl <- oneis / 3
> > max <- 1:n * oneis
> > min <- c(0, max[1:length(max)-1])
> > for (i in 1:n) {
> > axis(side=2, at=c(min[i]-sptl,max[i]+sptl), labels=NA, line=0.9,
> > lwd=3, lty=1, tick=TRUE, tck=0, col=fcolors[i],lend=2)
> > }
> >
> > Now, this code works without error on values of n up to and including
> > 81, but produces the error when it is 82:
> >
> > Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
> > NA,  :
> >Error: X11 cannot allocate additional graphics colours.
> > Consider using X11 with colortype="pseudo.cube" or "gray".
> >
> > The issue I have with it is that if I do a normal 

Re: [R] coef se in lme

2007-10-15 Thread Irene Mantzouni
Let's say that I can estimate se for ranef by group
and the se for fixef (modifying the se.fixef and se.ranef functions of "arm" 
package for lmer). 
Since, I need the se for coef=ranef+fixef
can I estimate it based on the SEs of ranef and fixef?
 
Thank you!
 
Irene

__
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] coef se in lme

2007-10-15 Thread Doran, Harold
?vcov


-Original Message-
From: [EMAIL PROTECTED] on behalf of Irene Mantzouni
Sent: Mon 10/15/2007 3:20 PM
To: [EMAIL PROTECTED]
Subject: [R] coef se in lme
 
Hi all!
 
How is it possible to estimate  standard errors for coef obtained from lme?
Is there sth like se.coef() for lmer or what is the anaytical solution?
 
Thank you!

__
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] some question about partial prediction in survival

2007-10-15 Thread Terry Therneau
 For numerical accuracy, the coxph routine centers each covariate before doing 
the computation.  All of the downstream results (predict, survfit, etc) use 
this 
centered data.  
Terry Therneau

__
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] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread Paul Gilbert
(This could be fixed, it has not happened to me in a long time, but I 
will mention it mainly because it is not something you are likely to 
think of.)

It used to be that the X colours might be defined by the first 
application that needed them, so if the systems administrator happened 
to start up X and mozilla on the server, especially if the server had 
limited graphics, then that could potentially cause this problem. I 
never really understood why it would be like this, so probably it is 
fixed. (This was not an R bug.)

Paul

Marc Schwartz wrote:
> This is not a X server version issue.
> 
> There are Linux system (not R) display settings that will dictate the
> number of simultaneous colors that can be displayed. This will be
> dependent upon the display resolution defined and the amount of video
> RAM on the graphics card. The higher the display resolution the more
> video memory it takes since you have more pixels. The more colors you
> want to display simultaneously, the more memory per pixel it takes.
> 
> Those concepts, BTW, are the same on Windows and OS X.
> 
> So if you are running directly on the RHEL system, check the display
> setting to be sure that it is set for a sufficient number of colors.
> This would be an administrative task requiring root privilege. Ideally,
> you want so-called TrueColor or "Millions of Colors" to be set. This
> requires a pixel depth of 24 bpp or 32 bpp, depending upon VRAM
> available.
> 
> On the other hand, if you are connected remotely to the RHEL server,
> using ssh and Xvfb on a server that is not running X, then you will need
> to adjust (or have the SysAdmin adjust) the -pixdepths setting on the
> RHEL server. This controls the 'bpp' available on the server. 
> 
> See 'man Xvfb' for more information for the latter scenario.
> 
> HTH,
> 
> Marc Schwartz
> 
> On Mon, 2007-10-15 at 20:53 +0100, michael watson (IAH-C) wrote:
>> Thanks for the response...
>>
>> My confusion about plot stems from the fact I am plotting 82 points
>> with 82 colours, so surely all colours get plotted?
>>
>> As for updating X, I recently installed the latest version of XFree86
>> for my version of linux, RHEL 4.
>>
>> As for Brian's e-mail you quoted, I do try and look at things like
>> that, but I don't know what arguments he refers to:
>>
>> "Run the X11 device with the arguments stated"
>>
>> Which arguments, and how do I run my X11 device with them?
>>
>> I've pretty much had this problem with every version of R on linux,
>> all the way from SuSe 8.2 to SuSe 9.2, through to RHEL3 and now RHEL4
>> - I always have this problem.
>>
>> Perhaps you could tell me which version of X you use to generate 1000
>> colours without getting the error message?  I'm sorry, but what i
>> would really love is someone to say "RHEL4?  Aha , you need to install
>> X version foo, available from http://www.foo.com/bar.rpm...)
>>
>> -Original Message-
>> From: Charles C. Berry [mailto:[EMAIL PROTECTED]
>> Sent: Mon 15/10/2007 7:54 PM
>> To: michael watson (IAH-C)
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Error: X11 cannot allocate additional graphics colours.
>>  
>>
>> You knew this?
>>
>>  http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0640.html
>>
>> I cannot replicate your error. I use n <- 1000 on R-2.6.0, and it still 
>> works.
>>
>>
>> Only a guess, but maybe your X setup is out of date. Maybe an update would 
>> help?
>>
>> As for why axis triggers this, axis uses all the colors, but image only 
>> uses (something like) those that fall into the bins shown here:
>>
>>  hist( mat, breaks=n )
>>
>>
>>
>> As you see there are usually some empty bins and those colors do not get 
>> rendered till axis() does its thing.
>>
>> Chuck
>>
>> On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:
>>
>>> Dear All
>>>
>>> Another one I have touched on before with a much older OS and version.
>>>
>>> My sessionInfo() is:
 sessionInfo()
>>> R version 2.5.1 (2007-06-27)
>>> i686-redhat-linux-gnu
>>>
>>> locale:
>>> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
>>> TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
>>> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
>>> ENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
>>> "methods"
>>> [7] "base"
>>>
>>> other attached packages:
>>> DetectiV
>>>   "1.1"
>>>
>>> I'm getting the following error message when plotting a quite complex
>>> graph:
>>>
>>> Error in axis(side = 2, at = c(min[i] - sptl, max[i] + sptl), labels =
>>> NA,  :
>>>Error: X11 cannot allocate additional graphics colours.
>>> Consider using X11 with colortype="pseudo.cube" or "gray".
>>>
>>> The problem is I only get it under certain circumstances.  I have some
>>> quite convoluted test code:
>>>
>>> n <- 82
>>> mat <- matrix(rnorm(n*10), ncol=n)
>>> fcolors <- terrain.colors(n)
>>> image(z=mat, axes=FALSE)
>>> oneis <- 1 / n

Re: [R] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread michael watson (IAH-C)
Thank you both.
 
I use R on linux both remotely (over CGI) and I log in using Exceed from 
windows.  The problem occurs over both.
 
I don't run Xvfb (though I can do as I have done in the past).
 
I have root priveleges so I will look and see what the settings are, though I 
don't think my pet sys/admin will have changed the defaults



From: [EMAIL PROTECTED] on behalf of Paul Gilbert
Sent: Mon 15/10/2007 10:13 PM
To: r-help@r-project.org
Subject: Re: [R] Error: X11 cannot allocate additional graphics colours.



(This could be fixed, it has not happened to me in a long time, but I
will mention it mainly because it is not something you are likely to
think of.)

It used to be that the X colours might be defined by the first
application that needed them, so if the systems administrator happened
to start up X and mozilla on the server, especially if the server had
limited graphics, then that could potentially cause this problem. I
never really understood why it would be like this, so probably it is
fixed. (This was not an R bug.)

Paul

Marc Schwartz wrote:
> This is not a X server version issue.
>
> There are Linux system (not R) display settings that will dictate the
> number of simultaneous colors that can be displayed. This will be
> dependent upon the display resolution defined and the amount of video
> RAM on the graphics card. The higher the display resolution the more
> video memory it takes since you have more pixels. The more colors you
> want to display simultaneously, the more memory per pixel it takes.
>
> Those concepts, BTW, are the same on Windows and OS X.
>
> So if you are running directly on the RHEL system, check the display
> setting to be sure that it is set for a sufficient number of colors.
> This would be an administrative task requiring root privilege. Ideally,
> you want so-called TrueColor or "Millions of Colors" to be set. This
> requires a pixel depth of 24 bpp or 32 bpp, depending upon VRAM
> available.
>
> On the other hand, if you are connected remotely to the RHEL server,
> using ssh and Xvfb on a server that is not running X, then you will need
> to adjust (or have the SysAdmin adjust) the -pixdepths setting on the
> RHEL server. This controls the 'bpp' available on the server.
>
> See 'man Xvfb' for more information for the latter scenario.
>
> HTH,
>
> Marc Schwartz
>
> On Mon, 2007-10-15 at 20:53 +0100, michael watson (IAH-C) wrote:
>> Thanks for the response...
>>
>> My confusion about plot stems from the fact I am plotting 82 points
>> with 82 colours, so surely all colours get plotted?
>>
>> As for updating X, I recently installed the latest version of XFree86
>> for my version of linux, RHEL 4.
>>
>> As for Brian's e-mail you quoted, I do try and look at things like
>> that, but I don't know what arguments he refers to:
>>
>> "Run the X11 device with the arguments stated"
>>
>> Which arguments, and how do I run my X11 device with them?
>>
>> I've pretty much had this problem with every version of R on linux,
>> all the way from SuSe 8.2 to SuSe 9.2, through to RHEL3 and now RHEL4
>> - I always have this problem.
>>
>> Perhaps you could tell me which version of X you use to generate 1000
>> colours without getting the error message?  I'm sorry, but what i
>> would really love is someone to say "RHEL4?  Aha , you need to install
>> X version foo, available from http://www.foo.com/bar.rpm...)
>>
>> -Original Message-
>> From: Charles C. Berry [mailto:[EMAIL PROTECTED]
>> Sent: Mon 15/10/2007 7:54 PM
>> To: michael watson (IAH-C)
>> Cc: r-help@r-project.org
>> Subject: Re: [R] Error: X11 cannot allocate additional graphics colours.
>> 
>>
>> You knew this?
>>
>>  http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0640.html
>>
>> I cannot replicate your error. I use n <- 1000 on R-2.6.0, and it still
>> works.
>>
>>
>> Only a guess, but maybe your X setup is out of date. Maybe an update would
>> help?
>>
>> As for why axis triggers this, axis uses all the colors, but image only
>> uses (something like) those that fall into the bins shown here:
>>
>>  hist( mat, breaks=n )
>>
>>
>>
>> As you see there are usually some empty bins and those colors do not get
>> rendered till axis() does its thing.
>>
>> Chuck
>>
>> On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:
>>
>>> Dear All
>>>
>>> Another one I have touched on before with a much older OS and version.
>>>
>>> My sessionInfo() is:
 sessionInfo()
>>> R version 2.5.1 (2007-06-27)
>>> i686-redhat-linux-gnu
>>>
>>> locale:
>>> LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U
>>> TF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-
>>> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_ID
>>> ENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
>>> "methods"
>>> [7] "base"
>>>
>>> other attached packages:
>>> DetectiV
>>>   "1.1"
>>>
>>> I'm gettin

Re: [R] Make playwith a default graphic device

2007-10-15 Thread Deepayan Sarkar
On 10/15/07, Felix Andrews <[EMAIL PROTECTED]> wrote:
> My previous suggestion was inconsistent with the Trellis/Lattice idea
> of creating a trellis object without necessarily creating a plot. And
> it also interfered with attempts to plot to a file device. So here is
> a better solution, based on replacing `print.trellis`, though it is
> still basically a hack.
>
> library(lattice)
> library(plotAndPlayGTK)
>
> setAutoPlaywith <- function(on=TRUE) {
> if (on == FALSE) {
> return(rm(print.trellis, envir=.GlobalEnv))
> }
> assign("print.trellis",
> function(x, position = NULL, split = NULL, more = FALSE, newpage = 
> TRUE,
> packet.panel = packet.panel.default, draw.in = NULL, ...)
> {
> dev.interactive2 <- function(orNone) dev.interactive(orNone) 
> ||
> (interactive() && .Device == "null device" &&
> getOption("device") == "Cairo")
> playing <- 'plotAndPlayUpdate' %in% sapply(sys.calls(), 
> function(x)
> ifelse(is.symbol(x[[1]]), toString(x[[1]]), ""))
> new <- newpage && is.null(draw.in) &&
> !lattice:::lattice.getStatus("print.more")
> if (require(plotAndPlayGTK, quietly=TRUE) &&
> dev.interactive2(TRUE) && !playing && new) {
> # starting a new plot on an interactive device
> eval.parent(call("playwith", x$call), n=2)
> return(invisible())
> }
> # call the real `print.trellis`, from lattice package
> ocall <- sys.call()
> ocall[[1]] <- quote(lattice:::print.trellis)
> eval.parent(ocall)
> }, envir=.GlobalEnv)
> invisible()
> }
>
> setAutoPlaywith(TRUE)
> xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)
> setAutoPlaywith(FALSE)
> xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)
>
> Deepayan, what do you think -- would it be appropriate to make a
> Lattice option for something like this?

In the next update (today or tomorrow), I'll have print.trellis changed to

print.trellis <- function(x, ...)
{
printFunction <- lattice.getOption("print.function")
if (is.null(printFunction)) printFunction <- plot.trellis
printFunction(x, ...)
invisible(x)
}

With this, you could do:

> lattice.options(print.function = function(x, ...) print(summary(x, ...)))
> xyplot(Sepal.Length ~ Sepal.Width | Species, data=iris)

Call:
xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris)

Number of observations:
Species
setosa versicolor  virginica
50 50 50

and plotAndPlayGTK could have:


plotAndPlayGTK.trellis <-
function(x, position = NULL, split = NULL, more = FALSE, newpage = TRUE,
 packet.panel = packet.panel.default, draw.in = NULL, ...)
{
dev.interactive2 <- function(orNone)
{
dev.interactive(orNone) ||
(interactive() && .Device == "null device" &&
 getOption("device") == "Cairo")
}
playing <-
'plotAndPlayUpdate' %in% sapply(sys.calls(),
function(x)
ifelse(is.symbol(x[[1]]),
   toString(x[[1]]), ""))
new <- (newpage && is.null(draw.in) &&
!lattice:::lattice.getStatus("print.more"))
if (require(plotAndPlayGTK, quietly=TRUE) &&
dev.interactive2(TRUE) && !playing && new) {
## starting a new plot on an interactive device
eval.parent(call("playwith", x$call), n=2)
return(invisible())
}
## call the real `print.trellis`, from lattice package
ocall <- sys.call()
ocall[[1]] <- quote(plot)
eval.parent(ocall)
}


setAutoPlaywith <- function(on=TRUE)
{
require("lattice")
lattice.options(print.function = if (on) plotAndPlayGTK.trellis
else NULL)
}


-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] Error: X11 cannot allocate additional graphics colours.

2007-10-15 Thread Charles C. Berry
On Mon, 15 Oct 2007, michael watson (IAH-C) wrote:

> Thanks for the response...
>
> My confusion about plot stems from the fact I am plotting 82 points with 82 
> colours, so surely all colours get plotted?
>
[snip]

No. That was the point of this bit:

>
>   hist( mat, breaks=n )
>

Or if that is too obscure, try this a few times:

> mat <- matrix(rnorm(5),nc=1)
> image(mat,col=terrain.colors(5))


Usually you will see fewer than 5 colors.

---

Sorry about the misdirection about X-server issues, which Marc corrected.

---

I did not see any pointers to

X11( colortype = "pseudo.cube" )

which the error message was pointing you to. see ?X11 for more.

[snip]

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] Linear regression and slope from 1

2007-10-15 Thread daniel guertin

Dear R-Users,

I am new to R, so please excuse the ignorance.

I have data:
x (2.14, 2.41, 1.09, 0.17, 8.18)
y (3.81, 5.13, 0.63, 0.75, 6.35)

I would like to use simple linear regression and test 2 things:
1) slope of line of best fit is statistically different from 1
2) y-intercept is statically different from 0

Could anyone provide me with the R terminology to do this?

Thanks so much,
Dan


_
[[replacing trailing spam]]

ilnews
[[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] Distance matrix in SpDep-package

2007-10-15 Thread Elke Moons
Hello everybody,

 

I would like to use the SpDep-package (especially the Local Moran index
analysis and the Getis-Ord statistics) in R for analysing my data. However,
I don't have x-y coordinates, but my data is in a distance matrix format. Is
it possible to use the SpDep package with predefined distances as well
instead of letting the program determining the distance itself by the
function dnearneigh based on x-y coordinates. Or is there another package
that can transform a distance matrix into "fake" x-y coordinates, so that
the SpDep-package can work with it?

Thank you very much for your answer.

 

Kind regards,

 

 

Elke Moons

 

 

__

Elke Moons, PhD

Transportation Research Institute/

Instituut voor Mobiliteit (IMOB)

Universiteit Hasselt

Wetenschapspark 5, bus 6

3590 Diepenbeek

Belgium

Tel. +32-11- 26.91.26

Fax. +32-11-26.91.99

E-mail:   [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] Need help ploting time series(2)

2007-10-15 Thread gsmkb86

hi:
Yesterday I post a message about hoy to plot a time series, but someone told
me to post more information about the file so here it is:
the file was read using read.table and the name is list. When I use
str(list) it tells the following variables:
YEAR int: 2003,2003,20032004
MONTH int:1,1,1,1,
DAY:int 1,1,1,...
STATE: factor with 51 levels. 
SALES: int (sales per day)
The reason why the month day and year are repeated is because there is 1
observation on day 1 month 1 and year 1 for each state. 
What i want to do is plot a time series for every state (each separated but
in the same page) being on Y axis the sales and on the X axis the time. Any
help is greatly appreciated.
Thanks in advance.
-- 
View this message in context: 
http://www.nabble.com/Need-help-ploting-time-series%282%29-tf4628022.html#a13214340
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] Need some help

2007-10-15 Thread azzza


Thanks Jholtman.
However, the plot didnt come out the way I envisone dit to be. On the Y
axis, i should have sign changes in 1000 tosses, the range being from
negative to postitive, and a straight horizontal line across  y=0. The
X-axis should have the toss number, range 0-1000

I'm glad u mentioned rle(x)works perfect!



jholtman wrote:
> 
> I really depends on what you want to plot.  You can plot the
> cumulative count of the sign changes with:
> 
> x <- sample(c(0,1), 1000, TRUE)
> plot(cumsum(x), type='l')
> 
> There are other things you can do.  You can get a rough histogram of
> the length of the run by:
> 
>> stem(rle(x)$length)
> 
>   The decimal point is at the |
> 
>   1 |
> +201
>   1 |
>   2 |
> +60
>   2 |
>   3 | 0
>   3 |
>   4 | 00
>   4 |
>   5 | 0
>   5 |
>   6 | 
>   6 |
>   7 | 0
> 
> With R, almost anything is possible.
> 
> On 10/15/07, azzza <[EMAIL PROTECTED]> wrote:
>>
>> Umm, yes, what you had makes a lot of sense. How would I represent that
>> in a
>> plot of the number of sign changes in the to  Y axis, and the toss number
>> (from 0 to 1000) in the x-axis?
>>
>>
>>
>>
>> jholtman wrote:
>> >
>> > You might want to check out 'rle'.  This will give you the 'lengths'
>> > of runs of the same value and therefore when the value changes (sign
>> > change?) you can see how often:
>> >
>> >> x <- sample(c(-1,1), 1000, TRUE)
>> >> rle(x)
>> > Run Length Encoding
>> >   lengths: int [1:483] 2 2 1 4 3 1 1 1 1 2 ...
>> >   values : num [1:483] -1 1 -1 1 -1 1 -1 1 -1 1 ...
>> >
>> > Here was a sample of 1000, and there were 483 changes between the
>> > samples.  Is this what you are looking for?
>> >
>> > On 10/15/07, azzza <[EMAIL PROTECTED]> wrote:
>> >>
>> >>
>> >> Quite helpful indeed. Greatly appreciated.
>> >> Another problem I had was trying to simulate an example from my book.
>> >> Simulating 1000 coin tosses, and finding the frequency of sign
>> changes.
>> >> So
>> >> how will we plot this using R? (frequency of sign changes in Y axis)
>> >>
>> >>
>> >>
>> >>
>> >> Daniel Nordlund wrote:
>> >> >
>> >> >> -Original Message-
>> >> >> From: [EMAIL PROTECTED]
>> >> [mailto:[EMAIL PROTECTED]
>> >> >> On Behalf
>> >> >> Of azzza
>> >> >> Sent: Sunday, October 14, 2007 10:21 PM
>> >> >> To: r-help@r-project.org
>> >> >> Subject: [R] Need some help
>> >> >>
>> >> >>
>> >> >> Hi!
>> >> >> I'm taking a course that requires some programming background, but
>> I'm
>> >> a
>> >> >> complete novice in the field.
>> >> >>
>> >> >> when asked to generate a list of 20 uniform random numbers, is it
>> >> alright
>> >> >> if
>> >> >> I put in >randu, and just copy-paste the first 20 numbers?? Or is
>> >> there,
>> >> >> as
>> >> >> I suspect, a better way of calling out exactly 20 uniform random
>> >> >> numbers??
>> >> >>
>> >> > See ?runif
>> >> >
>> >> > rand_nums <- runif(20)
>> >> >
>> >> >> I'm also unable to solve the following problem:
>> >> >> We know that on average 30% of the customers who enter a store make
>> a
>> >> >> purchase. Suppose 200
>> >> >> people enter the store today. Run a simulation to see how many
>> >> purchases
>> >> >> we
>> >> >> will have today.
>> >> >>
>> >> > see ?sample
>> >> >> number_of_purchases <- sum(sample(c(0,1), 200, prob=c(.70, .30),
>> >> >> replace=TRUE))
>> >> >
>> >> > Hope this is helpful,
>> >> >
>> >> > Dan
>> >> >
>> >> > Daniel Nordlund
>> >> > Bothell, WA USA
>> >> >
>> >> > __
>> >> > 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.
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Need-some-help-tf4624513.html#a13214128
>> >> 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.
>> >>
>> >
>> >
>> > --
>> > 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.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/N

[R] survreg's algorithm

2007-10-15 Thread Gad Abraham
Hi,

I'm using survreg() from the survival package for parametric survival 
regression (modelling inter-arrival times of patients to a waiting list 
as exponentially distributed, with various regressors such as queue size 
and season).

Does anyone know which algorithm survreg() uses for this?

Thanks,
Gad

-- 
Gad Abraham
Department of Mathematics and Statistics
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.ms.unimelb.edu.au/~gabraham

__
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] Need help ploting time series(2)

2007-10-15 Thread jim holtman
Here are a couple of ways that you can do it:

x <- expand.grid(YEAR=c(2003,2004), MONTH=1:12, DAY=1, STATE=LETTERS[1:4])
x$SALES <- runif(nrow(x), 10, 100)
# add date for plotting
x$date <- ISOdate(x$YEAR, x$MONTH, x$DAY)
# sort into date order for plotting
x <- x[order(x$date),]
# you can use lattice
require(lattice)
xyplot(x$SALES ~ x$date | x$STATE, type='l')
# or you can use base plot
par(mfrow=c(2,2))
invisible(lapply(split(x, x$STATE), function(.state){
plot(.state$date, .state$SALES, type='l', main=.state$STATE[1])
}))



On 10/15/07, gsmkb86 <[EMAIL PROTECTED]> wrote:
>
> hi:
> Yesterday I post a message about hoy to plot a time series, but someone told
> me to post more information about the file so here it is:
> the file was read using read.table and the name is list. When I use
> str(list) it tells the following variables:
> YEAR int: 2003,2003,20032004
> MONTH int:1,1,1,1,
> DAY:int 1,1,1,...
> STATE: factor with 51 levels.
> SALES: int (sales per day)
> The reason why the month day and year are repeated is because there is 1
> observation on day 1 month 1 and year 1 for each state.
> What i want to do is plot a time series for every state (each separated but
> in the same page) being on Y axis the sales and on the X axis the time. Any
> help is greatly appreciated.
> Thanks in advance.
> --
> View this message in context: 
> http://www.nabble.com/Need-help-ploting-time-series%282%29-tf4628022.html#a13214340
> 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.
>


-- 
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] survreg's algorithm

2007-10-15 Thread Gad Abraham
Gad Abraham wrote:
> Hi,
> 
> I'm using survreg() from the survival package for parametric survival 
> regression (modelling inter-arrival times of patients to a waiting list 
> as exponentially distributed, with various regressors such as queue size 
> and season).
> 
> Does anyone know which algorithm survreg() uses for this?
> 
> Thanks,
> Gad
> 

Due diligence:

I have actually looked at ?survreg and friends, and at the source code; 
except for a brief mention of a "sparse Newton-Rapshon algorithm" in the 
frailty model code, I couldn't find anything substantive.


-- 
Gad Abraham
Department of Mathematics and Statistics
The University of Melbourne
Parkville 3010, Victoria, Australia
email: [EMAIL PROTECTED]
web: http://www.ms.unimelb.edu.au/~gabraham

__
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] Linear regression and slope from 1

2007-10-15 Thread Ben Bolker



Dan-157 wrote:
> 
> 
> Dear R-Users,
> 
> I am new to R, so please excuse the ignorance.
> 
> I have data:
> x (2.14, 2.41, 1.09, 0.17, 8.18)
> y (3.81, 5.13, 0.63, 0.75, 6.35)
> 
> I would like to use simple linear regression and test 2 things:
> 1) slope of line of best fit is statistically different from 1
> 2) y-intercept is statically different from 0
> 

x <- c(2.14, 2.41, 1.09, 0.17, 8.18)
y <- c(3.81, 5.13, 0.63, 0.75, 6.35) 

lm(y~x)## regular regression
L1 <- lm(y~x+offset(x))  ## regression, tested vs slope=1
summary(L1)

  Ben Bolker

-- 
View this message in context: 
http://www.nabble.com/Linear-regression-and-slope-from-1-tf4631389.html#a13226196
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] Bootstrapping Contrasts for Repeated Measures ANOVA

2007-10-15 Thread Alex Baugh
I have executed a Repeated Measures ANOVA with one DV (latency) and
one within subject factor (acoustic condtion: 3 levels) by
bootstrapping my sampling distribution of F from the empirical sample
distribution. I chose to resample because the sample distribution
deviates from normality a lot.

The overall F is significant and now I wish to decompose this with
contrasts to ask if latencies to acoustic condition #1 are different
than acoustic condition #2 + #3.

However, I don't know where to begin to write a program to do
contrasts with a resampling technique.

Any ideas would be terrific.

Thanks,
Alex




-- 
Alexander T Baugh
Section of Integrative Biology
Univ. of Texas at Austin C0930
Austin, TX 78712
http://darktropic.blogspot.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] Need some help

2007-10-15 Thread Daniel Nordlund
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of azzza
> Sent: Monday, October 15, 2007 6:06 PM
> To: r-help@r-project.org
> Subject: Re: [R] Need some help
> 
> 
> 
> Thanks Jholtman.
> However, the plot didnt come out the way I envisone dit to be. On the Y
> axis, i should have sign changes in 1000 tosses, the range being from
> negative to postitive, and a straight horizontal line across  y=0. The
> X-axis should have the toss number, range 0-1000
> 

You would probably get more prompt and useful help if you would provide a 
small, self- contained example of what you wanted (maybe small enough that you 
could work it by hand).  Also, if you provided some code using the help that 
you have already received, that would show that you are trying to solve the 
problem yourself and others could help with the specific R program issues that 
you are having.  For example, it is not clear to me if you want to count the 
first run of tosses as 0 or 1 sign change.  I will assume it is zero.  So with 
that assumption, does this get you what you want?

n <- 1000
x <- sample(c(0,1), n, TRUE)
y <- rle(x)

z <- rep(1:length(y$lengths),y$lengths)
plot(1:n,z-1)

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA

__
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] partitioning data [SEC=UNCLASSIFIED]

2007-10-15 Thread Crombie, Joe
Hi Stephen,

Check the help for predict.glm().  The argument for passing new data is
actually 'newdata', as in:

> pred =  predict(glm.model, newdata=form[150001:20,-1], 
> type="response")
 
Cheers  Joe

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, 16 October 2007 5:30 AM
To: [EMAIL PROTECTED]
Subject: [R] partitioning data

I am trying to train on part of my data and test on another part:

> glm.model = glm(as.factor(h_finished) ~ . , family=binomial,
data=form[1:15,])
> pred =  predict(glm.model, data=form[150001:20,-1],
> type="response") t = table(pred, form[150001:20,1])
Error in table(pred, form[150001:2e+05, 1]) :
all arguments must have the same length

but try as I might my pred has too many lines:

> length(pred)
[1] 15
> length(form[15:20, 1])
[1] 5

[15:20, 1] works in the table function and indeed immediately
above. How can I make the [15:20, 1] work the predict function?

__
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.

--IMPORTANT - This message has been issued by The Department of 
Agriculture, Fisheries and Forestry (DAFF). The information transmitted is for 
the use of the intended recipient only and may contain confidential and/or 
legally privileged material. It is your responsibility to check any attachments 
for viruses and defects before opening or sending them on. 

Any reproduction, publication, communication, re-transmission, disclosure, 
dissemination or other use of the information contained in this e-mail by 
persons or entities other than the intended recipient is prohibited. The taking 
of any action in reliance upon this information by persons or entities other 
than the intended recipient is prohibited. If you have received this e-mail in 
error please notify the sender and delete all copies of this transmission 
together with any attachments. If you have received this e-mail as part of a 
valid mailing list and no longer want to receive a message such as this one 
advise the sender by return e-mail accordingly. Only e-mail correspondence 
which includes this footer, has been authorised by DAFF 
--

__
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] survreg's algorithm

2007-10-15 Thread Simon Blomberg
Did you look at the C source code? There are 4 different variants
(survregN.c, where N <- 2:5) , depending on whether the distribution is
built-in or not, and penalized likelihood is being used or not. They all
look like NR to me, but I confess I haven't read the code in extreme
detail. It is well commented, however.

Cheers,

Simon.

PS Try figuring out what 
is actually doing by reading the source code. Take that, large software
corporations! The future belongs to R!

On Tue, 2007-10-16 at 13:12 +1000, Gad Abraham wrote:
> Gad Abraham wrote:
> > Hi,
> > 
> > I'm using survreg() from the survival package for parametric survival 
> > regression (modelling inter-arrival times of patients to a waiting list 
> > as exponentially distributed, with various regressors such as queue size 
> > and season).
> > 
> > Does anyone know which algorithm survreg() uses for this?
> > 
> > Thanks,
> > Gad
> > 
> 
> Due diligence:
> 
> I have actually looked at ?survreg and friends, and at the source code; 
> except for a brief mention of a "sparse Newton-Rapshon algorithm" in the 
> frailty model code, I couldn't find anything substantive.
> 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506 
email: S.Blomberg1_at_uq.edu.au

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.

__
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.


  1   2   >