Re: [R] Compress (gzip) a pdf device

2009-10-02 Thread Gábor Csárdi
Rainer,

if you are willing to patch the R source, then a solution might be the
R connection patch, see
http://wiki.r-project.org/rwiki/doku.php?id=developers:r_connections_api
It is a bit outdated, but with a little work I could use it for R
2.9.2 and works fine.

Best,
Gabor

On Fri, Oct 2, 2009 at 8:54 AM, Rainer M Krug  wrote:
> On Thu, Oct 1, 2009 at 7:26 PM, Martin Renner <
> martin.ren...@stonebow.otago.ac.nz> wrote:
>
>> try pdftk. Not quite on the fly but should do the trick. (I saw this on
>> this list a little while ago)
>>
>
> pdftk compresses the pdf internally - it is still a pdf, can be opened as a
> pdf, and is not an externally compressed pdf (pdf in an archive).
> Below is the approach which I am using, but as stated earlier, if somebody
> could provide a way of only doing dev.off() whhich then calls pdfComp() with
> the filename, I would be glad to know. Otherwise.
>
> Rainer
>
>
>>
>> pdfComp <- function (pdfname){
>>  if (0){
>>    x <- tempfile()
>>    system (paste ("mv", pdfname, x))
>>    system (paste ("pdftk", x, "output", pdfname, "compress"))
>>    unlink (x)
>>  }
>> }
>>
>> pdf ("test.pdf")
>> plot (1:10)
>> dev.off()
>> pdfComp ("test.pdf")
>>
>>
>> On 30 Sep 2009, at 00:25 , Rainer M Krug wrote:
>>
>>  2009/9/30 Daniele Amberti 
>>>
>>>  I have not found an easy way to compress a file on filesystem.
 Especially I'd like to compress a pdf from pdf() function/device. Is it
 possible to compress It on the flight?
 I'd like to do something like:
 pdf(gzipconnection())
 dev.off()


  I guess this boils down to a question I asked some time ago concerning
>>> getting the filename of a pdf() device, as I wanted to create a compressed
>>> pdf from the uncompressed pdf created by R (not "zipping" the pdf).
>>> It does not seem to be possible, at least I did not get any response which
>>> I
>>> could use to implement my idea (create my dev.off(), which calls dev.off()
>>> and afterwards compresses the pdf by using the file name).
>>>
>>> If you find a solution, please let me know.
>>>
>>> Cheers,
>>>
>>> Rainer
>>>
>>> If It is not possible, how can I create a gzip with the pdf?
>>>

 Thanks
 Daniele A.



 
 ORS Srl

 Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy
 Tel. +39 0173 620211
 Fax. +39 0173 620299 / +39 0173 433111
 Web Site www.ors.it



 
 Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi
 allegati ? vietato e potrebbe costituire reato.
 Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se
 provvedesse alla distruzione dello stesso
 e degli eventuali allegati.
 Opinioni, conclusioni o altre informazioni riportate nella e-mail, che
 non
 siano relative alle attivit? e/o
 alla missione aziendale di O.R.S. Srl si intendono non attribuibili alla
 societ? stessa, n? la impegnano in alcun modo.

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


>>>
>>>
>>> --
>>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
>>> Biology,
>>> UCT), Dipl. Phys. (Germany)
>>>
>>> Centre of Excellence for Invasion Biology
>>> Natural Sciences Building
>>> Office Suite 2039
>>> Stellenbosch University
>>> Main Campus, Merriman Avenue
>>> Stellenbosch
>>> South Africa
>>>
>>> Cell:           +27 - (0)83 9479 042
>>> Fax:            +27 - (0)86 516 2782
>>> Fax:            +49 - (0)721 151 334 888
>>> email:          rai...@krugs.de
>>>
>>> Skype:          RMkrug
>>> Google:         r.m.k...@gmail.com
>>>
>>>        [[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.
>>>
>>
>>
>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
> UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Natural Sciences Building
> Office Suite 2039
> Stellenbosch University
> Main Campus, Merriman Avenue
> Stellenbosch
> South Africa
>
> Cell:           +27 - (0)83 9479 042
> Fax:            +27 - (0)86 516 2782
> Fax:            +49 - (0)721 151 334 888
> email:          rai...@krugs.de
>
> Skype:          RMkrug
> Google:         r.m.k...@gmail.com
>
>        [[alternative HTML version deleted]]
>
> 

[R] Robust ANOVA with variance heterogeneity

2009-10-02 Thread Maike Luhmann
Dear list members, 

I am looking for an alternative function for a two-way ANOVA in the case of
variance heterogeneity. For one-way ANOVA, I found oneway.test(), but I
didn't find anything alike for two-way ANOVA. Does anyone have a suggestion?

Thank you!

Maike Luhmann
Freie Universität Berlin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compress (gzip) a pdf device

2009-10-02 Thread Rainer M Krug
On Fri, Oct 2, 2009 at 9:02 AM, Gábor Csárdi  wrote:

> Rainer,
>
> if you are willing to patch the R source, then a solution might be the
> R connection patch, see
> http://wiki.r-project.org/rwiki/doku.php?id=developers:r_connections_api
> It is a bit outdated, but with a little work I could use it for R
> 2.9.2 and works fine.
>

Thanks - I will look into it and give feedback as soon as I have done.

Cheers,

Rainer


>
> Best,
> Gabor
>
> On Fri, Oct 2, 2009 at 8:54 AM, Rainer M Krug  wrote:
> > On Thu, Oct 1, 2009 at 7:26 PM, Martin Renner <
> > martin.ren...@stonebow.otago.ac.nz> wrote:
> >
> >> try pdftk. Not quite on the fly but should do the trick. (I saw this on
> >> this list a little while ago)
> >>
> >
> > pdftk compresses the pdf internally - it is still a pdf, can be opened as
> a
> > pdf, and is not an externally compressed pdf (pdf in an archive).
> > Below is the approach which I am using, but as stated earlier, if
> somebody
> > could provide a way of only doing dev.off() whhich then calls pdfComp()
> with
> > the filename, I would be glad to know. Otherwise.
> >
> > Rainer
> >
> >
> >>
> >> pdfComp <- function (pdfname){
> >>  if (0){
> >>x <- tempfile()
> >>system (paste ("mv", pdfname, x))
> >>system (paste ("pdftk", x, "output", pdfname, "compress"))
> >>unlink (x)
> >>  }
> >> }
> >>
> >> pdf ("test.pdf")
> >> plot (1:10)
> >> dev.off()
> >> pdfComp ("test.pdf")
> >>
> >>
> >> On 30 Sep 2009, at 00:25 , Rainer M Krug wrote:
> >>
> >>  2009/9/30 Daniele Amberti 
> >>>
> >>>  I have not found an easy way to compress a file on filesystem.
>  Especially I'd like to compress a pdf from pdf() function/device. Is
> it
>  possible to compress It on the flight?
>  I'd like to do something like:
>  pdf(gzipconnection())
>  dev.off()
> 
> 
>   I guess this boils down to a question I asked some time ago
> concerning
> >>> getting the filename of a pdf() device, as I wanted to create a
> compressed
> >>> pdf from the uncompressed pdf created by R (not "zipping" the pdf).
> >>> It does not seem to be possible, at least I did not get any response
> which
> >>> I
> >>> could use to implement my idea (create my dev.off(), which calls
> dev.off()
> >>> and afterwards compresses the pdf by using the file name).
> >>>
> >>> If you find a solution, please let me know.
> >>>
> >>> Cheers,
> >>>
> >>> Rainer
> >>>
> >>> If It is not possible, how can I create a gzip with the pdf?
> >>>
> 
>  Thanks
>  Daniele A.
> 
> 
> 
>  
>  ORS Srl
> 
>  Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy
>  Tel. +39 0173 620211
>  Fax. +39 0173 620299 / +39 0173 433111
>  Web Site www.ors.it
> 
> 
> 
> 
> 
>  Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi
>  allegati ? vietato e potrebbe costituire reato.
>  Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati
> se
>  provvedesse alla distruzione dello stesso
>  e degli eventuali allegati.
>  Opinioni, conclusioni o altre informazioni riportate nella e-mail, che
>  non
>  siano relative alle attivit? e/o
>  alla missione aziendale di O.R.S. Srl si intendono non attribuibili
> alla
>  societ? stessa, n? la impegnano in alcun modo.
> 
>   [[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.
> 
> 
> >>>
> >>>
> >>> --
> >>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> >>> Biology,
> >>> UCT), Dipl. Phys. (Germany)
> >>>
> >>> Centre of Excellence for Invasion Biology
> >>> Natural Sciences Building
> >>> Office Suite 2039
> >>> Stellenbosch University
> >>> Main Campus, Merriman Avenue
> >>> Stellenbosch
> >>> South Africa
> >>>
> >>> Cell:   +27 - (0)83 9479 042
> >>> Fax:+27 - (0)86 516 2782
> >>> Fax:+49 - (0)721 151 334 888
> >>> email:  rai...@krugs.de
> >>>
> >>> Skype:  RMkrug
> >>> Google: r.m.k...@gmail.com
> >>>
> >>>[[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.
> >>>
> >>
> >>
> >
> >
> > --
> > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology,
> > UCT), Dipl. Phys. (Germany)
> >
> > Centre o

[R] nls not accepting control parameter?

2009-10-02 Thread Rainer M Krug
Hi

I want to change a control parameter for an nls () as I am getting an error
message  "step factor 0.000488281 reduced below 'minFactor' of 0.000976562".
Despite all tries, it seems that the control parameter of the nls, does not
seem to get handed down to the function itself, or the error message is
using a different one.

Below system info and an example highlighting the problem.

Thanks,

Rainer


> version   _
platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)

> sessionInfo()
R version 2.9.2 (2009-08-24)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_ZA.UTF-8;LC_NUMERIC=C;LC_TIME=en_ZA.UTF-8;LC_COLLATE=en_ZA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_ZA.UTF-8;LC_PAPER=en_ZA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_ZA.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] R.utils_1.2.0 R.oo_1.5.0R.methodsS3_1.0.3 maptools_0.7-26
[5] sp_0.9-44 foreign_0.8-37

loaded via a namespace (and not attached):
[1] grid_2.9.2  lattice_0.17-25


#

EXAMPLE:

dat <- data.frame(
  x = 2006:2037,
  y = c(143088, 140218, 137964,
138313, 140005, 141483, 142365,
144114, 145335, 146958, 148584,
149398, 151074, 152241, 153919,
155580, 157258, 158981, 160591,
162126, 163743, 165213, 166695,
168023, 169522, 170746, 172057,
173287, 173977, 175232, 176308,
177484)
  )

nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, trace=TRUE)

(newMinFactor <- 1/(4*1024))
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=nls.control(minFactor=newMinFactor), trace=TRUE)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=c(minFactor=newMinFactor), trace=TRUE)


(newMinFactor <- 4/1024)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=nls.control(minFactor=newMinFactor), trace=TRUE)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=c(minFactor=newMinFactor), trace=TRUE)



-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:   +27 - (0)83 9479 042
Fax:+27 - (0)86 516 2782
Fax:+49 - (0)721 151 334 888
email:  rai...@krugs.de

Skype:  RMkrug
Google: r.m.k...@gmail.com

[[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] plot scale

2009-10-02 Thread Ben Kenward
Hi,

Is there a way to set the scale of a plot (i.e. number of axis units
per centimeter) when you output it to postscript? If not, how am I
supposed to plot graphs with different axis limits to the same scale?
They just get resized to fit the paper so that graphs which show a
smaller number of axis units end up with a larger scale.

Cheers,

Ben

-- 
Dr. Ben Kenward
Department of Psychology, Uppsala University, Sweden
http://www.benkenward.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] Unable to install lme4

2009-10-02 Thread Patrick Connolly
On Thu, 01-Oct-2009 at 10:13AM -0700, jamesmcc wrote:

|> 
|> This is the first time I've encountered R having difficulty with package and
|> R version compatibility. I cant believe no one has fixed generally so that
|> your version of R can get the latest package appropriate to that version.
|> How nice would that be? :)
|> 
|> Anyway, I figured it out for my version (2.8.1). I needed to install Matrix
|> package first, which was also outdated.
|> 
|> > R CMD INSTALL -l lib Matrix_0.999375-22.tar.gz
|> > R CMD INSTALL -l lib lme4_0.999375-28.tar.gz

You would have avoided that problem if you used update.packages within
R.  It will take care of such things if you set dependencies = TRUE.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] plot ᵒ C in graph axis label

2009-10-02 Thread Duncan Mackay

Hi

If you use a Microsoft OS and you just want to do a °C in the text there is 
the alternative of using ASCII

Just press the keys Alt-248. Have used it for a number of years with success.
Also applies to other characters and without having to go to plotmath etc
You just need to be careful of the code page etc for it to work.

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email Home: mac...@northnet.com.au

At 16:49 2/10/2009, you wrote:
Readers, I have tried to use a plotmath command to add the temperature 
degree sign (i.e. ᵒ C) to the axis label of a graph: > x<-(1:10) > 
y<-(200:191) > plot(x~y,ylab=expression(*degree~C)) Error: syntax error, 
unexpected '*', expecting ',' in "plot(x~y,ylab=expression(*" According to 
plotmath manual, the syntax is '*degree' and I am able to use this command 
when a number precedes the asterisk (e.g. ylab=expression(0*degree~C)). 
But I want to omit the need for a number before the degree sign. Any 
advice please? __ 
R-help@r-project.org mailing list 
https://stat.ethz.ch/mailman/listinfo/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] Problem with dist (bug?)

2009-10-02 Thread Corrado
Dear list,

using package "proxy".

In one situation, the dissimilarity between two vectors based on 
method=correlation returns a value of 1.9. That should not happen, should it?

The correlation is normally the cos() of the angle between the two vectors 


That dissimilarity

Any clue?

Package dist 0.4-3 on R 2.9.2 on Kubuntu 904 64 bit.

Regards
-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] How to use Subpopulation data?

2009-10-02 Thread Bernardo Rangel Tura
On Fri, 2009-10-02 at 00:42 +, KABELI MEFANE wrote:
> Thanks
> 
> But it seems like you don't get my problem.Do you mean that there is 
> something wrong with the code as it seems like what you are doing is 
> suggesting different ways to write a code. 
> 
> Will i get to use the variable that have been name previously like if i want 
> to calculate the standard deviation of stratum hypermarket in a sample not 
> population, the first start is to check if it would help me is to check the 
> length() of different levels if it is not same as that of the original data
> 
> Best Regards
> 
> I rest my case, i might dream it

Sorry

I don't understand your problem early.

In your case you have 2 data.frames: sampleframe and sample.strat so you
need show to R where calculate sd or length or summary


set.seed(1)# only to make this example don't use in your code
stra<-strata(sampleframe,c("type"),size=c(20,80,200,300,400),method="srswor")
sample.strat<-getdata(sampleframe,stra)

length of value in sampleframe where type is Hypermarket:
> length(sampleframet$value[sampleframe$type=="Hypermarket"]) 
[1] 100

SD of value in sampleframe where type is Hypermarket:
> sd(sampleframe$value[sampleframet$type=="Hypermarket"])
[1] 4586.854

length of value in sample.strat where type is Hypermarket:
> length(sample.strat$value[sample.strat$type=="Hypermarket"] )
[1] 20

SD of value in sample.strat where type is Hypermarket:
> sd(sample.strat$value[sample.strat$type=="Hypermarket"] )
[1] 4679.336


-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Normal distribution

2009-10-02 Thread Colin Millar
A quick google on 'normality test' (no quotes) gives 
http://en.wikipedia.org/wiki/Normality_test. This gives you a few more tests 
than the KS test.

Cheers,
Colin.


Steve Lianoglou wrote:
> Hi,
> 
> I think you can also use a qq-plot to do the same, no? You won't get a
> statistic score + p.value, but perhaps you're more of a visual person?
> :-)
> 
> -steve
> 
> On Thu, Oct 1, 2009 at 12:56 PM, Richardson, Patrick
>  wrote:
>> ?shapiro.test
>>
>>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
>> Behalf Of Noela Sánchez
>> Sent: Thursday, October 01, 2009 12:47 PM
>> To: r-help@r-project.org
>> Subject: [R] Normal distribution
>>
>> Hi,
>>
>> I am dealing with how to check in R if some data that I have belongs to a 
>> normal distribution or not. I am not interested in obtaining the 
>> theoreticall frequencies. I am only interested in determing if (by means of 
>> a test as Kolmogorov, or whatever), if my data are normal or not.
>>
>> But I have tried with ks.test() and I have not got it.
>>
>>
>> --
>> Noela
>> Grupo de Recursos Marinos y Pesquerías
>> Universidad de A Coruña
>>
>>[[alternative HTML version deleted]]
>>
>> This email message, including any attachments, is for th...{{dropped:6}}
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
>

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

__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

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


Re: [R] plot scale

2009-10-02 Thread Duncan Murdoch

On 02/10/2009 4:07 AM, Ben Kenward wrote:

Hi,

Is there a way to set the scale of a plot (i.e. number of axis units
per centimeter) when you output it to postscript? If not, how am I
supposed to plot graphs with different axis limits to the same scale?
They just get resized to fit the paper so that graphs which show a
smaller number of axis units end up with a larger scale.


I don't think there's a simple way to specify the exact relationship, 
but you can do it with some work.


When you open the postscript device, you can specify the size.  When you 
do a plot, you can specify the size of the margins, so that lets you 
indirectly specify the size of the plot region.  And of course you can 
specify the axis limits.


So the way I'd do what you want is as follows:  plot the data, use 
par("usr") to extract the axis limits, use par("mai") to extract the 
margin size.  Then calculate the size you want for the particular 
scaling, and open the postscript device with that size, reset par("mai") 
to the previous value, and repeat your plot.


Duncan Murdoch

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


Re: [R] plot scale

2009-10-02 Thread Ben Kenward
On Fri, Oct 2, 2009 at 11:10 AM, Duncan Murdoch  wrote:
> I don't think there's a simple way to specify the exact relationship, but
> you can do it with some work.

Thanks Duncan. That's what I was beginning to suspect, nice to have
confirmation, even if it will mean a bit of work.

Ben

-- 
Dr. Ben Kenward
Department of Psychology, Uppsala University, Sweden
http://www.benkenward.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] plot scale

2009-10-02 Thread baptiste auguie
Hi,

It looks like lattice or ggplot2 might make this easier, but I'm not
entirely sure I understood the problem, short of an example.

Best,

baptiste

2009/10/2 Duncan Murdoch :
> On 02/10/2009 4:07 AM, Ben Kenward wrote:
>>
>> Hi,
>>
>> Is there a way to set the scale of a plot (i.e. number of axis units
>> per centimeter) when you output it to postscript? If not, how am I
>> supposed to plot graphs with different axis limits to the same scale?
>> They just get resized to fit the paper so that graphs which show a
>> smaller number of axis units end up with a larger scale.
>
> I don't think there's a simple way to specify the exact relationship, but
> you can do it with some work.
>
> When you open the postscript device, you can specify the size.  When you do
> a plot, you can specify the size of the margins, so that lets you indirectly
> specify the size of the plot region.  And of course you can specify the axis
> limits.
>
> So the way I'd do what you want is as follows:  plot the data, use
> par("usr") to extract the axis limits, use par("mai") to extract the margin
> size.  Then calculate the size you want for the particular scaling, and open
> the postscript device with that size, reset par("mai") to the previous
> value, and repeat your plot.
>
> Duncan Murdoch
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] removing missing values from a matrix

2009-10-02 Thread jim holtman
Here is one way to do it.  BTW 'a'-'z' won't work because there are 41
splits.  Use a list instead:

> red <- matrix(seq(23688 * 164), nrow=23688, ncol=164)
> # create indices
> indx <- split(1:164, cut(1:164, 41))
> # now split matrix
> newMatrix <- lapply(indx, function(x) red[, x])
>
> str(newMatrix)
List of 41
 $ (0.837,4.82]: int [1:23688, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
 $ (4.82,8.8]  : int [1:23688, 1:4] 94753 94754 94755 94756 94757
94758 94759 94760 94761 94762 ...
 $ (8.8,12.8]  : int [1:23688, 1:4] 189505 189506 189507 189508 189509
189510 189511 189512 189513 189514 ...
 $ (12.8,16.8] : int [1:23688, 1:4] 284257 284258 284259 284260 284261
284262 284263 284264 284265 284266 ...
 $ (16.8,20.8] : int [1:23688, 1:4] 379009 379010 379011 379012 379013
379014 379015 379016 379017 379018 ...
 $ (20.8,24.7] : int [1:23688, 1:4] 473761 473762 473763 473764 473765
473766 473767 473768 473769 473770 ...
 $ (24.7,28.7] : int [1:23688, 1:4] 568513 568514 568515 568516 568517
568518 568519 568520 568521 568522 ...
 $ (28.7,32.7] : int [1:23688, 1:4] 663265 663266 663267 663268 663269
663270 663271 663272 663273 663274 ...
 $ (32.7,36.7] : int [1:23688, 1:4] 758017 758018 758019 758020 758021
758022 758023 758024 758025 758026 ...
 $ (36.7,40.7] : int [1:23688, 1:4] 852769 852770 852771 852772 852773
852774 852775 852776 852777 852778 ...
 $ (40.7,44.7] : int [1:23688, 1:4] 947521 947522 947523 947524 947525
947526 947527 947528 947529 947530 ...


On Thu, Oct 1, 2009 at 6:57 PM, Amit Kumar  wrote:
> Thanks!
> It worked! There is another problem I want to subset the matrix 'red'
> in following manner:
>>dim(red)
>  23688  164
>>a=red[1:23688,1:4]
>>b=red[1:23688,5:8]
>>c=red[1:23688,9:12]
> ..
> ..
>>z=red[1:23688,161:164]
> If there any efficient way to do it?
> cheers!
> Amit
>
>>
>> On Thu, 1 Oct 2009, Amit Kumar wrote:
>>
>>> Hi! All,
>>> I am working with a large matrix of dimension 23689 x 162. Some of the
>>> values of this matrix is missing (NA). And it looks something like
>>> that:
>>>
 dim(red)
>>>
>>>  23689  162
>>>
 red
>>>
>>>       [,1]  [,2]  [,3]  [,4]  [,5]
>>> [1,]    2     NA    4     9     6
>>> [2,]    5     NA    6   NA     1
>>> [3,]   NA    2     11   23    20
>>> [4,]    2      1     21  NA    3
>>> [5,]   NA    7     NA  52    NA
>>>
>>> Here I want to convert NA to zero everywhere in the matrix. I do no
>>> want to omit NA using na.omit(red). I want output something like that:

 red
>>>
>>>       [,1]  [,2]  [,3]  [,4]  [,5]
>>> [1,]    2      0     4     9     6
>>> [2,]    5      0     6     0     1
>>> [3,]    0      2     11   23    20
>>> [4,]    2      1     21    0     3
>>> [5,]    0      7      0    52     0
>>>
>>> Please, help thanks.
>>> Amit
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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 that 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] aproximate a titration kurve to the measure data.

2009-10-02 Thread Bernardo Rangel Tura
On Thu, 2009-10-01 at 10:18 -0700, awayguy wrote:
> yes, halo thank you.
> my measure data:
> v2 <- c(0, 2, 4, 6, 6.2, 6.4, 6.6, 6.8, 7, 7.2, 7.4, 7.6, 7.8, 8, 10, 12,
> 14)
> ph2 <- c(12.10, 11.94, 11.68, 11.11, 10.91, 10.74, 10.47, 9.71, 7.1, 4.24,
> 3.3, 3.08, 2.98, 2.86, 2.33, 2.11, 1.98)
> 
> with regards

Ok

temp<-data.frame(ph2,v2)
> drm(temp,, fct = LL.4())

A 'drc' model.

Call:
drm(formula = temp, fct = LL.4())

Coefficients:
b:(Intercept)  c:(Intercept)  d:(Intercept)  e:(Intercept)  
   39.420  2.425 11.487  7.002 

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] removing missing values from a matrix

2009-10-02 Thread Amit Kumar
Thanks! Jim
It solved my problem.

Best
Amit

On Fri, Oct 2, 2009 at 11:19 AM, jim holtman  wrote:
> Here is one way to do it.  BTW 'a'-'z' won't work because there are 41
> splits.  Use a list instead:
>
>> red <- matrix(seq(23688 * 164), nrow=23688, ncol=164)
>> # create indices
>> indx <- split(1:164, cut(1:164, 41))
>> # now split matrix
>> newMatrix <- lapply(indx, function(x) red[, x])
>>
>> str(newMatrix)
> List of 41
>  $ (0.837,4.82]: int [1:23688, 1:4] 1 2 3 4 5 6 7 8 9 10 ...
>  $ (4.82,8.8]  : int [1:23688, 1:4] 94753 94754 94755 94756 94757
> 94758 94759 94760 94761 94762 ...
>  $ (8.8,12.8]  : int [1:23688, 1:4] 189505 189506 189507 189508 189509
> 189510 189511 189512 189513 189514 ...
>  $ (12.8,16.8] : int [1:23688, 1:4] 284257 284258 284259 284260 284261
> 284262 284263 284264 284265 284266 ...
>  $ (16.8,20.8] : int [1:23688, 1:4] 379009 379010 379011 379012 379013
> 379014 379015 379016 379017 379018 ...
>  $ (20.8,24.7] : int [1:23688, 1:4] 473761 473762 473763 473764 473765
> 473766 473767 473768 473769 473770 ...
>  $ (24.7,28.7] : int [1:23688, 1:4] 568513 568514 568515 568516 568517
> 568518 568519 568520 568521 568522 ...
>  $ (28.7,32.7] : int [1:23688, 1:4] 663265 663266 663267 663268 663269
> 663270 663271 663272 663273 663274 ...
>  $ (32.7,36.7] : int [1:23688, 1:4] 758017 758018 758019 758020 758021
> 758022 758023 758024 758025 758026 ...
>  $ (36.7,40.7] : int [1:23688, 1:4] 852769 852770 852771 852772 852773
> 852774 852775 852776 852777 852778 ...
>  $ (40.7,44.7] : int [1:23688, 1:4] 947521 947522 947523 947524 947525
> 947526 947527 947528 947529 947530 ...
>
>
> On Thu, Oct 1, 2009 at 6:57 PM, Amit Kumar  wrote:
>> Thanks!
>> It worked! There is another problem I want to subset the matrix 'red'
>> in following manner:
>>>dim(red)
>>  23688  164
>>>a=red[1:23688,1:4]
>>>b=red[1:23688,5:8]
>>>c=red[1:23688,9:12]
>> ..
>> ..
>>>z=red[1:23688,161:164]
>> If there any efficient way to do it?
>> cheers!
>> Amit
>>
>>>
>>> On Thu, 1 Oct 2009, Amit Kumar wrote:
>>>
 Hi! All,
 I am working with a large matrix of dimension 23689 x 162. Some of the
 values of this matrix is missing (NA). And it looks something like
 that:

> dim(red)

  23689  162

> red

       [,1]  [,2]  [,3]  [,4]  [,5]
 [1,]    2     NA    4     9     6
 [2,]    5     NA    6   NA     1
 [3,]   NA    2     11   23    20
 [4,]    2      1     21  NA    3
 [5,]   NA    7     NA  52    NA

 Here I want to convert NA to zero everywhere in the matrix. I do no
 want to omit NA using na.omit(red). I want output something like that:
>
> red

       [,1]  [,2]  [,3]  [,4]  [,5]
 [1,]    2      0     4     9     6
 [2,]    5      0     6     0     1
 [3,]    0      2     11   23    20
 [4,]    2      1     21    0     3
 [5,]    0      7      0    52     0

 Please, help thanks.
 Amit

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 that 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] split-apply question

2009-10-02 Thread jim holtman
try this:

> x <- read.table(textConnection("x1  x2  x3
+ A   11.5
+ B   20.9
+ B   32.7
+ C   71.8
+ D   71.3"), header=TRUE)
> closeAllConnections()
> do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){
+ x[.row[which.min(x$x2[.row])],]
+ }))
  x1 x2  x3
A  A  1 1.5
B  B  2 0.9
C  C  7 1.8
D  D  7 1.3
>


On Thu, Oct 1, 2009 at 11:43 PM, Kavitha Venkatesan
 wrote:
> Hi,
>
> I have a data frame that looks like this:
>
>>x
>
> x1  x2  x3
> A   1    1.5
> B   2    0.9
> B   3    2.7
> C   7    1.8
> D   7    1.3
>
> I want to "group" by the x1 column and in the case of multiple x$x1 values
> (e.g., "B")d, return rows that have the smallest values of x2. In the case
> of rows with only one value of x1 (e.g., "A"), return the row as is. How can
> I do that?  For example, in the above case, the output I want would be:
>
> x1  x2  x3
> A   1    1.5
> B   2    0.9
> C   7    1.8
> D   7    1.3
>
>
> Thanks!
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


[R] problems with kzft

2009-10-02 Thread Markus Häge
Hello there

after I became familiar with R and Design of Experiments, I tried to
make a fourier transform with kzft but failed. I don't understand
kzft.pdf right.

I tried:
t<-1:1000
x<-cos(2*pi*(1/100)*t)
kzft.x1<-kzft(x,200,1,0.005)
x1<-2*Re(kzft.x1$tf[,2]) //Is it "Re" because it's complex? What exactly
do I acess here?

plot(x1,main="sin") /with this I plot the pure sin

I don't understand the fifth argument "n" in kzft().

Now I like to have a picture of the frequencies. Is it the periodogram
with kzp()? I tried something but once more... I don't understand the
examples in kzft.pdf completely:

omega<-seq(0,1,length=481)[2:241]//What for is [2:241]

My idea is to use kzft at different sampling rates of an ADC, or to
improve the measurements of my cheap oscilloscope. Like the FFT-button,
but better and with R.
Is there somewhere a better explanation of kzft() than kzft.pdf?
Or can anybody help me with this package?

thanks

Markus

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread J Chen

dear all,

I have some very long strings and would like to break up each long string
into multiple strings with a fixed length, e.g. to break up

abcdefghijkl

into

abc, def, ghi, jkl

I tried a couple of commands but was not successful. Any help will be
appreciated.

Best,
Jimmy
-- 
View this message in context: 
http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] help with regexp mass substitution

2009-10-02 Thread Luca Braglia
Hello *

i have to rename a lot of variables, and, given that they have regular name 
constructs, I would like to use regexps.

Here's a dump of my head(names(df))

varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3", 
"col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3", 
"col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3", 
"col4.3.3", "col5.3.3", "txt.4.3", "col1.4.3", "col2.4.3", "col3.4.3", 
"col4.4.3", "col5.4.3", "txt.5.3", "col1.5.3", "col2.5.3", "col3.5.3", 
"col4.5.3", "col5.5.3", "txt.6.3", "col1.6.3", "col2.6.3", "col3.6.3", 
"col4.6.3", "col5.6.3", "txt.7.3", "col1.7.3", "col2.7.3", "col3.7.3", 
"col4.7.3", "col5.7.3", "txt.8.3", "col1.8.3", "col2.8.3", "col3.8.3", 
"col4.8.3", "col5.8.3", "txt.9.3", "col1.9.3", "col2.9.3", "col3.9.3", 
"col4.9.3", "col5.9.3", "txt.10.3", "col1.10.3", "col2.10.3", 
"col3.10.3", "col4.10.3", "col5.10.3", "txt.11.3", "col1.11.3", 
"col2.11.3", "col3.11.3", "col4.11.3", "col5.11.3", "txt.12.3", 
"col1.12.3", "col2.12.3", "col3.12.3", "col4.12.3", "col5.12.3", 
"txt.13.3", "col1.13.3", "col2.13.3", "col3.13.3", "col4.13.3", 
"col5.13.3", "txt.14.3", "col1.14.3", "col2.14.3", "col3.14.3", 
"col4.14.3", "col5.14.3", "txt.15.3", "col1.15.3", "col2.15.3", 
"col3.15.3", "col4.15.3", "col5.15.3", "txt.16.3", "col1.16.3", 
"col2.16.3", "col3.16.3", "col4.16.3", "col5.16.3", "txt.17.3", 
"col1.17.3", "col2.17.3")

I'd like to convert only ^col variables to have eg

>From "col4.1.3" --> To "dom3.rig1.col4"

to test the matching regex I've tryied

grep("^col\\d{1,2}.\\d{1,2}.\\d{1,2}$",varnames, perl=T, value=T)

to substitute the ^col variables, I've tryied

gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", varnames)

I'm a newbie with regexps and I got the starting vector (==varnames)

all(gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", 
varnames) == varnames )

How can I do?

Many thanks and have a nice weekend.

Luca

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Please Help me!

2009-10-02 Thread Tammy Ma

Hi, R-users,


I have a problem: Because there are few files which can't be readed
into R completely, so on the following subsequence programme, I use
write.table, which creates the "NA" files for those incomplete files
autimatically. 
I don't want those NA files.

My programes formats looks like:



name_c<-Sys.glob("C:/Documents and Settings/lma/My 
Documents/habitdata/*/calllog/*")

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

log1<-readLines(name_c[i])


write.table(Temps, file=paste("C:/Documents and Settings/lma/My 
Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/"))

}


Error Information:
Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection

 In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/Documents and Settings/lma/My 
Documents/habitdata1/NA/NA/NA': Permission denied


I have checked why the error appears, because  when I use "readLines" to read 
data, but when processing the large data set, there are few files which can not 
be readed in completely:

48: In readLines(name_c[i]) ... :
 
incomplete final line found on 'C:/Documents and Settings/lma/My
Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt'
...


So it create the "NA" file when implementing the subsequence procedure by 
write.table.How can I do: whenever readLines can't completely read one file, 
then autimatically doesn't implement the subsequence programmes?

Thanks.
Tammy 
_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
[[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] plot subscript text and percentage symbol in graph label axis

2009-10-02 Thread e-letter
Readers,

I am unable to plot a label consisting of both subscript text and
percentage (%) symbol:

x<-(1:10)
y<-(200:191)
plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~%))
Error: syntax error, unexpected ERROR in
"plot(x~y,ylab=expression(~degree~C),xlab=expression(x~%)"

It seems that % is a special character in R? I have looked in the
introductory manual but can see no reference to reserved characters.

Yours,

rhelpatconference.jabber.org
r251
mandriva2008

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread jim holtman
try this:

> a <- paste(letters, collapse='')
> # partitions into lengths of 4
> indx <- seq(1, nchar(a), 4)
> a.p <- sapply(indx, function(x) substring(a, x, x+3))
>
> a.p
[1] "abcd" "efgh" "ijkl" "mnop" "qrst" "uvwx" "yz"
>


On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>
> dear all,
>
> I have some very long strings and would like to break up each long string
> into multiple strings with a fixed length, e.g. to break up
>
> abcdefghijkl
>
> into
>
> abc, def, ghi, jkl
>
> I tried a couple of commands but was not successful. Any help will be
> appreciated.
>
> Best,
> Jimmy
> --
> View this message in context: 
> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that 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] Please Help me!

2009-10-02 Thread jim holtman
try this:  (?try)

name_c<-Sys.glob("C:/Documents and Settings/lma/My
Documents/habitdata/*/calllog/*")

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

log1<-try(readLines(name_c[i]))
if (inherits(log1, 'try-error')) next  # skip if error


write.table(Temps, file=paste("C:/Documents and Settings/lma/My
Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/"))

}

On Fri, Oct 2, 2009 at 7:04 AM, Tammy Ma  wrote:
>
> Hi, R-users,
>
>
> I have a problem: Because there are few files which can't be readed
> into R completely, so on the following subsequence programme, I use
> write.table, which creates the "NA" files for those incomplete files
> autimatically.
> I don't want those NA files.
>
> My programes formats looks like:
>
>
>
> name_c<-Sys.glob("C:/Documents and Settings/lma/My 
> Documents/habitdata/*/calllog/*")
>
> for (i in 1:length(name_c)){
>
> log1<-readLines(name_c[i])
> 
>
> write.table(Temps, file=paste("C:/Documents and Settings/lma/My 
> Documents/habitdata1",pname,lname,basename(name_c[i]),sep="/"))
>
> }
>
>
> Error Information:
> Error in file(file, ifelse(append, "a", "w")) :
>  cannot open the connection
>
>  In file(file, ifelse(append, "a", "w")) :
>  cannot open file 'C:/Documents and Settings/lma/My 
> Documents/habitdata1/NA/NA/NA': Permission denied
>
>
> I have checked why the error appears, because  when I use "readLines" to read 
> data, but when processing the large data set, there are few files which can 
> not be readed in completely:
>
> 48: In readLines(name_c[i]) ... :
>
> incomplete final line found on 'C:/Documents and Settings/lma/My
> Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt'
> ...
>
>
> So it create the "NA" file when implementing the subsequence procedure by 
> write.table.How can I do: whenever readLines can't completely read one file, 
> then autimatically doesn't implement the subsequence programmes?
>
> Thanks.
> Tammy
> _
> More than messages–check out the rest of the Windows Live™.
> http://www.microsoft.com/windows/windowslive/
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



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

What is the problem that 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] Robust ANOVA with variance heterogeneity

2009-10-02 Thread John Fox
Dear Maike,

You could use the Anova() function in the car package with a
heteroscedasticity-consistent coefficient covariance matrix (via the
argument white.adjust=TRUE).

Regards,
 John


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
> Behalf Of Maike Luhmann
> Sent: October-02-09 3:05 AM
> To: r-help@r-project.org
> Subject: [R] Robust ANOVA with variance heterogeneity
> 
> Dear list members,
> 
> I am looking for an alternative function for a two-way ANOVA in the case
of
> variance heterogeneity. For one-way ANOVA, I found oneway.test(), but I
> didn't find anything alike for two-way ANOVA. Does anyone have a
suggestion?
> 
> Thank you!
> 
> Maike Luhmann
> Freie Universität Berlin
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 get duplicated items in a vector?

2009-10-02 Thread jim holtman
Try this:

>  x=c(rep(1,3),rep(3,2))
> x
[1] 1 1 1 3 3
> duplicated(x) | duplicated(x, fromLast=TRUE)
[1] TRUE TRUE TRUE TRUE TRUE
>


On Thu, Oct 1, 2009 at 10:42 PM, Peng Yu  wrote:
> Hi,
>
>> x=c(rep(1,3),rep(3,2))
>> x
> [1] 1 1 1 3 3
>> duplicated(x)
> [1] FALSE  TRUE  TRUE FALSE  TRUE
>>
>
> As shown in the above code, 'duplicated' doesn't return 'F' for the
> first '1' and first '3' in 'x'. I am wondering if there is a function
> that can return an indicator for any element whether it appears in a
> vector twice or more.
>
> Regards,
> Peng
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 that 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] break up a string into strings with a fixed length

2009-10-02 Thread Gabor Grothendieck
Try this:

> library(gsubfn)
> s <- "abcdefghijkl"

> strapply(s, "...")[[1]]
[1] "abc" "def" "ghi" "jkl"


On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>
> dear all,
>
> I have some very long strings and would like to break up each long string
> into multiple strings with a fixed length, e.g. to break up
>
> abcdefghijkl
>
> into
>
> abc, def, ghi, jkl
>
> I tried a couple of commands but was not successful. Any help will be
> appreciated.
>
> Best,
> Jimmy
> --
> View this message in context: 
> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread jim holtman
But it misses the last set if not a multiple of the subset length:

> library(gsubfn)
> s <- "abcdefghijklm"
>
> # no 'm'
> strapply(s, "...")[[1]]
[1] "abc" "def" "ghi" "jkl"
>


On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
 wrote:
> Try this:
>
>> library(gsubfn)
>> s <- "abcdefghijkl"
>
>> strapply(s, "...")[[1]]
> [1] "abc" "def" "ghi" "jkl"
>
>
> On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>>
>> dear all,
>>
>> I have some very long strings and would like to break up each long string
>> into multiple strings with a fixed length, e.g. to break up
>>
>> abcdefghijkl
>>
>> into
>>
>> abc, def, ghi, jkl
>>
>> I tried a couple of commands but was not successful. Any help will be
>> appreciated.
>>
>> Best,
>> Jimmy
>> --
>> View this message in context: 
>> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 that 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] plot subscript text and percentage symbol in graph label axis

2009-10-02 Thread baptiste auguie
try this,

plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~"%"))


baptiste

2009/10/2 e-letter :
> Readers,
>
> I am unable to plot a label consisting of both subscript text and
> percentage (%) symbol:
>
> x<-(1:10)
> y<-(200:191)
> plot(x~y,ylab=expression(~degree~C),xlab=expression(x[2]~%))
> Error: syntax error, unexpected ERROR in
> "plot(x~y,ylab=expression(~degree~C),xlab=expression(x~%)"
>
> It seems that % is a special character in R? I have looked in the
> introductory manual but can see no reference to reserved characters.
>
> Yours,
>
> rhelpatconference.jabber.org
> r251
> mandriva2008
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] help with regexp mass substitution

2009-10-02 Thread jim holtman
You need perl=TRUE:

gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1",
varnames, perl=TRUE)
  [1] "id.quest""txt.1.3" "dom3.rig1.col1"
"dom3.rig1.col2"  "dom3.rig1.col3"  "dom3.rig1.col4"  "dom3.rig1.col5"
  [8] "txt.2.3" "dom3.rig2.col1"  "dom3.rig2.col2"
"dom3.rig2.col3"  "dom3.rig2.col4"  "dom3.rig2.col5"  "txt.3.3"
 [15] "dom3.rig3.col1"  "dom3.rig3.col2"  "dom3.rig3.col3"
"dom3.rig3.col4"  "dom3.rig3.col5"  "txt.4.3" "dom3.rig4.col1"
 [22] "dom3.rig4.col2"  "dom3.rig4.col3"  "dom3.rig4.col4"
"dom3.rig4.col5"  "txt.5.3" "dom3.rig5.col1"  "dom3.rig5.col2"
 [29] "dom3.rig5.col3"  "dom3.rig5.col4"  "dom3.rig5.col5"  "txt.6.3"
   "dom3.rig6.col1"  "dom3.rig6.col2"  "dom3.rig6.col3"
 [36] "dom3.rig6.col4"  "dom3.rig6.col5"  "txt.7.3"
"dom3.rig7.col1"  "dom3.rig7.col2"  "dom3.rig7.col3"  "dom3.rig7.col4"
 [43] "dom3.rig7.col5"  "txt.8.3" "dom3.rig8.col1"
"dom3.rig8.col2"  "dom3.rig8.col3"  "dom3.rig8.col4"  "dom3.rig8.col5"
 [50] "txt.9.3" "dom3.rig9.col1"  "dom3.rig9.col2"
"dom3.rig9.col3"  "dom3.rig9.col4"  "dom3.rig9.col5"  "txt.10.3"
 [57] "dom3.rig10.col1" "dom3.rig10.col2" "dom3.rig10.col3"
"dom3.rig10.col4" "dom3.rig10.col5" "txt.11.3"
"dom3.rig11.col1"
 [64] "dom3.rig11.col2" "dom3.rig11.col3" "dom3.rig11.col4"
"dom3.rig11.col5" "txt.12.3""dom3.rig12.col1"
"dom3.rig12.col2"
 [71] "dom3.rig12.col3" "dom3.rig12.col4" "dom3.rig12.col5" "txt.13.3"
   "dom3.rig13.col1" "dom3.rig13.col2" "dom3.rig13.col3"
 [78] "dom3.rig13.col4" "dom3.rig13.col5" "txt.14.3"
"dom3.rig14.col1" "dom3.rig14.col2" "dom3.rig14.col3"
"dom3.rig14.col4"
 [85] "dom3.rig14.col5" "txt.15.3""dom3.rig15.col1"
"dom3.rig15.col2" "dom3.rig15.col3" "dom3.rig15.col4"
"dom3.rig15.col5"
 [92] "txt.16.3""dom3.rig16.col1" "dom3.rig16.col2"
"dom3.rig16.col3" "dom3.rig16.col4" "dom3.rig16.col5" "txt.17.3"
 [99] "dom3.rig17.col1" "dom3.rig17.col2"
>


On Fri, Oct 2, 2009 at 5:39 AM, Luca Braglia  wrote:
> Hello *
>
> i have to rename a lot of variables, and, given that they have regular name 
> constructs, I would like to use regexps.
>
> Here's a dump of my head(names(df))
>
> varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3",
> "col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3",
> "col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3",
> "col4.3.3", "col5.3.3", "txt.4.3", "col1.4.3", "col2.4.3", "col3.4.3",
> "col4.4.3", "col5.4.3", "txt.5.3", "col1.5.3", "col2.5.3", "col3.5.3",
> "col4.5.3", "col5.5.3", "txt.6.3", "col1.6.3", "col2.6.3", "col3.6.3",
> "col4.6.3", "col5.6.3", "txt.7.3", "col1.7.3", "col2.7.3", "col3.7.3",
> "col4.7.3", "col5.7.3", "txt.8.3", "col1.8.3", "col2.8.3", "col3.8.3",
> "col4.8.3", "col5.8.3", "txt.9.3", "col1.9.3", "col2.9.3", "col3.9.3",
> "col4.9.3", "col5.9.3", "txt.10.3", "col1.10.3", "col2.10.3",
> "col3.10.3", "col4.10.3", "col5.10.3", "txt.11.3", "col1.11.3",
> "col2.11.3", "col3.11.3", "col4.11.3", "col5.11.3", "txt.12.3",
> "col1.12.3", "col2.12.3", "col3.12.3", "col4.12.3", "col5.12.3",
> "txt.13.3", "col1.13.3", "col2.13.3", "col3.13.3", "col4.13.3",
> "col5.13.3", "txt.14.3", "col1.14.3", "col2.14.3", "col3.14.3",
> "col4.14.3", "col5.14.3", "txt.15.3", "col1.15.3", "col2.15.3",
> "col3.15.3", "col4.15.3", "col5.15.3", "txt.16.3", "col1.16.3",
> "col2.16.3", "col3.16.3", "col4.16.3", "col5.16.3", "txt.17.3",
> "col1.17.3", "col2.17.3")
>
> I'd like to convert only ^col variables to have eg
>
> >From "col4.1.3" --> To "dom3.rig1.col4"
>
> to test the matching regex I've tryied
>
> grep("^col\\d{1,2}.\\d{1,2}.\\d{1,2}$",varnames, perl=T, value=T)
>
> to substitute the ^col variables, I've tryied
>
> gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", varnames)
>
> I'm a newbie with regexps and I got the starting vector (==varnames)
>
> all(gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", 
> varnames) == varnames )
>
> How can I do?
>
> Many thanks and have a nice weekend.
>
> Luca
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 that 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] help with regexp mass substitution

2009-10-02 Thread Gabor Grothendieck
dot (.) matches anything so be sure to escape it so that it only
matches a literal dot in your regular expression.

On Fri, Oct 2, 2009 at 5:39 AM, Luca Braglia  wrote:
> Hello *
>
> i have to rename a lot of variables, and, given that they have regular name 
> constructs, I would like to use regexps.
>
> Here's a dump of my head(names(df))
>
> varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3",
> "col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3",
> "col4.2.3", "col5.2.3", "txt.3.3", "col1.3.3", "col2.3.3", "col3.3.3",
> "col4.3.3", "col5.3.3", "txt.4.3", "col1.4.3", "col2.4.3", "col3.4.3",
> "col4.4.3", "col5.4.3", "txt.5.3", "col1.5.3", "col2.5.3", "col3.5.3",
> "col4.5.3", "col5.5.3", "txt.6.3", "col1.6.3", "col2.6.3", "col3.6.3",
> "col4.6.3", "col5.6.3", "txt.7.3", "col1.7.3", "col2.7.3", "col3.7.3",
> "col4.7.3", "col5.7.3", "txt.8.3", "col1.8.3", "col2.8.3", "col3.8.3",
> "col4.8.3", "col5.8.3", "txt.9.3", "col1.9.3", "col2.9.3", "col3.9.3",
> "col4.9.3", "col5.9.3", "txt.10.3", "col1.10.3", "col2.10.3",
> "col3.10.3", "col4.10.3", "col5.10.3", "txt.11.3", "col1.11.3",
> "col2.11.3", "col3.11.3", "col4.11.3", "col5.11.3", "txt.12.3",
> "col1.12.3", "col2.12.3", "col3.12.3", "col4.12.3", "col5.12.3",
> "txt.13.3", "col1.13.3", "col2.13.3", "col3.13.3", "col4.13.3",
> "col5.13.3", "txt.14.3", "col1.14.3", "col2.14.3", "col3.14.3",
> "col4.14.3", "col5.14.3", "txt.15.3", "col1.15.3", "col2.15.3",
> "col3.15.3", "col4.15.3", "col5.15.3", "txt.16.3", "col1.16.3",
> "col2.16.3", "col3.16.3", "col4.16.3", "col5.16.3", "txt.17.3",
> "col1.17.3", "col2.17.3")
>
> I'd like to convert only ^col variables to have eg
>
> >From "col4.1.3" --> To "dom3.rig1.col4"
>
> to test the matching regex I've tryied
>
> grep("^col\\d{1,2}.\\d{1,2}.\\d{1,2}$",varnames, perl=T, value=T)
>
> to substitute the ^col variables, I've tryied
>
> gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", varnames)
>
> I'm a newbie with regexps and I got the starting vector (==varnames)
>
> all(gsub("^col(\\d{1,2}).(\\d{1,2}).(\\d{1,2})", "dom\\3.rig\\2.col\\1", 
> varnames) == varnames )
>
> How can I do?
>
> Many thanks and have a nice weekend.
>
> Luca
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread Gabor Grothendieck
That part wasn't specified so we can't say what the required behavior
is in that case; however, if a non-multiple of 3 were possible and if
the short string is to be emitted at the end then we can just add to
the regular expression:

> library(gsubfn)
> s <- paste(letters, collapse = "")

> strapply(s, "...|..$|.$", c)[[1]]
[1] "abc" "def" "ghi" "jkl" "mno" "pqr" "stu" "vwx" "yz"

On Fri, Oct 2, 2009 at 8:08 AM, jim holtman  wrote:
> But it misses the last set if not a multiple of the subset length:
>
>> library(gsubfn)
>> s <- "abcdefghijklm"
>>
>> # no 'm'
>> strapply(s, "...")[[1]]
> [1] "abc" "def" "ghi" "jkl"
>>
>
>
> On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
>  wrote:
>> Try this:
>>
>>> library(gsubfn)
>>> s <- "abcdefghijkl"
>>
>>> strapply(s, "...")[[1]]
>> [1] "abc" "def" "ghi" "jkl"
>>
>>
>> On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:
>>>
>>> dear all,
>>>
>>> I have some very long strings and would like to break up each long string
>>> into multiple strings with a fixed length, e.g. to break up
>>>
>>> abcdefghijkl
>>>
>>> into
>>>
>>> abc, def, ghi, jkl
>>>
>>> I tried a couple of commands but was not successful. Any help will be
>>> appreciated.
>>>
>>> Best,
>>> Jimmy
>>> --
>>> View this message in context: 
>>> http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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 that 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] split-apply question

2009-10-02 Thread David Winsemius
As is typical with R there are often other ways. Here is another  
approach that determines the rows of interest with tapply and min,  
converts those minimums into logical "targets" with %in%, and extracts  
them from "x" using indexing:


x[x$x2 %in% tapply(x$x2, x$x1, min), ]


  x1 x2  x3
1  A  1 1.5
2  B  2 0.9
4  C  7 1.8
5  D  7 1.3

You might want to determine whether both would return all rows if  
there were multiple instances of a minimum. I think the above solution  
would return multiples while the one below would not. You choose based  
on the nature of the problem.


--
David


On Oct 2, 2009, at 5:24 AM, jim holtman wrote:


try this:


x <- read.table(textConnection("x1  x2  x3

+ A   11.5
+ B   20.9
+ B   32.7
+ C   71.8
+ D   71.3"), header=TRUE)

closeAllConnections()
do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){

+ x[.row[which.min(x$x2[.row])],]
+ }))
 x1 x2  x3
A  A  1 1.5
B  B  2 0.9
C  C  7 1.8
D  D  7 1.3





On Thu, Oct 1, 2009 at 11:43 PM, Kavitha Venkatesan
 wrote:

Hi,

I have a data frame that looks like this:


x


x1  x2  x3
A   11.5
B   20.9
B   32.7
C   71.8
D   71.3

I want to "group" by the x1 column and in the case of multiple x$x1  
values
(e.g., "B")d, return rows that have the smallest values of x2. In  
the case
of rows with only one value of x1 (e.g., "A"), return the row as  
is. How can
I do that?  For example, in the above case, the output I want would  
be:


x1  x2  x3
A   11.5
B   20.9
C   71.8
D   71.3


Thanks!

   [[alternative HTML version deleted]]

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





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

What is the problem that 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Robust ANOVA with variance heterogeneity

2009-10-02 Thread David Winsemius
There are multiple routes to "robust" statistics, but the quick answer  
to this question is probably friedman.test


I seem to remember a CRAN Task View on the area of Robust Statistics.

--
David Winsemius


On Oct 2, 2009, at 3:05 AM, Maike Luhmann wrote:


Dear list members,

I am looking for an alternative function for a two-way ANOVA in the  
case of
variance heterogeneity. For one-way ANOVA, I found oneway.test(),  
but I
didn't find anything alike for two-way ANOVA. Does anyone have a  
suggestion?


Thank you!

Maike Luhmann
Freie Universität Berlin


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] split-apply question

2009-10-02 Thread Henrique Dallazuanna
You can use aggregate:

aggregate(x[,c('x2','x3')], x['x1'], min)

On Fri, Oct 2, 2009 at 12:43 AM, Kavitha Venkatesan
 wrote:
> Hi,
>
> I have a data frame that looks like this:
>
>>x
>
> x1  x2  x3
> A   1    1.5
> B   2    0.9
> B   3    2.7
> C   7    1.8
> D   7    1.3
>
> I want to "group" by the x1 column and in the case of multiple x$x1 values
> (e.g., "B")d, return rows that have the smallest values of x2. In the case
> of rows with only one value of x1 (e.g., "A"), return the row as is. How can
> I do that?  For example, in the above case, the output I want would be:
>
> x1  x2  x3
> A   1    1.5
> B   2    0.9
> C   7    1.8
> D   7    1.3
>
>
> Thanks!
>
>        [[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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fetch large sized file from SQL

2009-10-02 Thread Dr. Alireza Zolfaghari
Hi List,
Does any one know what package I need to use in order to fetch/get a large
sized dataframe from SQL? I have already used sqldf package which is good
for fetching large sized csv files.

Thanks
Alireza

[[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] inverse currying

2009-10-02 Thread baptiste auguie
After some more digging (grep "alist" R-devel/ ), I've come up with this,

tools:::as.alist.symbol("x")

sugar = function(fun, id = "id"){
 ff <- formals(fun)
 if( id %in% names(ff))
   stop(paste(id, "is part of args(fun)"))

 new.arg <- tools:::as.alist.symbol(id)

 formals(fun) <- c(unlist(ff), new.arg)
 fun

}

foo = function(x, a=1){
 x
}

sugar(foo)
sugar(foo, 'a')
sugar(sugar(foo))

sugar(foo, 'my.new.arg')


Best,

baptiste



2009/10/1 baptiste auguie :
> Dear list,
>
> I have the following function,
>
> sugar = function(fun, id = "id"){
>  ff <- formals(fun)
>  if( id %in% names(ff))
>    stop("id is part of args(fun)")
>  formals(fun) <- c(unlist(ff), alist(id=))
>  fun
> }
>
> which one may use on a function foo,
>
> foo = function(x){
>  x
> }
>
> sugar(foo) # results in the extended closure,
>
> function (x, id)
> {
>    x
> }
>
> Its limitation (other than not working with .Primitives) is the 'id'
> tag that I add in the formals of fun(). I don't know how to create a
> alist(id=) pairlist where id can be changed. I tried the usual bquote
> and substitute approach but they don't seem to work here. I suppose I
> could do something like,
>
> parse(text = paste("alist(",id, "=)", sep=""))
>
> but this is usually not recommended.
>
> Any ideas?
>
> Best regards,
>
> baptiste
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rd files, \itemize in \value

2009-10-02 Thread Gábor Csárdi
Dear All,

how can I create a list in the \value{} section of an Rd file? The
things I have tried:

1.

\value{
text text
\item more text
\item even more
}

*** Syntax error: \item in
/-
\item more text
\item even more\-

2.

\value{
text text
\item{more text}
\item{even more}
}

This gives no error or warning, but the manual page looks as

Value:
 text text

more text: Numeric scalar giving the minimum correlation for
  convergence.

even more: Numeric scalar giving the minimum correlation for
  convergence.


The "Numeric..." text is coming from the last \item{} in arguments{}...

3.

\value{
text text
\itemize{
\item{more text}
\item{even more}
}
}

Gives the same result as 2, but with a warning

Is there a proper way?

Thanks,
Gabor

-- 
Gabor Csardi  UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] split-apply question

2009-10-02 Thread hadley wickham
On Fri, Oct 2, 2009 at 4:24 AM, jim holtman  wrote:
> try this:
>
>> x <- read.table(textConnection("x1  x2  x3
> + A   1    1.5
> + B   2    0.9
> + B   3    2.7
> + C   7    1.8
> + D   7    1.3"), header=TRUE)
>> closeAllConnections()
>> do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){
> +     x[.row[which.min(x$x2[.row])],]
> + }))
>  x1 x2  x3
> A  A  1 1.5
> B  B  2 0.9
> C  C  7 1.8
> D  D  7 1.3
>>

Or, using plyr and subset

library(plyr)
ddply(x, "x1", subset, x2 == min(x2))

Hadley

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

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


Re: [R] Problem with dist (bug?)

2009-10-02 Thread Corrado
Dear list,

here is the code that generates the problem:

library(proxy)
scot<-read.csv("scot.csv",header=TRUE)
scot24_climate<-scot24[,1105:1109]

# Scotland
dist_scot24_climate<-
dist(scot24_climate,method="correlation",diag=TRUE,upper=TRUE)

max(dist_scot24_climate)  

is 1.9. I do not think it should be, because the value is usually the cos() of 
the angle between the 2 vectors. If you use method="cosine" you have  1.8, 
which I think it should not be.

Is there a problem with the way I use it, or is there a bug?

I have been able to reduce the scot.csv to under 200MB, but I thought of not 
posting it to the list 

> We need to see the data and the script that produced the error.
>
> On Fri, Oct 2, 2009 at 5:06 AM, Corrado  wrote:
> > Dear list,
> >
> > using package "proxy".
> >


> > In one situation, the dissimilarity between two vectors based on
> > method=correlation returns a value of 1.9. That should not happen, should
> > it?
> >
> > The correlation is normally the cos() of the angle between the two
> > vectors 
> >
> > Any clue?
> >
> > Package dist 0.4-3 on R 2.9.2 on Kubuntu 904 64 bit.
> >
> > Regards
> > --
> > Corrado Topi
> >
> > Global Climate Change & Biodiversity Indicators
> > Area 18,Department of Biology
> > University of York, York, YO10 5YW, UK
> > Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html and provide commented,
> > minimal, self-contained, reproducible code.



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] Fetch large sized file from SQL

2009-10-02 Thread Corrado
You can try using RODBC, it allows you to connect to databases using the ODBC 
driver. 

I had some difficulties using it with the postgresSQL driver in the past, 
because of some apparent incompatibility with the native postrgesSQL ODBC 
driver. I think the problem where solved by the new ODBC driver for 
postgresSQL and the new revision for RODBC.

On Friday 02 October 2009 13:56:02 Dr. Alireza Zolfaghari wrote:
> Hi List,
> Does any one know what package I need to use in order to fetch/get a large
> sized dataframe from SQL? I have already used sqldf package which is good
> for fetching large sized csv files.
>
> Thanks
> Alireza
>
>   [[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.



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


[R] Legend

2009-10-02 Thread Ashta
I have more than three lines in one  and I want to add a legend  for each
line

abline( m1, col = 'red' )
ablime( m2, col = 'blue' )
abline( m3, col = 'purple' )

How can I add a legend? . Is it also possible to increase the thickness of
the lines?

Thanks

[[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] Legend

2009-10-02 Thread Gábor Csárdi
On Fri, Oct 2, 2009 at 3:46 PM, Ashta  wrote:
> I have more than three lines in one  and I want to add a legend  for each
> line
>
> abline( m1, col = 'red' )
> ablime( m2, col = 'blue' )
> abline( m3, col = 'purple' )
>
> How can I add a legend? .

Surprisingly, it is the legend() function. See ?legend.

>  Is it also possible to increase the thickness of
> the lines?

It is, see the 'lwd' parameter in ?par.

Best,
Gabor

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



-- 
Gabor Csardi  UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Legend

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 9:46 AM, Ashta wrote:

I have more than three lines in one  and I want to add a legend  for  
each

line

abline( m1, col = 'red' )
ablime( m2, col = 'blue' )
abline( m3, col = 'purple' )

How can I add a legend? . Is it also possible to increase the  
thickness of

the lines?


?abline and this time pay closer attention to the lwd parameter.

The answer to the legend question may depend on the details of the  
plot call, but I am unclear why you have not yet tried:


?legend

I am getting the impression that you are not taking advantage of R's  
help system.


--
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fetch large sized file from SQL

2009-10-02 Thread Dr. Alireza Zolfaghari
But the problem is that the dataframe size in sql is large, therefore odbc
can sqlQuery() can not handel it.

On Fri, Oct 2, 2009 at 2:14 PM, Corrado  wrote:

> You can try using RODBC, it allows you to connect to databases using the
> ODBC
> driver.
>
> I had some difficulties using it with the postgresSQL driver in the past,
> because of some apparent incompatibility with the native postrgesSQL ODBC
> driver. I think the problem where solved by the new ODBC driver for
> postgresSQL and the new revision for RODBC.
>
> On Friday 02 October 2009 13:56:02 Dr. Alireza Zolfaghari wrote:
> > Hi List,
> > Does any one know what package I need to use in order to fetch/get a
> large
> > sized dataframe from SQL? I have already used sqldf package which is good
> > for fetching large sized csv files.
> >
> > Thanks
> > Alireza
> >
> >   [[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.htmland
> >  provide commented, minimal,
> > self-contained, reproducible code.
>
>
>
> --
> Corrado Topi
>
> Global Climate Change & Biodiversity Indicators
> Area 18,Department of Biology
> University of York, York, YO10 5YW, UK
> Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk
>
>

[[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] confint fails in quasibinomial glm: dims do not match

2009-10-02 Thread joris meys
Confint doesn't work if you have a multi-dimensional dependent variable.

Kind regards
Joris

On Fri, Oct 2, 2009 at 4:29 AM, smith_cc  wrote:
>
> I am unable to calculate confidence intervals for the slope estimate in a
> quasibinomial glm using confint(). Below is the output and the package info
> for MASS. Thanks in advance!
>
> R 2.9.2
> MASS 7.2-48
>
>> confint(glm.palive.0.str)
> Waiting for profiling to be done...
> Error: dims [product 37] do not match the length of object [74]
>> glm.palive.0.str
>
> Call:  glm(formula = cbind(alive, red) ~ str, family = quasibinomial,
> data = subset(master.palive, vtime == 0))
>
> Coefficients:
> (Intercept)         strs
>       1.05         1.01
>
> Degrees of Freedom: 36 Total (i.e. Null);  35 Residual
> Null Deviance:      20800
> Residual Deviance: 16200        AIC: NA
>
>> packageDescription("MASS")
> Bundle: VR
> Contains: MASS class nnet spatial
> Priority: recommended
> Version: 7.2-48
> Date: 2009-07-29
> Depends: R (>= 2.5.0), grDevices, graphics, stats, utils
> Suggests: lattice, nlme, survival
> Author: S original by Venables & Ripley. R port by Brian Ripley
> , following earlier work by Kurt Hornik and Albrecht
>                Gebhardt.
> Maintainer: Brian Ripley 
> BundleDescription: Functions and datasets to support Venables and Ripley,
> 'Modern Applied Statistics with S' (4th edition).
> License: GPL-2 | GPL-3
> URL: http://www.stats.ox.ac.uk/pub/MASS4/
> Packaged: 2009-07-31 13:56:57 UTC; ripley
> Repository: CRAN
> Date/Publication: 2009-08-05 11:20:53
> Package: MASS
> Description: The main library and the datasets
> Title: Main Package of Venables and Ripley's MASS
> LazyLoad: yes
> LazyData: yes
> Built: R 2.9.2; i686-pc-linux-gnu; 2009-08-25 10:52:10 UTC; unix
>
> Cheers,
> Chad
> --
> View this message in context: 
> http://www.nabble.com/confint-fails-in-quasibinomial-glm%3A-dims-do-not-match-tp25709756p25709756.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Fetch large sized file from SQL

2009-10-02 Thread Corrado
I think you can specify the number of rows to be loaded at a time.  It was 
quite a while ago. Try reading

?sqlQuery
?odbcConnect

I have loaded quite large tables.

On Friday 02 October 2009 14:59:59 Dr. Alireza Zolfaghari wrote:
> But the problem is that the dataframe size in sql is large, therefore odbc
> can sqlQuery() can not handel it.
>
> On Fri, Oct 2, 2009 at 2:14 PM, Corrado  wrote:
> > You can try using RODBC, it allows you to connect to databases using the
> > ODBC
> > driver.
> >
> > I had some difficulties using it with the postgresSQL driver in the past,
> > because of some apparent incompatibility with the native postrgesSQL ODBC
> > driver. I think the problem where solved by the new ODBC driver for
> > postgresSQL and the new revision for RODBC.
> >
> > On Friday 02 October 2009 13:56:02 Dr. Alireza Zolfaghari wrote:
> > > Hi List,
> > > Does any one know what package I need to use in order to fetch/get a
> >
> > large
> >
> > > sized dataframe from SQL? I have already used sqldf package which is
> > > good for fetching large sized csv files.
> > >
> > > Thanks
> > > Alireza
> > >
> > >   [[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 > >sting-guide.html>and provide commented, minimal, self-contained,
> > > reproducible code.
> >
> > --
> > Corrado Topi
> >
> > Global Climate Change & Biodiversity Indicators
> > Area 18,Department of Biology
> > University of York, York, YO10 5YW, UK
> > Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk



-- 
Corrado Topi

Global Climate Change & Biodiversity Indicators
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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


Re: [R] How to use Subpopulation data?

2009-10-02 Thread KABELI MEFANE
Thank you very much!!
 
To trouble you again: I cannot do the sum and i have looked at several package 
since startng with this problem. I have a very large code just to do simple 
random, normal stratified sampling with proportional allocation and Dollar 
stratification with Neyman allocation using that dataframe i created. Now the 
code its becoming very large i just wish i could just call everything by the 
same name it was called in the original data frame, i tried usiing attach with 
no success. Therefore if you can just help me calculate the sum and mean then i 
will learn how to shorten this code. 
 
Thanks once again you really helped a lot.Thanks 

--- On Fri, 2/10/09, Bernardo Rangel Tura  wrote:


From: Bernardo Rangel Tura 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 10:08 AM


On Fri, 2009-10-02 at 00:42 +, KABELI MEFANE wrote:
> Thanks
> 
> But it seems like you don't get my problem.Do you mean that there is 
> something wrong with the code as it seems like what you are doing is 
> suggesting different ways to write a code. 
> 
> Will i get to use the variable that have been name previously like if i want 
> to calculate the standard deviation of stratum hypermarket in a sample not 
> population, the first start is to check if it would help me is to check the 
> length() of different levels if it is not same as that of the original data
> 
> Best Regards
> 
> I rest my case, i might dream it

Sorry

I don't understand your problem early.

In your case you have 2 data.frames: sampleframe and sample.strat so you
need show to R where calculate sd or length or summary


set.seed(1)# only to make this example don't use in your code
stra<-strata(sampleframe,c("type"),size=c(20,80,200,300,400),method="srswor")
sample.strat<-getdata(sampleframe,stra)

length of value in sampleframe where type is Hypermarket:
> length(sampleframet$value[sampleframe$type=="Hypermarket"]) 
[1] 100

SD of value in sampleframe where type is Hypermarket:
> sd(sampleframe$value[sampleframet$type=="Hypermarket"])
[1] 4586.854

length of value in sample.strat where type is Hypermarket:
> length(sample.strat$value[sample.strat$type=="Hypermarket"] )
[1] 20

SD of value in sample.strat where type is Hypermarket:
> sd(sample.strat$value[sample.strat$type=="Hypermarket"] )
[1] 4679.336


-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil




  
[[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] svDialogs

2009-10-02 Thread Tubin

Did you ever get a response on this?  I have been having a similar problem.

Thanks,
Sarah


antje-4 wrote:
> 
> Hi there,
> 
> I was using Open/Save-dialogs from the package svDialogs (SciViews). But
> now 
> the package has dissapeared? How do I have to set up my R-installation to 
> further use these dialogs??? (beside copying my old packages to the new 
> installation).
> 
> Ciao,
> Antje
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/svDialogs-tp22539778p25716496.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to use Subpopulation data?

2009-10-02 Thread David Winsemius


On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:


Dear Helpers

I have a sample frame and i have sampled from it using three methods  
and now i want to calculate the statistics but i only get the  
population parameters.


H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe

str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat


If you want the number of rows in sample.strat then length(H) is the  
wrong approach since that is the original (unsampled) object.



length(H)
i get:

length(H)
[1] 100

Desire to get:
length(H)
[1] 20


I cannot tell what packages you have loaded and strata is not in the  
sampling package which I guessed (wrongly) was where you were getting  
"getdata". When you post code you should precede that code with calls  
that load any non-base packages.


In later posting you ask for ways to calculate "the sum" but you do  
not say what it is that you want the sum of . Our abilities to  
read minds is extremely limited.


--
David Winsemius

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] svDialogs

2009-10-02 Thread Philippe Grosjean

Hello,

Now, the *bundle* SciViews has disappeared from CRAN, but the *package* 
svDialogs is still there.

Best,

Philippe
..<°}))><
 ) ) ) ) )
( ( ( ( (Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons University, Belgium
( ( ( ( (
..

Tubin wrote:

Did you ever get a response on this?  I have been having a similar problem.

Thanks,
Sarah


antje-4 wrote:

Hi there,

I was using Open/Save-dialogs from the package svDialogs (SciViews). But
now 
the package has dissapeared? How do I have to set up my R-installation to 
further use these dialogs??? (beside copying my old packages to the new 
installation).


Ciao,
Antje

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] How to select a subset

2009-10-02 Thread Hyo Lee
Hi guys,
I need your help.

I would like to select a subset from a dataset.
This is the dimension of the dataset.

> dim(data1)
[1]   72   36 1916

so, it's like.. there are 1916 of  72 * 36 matrix. ==> looks like 72 * (
36*1916 )
**
*1)*
And I would like to select the first 72*36 matrix. This is how I did:

> two=data1[,1:36]
Error in data1[, 1:36] : incorrect number of dimensions

Do you have any idea how I should fix this?


*2) *I thought about another way to deal with this problem.
Firstly, I name the each column variable:

>colnames(data1)=paste('lati',1:36)

and then select:

>one=subset(data1,subset=TRUE, select = lati1:lati36)

but the problem is that, although I tried to select only 36 columns, above
command selects the all columns. (36*1916  =68976)
I think if I can name all the variables at one time, say ,
colnames(data1)=paste('lati',1:68976) ,then it wouldn't have been a problem.
(but obviously, <---this command does not work)
Do you have any idea how to deal with this??


*3)* After all, what I would really like to do is to transpose the data:
The dataset I have above is 72*68976. (hard to export to csv; since max
column# is 18000 something.)
I have to transpose the data.. obviously.
But, the problem is,  after I transpose the data and export it to csv, I
can't really see the data.
Besides, I think tranpose thing does not seem work as I want,
>bbb=t(as.matrix(data1))
>write.csv(bbb,"c:/oo.csv")

Please help me,
Thanks.

-Hyo

[[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] svDialogs

2009-10-02 Thread Tubin

Download the package to your hard drive from here:
http://cran.r-project.org/web/packages/svDialogs/ 

Then install directly using install.packages (for instructions on doing
this, type ?install.packages)

Just tried it, worked fine for me.


Hi there,

I was using Open/Save-dialogs from the package svDialogs (SciViews). But now 
the package has dissapeared? How do I have to set up my R-installation to 
further use these dialogs??? (beside copying my old packages to the new 
installation).

Ciao,
Antje

-- 
View this message in context: 
http://www.nabble.com/svDialogs-tp22539778p25716506.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to select a subset

2009-10-02 Thread Steve Lianoglou

Hi,

On Oct 2, 2009, at 10:47 AM, Hyo Lee wrote:


Hi guys,
I need your help.

I would like to select a subset from a dataset.
This is the dimension of the dataset.


dim(data1)

[1]   72   36 1916

so, it's like.. there are 1916 of  72 * 36 matrix. ==> looks like 72  
* (

36*1916 )
**
*1)*
And I would like to select the first 72*36 matrix. This is how I did:


two=data1[,1:36]

Error in data1[, 1:36] : incorrect number of dimensions


You have an object with three dimensions, but only passing in two dims  
to "slice" with.


Do you have any idea how I should fix this?


This is a similar array : think of it as 5 10x2 matrices

R> m <- array(1:100, dim=c(10,2,5))

I can get the first 10x2 matrix like so:

R> m[,,1]
  [,1] [,2]
 [1,]1   11
 [2,]2   12
 [3,]3   13
 [4,]4   14
 [5,]5   15
 [6,]6   16
 [7,]7   17
 [8,]8   18
 [9,]9   19
[10,]   10   20

The second would be: m[,,2]

Does answering the first question take care of the rest?

-steve




*2) *I thought about another way to deal with this problem.
Firstly, I name the each column variable:


colnames(data1)=paste('lati',1:36)


and then select:


one=subset(data1,subset=TRUE, select = lati1:lati36)


but the problem is that, although I tried to select only 36 columns,  
above

command selects the all columns. (36*1916  =68976)
I think if I can name all the variables at one time, say ,
colnames(data1)=paste('lati',1:68976) ,then it wouldn't have been a  
problem.

(but obviously, <---this command does not work)
Do you have any idea how to deal with this??


*3)* After all, what I would really like to do is to transpose the  
data:
The dataset I have above is 72*68976. (hard to export to csv; since  
max

column# is 18000 something.)
I have to transpose the data.. obviously.
But, the problem is,  after I transpose the data and export it to  
csv, I

can't really see the data.
Besides, I think tranpose thing does not seem work as I want,

bbb=t(as.matrix(data1))
write.csv(bbb,"c:/oo.csv")


Please help me,
Thanks.

-Hyo

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


--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread William Dunlap

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of jim holtman
> Sent: Friday, October 02, 2009 5:09 AM
> To: Gabor Grothendieck
> Cc: r-help@r-project.org; J Chen
> Subject: Re: [R] break up a string into strings with a fixed length
> 
> But it misses the last set if not a multiple of the subset length:
> 
> > library(gsubfn)
> > s <- "abcdefghijklm"
> >
> > # no 'm'
> > strapply(s, "...")[[1]]
> [1] "abc" "def" "ghi" "jkl"
> >

Perhaps the pattern ".{1,3}" would do it.

S+'s strapply has a keep=FALSE/TRUE argument.  If FALSE,
the default, it omits that parts of string that match the pattern
as R's strapply does.  If TRUE it keeps the parts of the string
that match the pattern and omits the parts that do not.  I added
it to make it easier to pull all the numbers out of a string that
might include commas, spaces, and words but it works in this
case also:

  > s<-sapply(1:10, function(i)substring("abcdefghij",1,i))
  > strsplit(s, ".{1,3}", keep=TRUE)[c(1,3,4,9,10)]
  [[1]]:
  [1] "a"

  [[2]]:
  [1] "abc"

  [[3]]:
  [1] "abc" "d"  

  [[4]]:
  [1] "abc" "def" "ghi"

  [[5]]:
  [1] "abc" "def" "ghi" "j"  

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
> 
> 
> On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
>  wrote:
> > Try this:
> >
> >> library(gsubfn)
> >> s <- "abcdefghijkl"
> >
> >> strapply(s, "...")[[1]]
> > [1] "abc" "def" "ghi" "jkl"
> >
> >
> > On Fri, Oct 2, 2009 at 5:36 AM, J Chen 
>  wrote:
> >>
> >> dear all,
> >>
> >> I have some very long strings and would like to break up 
> each long string
> >> into multiple strings with a fixed length, e.g. to break up
> >>
> >> abcdefghijkl
> >>
> >> into
> >>
> >> abc, def, ghi, jkl
> >>
> >> I tried a couple of commands but was not successful. Any 
> help will be
> >> appreciated.
> >>
> >> Best,
> >> Jimmy
> >> --
> >> View this message in context: 
> http://www.nabble.com/break-up-a-string-into-strings-with-a-fi
> xed-length-tp25712955p25712955.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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 that 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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Rd files, \itemize in \value

2009-10-02 Thread Duncan Murdoch

On 10/2/2009 9:05 AM, Gábor Csárdi wrote:

Dear All,

how can I create a list in the \value{} section of an Rd file? The
things I have tried:

1.

\value{
text text
\item more text
\item even more
}

*** Syntax error: \item in
/-
\item more text
\item even more\-

2.

\value{
text text
\item{more text}
\item{even more}
}

This gives no error or warning, but the manual page looks as


The value section is like the \arguments section, there's an implicit 
\describe around everything.




Value:
 text text

more text: Numeric scalar giving the minimum correlation for
  convergence.

even more: Numeric scalar giving the minimum correlation for
  convergence.


That looks like a bug:  you should have got nothing for the second arg 
(or an error/warning that it was missing).





The "Numeric..." text is coming from the last \item{} in arguments{}...

3.

\value{
text text
\itemize{
\item{more text}
\item{even more}
}
}

Gives the same result as 2, but with a warning


The itemize style of list has zero-arguments on \item.  So that's really 
a bug if "Numeric scalar..." is showing up here.



Is there a proper way?


If you want a \describe style of list, just enter items as

\item{name}{description}

If you want an itemize style of list, enter it as

\itemize{
  \item content
  \item more content
}

Thanks for the report...

Duncan Murdoch

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


Re: [R] Robust ANOVA with variance heterogeneity

2009-10-02 Thread Kjetil Halvorsen
On Fri, Oct 2, 2009 at 8:45 AM, David Winsemius  wrote:
> There are multiple routes to "robust" statistics, but the quick answer to
> this question is probably friedman.test

I don't think friedman.test is robust to variance heterogeneity. It is
only robust to
non-normality.

Kjetil



>
> I seem to remember a CRAN Task View on the area of Robust Statistics.
>
> --
> David Winsemius
>
>
> On Oct 2, 2009, at 3:05 AM, Maike Luhmann wrote:
>
>> Dear list members,
>>
>> I am looking for an alternative function for a two-way ANOVA in the case
>> of
>> variance heterogeneity. For one-way ANOVA, I found oneway.test(), but I
>> didn't find anything alike for two-way ANOVA. Does anyone have a
>> suggestion?
>>
>> Thank you!
>>
>> Maike Luhmann
>> Freie Universität Berlin
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] ggplot2: proper use of facet_grid inside a function

2009-10-02 Thread Bryan Hanson
Hello Again R Folk:

I have found items about this in the archives, but I’m still not getting
it right.  I want to use ggplot2 with facet_grid inside a function with
user specified variables, for instance:

p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(. ~
fac2)

Where data, fac1, fac2 and res are arguments to the function.  I have
tried

p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(. ~
as.name(fac2))

and 

p <- ggplot(data, aes_string(x = fac1, y = res)) + facet_grid(“. ~
fac2”)

But all of these produce the same error:

Error in `[.data.frame`(plot$data, , setdiff(cond, names(df)), drop =
FALSE) : 
  undefined columns selected

If I hardwire the true identity of fac2 into the function, it works as
desired, so I know this is a problem of connecting the name with the
proper value.

I'm up to date on everything:

R version 2.9.2 (2009-08-24) 
i386-apple-darwin8.11.1 

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid  datasets  tools utils stats graphics 
grDevices methods  
[9] base 

other attached packages:
 [1] Hmisc_3.6-0ggplot2_0.8.3  reshape_0.8.3 
proto_0.3-8   
 [5] mvbutils_2.2.0 ChemoSpec_1.1  lattice_0.17-25   
mvoutlier_1.4 
 [9] plyr_0.1.8 RColorBrewer_1.0-2 chemometrics_0.4   som_0.3-4 
   
[13] robustbase_0.4-5   rpart_3.1-45   pls_2.1-0  pcaPP_1.7 
   
[17] mvtnorm_0.9-7  nnet_7.2-48mclust_3.2
MASS_7.2-48   
[21] lars_0.9-7 e1071_1.5-19   class_7.2-48  

loaded via a namespace (and not attached):
[1] cluster_1.12.0

Thanks for any help!  Bryan
*
Bryan Hanson
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN 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.


[R] How to speed up R with version 2.9.2?

2009-10-02 Thread FMH
Dear All,

I'm sorry if my question does not suit with this R group.

I have recently installed R software with version 2.9.2, but i found the 
program took almost 1 minute as soon as it was opened, before it can be used. 
However, the previous version 2.9.1 only take few seconds after the menu bar 
was clicked. This circumstance has caused me to wait for couple of minutes as 
several R windows were opened simultaneously.

Are there any ways to speed up on this 2.9.2 version? Could someone give some 
hints, please?

Thank you
Fir




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] decision trees using the Hellinger distance rather than

2009-10-02 Thread Rajarshi Guha
Hi, while working with decision trees and unbalanced data, I came across the
use of the Hellinger distance as an alternative to information gain [1,2],
when dealing with skewed data. Does anybody know of R implementations of
this approach to decision trees?

Thanks,

[1] http://www.cse.nd.edu/Reports/2008/TR-2008-06.pdf
[2] http://csmr.ca.sandia.gov/~wpk/slides/wdmda-sem.pdf
-- 
Rajarshi Guha
NIH Chemical Genomics Center

[[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] How to speed up R with version 2.9.2?

2009-10-02 Thread stephen sefick
You're fine, but please do read the posting guide.  What OS etc.
Where you doing anything else on the computer?  Is this a RAM
limitation?  I have 2.9.2 running on two flavours of linux, mac os x
and windows all 2.9.2 and there doesn't seem to be a problem.
regards,

Stephen

On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
> Dear All,
>
> I'm sorry if my question does not suit with this R group.
>
> I have recently installed R software with version 2.9.2, but i found the 
> program took almost 1 minute as soon as it was opened, before it can be used. 
> However, the previous version 2.9.1 only take few seconds after the menu bar 
> was clicked. This circumstance has caused me to wait for couple of minutes as 
> several R windows were opened simultaneously.
>
> Are there any ways to speed up on this 2.9.2 version? Could someone give some 
> hints, please?
>
> Thank you
> Fir
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

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

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] decision trees using the Hellinger distance rather than

2009-10-02 Thread Erik Iverson
Do you happen to have a large .Rdata file that is being loaded, or something in 
your .Rprofile?  Try searching for a file with that name.  Or start R with a 
--vanilla and see if that helps... 

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Rajarshi Guha
> Sent: Friday, October 02, 2009 10:33 AM
> To: R
> Subject: [R] decision trees using the Hellinger distance rather than
> 
> Hi, while working with decision trees and unbalanced data, I came across
> the
> use of the Hellinger distance as an alternative to information gain [1,2],
> when dealing with skewed data. Does anybody know of R implementations of
> this approach to decision trees?
> 
> Thanks,
> 
> [1] http://www.cse.nd.edu/Reports/2008/TR-2008-06.pdf
> [2] http://csmr.ca.sandia.gov/~wpk/slides/wdmda-sem.pdf
> --
> Rajarshi Guha
> NIH Chemical Genomics Center
> 
>   [[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] How to speed up R with version 2.9.2?

2009-10-02 Thread FMH
Thank you for your answer. I'm using Win XP with 2GB RAM in memory.

Cheers
Fir



- Original Message 
From: stephen sefick 
To: FMH 
Cc: r-help@r-project.org
Sent: Fri, October 2, 2009 4:38:10 PM
Subject: Re: [R] How to speed up R with version 2.9.2?

You're fine, but please do read the posting guide.  What OS etc.
Where you doing anything else on the computer?  Is this a RAM
limitation?  I have 2.9.2 running on two flavours of linux, mac os x
and windows all 2.9.2 and there doesn't seem to be a problem.
regards,

Stephen

On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
> Dear All,
>
> I'm sorry if my question does not suit with this R group.
>
> I have recently installed R software with version 2.9.2, but i found the 
> program took almost 1 minute as soon as it was opened, before it can be used. 
> However, the previous version 2.9.1 only take few seconds after the menu bar 
> was clicked. This circumstance has caused me to wait for couple of minutes as 
> several R windows were opened simultaneously.
>
> Are there any ways to speed up on this 2.9.2 version? Could someone give some 
> hints, please?
>
> Thank you
> Fir
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Stephen Sefick

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

                                -K. Mullis





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 speed up R with version 2.9.2?

2009-10-02 Thread Erik Iverson
Sorry, original replied to wrong post... 

Do you happen to have a large .Rdata file that is being loaded, or something in 
your .Rprofile?  Try searching for a file with that name.  Or start R with a 
--vanilla and see if that helps...

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of FMH
> Sent: Friday, October 02, 2009 10:35 AM
> To: r-help@r-project.org
> Subject: [R] How to speed up R with version 2.9.2?
> 
> Dear All,
> 
> I'm sorry if my question does not suit with this R group.
> 
> I have recently installed R software with version 2.9.2, but i found the
> program took almost 1 minute as soon as it was opened, before it can be
> used. However, the previous version 2.9.1 only take few seconds after the
> menu bar was clicked. This circumstance has caused me to wait for couple
> of minutes as several R windows were opened simultaneously.
> 
> Are there any ways to speed up on this 2.9.2 version? Could someone give
> some hints, please?
> 
> Thank you
> Fir
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 speed up R with version 2.9.2?

2009-10-02 Thread Gabor Grothendieck
Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
  Rgui --vanilla
is much faster then your startup files are the problem.

On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>
> Cheers
> Fir
>
>
>
> - Original Message 
> From: stephen sefick 
> To: FMH 
> Cc: r-help@r-project.org
> Sent: Fri, October 2, 2009 4:38:10 PM
> Subject: Re: [R] How to speed up R with version 2.9.2?
>
> You're fine, but please do read the posting guide.  What OS etc.
> Where you doing anything else on the computer?  Is this a RAM
> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
> and windows all 2.9.2 and there doesn't seem to be a problem.
> regards,
>
> Stephen
>
> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>> Dear All,
>>
>> I'm sorry if my question does not suit with this R group.
>>
>> I have recently installed R software with version 2.9.2, but i found the 
>> program took almost 1 minute as soon as it was opened, before it can be 
>> used. However, the previous version 2.9.1 only take few seconds after the 
>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>> minutes as several R windows were opened simultaneously.
>>
>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>> some hints, please?
>>
>> Thank you
>> Fir
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                 -K. Mullis
>
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 speed up R with version 2.9.2?

2009-10-02 Thread Sundar Dorai-Raj
Another possibility is a very large .RData file in the directory where
you're starting R. You can try

Rgui --no-restore

(I don't have windows, so I'm not sure if this an option with RGui,
though I know it is with R.)

--sundar

On Fri, Oct 2, 2009 at 8:50 AM, Gabor Grothendieck
 wrote:
> Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
>  Rgui --vanilla
> is much faster then your startup files are the problem.
>
> On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
>> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>>
>> Cheers
>> Fir
>>
>>
>>
>> - Original Message 
>> From: stephen sefick 
>> To: FMH 
>> Cc: r-help@r-project.org
>> Sent: Fri, October 2, 2009 4:38:10 PM
>> Subject: Re: [R] How to speed up R with version 2.9.2?
>>
>> You're fine, but please do read the posting guide.  What OS etc.
>> Where you doing anything else on the computer?  Is this a RAM
>> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
>> and windows all 2.9.2 and there doesn't seem to be a problem.
>> regards,
>>
>> Stephen
>>
>> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>>> Dear All,
>>>
>>> I'm sorry if my question does not suit with this R group.
>>>
>>> I have recently installed R software with version 2.9.2, but i found the 
>>> program took almost 1 minute as soon as it was opened, before it can be 
>>> used. However, the previous version 2.9.1 only take few seconds after the 
>>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>>> minutes as several R windows were opened simultaneously.
>>>
>>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>>> some hints, please?
>>>
>>> Thank you
>>> Fir
>>>
>>>
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Stephen Sefick
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>                                 -K. Mullis
>>
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] How to speed up R with version 2.9.2?

2009-10-02 Thread FMH
Yes, i noticed there are few Windows start up programs, shown by the 
EasyCleaner software.

Cheers

 


- Original Message 
From: Gabor Grothendieck 
To: FMH 
Cc: stephen sefick ;
Sent: Fri, October 2, 2009 4:50:52 PM
Subject: Re: [R] How to speed up R with version 2.9.2?

Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
  Rgui --vanilla
is much faster then your startup files are the problem.

On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>
> Cheers
> Fir
>
>
>
> - Original Message 
> From: stephen sefick 
> To: FMH 
> Cc: r-help@r-project.org
> Sent: Fri, October 2, 2009 4:38:10 PM
> Subject: Re: [R] How to speed up R with version 2.9.2?
>
> You're fine, but please do read the posting guide.  What OS etc.
> Where you doing anything else on the computer?  Is this a RAM
> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
> and windows all 2.9.2 and there doesn't seem to be a problem.
> regards,
>
> Stephen
>
> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>> Dear All,
>>
>> I'm sorry if my question does not suit with this R group.
>>
>> I have recently installed R software with version 2.9.2, but i found the 
>> program took almost 1 minute as soon as it was opened, before it can be 
>> used. However, the previous version 2.9.1 only take few seconds after the 
>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>> minutes as several R windows were opened simultaneously.
>>
>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>> some hints, please?
>>
>> Thank you
>> Fir
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Stephen Sefick
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                 -K. Mullis
>
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 speed up R with version 2.9.2?

2009-10-02 Thread Gabor Grothendieck
I was thinking of startup code in your C:\Program
Files\R\R-2.9.2\etc\Rprofile.site file or other startup R file that
you provided.  See ?Startup

On Fri, Oct 2, 2009 at 12:01 PM, FMH  wrote:
> Yes, i noticed there are few Windows start up programs, shown by the 
> EasyCleaner software.
>
> Cheers
>
>
>
>
> - Original Message 
> From: Gabor Grothendieck 
> To: FMH 
> Cc: stephen sefick ;
> Sent: Fri, October 2, 2009 4:50:52 PM
> Subject: Re: [R] How to speed up R with version 2.9.2?
>
> Its under 5 seconds on my Vista laptop.  Do you have any startup files?  If
>   Rgui --vanilla
> is much faster then your startup files are the problem.
>
> On Fri, Oct 2, 2009 at 11:45 AM, FMH  wrote:
>> Thank you for your answer. I'm using Win XP with 2GB RAM in memory.
>>
>> Cheers
>> Fir
>>
>>
>>
>> - Original Message 
>> From: stephen sefick 
>> To: FMH 
>> Cc: r-help@r-project.org
>> Sent: Fri, October 2, 2009 4:38:10 PM
>> Subject: Re: [R] How to speed up R with version 2.9.2?
>>
>> You're fine, but please do read the posting guide.  What OS etc.
>> Where you doing anything else on the computer?  Is this a RAM
>> limitation?  I have 2.9.2 running on two flavours of linux, mac os x
>> and windows all 2.9.2 and there doesn't seem to be a problem.
>> regards,
>>
>> Stephen
>>
>> On Fri, Oct 2, 2009 at 10:35 AM, FMH  wrote:
>>> Dear All,
>>>
>>> I'm sorry if my question does not suit with this R group.
>>>
>>> I have recently installed R software with version 2.9.2, but i found the 
>>> program took almost 1 minute as soon as it was opened, before it can be 
>>> used. However, the previous version 2.9.1 only take few seconds after the 
>>> menu bar was clicked. This circumstance has caused me to wait for couple of 
>>> minutes as several R windows were opened simultaneously.
>>>
>>> Are there any ways to speed up on this 2.9.2 version? Could someone give 
>>> some hints, please?
>>>
>>> Thank you
>>> Fir
>>>
>>>
>>>
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Stephen Sefick
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>                                 -K. Mullis
>>
>>
>>
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread Stefan Th. Gries
This should do what you want:

x<-"abcdefghijkl"
strsplit(x, "(?<=...)", perl=T)

HTH,
STG
--
Stefan Th. Gries
---
University of California, Santa Barbara
http://www.linguistics.ucsb.edu/faculty/stgries

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] break up a string into strings with a fixed length

2009-10-02 Thread Gabor Grothendieck
Here is a slightly simpler version of the strapply solution with a
short string at the end:

> strapply("abcdefghijk", ".{1,3}")[[1]]
[1] "abc" "def" "ghi" "jk"

On Fri, Oct 2, 2009 at 8:20 AM, Gabor Grothendieck
 wrote:
> That part wasn't specified so we can't say what the required behavior
> is in that case; however, if a non-multiple of 3 were possible and if
> the short string is to be emitted at the end then we can just add to
> the regular expression:
>
>> library(gsubfn)
>> s <- paste(letters, collapse = "")
>
>> strapply(s, "...|..$|.$", c)[[1]]
> [1] "abc" "def" "ghi" "jkl" "mno" "pqr" "stu" "vwx" "yz"
>
> On Fri, Oct 2, 2009 at 8:08 AM, jim holtman  wrote:
>> But it misses the last set if not a multiple of the subset length:
>>
>>> library(gsubfn)
>>> s <- "abcdefghijklm"
>>>
>>> # no 'm'
>>> strapply(s, "...")[[1]]
>> [1] "abc" "def" "ghi" "jkl"
>>>
>>
>>
>> On Fri, Oct 2, 2009 at 7:58 AM, Gabor Grothendieck
>>  wrote:
>>> Try this:
>>>
 library(gsubfn)
 s <- "abcdefghijkl"
>>>
 strapply(s, "...")[[1]]
>>> [1] "abc" "def" "ghi" "jkl"
>>>
>>>
>>> On Fri, Oct 2, 2009 at 5:36 AM, J Chen  wrote:

 dear all,

 I have some very long strings and would like to break up each long string
 into multiple strings with a fixed length, e.g. to break up

 abcdefghijkl

 into

 abc, def, ghi, jkl

 I tried a couple of commands but was not successful. Any help will be
 appreciated.

 Best,
 Jimmy
 --
 View this message in context: 
 http://www.nabble.com/break-up-a-string-into-strings-with-a-fixed-length-tp25712955p25712955.html
 Sent from the R help mailing list archive at Nabble.com.

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

>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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 that 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] Normal distribution

2009-10-02 Thread Greg Snow
See fortune(234)

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Noela Sánchez
> Sent: Thursday, October 01, 2009 10:47 AM
> To: r-help@r-project.org
> Subject: [R] Normal distribution
> 
> Hi,
> 
> I am dealing with how to check in R if some data that I have belongs to
> a
> normal distribution or not. I am not interested in obtaining the
> theoreticall frequencies. I am only interested in determing if (by
> means of
> a test as Kolmogorov, or whatever), if my data are normal or not.
> 
> But I have tried with ks.test() and I have not got it.
> 
> 
> --
> Noela
> Grupo de Recursos Marinos y Pesquerías
> Universidad de A Coruña
> 
>   [[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] confint fails in quasibinomial glm: dims do not match

2009-10-02 Thread Peter Ehlers

Chad,

(inline below)

joris meys wrote:

Confint doesn't work if you have a multi-dimensional dependent variable.


Well, it will work, but not for the quasibinomial family.

The simple solution would seem to be to change your response from
the matrix cbind(,) to the vector alive/sum(alive+red) and use
the weights=sum(alive+red) argument.

 -Peter Ehlers



Kind regards
Joris

On Fri, Oct 2, 2009 at 4:29 AM, smith_cc  wrote:

I am unable to calculate confidence intervals for the slope estimate in a
quasibinomial glm using confint(). Below is the output and the package info
for MASS. Thanks in advance!

R 2.9.2
MASS 7.2-48


confint(glm.palive.0.str)

Waiting for profiling to be done...
Error: dims [product 37] do not match the length of object [74]

glm.palive.0.str

Call:  glm(formula = cbind(alive, red) ~ str, family = quasibinomial,
data = subset(master.palive, vtime == 0))

Coefficients:
(Intercept) strs
  1.05 1.01

Degrees of Freedom: 36 Total (i.e. Null);  35 Residual
Null Deviance:  20800
Residual Deviance: 16200AIC: NA


packageDescription("MASS")

Bundle: VR
Contains: MASS class nnet spatial
Priority: recommended
Version: 7.2-48
Date: 2009-07-29
Depends: R (>= 2.5.0), grDevices, graphics, stats, utils
Suggests: lattice, nlme, survival
Author: S original by Venables & Ripley. R port by Brian Ripley
, following earlier work by Kurt Hornik and Albrecht
   Gebhardt.
Maintainer: Brian Ripley 
BundleDescription: Functions and datasets to support Venables and Ripley,
'Modern Applied Statistics with S' (4th edition).
License: GPL-2 | GPL-3
URL: http://www.stats.ox.ac.uk/pub/MASS4/
Packaged: 2009-07-31 13:56:57 UTC; ripley
Repository: CRAN
Date/Publication: 2009-08-05 11:20:53
Package: MASS
Description: The main library and the datasets
Title: Main Package of Venables and Ripley's MASS
LazyLoad: yes
LazyData: yes
Built: R 2.9.2; i686-pc-linux-gnu; 2009-08-25 10:52:10 UTC; unix

Cheers,
Chad
--
View this message in context: 
http://www.nabble.com/confint-fails-in-quasibinomial-glm%3A-dims-do-not-match-tp25709756p25709756.html
Sent from the R help mailing list archive at Nabble.com.

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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] nls not accepting control parameter?

2009-10-02 Thread Peter Ehlers

Hello Rainer,

I think that your problem is with trying to fit a logistic model to
data that don't support that model. Removing the first two points
from your data will work (but of course it may not represent reality).
The logistic function does not exhibit the kind of minimum that
your data suggest.

 -Peter Ehlers

Rainer M Krug wrote:

Hi

I want to change a control parameter for an nls () as I am getting an error
message  "step factor 0.000488281 reduced below 'minFactor' of 0.000976562".
Despite all tries, it seems that the control parameter of the nls, does not
seem to get handed down to the function itself, or the error message is
using a different one.

Below system info and an example highlighting the problem.

Thanks,

Rainer



version   _

platform   i486-pc-linux-gnu
arch   i486
os linux-gnu
system i486, linux-gnu
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)


sessionInfo()

R version 2.9.2 (2009-08-24)
i486-pc-linux-gnu

locale:
LC_CTYPE=en_ZA.UTF-8;LC_NUMERIC=C;LC_TIME=en_ZA.UTF-8;LC_COLLATE=en_ZA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_ZA.UTF-8;LC_PAPER=en_ZA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_ZA.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] R.utils_1.2.0 R.oo_1.5.0R.methodsS3_1.0.3 maptools_0.7-26
[5] sp_0.9-44 foreign_0.8-37

loaded via a namespace (and not attached):
[1] grid_2.9.2  lattice_0.17-25


#

EXAMPLE:

dat <- data.frame(
  x = 2006:2037,
  y = c(143088, 140218, 137964,
138313, 140005, 141483, 142365,
144114, 145335, 146958, 148584,
149398, 151074, 152241, 153919,
155580, 157258, 158981, 160591,
162126, 163743, 165213, 166695,
168023, 169522, 170746, 172057,
173287, 173977, 175232, 176308,
177484)
  )

nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, trace=TRUE)

(newMinFactor <- 1/(4*1024))
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=nls.control(minFactor=newMinFactor), trace=TRUE)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=c(minFactor=newMinFactor), trace=TRUE)


(newMinFactor <- 4/1024)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=nls.control(minFactor=newMinFactor), trace=TRUE)
nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat,
control=c(minFactor=newMinFactor), trace=TRUE)





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] split-apply question

2009-10-02 Thread William Dunlap

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of hadley wickham
> Sent: Friday, October 02, 2009 6:07 AM
> To: jim holtman
> Cc: r-help@r-project.org; Kavitha Venkatesan
> Subject: Re: [R] split-apply question
> 
> On Fri, Oct 2, 2009 at 4:24 AM, jim holtman 
>  wrote:
> > try this:
> >
> >> x <- read.table(textConnection("x1  x2  x3
> > + A   1    1.5
> > + B   2    0.9
> > + B   3    2.7
> > + C   7    1.8
> > + D   7    1.3"), header=TRUE)
> >> closeAllConnections()
> >> do.call(rbind, lapply(split(seq(nrow(x)), x$x1), function(.row){
> > +     x[.row[which.min(x$x2[.row])],]
> > + }))
> >  x1 x2  x3
> > A  A  1 1.5
> > B  B  2 0.9
> > C  C  7 1.8
> > D  D  7 1.3
> >>
> 
> Or, using plyr and subset
> 
> library(plyr)
> ddply(x, "x1", subset, x2 == min(x2))
> 
> Hadley

Since we are using min() we can use sorting tricks

f3 <- function(x) {
   x <- x[with(x, order(x1,x2)),]
   isFirstInRun <- function(z)c(TRUE, z[-1] != z[-length(z)])
   x[isFirstInRun(x$x1),]
}

This has the advantage that it keeps the original row names intact.
It is quick even when there are lots of unique values in x1.

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] text mining

2009-10-02 Thread PDXRugger

The following code is derived from a paper titled "Text Mining Infrastructure
in R" (http://www.jstatsoft.org/v25/i05/paper).  The example below seems to
load some default documents for analysis, some sort of latin document.  I
cannot for the life of me figure out to load my own document let alone an
entire corpus.  I have searched the above documenet as well as related
documentation.  Any leads or help would be appreciated.  Thanks everyone

from document

txt <- system.file("texts", "txt", package = "tm")
 (ovid <- Corpus(DirSource(txt),
 readerControl = list(reader = readPlain,
language = "la",
 load = TRUE)))

my attempt
txt <- system.file("Speeches/speech", "txt", package = "tm")
 (ovid <- Corpus(DirSource(txt),
 readerControl = list(reader = readPlain,
language = "la",
 load = TRUE)))


-- 
View this message in context: 
http://www.nabble.com/text-mining-tp25717142p25717142.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] loop problem

2009-10-02 Thread crenial30

Thanks a lot David for your answer. I am sorry for being so minimal.

I wanted to produce a list/vector/table consisting each vector produced from
this code

len<-20
for (n1 in seq(0,(len-1),by=1)){

f <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] + 300*(n1+1))]
//create list for each values of n1

R_ev_char <- as.character(f)

lis01 <- c(length(R_ev_char)) // here I want to store the values of lengths
of R_ev_char vector for successive values of n1(0,1,2,3,...20)

I already tried with vector notation but no help.

I just want to store Lengths on each successive  integer so that I can draw
the list on 300(secs) interval.

Any suggestion would be very much helpful.
crenial


crenial30 wrote:
> 
> I have the following code which I wanted to convert using for loop
> 
> previous code:
> R_ev1 <- R_event[R_event > (rx[1] + 300*0)& R_event <= (rx[1] + 300*1)]
> R_ev2 <- R_event[R_event > (rx[1] + 300*1)& R_event <= (rx[1] + 300*2)]
> R_ev3 <- R_event[R_event > (rx[1] + 300*2)& R_event <= (rx[1] + 300*3)]
> R_ev4 <- R_event[R_event > (rx[1] + 300*3)& R_event <= (rx[1] + 300*4)]
> 
> R_ev5 <- R_event[R_event > (rx[1] + 300*4)& R_event <= (rx[1] + 300*5)]
> R_ev6 <- R_event[R_event > (rx[1] + 300*5)& R_event <= (rx[1] + 300*6)]
> R_ev7 <- R_event[R_event > (rx[1] + 300*6)& R_event <= (rx[1] + 300*7)]
> R_ev8 <- R_event[R_event > (rx[1] + 300*7)& R_event <= (rx[1] + 300*8)]
> 
> R_ev9 <- R_event[R_event  > (rx[1] + 300*8)& R_event <= (rx[1] + 300*9)]
> R_ev10 <- R_event[R_event > (rx[1] + 300*9)& R_event <= (rx[1] + 300*10)]
> R_ev11 <- R_event[R_event > (rx[1] + 300*10)& R_event <= (rx[1] + 300*11)]
> R_ev12 <- R_event[R_event > (rx[1] + 300*11)& R_event <= (rx[1] + 300*12)]
> 
> R_ev13 <- R_event[R_event > (rx[1] + 300*12)& R_event <= (rx[1] + 300*13)]
> R_ev14 <- R_event[R_event > (rx[1] + 300*13)& R_event <= (rx[1] + 300*14)]
> R_ev15 <- R_event[R_event > (rx[1] + 300*14)& R_event <= (rx[1] + 300*15)]
> R_ev16 <- R_event[R_event > (rx[1] + 300*15)& R_event <= (rx[1] + 300*16)]
> 
> 
> R_ev1c <- as.character(R_ev1)
> R_ev2c <- as.character(R_ev2)
> R_ev3c <- as.character(R_ev3)
> R_ev4c <- as.character(R_ev4)
> R_ev5c <- as.character(R_ev5)
> R_ev6c <- as.character(R_ev6)
> R_ev7c <- as.character(R_ev7)
> R_ev8c <- as.character(R_ev8)
> 
> R_ev9c  <- as.character(R_ev9)
> R_ev10c <- as.character(R_ev10)
> R_ev11c <- as.character(R_ev11)
> R_ev12c <- as.character(R_ev12)
> R_ev13c <- as.character(R_ev13)
> R_ev14c <- as.character(R_ev14)
> R_ev15c <- as.character(R_ev15)
> R_ev16c <- as.character(R_ev16)
> 
> 
> 
> 
> lis1 <- c(
> length(R_ev1c),
> length(R_ev2c),
> length(R_ev3c),
> length(R_ev4c),
> length(R_ev5c),
> length(R_ev6c),
> length(R_ev7c),
> length(R_ev8c),
> length(R_ev9c),
> length(R_ev10c),
> length(R_ev11c),
> length(R_ev12c),
> length(R_ev13c),
> length(R_ev14c),
> length(R_ev15c),
> length(R_ev16c)
> )
> 
> 
> # R_ev1_mat <- matrix(unlist(R_ev1),nrow=T)
> 
> 
> barplot(lis1, angle = 15+10*1:5, density = 20, col = "black",
>legend = rownames(lis1))
>  title(main = list("Number of Occurred Received events in every 5 mins",
> font = 4))
> 
> # dev.off()
> 
> 
> New code:
> 
> f1<- seq(rx[1],rx[2],by=300)
> f<- as.character(f1)
> len <- length(f)
> 
> for (n1 in 0:(len-1)){
> for(n2 in 1:len){
> # R_ev_01 <- R_event[R_event <= (rx[1] + 300)]
> 
> R_ev[n1] <- R_event[R_event > (rx[1]+ n1*300)& R_event <= (rx[1] +
> 300*n2)]
> R_ev_char <- as.character(R_ev)
> 
> lis01 <- list(length(R_ev_char))
> barplot(lis01, angle = 15+10*1:5, density = 20, col = "blue",
>legend = rownames(lis01))
>  title(main = list("Number of Occurred Received Events in every 5 mins",
> font = 4))
> }
> }
> 
> Somehow it is not working and giving an error saying "Fehler in -0.01 *
> height : nicht-numerisches Argument für binären Operator".
> 
> Any help would be really appreciated.
> 
> Thanks
> Crenial
> 

-- 
View this message in context: 
http://www.nabble.com/loop-problem-tp25665329p25714305.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] .Rprofile file

2009-10-02 Thread Marianne Promberger
> I want to use the .RProfile to set defaults such as text editor.  Is  
> this a file I need to create?  Also, where should I put it?  I tend to  
> create .RData files for different projects, putting each in a different  
> Windows (Vista) folder.  Is one .Rprofile file created  that any   
> instance of R can access  (I would imagine so)?

I'm just trying to find that out myself for XP -- on Linux it is very
easy, you just create ~/.Rprofile in your home directory.

I think this thread might help, but I haven't had time to pursue this
yet:

http://tolstoy.newcastle.edu.au/R/devel/05/12/3454.html

Marianne


-- 
Marianne Promberger PhD
King's College London
London SE1 9RT
Phone: 020 7188 2590
GnuPG/PGP public key ID 80AD9916
.tex .bib .R .Rnw files welcome

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Weibull survival regression model with different shape parameters

2009-10-02 Thread Nicolas RODE
Dear R users,

I'm trying to fit a parametric survival model using the survreg function
with a Weibull distribution.
I'm studying the time to death of individuals from different families
and I would like to fit different shape parameters (ie 1/scale in R) for
each of the families. I looked it up in the help pdf and on the
internet, but I couldn't find anything.
Would it be possible to do such a thing ?

Thanks in advance,

Best regards,

Nicolas


N. Rode
PhD student
CEFE (Centre d'Ecologie Fonctionnelle et Evolutive)
34293 Montpellier, France



-- 
passerelle antivirus du campus CNRS de Montpellier
--



[[alternative HTML version deleted]]

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


Re: [R] plot scale

2009-10-02 Thread Ryan
> 
> Hi,
> 
> Is there a way to set the scale of a plot (i.e. number of axis units
> per centimeter) when you output it to postscript? If not, how am I
> supposed to plot graphs with different axis limits to the same scale?
> They just get resized to fit the paper so that graphs which show a
> smaller number of axis units end up with a larger scale.
> 
> Cheers,
> 
> Ben
> 

If I understand you correctly, you want the units on each axis to 
be physically represented equally on the same scale.  If this is right, 
try using the lattice package (xyplot, etc.) with aspect="iso".

Lattice lets you adjust the aspect ratio of the plot to whatever you 
like and constrains the dimensions of the plot accordingly.  Base 
graphics also allow for control of the aspect ratio using "asp=", but 
extend the limits of the plot to fill whatever region you are plotting 
in.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 use Subpopulation data?

2009-10-02 Thread KABELI MEFANE
Dear Mr Winsemius
 
I am sorry to have offended any of you by the mistakes i made. The package i 
loaded is sampling and there was an unwanted comma between size c(20, )and the 
bracket. What i wanted was to calculate the sum of H in a sample not in the 
original dataframe. If i do 
sum(H) i get the sum value of H's in the original dataframe.
 
 
Load package sampling
 
H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat
 
Thanks for the input. Once again sorry for wasting your time.
 
Best Regards 
 
 


--- On Fri, 2/10/09, David Winsemius  wrote:


From: David Winsemius 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM



On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:

> Dear Helpers
> 
> I have a sample frame and i have sampled from it using three methods and now 
> i want to calculate the statistics but i only get the population parameters.
> 
> H <- matrix(rnorm(100, mean=5, sd=5000))
> sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
> sampleframe
> 
> str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
> sample.strat<-getdata(sampleframe,str)
> sample.strat

If you want the number of rows in sample.strat then length(H) is the wrong 
approach since that is the original (unsampled) object.

> length(H)
> i get:
> 
> length(H)
> [1] 100
> 
> Desire to get:
> length(H)
> [1] 20

I cannot tell what packages you have loaded and strata is not in the sampling 
package which I guessed (wrongly) was where you were getting "getdata". When 
you post code you should precede that code with calls that load any non-base 
packages.

In later posting you ask for ways to calculate "the sum" but you do not say 
what it is that you want the sum of . Our abilities to read minds is 
extremely limited.

--David Winsemius



  
[[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] text mining

2009-10-02 Thread Corey Dow-Hygelund
Your problem lies in the use of system.file.  This command looks in the
folder location of tm for specific folders.  See ?system.files.

Basically, for the document example, it assigning txt to the directory
string like "C:/Program Files (x86)/R/R-2.9.0/library/tm/texts/txt"
Then the DirSource(txt) constructs a directory source from directory string
txt.
Finally Corpus constructs a tm corpus from the DirSource object (with some
extra arguments to boot).

So, to solve your problem, replace txt with the directory containing your
files:
txt<-"C://docs"

and then run the subsequent command
 ovid <- Corpus(DirSource(txt),
 readerControl = list(reader = readPlain,
language = "la",
 load = TRUE))

(though you may want to change the object name "ovid" to something more
descriptive)

C






On Fri, Oct 2, 2009 at 10:15 AM, PDXRugger  wrote:

>
> The following code is derived from a paper titled "Text Mining
> Infrastructure
> in R" (http://www.jstatsoft.org/v25/i05/paper).  The example below seems
> to
> load some default documents for analysis, some sort of latin document.  I
> cannot for the life of me figure out to load my own document let alone an
> entire corpus.  I have searched the above documenet as well as related
> documentation.  Any leads or help would be appreciated.  Thanks everyone
>
> from document
>
> txt <- system.file("texts", "txt", package = "tm")
>  (ovid <- Corpus(DirSource(txt),
>  readerControl = list(reader = readPlain,
> language = "la",
>  load = TRUE)))
>
> my attempt
> txt <- system.file("Speeches/speech", "txt", package = "tm")
>  (ovid <- Corpus(DirSource(txt),
>  readerControl = list(reader = readPlain,
> language = "la",
>  load = TRUE)))
>
>
> --
> View this message in context:
> http://www.nabble.com/text-mining-tp25717142p25717142.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[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] RE xcel foreground and background server

2009-10-02 Thread ryusuke

I have installed, its workable in frontground mode while but background mode,
may I know how do I activate background mode? Thanks


Irina Ursachi wrote:
> 
> Dear all,
> 
> I have a question regarding background and foreground server in RExcel:
> Can somebody explain the main difference between them? As far as I
> understood from the RExcel webpage, for both of them one  needs rights
> for access to Windows registries. The only difference that I can see so
> far is that for the installation of the background server, one needs the
> R(D)COM package, whereas for the foreground server installation, the
> rcom package is required.
> 
> Further more, does anyone know, how Excel proccesses and R processes
> communicate? Is it possible for more than one Excel-process to
> communicate with more than one R process?
> 
> Thank you in advance!
> 
> Best regards,
> Irina Ursachi.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/RExcel-foreground-and-background-server-tp21668224p25720937.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] xts dates spacings

2009-10-02 Thread devol

Hello!

  Please help - can't find any options how to remove very big spaces between
two dates containing intraday prices plotted by plot.xts. It looks like the
following: on the left side of the plot window is the first bunch of points,
the same is for the right hand side and a long line connecting them in the
middle. I would want to merge them (cut spaces) somehow.

In any case thanks for help.

Alex
-- 
View this message in context: 
http://www.nabble.com/xts-dates-spacings-tp25721103p25721103.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] plot scale

2009-10-02 Thread Greg Snow
Here is a different approach:
This example uses the default plotting device, but should work the same with 
postscript or any other device.  Just set the size of the paper to a standard 
size, or a large enough size to fit your largest plot:

dev.new()
tmp <- par('plt')

scale <- 5
x <- runif(100, 0, 20)
y <- rnorm(100, x)

dx <- diff(range(x))*1.08
wx <- grconvertX(dx/scale, from='inches', to='ndc')

dy <- diff(range(y))*1.08
wy <- grconvertY(dy/scale, from='inches', to='ndc')

par(plt = c(tmp[1], tmp[1]+wx, tmp[3], tmp[3]+wy) )
plot(x,y)

dev.new()

x2 <- runif(100, 0,5)
y2 <- rnorm(100, x2)

dx <- diff(range(x2))*1.08
wx <- grconvertX(dx/scale, from='inches', to='ndc')

dy <- diff(range(y2))*1.08
wy <- grconvertY(dy/scale, from='inches', to='ndc')

par(plt = c(tmp[1], tmp[1]+wx, tmp[3], tmp[3]+wy) )
plot(x2,y2)


The above only works for 1 plot per page (no layout or par(mfrow=... ) ).

This keeps the lower left corner of the plot in the same place (so change the 
margins before the call to par('plt') if you want them different). Then sets 
the top and right parts of the plotting region leaving white space on the top 
and right to get the scaling correct (you will have problems if your desired 
scale does not fit in the window/on the page).  This example uses a "scale" of 
5 plot units per inch, change as appropriate.  The *1.08 is to account for the 
extra area that is added to the plot by default, change this for the other axis 
type.

Hope this helps,



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Ben Kenward
> Sent: Friday, October 02, 2009 2:08 AM
> To: r-help@r-project.org
> Subject: [R] plot scale
> 
> Hi,
> 
> Is there a way to set the scale of a plot (i.e. number of axis units
> per centimeter) when you output it to postscript? If not, how am I
> supposed to plot graphs with different axis limits to the same scale?
> They just get resized to fit the paper so that graphs which show a
> smaller number of axis units end up with a larger scale.
> 
> Cheers,
> 
> Ben
> 
> --
> Dr. Ben Kenward
> Department of Psychology, Uppsala University, Sweden
> http://www.benkenward.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] error using frailty term

2009-10-02 Thread Mary Slaughter
Trying to fit a model using the Surv() with a frailty term but get the
following cryptic error message:
--
Error in frailty.brent(sqrt(x), y, lower = 0) :
  Ties for max(y), I surrender
Calls: runplots ... coxpenal.fit -> eval -> eval ->  -> frailty.brent
--
When I remove the frailty term from the model it runs just fine. Does
anyone know what this error message means?

Thanks,
M.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tabulating using arbitrary numbers of factors

2009-10-02 Thread Andrew Spence
Dear R-help,

 

First of all, thank you VERY much for any help you have time to offer. I
greatly appreciate it.

 

I would like to write a function that, given an arbitrary number of factors
from a data frame, tabulates the number of occurrences of each unique
combination of the factors. Cleary, this works:

 

> table(horse,date,surface)



, , surface = TURF

 

   date

horse   20080404 20080514 20081015 20081025 20081120 20081203
20090319

  Bedevil  000000
0

  Cut To The Point   22700000
0



 

But I would prefer output that skips all the zeros, flattens any dimensions
greater than 2, and gives the level names rather than codes. I can write
code specifically for n factors like this: (here 2 levels):

 

ft <- function(x,y) {cbind(
levels(x)[unique(cbind(x,y))[,1]],levels(y)[unique(cbind(x,y))[,2]],
table(x,y)[unique(cbind(x,y))])}

 

which gives the lovely output I'm looking for:

 

#  [,1][,2]   [,3]

# [1,] "Cut To The Point"  "20080404" "227"

# [2,] "Prairie Wolf"  "20080404" "364"

# [3,] "Bedevil"   "20080514" "319"

# [4,] "Prairie Wolf"  "20080514" "330"

 

But my attempts to make this into a function that handles arbitrary numbers
of factors as separate input arguments has failed. The closest I can get is:

 

ft2 <- function (...) { cbind( unique(cbind(...)),
table(...)[unique(cbind(...))] )

 

giving:

> ft2(horse,date)

  horse date

 [1,] 21 227

 [2,] 91 364

 [3,] 12 319

 [4,] 92 330

 [5,] 93 291

 [6,]123 249

 [7,]103 286

 [8,] 54 217

 [9,] 34 426

[10,] 84 468

[11,] 95 319

[12,]135 328

[13,]125 138

[14,] 76 375

[15,]116 366

[16,] 47 255

[17,] 67 517

 

I would be greatly in debt to anyone willing to show me how to make the
above function take arbitrary inputs and still produce output displaying
factor level names instead of the underlying coded numbers.

 

Cheers and thanks for your time!

 

Andrew Spence
RCUK Academic Research Fellow
Structure and Motion Laboratory
Royal Veterinary College
Hawkshead Lane
North Mymms, Hatfield
Hertfordshire AL9 7TA
+44 (0) 1707 666988

mailto:aspe...@rvc.ac.uk

http://www.rvc.ac.uk/sml/People/andrewspence.cfm

 

 


[[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] trouble with html() in Hmisc

2009-10-02 Thread Liviu Andronic
Dear all
On my system html() conversion of a `latex()' object fails. Follows a
dummy example:
> require(Hmisc)
> data(Angell)
> .object <- cor(Angell[,1:2], use="complete.obs")
> tmp <- latex(.object, cdec=c(2,2), title="")
> class(tmp)
[1] "latex"
> html(tmp)
/tmp/RtmprfPwzw/file7e72f7a7.tex:9: Warning: Command not found: \tabularnewline
Giving up command: \...@hevea@amper
/tmp/RtmprfPwzw/file7e72f7a7.tex:11: Error while reading LaTeX:
This array/tabular column has no specification
Adios


I have hevea-1.10 installed on Debian (according to the help page, it
performs the conversion). Attached is teh produced .tex file. Is this
a bug or would there be a way to work around this behaviour?
Thank you
Liviu


> sessionInfo()
R version 2.9.2 (2009-08-24)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=C;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_IDENTIFICATION=C

attached base packages:
[1] datasets  grDevices tcltk splines   graphics  utils stats
[8] methods   base

other attached packages:
 [1] fortunes_1.3-6   RcmdrPlugin.Export_0.3-0 Rcmdr_1.5-2
 [4] car_1.2-15   hints_1.0.1-1boot_1.2-39
 [7] relimp_1.0-1 xtable_1.5-5 Hmisc_3.7-0
[10] survival_2.35-7

loaded via a namespace (and not attached):
[1] cluster_1.12.0  grid_2.9.2  lattice_0.17-25 tools_2.9.2
> system("uname -a")
Linux debian-liv 2.6.30-1-amd64 #1 SMP Sat Aug 15 18:09:19 UTC 2009
x86_64 GNU/Linux





-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tabulating using arbitrary numbers of factors

2009-10-02 Thread Erik Iverson
Andrew, 

Is this what you're looking for?  Most likely a more elegant solution exists... 
but maybe this is good enough. 

## BEGIN R SAMPLE CODE
## sample data frame, 3 factors
tmp <- data.frame(f1 = sample(gl(2, 50, labels = c("Male", "Female"))),
  f2 = sample(gl(4, 25, labels =
c("White", "Black", "Hispanic", "Other"))),
  f3 = sample(gl(4, 25, labels =
c("0-20", "21-40", "41-60", "61-80"

summary(tmp)

## the function
test <- function(...) {
  tbl <- table(interaction(..., sep = "!"))
  tbl.nozero <- tbl[tbl > 0]
  
  nms <- strsplit(names(tbl.nozero), "!")
  
  cb <- cbind(t(do.call(data.frame, nms)), tbl.nozero)
  dimnames(cb) <- NULL
  cb
}

## test calling the function, does this produce what you want? 
with(tmp, test(f1, f2, f3))

## END R SAMPLE CODE 

Best Regards,
Erik Iverson

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Andrew Spence
> Sent: Friday, October 02, 2009 1:15 PM
> To: r-help@r-project.org
> Subject: [R] Tabulating using arbitrary numbers of factors
> 
> Dear R-help,
> 
> 
> 
> First of all, thank you VERY much for any help you have time to offer. I
> greatly appreciate it.
> 
> 
> 
> I would like to write a function that, given an arbitrary number of
> factors
> from a data frame, tabulates the number of occurrences of each unique
> combination of the factors. Cleary, this works:
> 
> 
> 
> > table(horse,date,surface)
> 
> 
> 
> , , surface = TURF
> 
> 
> 
>date
> 
> horse   20080404 20080514 20081015 20081025 20081120 20081203
> 20090319
> 
>   Bedevil  000000
> 0
> 
>   Cut To The Point   22700000
> 0
> 
> 
> 
> 
> 
> But I would prefer output that skips all the zeros, flattens any
> dimensions
> greater than 2, and gives the level names rather than codes. I can write
> code specifically for n factors like this: (here 2 levels):
> 
> 
> 
> ft <- function(x,y) {cbind(
> levels(x)[unique(cbind(x,y))[,1]],levels(y)[unique(cbind(x,y))[,2]],
> table(x,y)[unique(cbind(x,y))])}
> 
> 
> 
> which gives the lovely output I'm looking for:
> 
> 
> 
> #  [,1][,2]   [,3]
> 
> # [1,] "Cut To The Point"  "20080404" "227"
> 
> # [2,] "Prairie Wolf"  "20080404" "364"
> 
> # [3,] "Bedevil"   "20080514" "319"
> 
> # [4,] "Prairie Wolf"  "20080514" "330"
> 
> 
> 
> But my attempts to make this into a function that handles arbitrary
> numbers
> of factors as separate input arguments has failed. The closest I can get
> is:
> 
> 
> 
> ft2 <- function (...) { cbind( unique(cbind(...)),
> table(...)[unique(cbind(...))] )
> 
> 
> 
> giving:
> 
> > ft2(horse,date)
> 
>   horse date
> 
>  [1,] 21 227
> 
>  [2,] 91 364
> 
>  [3,] 12 319
> 
>  [4,] 92 330
> 
>  [5,] 93 291
> 
>  [6,]123 249
> 
>  [7,]103 286
> 
>  [8,] 54 217
> 
>  [9,] 34 426
> 
> [10,] 84 468
> 
> [11,] 95 319
> 
> [12,]135 328
> 
> [13,]125 138
> 
> [14,] 76 375
> 
> [15,]116 366
> 
> [16,] 47 255
> 
> [17,] 67 517
> 
> 
> 
> I would be greatly in debt to anyone willing to show me how to make the
> above function take arbitrary inputs and still produce output displaying
> factor level names instead of the underlying coded numbers.
> 
> 
> 
> Cheers and thanks for your time!
> 
> 
> 
> Andrew Spence
> RCUK Academic Research Fellow
> Structure and Motion Laboratory
> Royal Veterinary College
> Hawkshead Lane
> North Mymms, Hatfield
> Hertfordshire AL9 7TA
> +44 (0) 1707 666988
> 
> mailto:aspe...@rvc.ac.uk
> 
> http://www.rvc.ac.uk/sml/People/andrewspence.cfm
> 
> 
> 
> 
> 
> 
>   [[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] How to use Subpopulation data?

2009-10-02 Thread Peter Ehlers

Kabeli,

You seem to be doing your best to avoid working
your way through some introductory documentation
like An Introduction to R, which is sitting
right there on your computer.

So let's try to take it slowly, one step at a time.

#1. generate a vector of values to work with.
(forget the matrix() bit and the data.frame() bit
for now and forget about the sampling package
for now)

 x <- rnorm(100, mean=5, sd=5000)

#2. in order to select a random sample of values
from x, we'll randomly select 20 numbers from
the set {1, 2, 3, ..., 99, 100}. Those 20 numbers
will tell us which x-values get into our sample.

 idx <- sample(100, 20, replace = FALSE)

Here's what I got (you'll get different numbers):

> idx
 [1] 91 51 97 50 67 31 29 75 89 78 63 77
[13] 38 85 16 74 53 40 54  2

#3. now select x[91], x[51], etc as the elements
of x to be your sample:

 xsample <- x[idx]

#4. now do whatever you want with xsample;

 sum(xsample)
 mean(xsample)
 sd(xsample)

#5. in order to use something like the function
strata() in pkg:sampling, you will first have
to understand how to read its help page and
understand what's in the object returned by strata().

I do hope that this helps at least somewhat,
Peter Ehlers


KABELI MEFANE wrote:

Dear Mr Winsemius
 
I am sorry to have offended any of you by the mistakes i made. The package i loaded is sampling and there was an unwanted comma between size c(20, )and the bracket. What i wanted was to calculate the sum of H in a sample not in the original dataframe. If i do 
sum(H) i get the sum value of H's in the original dataframe.
 
 
Load package sampling
 
H <- matrix(rnorm(100, mean=5, sd=5000))

sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat
 
Thanks for the input. Once again sorry for wasting your time.
 
Best Regards 
 
 



--- On Fri, 2/10/09, David Winsemius  wrote:


From: David Winsemius 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM



On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:


Dear Helpers

I have a sample frame and i have sampled from it using three methods and now i 
want to calculate the statistics but i only get the population parameters.

H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe

str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat


If you want the number of rows in sample.strat then length(H) is the wrong 
approach since that is the original (unsampled) object.


length(H)
i get:

length(H)
[1] 100

Desire to get:
length(H)
[1] 20


I cannot tell what packages you have loaded and strata is not in the sampling package 
which I guessed (wrongly) was where you were getting "getdata". When you post 
code you should precede that code with calls that load any non-base packages.

In later posting you ask for ways to calculate "the sum" but you do not say 
what it is that you want the sum of . Our abilities to read minds is extremely 
limited.

--David Winsemius



  
	[[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] randomizing groups

2009-10-02 Thread Jason Priem
I have a list of participants in a study, identified by number.  I want 
to randomly sort them into an arbitrary number of groups. 
split(sample(1:96, 96), 1:16)

almost does it, but it only works where the division is even.  Any ideas?
Thanks!

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] aggregate data into an array

2009-10-02 Thread Juliane Struve
Dear list,
 
I would like to aggregate CVTimeDiff by Fish_ID and Trip and put the result 
into myarray,i.e. for the example below Trip 1,9 and Fish_ID 1646 I would like 
to obtain mean= (0.8104876+1.3676631)/2 and put it into myarray[1] .

 
mydataframe
 
 Trip Fish_ID CVTimeDiff
1    1,9 1646  0.8104876
2    1,9 1646  1.3676631
3  11,13    1647 NA

 
myarray
 
  1646 1647 1648 1649 1650 1654 1656 1662
1,9   NA   NA   NA   NA   NA   NA   NA   NA
10,11    NA   NA   NA   NA   NA   NA   NA   NA
11,13    NA   NA   NA   NA   NA   NA   NA   NA
 
Could somebody help me with this ?
 
Many thanks,
 
Juliane 




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Re gression line w/ residuals - tuning the plot

2009-10-02 Thread Primoz PETERLIN
Many thanks to both who replied, Ulrike and Petr. Indeed, some playing
with the margin-sizing options solved my problem.

All the best, Primož

2009/9/29 Ulrike Groemping :
>
> Hello Primoz,
>
> with traditional graphics, you may want to use par (?par), options like mar,
> mai, oma etc. may be interesting for you. And for the relation between
> y-axis and x-axis, the option asp to function plot (?plot.default) will
> help.
>
> Regards, Ulrike
>
>
>
> Primoz PETERLIN-2 wrote:
>>
>> Hello everybody,
>>
>> I am sure this is a beginners' problem which is being asked
>> recurrently every few months, but nevertheless I wasn't able to find
>> the answer searching through the r-help list.
>>
>> So here is my problem: I would like to plot a set of points (y vs. x),
>> a (linear) regression line through them, and on the second graph
>> underneath the first one I would want to plot residuals vs. x. I came
>> up with two solutions, unfortunately neither of them is fully
>> satisfactory.
>>
>> First I tried with what I later learned is called traditional graphics
>> (file norris.R). Here, the white space margins around the plots are
>> too wide, meaning that the data in the plot are crammed. Probably I
>> would be quite happy if I could somehow define a rectangular plotting
>> area with its height being ~150% of its width, but I cannot prevent R
>> from offering me a square plotting area.
>>
>> Next I tried a lattice package (file norris.lattice.R). Here, the
>> margins are smaller, but the lower plot does not fit exactly under the
>> upper one (the x-axes should match).
>>
>> Most likely I am not using the correct terminology (if I would have
>> known it, I could have looked in the help pages myself, thank you :),
>> but I hope that the attached files make more sense of what I am trying
>> to do.
>>
>> Thanks in advance.
>>
>> All the best,
>> Primoz
>>
>> --
>> Primož Peterlin,   Inštitut za biofiziko, Med. fakulteta, Univerza v
>> Ljubljani
>> Lipičeva 2, SI-1000 Ljubljana, Slovenija.
>> primoz.peter...@mf.uni-lj.si
>> Tel +386-1-5437612, fax +386-1-4315127,
>> http://biofiz.mf.uni-lj.si/~peterlin/
>> F8021D69 OpenPGP fingerprint: CB 6F F1 EE D9 67 E0 2F  0B 59 AF 0D 79 56
>> 19 0F
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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/Regression-line-w--residuals---tuning-the-plot-tp25647458p25670483.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Primož Peterlin,   Inštitut za biofiziko, Med. fakulteta, Univerza v Ljubljani
Lipičeva 2, SI-1000 Ljubljana, Slovenija.primoz.peter...@mf.uni-lj.si
Tel +386-1-5437612, fax +386-1-4315127,  http://biofiz.mf.uni-lj.si/~peterlin/
F8021D69 OpenPGP fingerprint: CB 6F F1 EE D9 67 E0 2F  0B 59 AF 0D 79 56 19 0F

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] (no subject)

2009-10-02 Thread C. Maranto

Dear R Community,

I am running GLM's within the "MASS" library.  My data are overdispersed and 
I am accounting for the overdispersion by using an ANOVA 'F' test instead of 
ANOVA 'Chisq'.  You will have to forgive me because I am new at this, but I 
am not sure if R is conducting an ANOVA 'F' test appropriately.  I was 
hoping to explain this using my data results below:



anova(glm.model,test="F")

Analysis of Deviance Table
Model:binomial,link:logit
Response: ytrips

Terms added squentially (first to last)

   DFDeviance 
Resid. DfResid. Dev. FPr(>F)
NULL 
1251008.55
WaterLevel10.14 
1241008.420.13650.7118
RiverFlowObserved   113.34 
123995.07  13.3427  0.0002594
WSBacklog   112.47 
122982.61  12.4675  0.0004141
factor(WDEW)  183.13 
121899.48  83.1258  <2.2e-16
ChickDays 1   157.22 
120742.26 157.2225 <2.2e-16
Salmon  16.91 
119735.34  6.91430.0085509
factor(Year)   3370.31 
116365.03  123.4375<2.2e-16
WSBacklog:factor(WDEW)  19.06 
115355.97  9.0644 0.0026063



I think the F-values in the results are over-inflated for an F-test.

For an F-test,

F-observed = (Deviance/Df numerator)/("MSE"=Residual Deviance/Residual Df)

When I calculate F-observed for one of my main effects, such as 
'WSBacklogfactor(WDEW)' above I get:


F-observed = (9.06/1)/(355.97/115)=2.92  NOT 9.0644(as shown in the results 
above)


It seems that the F-test in 'R' is not dividing by the "MSE".

Does anyone have any thoughts on this? Or can let me know where I am going 
wrong?


Thank you!


~Christina




Christina J. Maranto
University of Washington
Department of Zoology
Box 351800
Seattle, WA 98195
(206) 618-2956

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


[R] [Fwd: Re: randomizing groups]

2009-10-02 Thread Jason Priem
Duh. I just figured out that though I was getting a warning, it was 
still doing the split anyway. Sorry for the dumb question.


-jason

Jason Priem wrote:
I have a list of participants in a study, identified by number.  I 
want to randomly sort them into an arbitrary number of groups. 
split(sample(1:96, 96), 1:16)

almost does it, but it only works where the division is even.  Any ideas?
Thanks!

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] randomizing groups

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 4:36 PM, Jason Priem wrote:

I have a list of participants in a study, identified by number.  I  
want to randomly sort them into an arbitrary number of groups.  
split(sample(1:96, 96), 1:16)
almost does it, but it only works where the division is even.  Any  
ideas?

Thanks!


See if this gives you some ideas:

> idx <- sample(1:96, 96)
> cut(idx,  breaks=quantile(idx, prob=c(0, 0.25, 0.5, 0.75, 1),  
include.lowest=TRUE))
 [1] (48.5,72.2] (24.8,48.5] (24.8,48.5] (48.5,72.2] (1,24.8] 
(24.8,48.5] (24.8,48.5] (24.8,48.5] (48.5,72.2]
[10] (48.5,72.2] (1,24.8](48.5,72.2] (72.2,96]   (1,24.8] 
(1,24.8](24.8,48.5] (1,24.8](1,24.8]
[19] (72.2,96]   (72.2,96]   (24.8,48.5] (1,24.8](24.8,48.5]  
(24.8,48.5] (24.8,48.5] (72.2,96]   (72.2,96]
[28] (24.8,48.5] (48.5,72.2] (1,24.8](48.5,72.2] (48.5,72.2]  
(72.2,96]   (72.2,96]   (1,24.8](48.5,72.2]
[37] (48.5,72.2] (48.5,72.2] (24.8,48.5] (48.5,72.2] (1,24.8] 
(1,24.8](1,24.8](24.8,48.5] (1,24.8]
[46] (24.8,48.5] (72.2,96]   (24.8,48.5] (24.8,48.5] (1,24.8] 
(1,24.8](1,24.8](1,24.8](72.2,96]
[55] (48.5,72.2] (72.2,96]   (1,24.8](48.5,72.2] (48.5,72.2]  
(72.2,96]   (48.5,72.2] (48.5,72.2] (24.8,48.5]
[64] (72.2,96]   (48.5,72.2] (1,24.8](48.5,72.2] (24.8,48.5]  
(72.2,96]   (48.5,72.2] (48.5,72.2]
[73] (48.5,72.2] (1,24.8](24.8,48.5] (72.2,96]   (1,24.8] 
(24.8,48.5] (24.8,48.5] (1,24.8](72.2,96]
[82] (24.8,48.5] (24.8,48.5] (1,24.8](72.2,96]   (48.5,72.2]  
(72.2,96]   (72.2,96]   (72.2,96]   (24.8,48.5]
[91] (72.2,96]   (72.2,96]   (48.5,72.2] (72.2,96]   (72.2,96]
(72.2,96]

Levels: (1,24.8] (24.8,48.5] (48.5,72.2] (72.2,96]
> idx.grp <-as.numeric(cut(idx,  breaks=quantile(idx, prob=c(0, 0.25,  
0.5, 0.75, 1), include.lowest=TRUE)))

> tapply(idx, idx.grp, I)
$`1`
 [1]  6 21  4 14  8  7 20 23 18 22 24 13 17 10  3  2  5 11 19 16  9  
12 15


$`2`
 [1] 38 46 33 34 40 44 27 29 39 28 42 26 47 35 31 45 32 36 37 48 43  
30 41 25


$`3`
 [1] 61 62 70 50 67 69 52 55 51 68 56 54 57 60 53 59 65 66 49 63 72  
64 58 71


$`4`
 [1] 89 86 77 94 93 82 81 80 90 91 76 78 73 88 85 75 96 74 79 95 87  
83 84 92



--
David

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 use Subpopulation data?

2009-10-02 Thread David Winsemius


On Oct 2, 2009, at 2:39 PM, KABELI MEFANE wrote:


Dear Mr Winsemius

I am sorry to have offended any of you by the mistakes i made. The  
package i loaded is sampling and there was an unwanted comma between  
size c(20, )and the bracket. What i wanted was to calculate the sum  
of H in a sample not in the original dataframe. If i do

sum(H) i get the sum value of H's in the original dataframe.


Yes, and that would be expected, would it not?



Load package sampling

H <- matrix(rnorm(100, mean=5, sd=5000))
sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
sampleframe
 sum(H)

str=strata(sampleframe,c("type"),size=c(20), method="srswor")
sample.strat<-getdata(sampleframe,str)
sample.strat


Seems to me that you should be getting descriptive statisics on the  
sample.strat object rather than on H.

> summary(sample.strat)
 value   type  ID_unit   ProbStratum
 Min.   :37931   H:20   Min.   : 1.00   Min.   :0.2   Min.   :1
 1st Qu.:46547  1st Qu.:20.75   1st Qu.:0.2   1st Qu.:1
 Median :48848  Median :44.50   Median :0.2   Median :1
 Mean   :49193  Mean   :50.45   Mean   :0.2   Mean   :1
 3rd Qu.:51311  3rd Qu.:78.75   3rd Qu.:0.2   3rd Qu.:1
 Max.   :58523  Max.   :98.00   Max.   :0.2   Max.   :1
>



Thanks for the input. Once again sorry for wasting your time.

Best Regards




--- On Fri, 2/10/09, David Winsemius  wrote:

From: David Winsemius 
Subject: Re: [R] How to use Subpopulation data?
To: "KABELI MEFANE" 
Cc: R-help@r-project.org
Date: Friday, 2 October, 2009, 3:38 PM


On Oct 1, 2009, at 6:06 AM, KABELI MEFANE wrote:

> Dear Helpers
>
> I have a sample frame and i have sampled from it using three  
methods and now i want to calculate the statistics but i only get  
the population parameters.

>
> H <- matrix(rnorm(100, mean=5, sd=5000))
> sampleframe=data.frame(type=c(rep("H",100)),value=c(H))
> sampleframe
>
> str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
> sample.strat<-getdata(sampleframe,str)
> sample.strat

If you want the number of rows in sample.strat then length(H) is the  
wrong approach since that is the original (unsampled) object.


> length(H)
> i get:
>
> length(H)
> [1] 100
>
> Desire to get:
> length(H)
> [1] 20

I cannot tell what packages you have loaded and strata is not in the  
sampling package which I guessed (wrongly) was where you were  
getting "getdata". When you post code you should precede that code  
with calls that load any non-base packages.


In later posting you ask for ways to calculate "the sum" but you do  
not say what it is that you want the sum of . Our abilities to  
read minds is extremely limited.


--David Winsemius



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Re cursive regression

2009-10-02 Thread spencerg
 There is a huge literature on time series analysis with many 
functions and contributed packages in R, including many different ways 
"to estimate a recursive model". 



 If you are working with "asset returns", I suggest you start with 
Diethelm Würtz, Yohan Chalabi, William Chen, Andrew Ellis (2009) 
Portfolio Optimization with R/Rmetrics (www.rmetrics.org/ebook.htm) and 
the companion Rmetrics bundle documented in that book.  You may also be 
interested in Ruey Tsay (2005) Analysis of Financial Time Series (Wiley) 
and the companion "FinTS" package on CRAN.  For recursive regression, I 
suggest you consider Giovanni Petris, Sonia Petrone, and Patrizia 
Campagnoli (2009) Dynamic Linear Models with R (Springer) and the 
companion "dlm" package. 



 There are many other books discussing time series mentioned on 
"http://www.r-project.org/doc/bib/R-books.html";. 



 Beyond that, I suggest you acquaint yourself with the 
"RSiteSearch" function an the "sos" package to help search capabilities 
available in R. 



 Hope this helps. 
 Spencer Graves



manta wrote:

Hi there, I'm in desperate need to figure out how to solve this issue.
I need to estimate a recursive model for a time series data of asset
returns. The dependent variable is the asset return and then I have a set of
k variables, a lagged value of the dependent variable (plus an intercept) as
regressors. My sample period (monthly observations) starts on Jan 1972. What
I need to do is the following:

1)use a moving window regression (window of 60 observations, i.e. 5 years)
2)estimate all the possible model (Jan 1972 Dec 1977) using a subset of the
k variables (intercept and lagged values always present) and choose the best
model according to thee AIC criterion
3)once the best model is chosen, make one-step ahead prediction with that
model
4)go back to step 2 shifting the sample period one month ahead (i.e. Feb
1972, Jan 1978) and then repeat step 2 and 3
5)keep going until the end of the sample (May 2009)

Hope it helps
  



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


[R] how to fill out the empty spots when using rbind or cbind?

2009-10-02 Thread tkedch

I have uneven vectors I want to use cbind or rbind to combine them into a 
matrix. Is there a way to make it so that R would not return error msg saying 
they're uneven? 
Thanks. 

Edward Chen
Email: tke...@msn.com
Cell Phone: 510-371-4717


  
[[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] randomizing groups

2009-10-02 Thread Jason Priem
Duh.  I just figured out that though I was getting a warning, it was 
still doing the split anyway.  Sorry for the dumb question.

-jason

Jason Priem wrote:
I have a list of participants in a study, identified by number.  I 
want to randomly sort them into an arbitrary number of groups. 
split(sample(1:96, 96), 1:16)

almost does it, but it only works where the division is even.  Any ideas?
Thanks!

Jason Priem,
Doctoral Student,
School of Information and Library Science
University of North Carolina-Chapel Hill



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 fill out the empty spots when using rbind or cbind?

2009-10-02 Thread Daniel Malter
Fill the respective "empty" spots in the vectors with NAs.  

Daniel


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von tke...@msn.com
Gesendet: Friday, October 02, 2009 6:13 PM
An: R help
Betreff: [R] how to fill out the empty spots when using rbind or cbind?


I have uneven vectors I want to use cbind or rbind to combine them into a
matrix. Is there a way to make it so that R would not return error msg
saying they're uneven? 
Thanks. 

Edward Chen
Email: tke...@msn.com
Cell Phone: 510-371-4717


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


  1   2   >