Re: [R] Background Colour

2008-10-24 Thread Mag. Ferri Leberl
Thank you for your helpfull advice. Yet the par-command has to be placed 
before frame().
Yours, Leberl



Am Samstag 25 Oktober 2008 04:18:30 schrieb andystats:
> Pretty simple- use the par() function
> pdf("rotondje.pdf",width=m, height=m)
> frame()
> par(bg="yellow")
> #your stuff
> dev.off()
>
> Hope that helps
>
> Mag. Ferri Leberl wrote:
> > Dear eveerybody,
> > I am making a .pdf, starting:
> >
> > pdf("rotondje.pdf",width=m, height=m)
> > frame()
> >
> > How can I set the background-colour of the frame yellow?
> > Thank you in advance.
> > Yours, Leberl
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Transferring results from R to MS Word

2008-10-24 Thread Greg Snow
You may want to try the odfWeave package.  It uses openoffice which can read 
and write MSWord documents.  This is an alternative to the HTML > Excel > Word 
route.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Tom Backer Johnsen
> Sent: Friday, October 24, 2008 1:31 PM
> To: [EMAIL PROTECTED]
> Subject: [R] Transferring results from R to MS Word
>
> R-users
>
> At the moment I am teaching a course on the use of R for data analysis.
>   Part of course requirements involves the transfer of results from R
> to
> something that resembles the APA (American Psychological Associations)
> type tables to MS Word.  Until now I have used the HTML function in the
> R2HTML library, with a call like this:
>
> HTML(summary(model1), file("clipboard", "w"), digits=4)
>
> Where "model1" is an object containing results from a linear model
> (function lm ()).  I have to add that I do not remember where I got the
> digits argument from.  The main point is that the output is transferred
> to Excel as the first step where the output can be deleted and shuffled
> in order to produce a correctly formatted table according to APA
> standards which then is transferred to MS Word with a copy and paste
> operation.
>
> The problem is simply that what is tranferred to Excel varies with what
> you throw at the HTML function.  Nothing is rounded of with an lm()
> model.  With a function like sd () I seem to consistently get 2 decimal
> points transferred, less than what I want, while there are variations
> in
> respect to the number of decimals when I transfer the result on the
> summary () using a frame as the argument.
>
> The optimal thing for me (and the students) would be to consistently
> have all the decimals tranferred to Excel, any rounding to could be
> done
> there before the transfer of the table to MS Word.  Alternatively, that
> something like the argument digits=x works in a consistent manner with
> at least most objects.
>
> So:
>
> What do I tell my students on what to do using R2HTML in order to
> obtain
> consistent results?
>
> Alternativly: are there other alternatives I and my students could use
> for the transfer of results from R via Excel to MS Word?
>
> I really would appreciate some suggestions.
>
> Tom
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 embed residual dot plots of BHH2::anovaPlot(...) into plotMeans(...)?

2008-10-24 Thread Greg Snow
If the goal is to embed one (or more) plot into another plot, then the subplot 
function in the TeachingDemos package may help.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Xiaoxu LI
> Sent: Friday, October 24, 2008 2:03 PM
> To: r-help@r-project.org
> Subject: [R] How to embed residual dot plots of BHH2::anovaPlot(...)
> into plotMeans(...)?
>
> Dear R fans,
>
> I am preparing a lecture discussing the paper of Wilkinson and APA
> Task Force on Statistical Inference (1999, American Psychologist, 54,
> 594-604.) I'd like to demo their Figure 3B (p. 602) with R. That is to
> add plotMeans(...) with dots of BHH2::dotPlot(...) . Is there any
> elegant script to do the job?
>
>
>
> Thanks
>
> ---
> LI, Xiaoxu
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Automatically adjust text size in plot

2008-10-24 Thread Greg Snow
You can use strheight and strwidth to find the height and width of a string in 
user coordinates, current font, cex=1.  From that you can figure out how much 
to change the size to fit within the area of interest.  You may also want to 
look at the textplot function in the gplots package.  It adjusts text to fit a 
plot, looking at the code to see how that function does it may give you more 
ideas,

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Gustaf Rydevik
> Sent: Friday, October 24, 2008 9:29 AM
> To: r-help@r-project.org
> Subject: [R] Automatically adjust text size in plot
>
> Hi all,
>
> I'm writing a function that will automatically generate a report based
> on answers to a questionnaire. The exact questions and answers to the
> questionnaire can vary. One of the question types is in a "matrix"
> format, where the agreement to several statements can be indicated on
> a scale.
>
> I'm planning to plot this on a multilevel barplot, and only labeling
> each "bar column" once. However, I'm stuck as to how I should adjust
> text size and wrapping to fit to each column.
>
> Here's an example of what I mean:
>
> barnames<-c("I agree completely", "I agree", "I partly agree", "I do
> not agree", "I really hate this stupid question, don't you?")
> answers<-
> data.frame(question=paste("Q",1:5,sep=""),S1=sample(1:100,5),S2=sample(
> 1:100,5),S3=sample(1:100,5),S4=sample(1:100,5),S5=sample(1:100,5))
> Width<-50
> Cex<-1.5
>
> par(mfrow=c(nrow(answers)+1,1),mar=c(0,1,1,1))
> plot.new()
> plot.window(xlim=c(0,1),ylim=c(0,1))
> barnames.plot<-
> do.call("c",lapply(barnames,function(x)paste(strwrap(x,Width),collapse=
> "\n")))
> text(barnames.plot,x= (seq.int(0, 1, length.out =
> length(barnames)+1)-0.5/length(barnames))[-1],y=0.5,cex=Cex)
> for(i in 1:nrow(answers)){
> barheight<-rep(0,length(barnames))
> barheight[as.numeric(names(subQ.tables[[i]]))]<-subQ.tables[[i]]
> barplot(barheight,space=0)
> }
>
> The question is, how do I figure out the appropriate "Width"  and
> "Cex" parameters as a function of barnames?
> That is, with varying text lengths of the barnames, varying number of
> alternatives etc, and independent on which device type is used?
> strwrap uses "column" as units, and I can't really figure out how to
> convert that to graph units. Same goes for cex.
>
> Many thanks in advance,
>
> Gustaf
>
>
> PS: As an alternative, if someone could come up with a better way do
> display this type of data, I'd be all ears. I'm not too happy with my
> current solution
>
>
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Shading underneath a line plot.

2008-10-24 Thread Greg Snow
Is this what you want?

mydata <- c(268,251,254,250,244,246,247,243,241,243)
plot(mydata, type="o")
polygon( c( 1, 1:length(mydata), length(mydata) ), c(0,mydata,0), col='red')

I could not see your original plot since we don't know what ppp is.


--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Alastair Andrew
> Sent: Friday, October 24, 2008 10:17 AM
> To: r-help@r-project.org
> Subject: [R] Shading underneath a line plot.
>
>
> Hi,
>
> I'm sure this should be fairly simple to do but I haven't found an
> example.
> I have 10 data points which are plotted as a line, I want to shade
> under
> this line with a colour. Other examples have shading under curves where
> there are two sets of data use polygons.
>
> mydata <- c(268,251,254,250,244,246,247,243,241,243)
> plot(mydata, type="o")
> polygon(c(ppp$total,length(ppp$total)), col="red")
>
> This gives me almost what I want but the line from the x-axis up to the
> first point on the line is squint. Could anyone suggest how to create
> my
> polygon so that it correctly shades underneath the line?
>
> Thanks,
> Alastair
> --
> View this message in context: http://www.nabble.com/Shading-underneath-
> a-line-plot.-tp20153115p20153115.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] Background Colour

2008-10-24 Thread andystats

Pretty simple- use the par() function
pdf("rotondje.pdf",width=m, height=m)
frame()
par(bg="yellow")
#your stuff
dev.off()

Hope that helps


Mag. Ferri Leberl wrote:
> 
> Dear eveerybody,
> I am making a .pdf, starting:
> 
> pdf("rotondje.pdf",width=m, height=m)
> frame()
> 
> How can I set the background-colour of the frame yellow?
> Thank you in advance.
> Yours, Leberl
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/Background-Colour-tp20156600p20160652.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] how to do power transformation for time series data?

2008-10-24 Thread Ke Li

I am dealing with a seasonal time series data. In order to ger rid of the
nonstationarity of the variance, i need to perform power tranformation to
the data and choose the best lambda value. In Mass package, there is a
function called 'boxcox' to do power tranformation but it only deals with
linear model. Is there anyone who knows the other function that cannot
perform power tranformation to time series data? Thanks!  
-- 
View this message in context: 
http://www.nabble.com/how-to-do-power-transformation-for-time-series-data--tp20157719p20157719.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] how to plot chi-square distribution in the graph

2008-10-24 Thread leo_wa

if i want to plot the chi-square distribution with a different degree of
freedom how can i plot it in the graph?Sometimes i plot the histogram and
cut it in a lot of piece.It's distribution like a chi-square.So i want to
plot the chi-square with a different degree of freedom to compare it .
-- 
View this message in context: 
http://www.nabble.com/how-to-plot-chi-square-distribution-in-the-graph-tp20160946p20160946.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] Need Help using the OO package

2008-10-24 Thread Aditya Udas
Hi Henrik,
It would be great if you could help me out with my following problem.

I am trying to create a class like :

setConstructorS3("MyPTCM",function(tokenslist=0)
{
   extend(Object(), "MyPTCM",
   .gamma = 0.0,
   .rho = 0.0,
   .phi = 0.0,
   .tokenslist = tokenslist,
   .uniquetokens = unique(tokenslist),
   .numtypes = length(uniquetokens),
   .Nsq = numtypes*numtypes,
   .CONTEXTti = array(0,dim=numtypes),
   .CONTEXTtim = array(0,dim=numtypes),
   .ZEROVEC = .CONTEXTti,
   .MTF = array(0.0,dim=c(numtypes,numtypes)),
   .hIN = array(0.0,dim=c(numtypes,numtypes)),
   .tokencount <- 0);
}
)

Everytime I try to create an object of type MyPTCM, it gives me an error saying
> b <- MyPTCM(tokens)
Error in extend.Object(Object(), "MyPTCM", gamma = 0, rho = 0, phi = 0,  :
   object "uniquetokens" not found

I have tried using this$.uniquetokens and just by referencing it with
.uniquetokens and other such techniques but to no avail.

I'm sure I'm making some basic fundamental mistake.
Any kind of inputs would be greatly appreciated.
Thanks in Advance,
Aditya

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


Re: [R] multiple visualisation of a bootstrap

2008-10-24 Thread Greg Snow
Or if you want the plots to not all be the same size and line up in various 
ways (boxplots as margins of scatter plot, etc.) then look at the layout 
function.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Ben Bolker
> Sent: Friday, October 24, 2008 8:14 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [R] multiple visualisation of a bootstrap
>
> Fernando Marmolejo Ramos  adelaide.edu.au>
> writes:
>
> >
> > Dear R team
>
> > Vista offers a so-called Multiple Visualisation (MV) of the output of
> a
> > bootstrap (it shows on the same window scatter plots for a particular
> variable
> > showing the bootstrapped CI, a scatter plot of
> > the evolution of the bootstrapped
> > mean over many sample sizes, a box plot, a QQ plot, and a histogram).
> >
> > I wonder if there is any manner in which this sort of MV
> > could me mimicked by R
> > in the case of bootstrap. My best guess is that I’d have to create a
> 3 by 2
> > frame an insert each graph separately or maybe resort to Trellis
> > graphics… am I
> > right? Does anyone have a more sophisticated solution?
> >
>
>   I'm not sure this is the right kind of problem for Trellis graphics
> (which are geared toward using the same plot type for different
> subsets of the data in each panel, rather than different plot types
> of the same data).  The "unsophisticated" solution (which seems
> just fine), as you suggest, is to use par(mfrow) or par(mfcol)
> to break up the plot window into frames, and then plot the
> different bits in each window.
>
> See http://emdbolker.wikidot.com/blog:dynamite for an example
> of plotting the same data in different ways within subplots
> (and
> http://emdbolker.wdfiles.com/local--
> files/blog:dynamite/barboxdotviolin.R
> for the code).
>
>  As far as R is concerned, "sophisticated" would mean
> creating a plotting function for this so that you never
> had to look at the details again ...
>
>   Ben Bolker
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Computational problems in R

2008-10-24 Thread Steven McKinney
I suspect there's a deeper issue here.
sum(exp(yi)) when large yi occur is
problematic.  exp(yi) for yi>710 is
just a huge number, and summing additional
values only makes the overall sum larger as all
components of the summation are positive.
There's no way around that.

You could try this with Robin Hankins'
package "brobdingnag" which can handle
bunches of bizarrely large numbers.

What kind of process are you studying?
What kind of process generates values
such as exp(8/0.01) when other values
are much smaller?  Are these outliers
in an otherwise well-behaved
data set?  Perhaps then they need
to be set aside and investigated
separately, etc.


Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: [EMAIL PROTECTED] on behalf of Duncan Murdoch
Sent: Fri 10/24/2008 4:04 PM
To: A.Noufaily
Cc: r-help@r-project.org
Subject: Re: [R] Computational problems in R
 
On 24/10/2008 12:42 PM, A.Noufaily wrote:
> Dear all,
> 
> I would be grateful if anyone can help me with the following:
> 
> My aim is to compute explicitely the sum S=A+B where A=sum(exp(c_i/d)),
> i=1,...,n;
> B, c_i, and d are real numbers with -Inf0.
> The problem is that when c_i/d >710 (for some i) R is setting
> exp(c_i/d) to be equal to +Inf and hence the whole summation S.
> So in simple cases where for example c_i=8 (for some i), and d=0.01 the
> whole summation is turning out to be infinite.
> Is there a way to get round that in R?
> Can anyone suggest any computational trick to calculate S when c_i/d>710
> (for some i)?

Work on a log scale.  Use the identity that

A+B = A*(1 + B/A)
 = exp(log(A) + log(1 + B/A))

(where you chose A to be the biggest term in the sum).

Duncan Murdoch

> 
> Any suggestions would be much appreciated.
> 
> Regards,
> 
> Amy
> 
> 
> 
> 
> 
> -
> The Open University is incorporated by Royal Charter (RC 000391), an exempt 
> charity in England & Wales and a charity registered in Scotland (SC 038302).
> 
>   [[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] combining data from different datasets

2008-10-24 Thread Steven McKinney
If you are using regular R graphs
(i.e. not lattice or other library
graphics) try setting the margins
with the mar argument to par()

e.g.
par(mar = c(5, 10, 5, 1))

The four numbers specify the amount
of margin room on the bottom, left, top, right
respectively.  Set the left margin value large
enough to give your labels enough room.


HTH


Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney +at+ bccrc +dot+ ca

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada




-Original Message-
From: [EMAIL PROTECTED] on behalf of Dr Eberhard W Lisse
Sent: Fri 10/24/2008 2:44 PM
To: R-help Mailing List
Cc: Dr Eberhard W Lisse
Subject: Re: [R] combining data from different datasets
 
It's Complicated® :-)-O

I pull the data from a postgresql table, but I am getting
there, thank you the help.

Another question, I am barplotting the continents horizontally,
ie the more participants the lrger the bars are. I have managed
the make the labels (names of the nontinents) to be horizontally
but the longer ones (North and South America) flow off the left
side (right justified).

So, how do I make the plot smaller, and move it to the right so
that the complete names appear? I can make the plot smaller in
inches but that doesn't scale if I enlarge the window.

Pointers to read will be fine, but so far I haven't found it :-)-O

el

On 24 Oct 2008, at 18:24 , Gabor Grothendieck wrote:

> On Fri, Oct 24, 2008 at 11:37 AM, Dr Eberhard W Lisse <[EMAIL PROTECTED]>  
> wrote:
>>
>> This looks very cool.
>>
>> But I must still make a plan with regards to country = "NA" (Namibia)
>> or continent = "NA" (North America)
>>
>> But there are the vignettes.
>>
>> el
>>
>
> NA and "NA" are not the same:
>
>> DF <- data.frame(x = c("a", "NA", NA))
>> DF
> x
> 1a
> 2   NA
> 3 
>>
>> is.na(NA)
> [1] TRUE
>> is.na("NA")
> [1] FALSE
>

--
Dr. Eberhard W. Lisse  \/ Obstetrician & Gynaecologist (Saar)
[EMAIL PROTECTED] el108-ARIN /   *   |   Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please send DNS/NA-NiC related e-mail
Bachbrecht, Namibia ;/ to [EMAIL PROTECTED]

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

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


Re: [R] movie3d function in the rgl package

2008-10-24 Thread Duncan Murdoch

On 24/10/2008 1:55 PM, Dani wrote:

Dear list,

I'm using the function "movie3d" in the package "rgl" to create a .gif
animation of a 3d graphic.  The program "ImageMagik" is working
properly, R packages are working, basic examples available in the
manual also working fine.

Problem Solved: when I tried to create more complex movies, i.e.
combining different views and zooming, the R-console crashed or
returned error playing the function returned by par3dinterp, using
heterogeneous parameters. When not crashing, "Error:
length(userMatrix) == 16 * length(times) is not TRUE."


I'm glad you solved your problem.  Just one comment on your solution:


Counterexample:
#rotating
v=seq(from=1,to=61,by=2.5)
for (i in 1:length(v)){
  rgl.viewpoint(270+v[i],80-(v[i]/1)) #This is a counterexample


It's always a bad idea to mix rgl.* functions with *3d functions.  In 
this case you might get away with it, but you'd be better off using 
view3d().


Duncan Murdoch


  M <- par3d()
  lista[[k]]=M;
  k=k+1;
}
#zooming
v=seq(from=1,to=0.12,by=-0.02)
for (i in 1:length(v)){
 par3d(zoom=v[i])
 M <- par3d()
 lista[[k]]=M; k=k+1;
}
#-- Ending view
rgl.viewpoint(326,40)
par3d(zoom=1)
M <- par3d()
lista[[k]]=M; k=k+1;

p = par3dinterp(lista)
play3d(p) # or movie3d (p,12)
--
Light: after 2 weeks fighting with the function + a bag of coffee, I
found this function really helpful and I WANTED TO SHARE since I
didn't find anything like that in the web.
Step 1: set the zooming parameters to each view you want in a separate
vector (list_zooming) while accumulating the views in the
list_userMatrix
#rotating
v=seq(from=1,to=61,by=30)#2.5)
for (i in 1:length(v))
{
  rgl.viewpoint(270+v[i],80-(v[i]/1))
  M <- par3d("userMatrix")#This is an example who runs perfectly
  list_userMatrix[[k]]=M;
  k=k+1;
}
list_z=rep(1,length(v)); list_zooming=c(list_zooming,list_z)

#zooming
v=c(1,0.12)#seq(from=1,to=0.12,by=-0.2)
for (i in 1:length(v))
{
 list_zooming=c(list_zooming,v[i])
 M <- par3d("userMatrix")
 list_userMatrix[[k]]=M; k=k+1;
}
#--
rgl.viewpoint(345,30)
par3d(zoom=0.1)
M <- par3d("userMatrix")
list_userMatrix[[k]]=M; k=k+1;

p = par3dinterp( userMatrix=list_userMatrix,zoom=list_zooming)

movie3d (p,duration=12)#as.integer(length(list_userMatrix)))
#play3d(p)

Hope it was helpful! Good lucky!
--
-
Daniela

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

2008-10-24 Thread Duncan Murdoch

On 24/10/2008 12:42 PM, A.Noufaily wrote:

Dear all,

I would be grateful if anyone can help me with the following:

My aim is to compute explicitely the sum S=A+B where A=sum(exp(c_i/d)),
i=1,...,n;
B, c_i, and d are real numbers with -Inf0.
The problem is that when c_i/d >710 (for some i) R is setting
exp(c_i/d) to be equal to +Inf and hence the whole summation S.
So in simple cases where for example c_i=8 (for some i), and d=0.01 the
whole summation is turning out to be infinite.
Is there a way to get round that in R?
Can anyone suggest any computational trick to calculate S when c_i/d>710
(for some i)?


Work on a log scale.  Use the identity that

A+B = A*(1 + B/A)
= exp(log(A) + log(1 + B/A))

(where you chose A to be the biggest term in the sum).

Duncan Murdoch



Any suggestions would be much appreciated.

Regards,

Amy





-
The Open University is incorporated by Royal Charter (RC 000391), an exempt charity 
in England & Wales and a charity registered in Scotland (SC 038302).

[[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] Rgui.exe - Application Error

2008-10-24 Thread Duncan Murdoch

On 24/10/2008 7:52 AM, Rita. A wrote:

Hello All,

I get the following error when i run the following script in Rgui

Rgui.exe - Application Error

The instruction at "0x7c9109f9" referenced memory at "0x". The
memory could not be "read"
Click on OK to terminate the program

The script is

library(RODBC)
channel <- odbcConnect("curve", uid="curve", pwd="curve")
elastic <- sqlFetch(channel,"elasticband")
attach(elastic)
png(filename="e:/R/cf.png")
plot(spline(distance~stretch),type="l",xlab="Stretch",ylab="Distance")
odbcClose(channel)

I use R version 2.7.2 and using RODBC to fetch data from Oracle 10g, I would
appreciate any help


This is unlikely to be easy to fix.  It depends on R, the RODBC code, 
the ODBC driver for Oracle, and Oracle itself.  There are 3 or 4 
separate authors involved who will all blame the others.


I'll be first: it's probably not R.  And since Brian Ripley is away now, 
I'll cover for him too:  it's probably not RODBC.


So you should contact Oracle tech support for their denials.

Seriously, debugging this requires resources which probably only Oracle 
has, but which Oracle probably won't devote to the problem.  So if you 
don't get satisfaction from them I'd suggest dumping the database and 
reloading it in some other database.  Hopefully a free/open source one.


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] ggplot2: how to combine position=stack and position=dodge in a single graph?

2008-10-24 Thread Elena Schulz

Hi Hadley,

thanks a lot for your quick answer.
> You should be able to replicate any dodging layout with facetting
You mean instead of facetting by years, facetting by months? I will try 
this an see how the plot looks.


> shift the second layer across a bit
> with aes(x=as.numeric(CommitMont) + 0.5)).
I tried this, but it didn't work with my data. I think due to the fact 
that I am quite new to R.


> please send me a reproducible example.
It took me a bit to create some reproducible example data that shows my 
problem. Please see the example script below.


Wouldn't it be more intuitive to have some parameters for layers like 
stacking=c(s1, s2, ...), dodging=c(d1, d2), ..., or is the combination 
of both so rarely used?


Thanks a lot for your help to get it work with the below script.

-- Elena


Here is my script:

# create artificial timeseries data
library("its")
n = 12*2*20 # number of values = 12 * nyears * npermonth
tser = newIts(start="2006-01-01",end="2007-12-31", period="month", 
find="last", extract=TRUE, weekday=FALSE)

t = strptime(dates(tser), format="%Y-%m-%d")
CommitMonth = strftime(t, "%m")
CommitYear = strftime(t, "%Y")
n = 24*20 # number of values
Price = rnorm(1000, mean = 1000, sd = 500)[1:n]
newCust = as.logical(round(runif(n, min=0, max=1)))
c_dat = data.frame(cbind(CommitYear, CommitMonth, newCust), Price)
summary(c_dat)
str(c_dat)
# use reshape for flexibility
library("reshape")
c_datM = melt(c_dat,
   id = c("CommitYear", "CommitMonth", "newCust"),
   measured = c("Price"),
   na.rm = TRUE)
nc_dat = cast(c_datM, CommitMonth + CommitYear + newCust ~ variable, sum)
summary(nc_dat)
# separate data for different years
nc_dat_06 = subset(nc_dat, CommitYear == 2006)
nc_dat_07 = subset(nc_dat, CommitYear == 2007)

# try to combine dodging and stacking
library("ggplot2")
ggplot() +
layer(data = nc_dat_07,
  mapping = aes(x=CommitMonth,
y=Price,
fill = factor(newCust),
width=0.4),
  geom="bar",
  colour="red",
  stat="identity"
  ) +
layer(data = nc_dat_06,
  mapping = aes(x=factor(as.numeric(CommitMonth)+.5),
y=Price,
fill=factor(newCust),
width=0.4
),
  geom="bar",
  colour="black",
  stat="identity"
  )


hadley wickham wrote:

Hi Elena,

You should be able to replicate any dodging layout with facetting, but
you should be to shift the second layer across a bit with
aes(x=as.numeric(CommitMont) + 0.5)).  If that doesn't work, please
send me a reproducible example.

Hadley

On Tue, Oct 21, 2008 at 3:59 PM, Elena Schulz <[EMAIL PROTECTED]> wrote:

Hi Hadley,

my problem is that I want to compare data for different years month by
month. Each bar for a month is devided into two or more sections (->
stacking) By having all data of the same month right next to each other (->
dodging) comparision is much more easy than using faceting which does not
show subtle differences within the same month of different years since all
years get separated.

My approach to allow combining of stacking and dodging in a single
graphic would be the following:

# compare different years in one plot
# combine position_stack with position_dodge
ggplot() +
layer(data = nc_dat_06,
 mapping = aes(x=CommitMonth,
   y=Price,
   fill = factor(newCust),
   width=0.4),
 geom="bar",
 colour="red",
 stat="identity"
 ) +
layer(data = nc_dat_07,
 mapping = aes(x=CommitMonth,
   y=Price,
   fill=factor(newCust),
   width=0.4
   ),
 geom="bar",
 colour="black",
 stat="identity"
 )

This works except that the second layer (data = nc_dat_07) is plotted right
on top of the first one (data = nc_dat_06). If I could find a way to shift
the whole second layer (data = nc_dat_07) a bit parallel to the x axis, I'm
done. Is there an easy way for this? Adding an x-offset value to a layer?

Thanks for any help on this,

-- Elena


hadley wickham wrote:

Hi Elena,

Currently, there's no way to combine stacking and dodging in a single
graphic.  However, you can often use faceting to get a similar effect
to dodging.  Could you explain your problem in a little more detail?

Thanks,

Hadley

On Sat, Oct 4, 2008 at 4:22 PM, Elena Schulz <[EMAIL PROTECTED]> wrote:

Hi ggplot experts,

I need to plot two time series of stacked data: a barchart with bars for
each month. To compare the data of two years I need to combine both time
series with in a single graph via position=doge.
How should I do that?

I tried the following scenario:
I added two layers with the time series of the stacked data for both
years.
That worked well exept the bars are obscuring each other. How can  I
shift
one of the layers to get them displayed next to each other.

Is there an other easier way to achieve this?

Thanks a lot for any help on this.

-- Elena


Re: [R] combining data from different datasets

2008-10-24 Thread Dr Eberhard W Lisse

Daniel,

the parameter all.x=TRUE is required.

greetings, el

On 24 Oct 2008, at 21:24 , Daniel Malter wrote:


?merge.

It looks though that your "iso" has no identifier variable whereas the
"rawdata" has, so you probably cannot merge it unless/until you have  
an

identifier in "iso".


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


Re: [R] combining data from different datasets

2008-10-24 Thread Dr Eberhard W Lisse

It's Complicated® :-)-O

I pull the data from a postgresql table, but I am getting
there, thank you the help.

Another question, I am barplotting the continents horizontally,
ie the more participants the lrger the bars are. I have managed
the make the labels (names of the nontinents) to be horizontally
but the longer ones (North and South America) flow off the left
side (right justified).

So, how do I make the plot smaller, and move it to the right so
that the complete names appear? I can make the plot smaller in
inches but that doesn't scale if I enlarge the window.

Pointers to read will be fine, but so far I haven't found it :-)-O

el

On 24 Oct 2008, at 18:24 , Gabor Grothendieck wrote:

On Fri, Oct 24, 2008 at 11:37 AM, Dr Eberhard W Lisse <[EMAIL PROTECTED]>  
wrote:


This looks very cool.

But I must still make a plan with regards to country = "NA" (Namibia)
or continent = "NA" (North America)

But there are the vignettes.

el



NA and "NA" are not the same:


DF <- data.frame(x = c("a", "NA", NA))
DF

x
1a
2   NA
3 


is.na(NA)

[1] TRUE

is.na("NA")

[1] FALSE



--
Dr. Eberhard W. Lisse  \/ Obstetrician & Gynaecologist (Saar)
[EMAIL PROTECTED] el108-ARIN /   *   |   Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please send DNS/NA-NiC related e-mail
Bachbrecht, Namibia ;/ to [EMAIL PROTECTED]

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


Re: [R] Help regarding oo package

2008-10-24 Thread Henrik Bengtsson
Hi,

comments below.

On Fri, Oct 24, 2008 at 1:47 PM, Aditya Udas <[EMAIL PROTECTED]> wrote:
> Hi Henrik,
> I'm sorry to be bothering you, but there is something that I have been
> stuck with for a while now.
>
> I am trying to create a class like :
>
> setConstructorS3("MyPTCM",function(tokenslist=0)
> {
>   extend(Object(), "MyPTCM",
>   .gamma = 0.0,
>   .rho = 0.0,
>   .phi = 0.0,
>   .tokenslist = tokenslist,
>   .uniquetokens = unique(tokenslist),
>   .numtypes = length(uniquetokens),
>   .Nsq = numtypes*numtypes,
>   .CONTEXTti = array(0,dim=numtypes),
>   .CONTEXTtim = array(0,dim=numtypes),
>   .ZEROVEC = .CONTEXTti,
>   .MTF = array(0.0,dim=c(numtypes,numtypes)),
>   .hIN = array(0.0,dim=c(numtypes,numtypes)),
>   .tokencount <- 0);
> }
> )
>
> Everytime I try to create an object of type MyPTCM, it gives me an error 
> saying
>> b <- MyPTCM(tokens)
> Error in extend.Object(Object(), "MyPTCM", gamma = 0, rho = 0, phi = 0,  :
>   object "uniquetokens" not found

Yes, that is what is expected, because the object 'uniquetokens' does
not exist.  I understand that you might be tempted to think that it
became a "members" of the object/class, but it isn't.  Think about the
construct extend(Object(), "MyPTCM", ...) as if it was a regular R
list.  The problem you have is then analogue to:

> x <- list(a=1, b=length(a))
Error: object "a" not found

The following does not work either:

> x <- list(a=1, b=length(x$a))
Error: object "x" not found

because 'x' does not exist when you first try to access it by 'x$a'.

A workaround for this, is to first create a local variable 'a' and
then use that:

> a <- 1;
> x <- list(a=1, b=length(a));
> str(x);
List of 2
 $ a: num 1
 $ b: int 1

Alternatively, you can build up your list element by element:

x <- list(a=1);
x$b <- length(x$a);
str(x);
List of 2
 $ a: num 1
 $ b: int 1

Note that in you have to use 'x$a' to access element 'a' of list 'x'
(as expected).

Back to your case, if you want to do the latter, then you do something
like (where I allow myself to assign some elements immediately when
possible):

setConstructorS3("MyPTCM",function(tokenslist=0) {
 this <- extend(Object(), "MyPTCM",
.gamma = 0.0,
.rho = 0.0,
.phi = 0.0,
.tokenslist = tokenslist,
.tokencount = 0
  );

  this$.uniquetokens = unique(this$tokenslist);

  # Local variable used a lot
  n = length(this$uniquetokens);
  this$.numtypes = n;

  this$.Nsq = n*n;
  this$.CONTEXTti = array(0, dim=n);
  this$.CONTEXTtim = array(0, dim=n);
  this$.ZEROVEC = this$.CONTEXTti;
  this$.MTF = array(0.0,dim=c(n,n));
  this$.hIN = array(0.0,dim=c(n,n));

  # Return the object
  this;
});

>
> I have tried using this$.uniquetokens and just by referencing it with
> .uniquetokens and other such techniques but to no avail.

Hope the above list examples makes you understand what goes wrong.

More of a design comment: I would avoid storing redundant information
in an object (unless it is really expensive to generate the redundant
results).  In your case I would simply skip the variable
'uniquetokens' and instead create a method for it, i.e.

setMethodS3("getUniqueTokens", "MyPTCM", function(this, ...) {
  unique(this$tokenslist);
})

Then you can get the value by getUniqueTokens(obj).  Any subclass of
Object also a feature called "virtual fields", and that is actually
what the about method added, because if you call obj$uniqueTokens,
then it will look to see if there is a getUniqueTokens() than can be
called.  So, the 'uniqueTokens' field does not exist, but the object
behaves as it does.

You can also protection for trying to write to virtual fields (or
other field on that hand), e.g.

setMethodS3("setUniqueTokens", "MyPTCM", function(this, ...) {
  throw("You cannot set this value; it is inferred from the
'uniquetokens' field.");
})

Hope this helps

Henrik

>
> I'm sure I'm making some basic fundamental mistake.
> Any kind of inputs would be greatly appreciated.
> Thanks in Advance,
> Aditya
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Transferring results from R to MS Word

2008-10-24 Thread Gabor Grothendieck
Try using gsubfn from the gsubfn package:

# test data based on builtin iris data set
mod <- summary(lm(Sepal.Length ~., iris))

library(R2HTML); library(gsubfn)

HTML(mod, file = textConnection("out", "w"))
out2 <- gsubfn("[0-9]+[.][0-9]+", ~ round(as.numeric(x), 2), out)
cat(paste(out2, "\n"), "\n", file = "myfile.html")

Now read myfile.html into Word (or into Excel and then into Word).

On Fri, Oct 24, 2008 at 3:30 PM, Tom Backer Johnsen <[EMAIL PROTECTED]> wrote:
> R-users
>
> At the moment I am teaching a course on the use of R for data analysis.
>  Part of course requirements involves the transfer of results from R to
> something that resembles the APA (American Psychological Associations) type
> tables to MS Word.  Until now I have used the HTML function in the R2HTML
> library, with a call like this:
>
> HTML(summary(model1), file("clipboard", "w"), digits=4)
>
> Where "model1" is an object containing results from a linear model (function
> lm ()).  I have to add that I do not remember where I got the digits
> argument from.  The main point is that the output is transferred to Excel as
> the first step where the output can be deleted and shuffled in order to
> produce a correctly formatted table according to APA standards which then is
> transferred to MS Word with a copy and paste operation.
>
> The problem is simply that what is tranferred to Excel varies with what you
> throw at the HTML function.  Nothing is rounded of with an lm() model.  With
> a function like sd () I seem to consistently get 2 decimal points
> transferred, less than what I want, while there are variations in respect to
> the number of decimals when I transfer the result on the summary () using a
> frame as the argument.
>
> The optimal thing for me (and the students) would be to consistently have
> all the decimals tranferred to Excel, any rounding to could be done there
> before the transfer of the table to MS Word.  Alternatively, that something
> like the argument digits=x works in a consistent manner with at least most
> objects.
>
> So:
>
> What do I tell my students on what to do using R2HTML in order to obtain
> consistent results?
>
> Alternativly: are there other alternatives I and my students could use for
> the transfer of results from R via Excel to MS Word?
>
> I really would appreciate some suggestions.
>
> Tom
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] using chron() to convert julian -> calendar dates but ignoring leap years

2008-10-24 Thread mwestphal

Hello:

I am using R 2.7.2 for Windows.  I have been using chron() to convert from
Julian to calendar dates.  How do I ignore leap years?  Thanks.

Cheers,

Michael

--
Michael I. Westphal, PhD
Africa Region Water Resources (AFTWR)
Room J6-007 (mail stop: J6-603).
The World Bank
1818  H St NW, Washington DC 20433, 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] Help regarding oo package

2008-10-24 Thread Aditya Udas
Hi Henrik,
I'm sorry to be bothering you, but there is something that I have been
stuck with for a while now.

I am trying to create a class like :

setConstructorS3("MyPTCM",function(tokenslist=0)
{
   extend(Object(), "MyPTCM",
   .gamma = 0.0,
   .rho = 0.0,
   .phi = 0.0,
   .tokenslist = tokenslist,
   .uniquetokens = unique(tokenslist),
   .numtypes = length(uniquetokens),
   .Nsq = numtypes*numtypes,
   .CONTEXTti = array(0,dim=numtypes),
   .CONTEXTtim = array(0,dim=numtypes),
   .ZEROVEC = .CONTEXTti,
   .MTF = array(0.0,dim=c(numtypes,numtypes)),
   .hIN = array(0.0,dim=c(numtypes,numtypes)),
   .tokencount <- 0);
}
)

Everytime I try to create an object of type MyPTCM, it gives me an error saying
> b <- MyPTCM(tokens)
Error in extend.Object(Object(), "MyPTCM", gamma = 0, rho = 0, phi = 0,  :
   object "uniquetokens" not found

I have tried using this$.uniquetokens and just by referencing it with
.uniquetokens and other such techniques but to no avail.

I'm sure I'm making some basic fundamental mistake.
Any kind of inputs would be greatly appreciated.
Thanks in Advance,
Aditya

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


Re: [R] Shading underneath a line plot.

2008-10-24 Thread jim holtman
Is this what you want:

mydata <- c(268,251,254,250,244,246,247,243,241,243)
plot(mydata, type="o")
# choose a min y value
minY <- 240
polygon(c(1, 1:10, 10), c(240, mydata, 240), col='red')


On Fri, Oct 24, 2008 at 12:17 PM, Alastair Andrew
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm sure this should be fairly simple to do but I haven't found an example.
> I have 10 data points which are plotted as a line, I want to shade under
> this line with a colour. Other examples have shading under curves where
> there are two sets of data use polygons.
>
> mydata <- c(268,251,254,250,244,246,247,243,241,243)
> plot(mydata, type="o")
> polygon(c(ppp$total,length(ppp$total)), col="red")
>
> This gives me almost what I want but the line from the x-axis up to the
> first point on the line is squint. Could anyone suggest how to create my
> polygon so that it correctly shades underneath the line?
>
> Thanks,
> Alastair
> --
> View this message in context: 
> http://www.nabble.com/Shading-underneath-a-line-plot.-tp20153115p20153115.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.


[R] How to embed residual dot plots of BHH2::anovaPlot(...) into plotMeans(...)?

2008-10-24 Thread Xiaoxu LI
Dear R fans,

I am preparing a lecture discussing the paper of Wilkinson and APA
Task Force on Statistical Inference (1999, American Psychologist, 54,
594-604.) I'd like to demo their Figure 3B (p. 602) with R. That is to
add plotMeans(...) with dots of BHH2::dotPlot(...) . Is there any
elegant script to do the job?



Thanks

---
LI, Xiaoxu

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


Re: [R] Computational problems in R

2008-10-24 Thread Xiaoxu LI
I think you should try one X for A/X=sum(exp(c_i/d -log(X)))
The optional X could be as the following ...

## to test ### C = c(c_i/d; i=1,2,...,n)
n<-1000;
C<-runif(n,700,1000);
#

M<-1;while (2*M < Inf) M<-2*M;
X<- exp(max(C) - log (M/n));
cat('A=',sum(exp(C-log(X))),'*',X)


On Sat, Oct 25, 2008 at 12:42 AM, A.Noufaily <[EMAIL PROTECTED]> wrote:
>
> Dear all,
>
> I would be grateful if anyone can help me with the following:
>
> My aim is to compute explicitely the sum S=A+B where A=sum(exp(c_i/d)),
> i=1,...,n;
> B, c_i, and d are real numbers with -Inf0.
> The problem is that when c_i/d >710 (for some i) R is setting
> exp(c_i/d) to be equal to +Inf and hence the whole summation S.
> So in simple cases where for example c_i=8 (for some i), and d=0.01 the
> whole summation is turning out to be infinite.
> Is there a way to get round that in R?
> Can anyone suggest any computational trick to calculate S when c_i/d>710
> (for some i)?
>
> Any suggestions would be much appreciated.
>
> Regards,
>
> Amy
>
>
>
>
>
> -
> The Open University is incorporated by Royal Charter (RC 000391), an exempt 
> charity in England & Wales and a charity registered in Scotland (SC 038302).
>
>[[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] Background Colour

2008-10-24 Thread Mag. Ferri Leberl
Dear eveerybody,
I am making a .pdf, starting:

pdf("rotondje.pdf",width=m, height=m)
frame()

How can I set the background-colour of the frame yellow?
Thank you in advance.
Yours, Leberl

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Transferring results from R to MS Word

2008-10-24 Thread Tom Backer Johnsen

R-users

At the moment I am teaching a course on the use of R for data analysis. 
 Part of course requirements involves the transfer of results from R to 
something that resembles the APA (American Psychological Associations) 
type tables to MS Word.  Until now I have used the HTML function in the 
R2HTML library, with a call like this:


HTML(summary(model1), file("clipboard", "w"), digits=4)

Where "model1" is an object containing results from a linear model 
(function lm ()).  I have to add that I do not remember where I got the 
digits argument from.  The main point is that the output is transferred 
to Excel as the first step where the output can be deleted and shuffled 
in order to produce a correctly formatted table according to APA 
standards which then is transferred to MS Word with a copy and paste 
operation.


The problem is simply that what is tranferred to Excel varies with what 
you throw at the HTML function.  Nothing is rounded of with an lm() 
model.  With a function like sd () I seem to consistently get 2 decimal 
points transferred, less than what I want, while there are variations in 
respect to the number of decimals when I transfer the result on the 
summary () using a frame as the argument.


The optimal thing for me (and the students) would be to consistently 
have all the decimals tranferred to Excel, any rounding to could be done 
there before the transfer of the table to MS Word.  Alternatively, that 
something like the argument digits=x works in a consistent manner with 
at least most objects.


So:

What do I tell my students on what to do using R2HTML in order to obtain 
consistent results?


Alternativly: are there other alternatives I and my students could use 
for the transfer of results from R via Excel to MS Word?


I really would appreciate some suggestions.

Tom

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


Re: [R] combining data from different datasets

2008-10-24 Thread Daniel Malter
?merge.

It looks though that your "iso" has no identifier variable whereas the
"rawdata" has, so you probably cannot merge it unless/until you have an
identifier in "iso". If you know that all data is already ordered
accordingly, you can just bind the columns together in a new object like
this:

newdata=data.frame(rawdata$alter,rawdata$sex,iso$country)
newdata #return newdata

Cheers,
Daniel


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
Auftrag von Dr Eberhard W Lisse
Gesendet: Friday, October 24, 2008 11:02 AM
An: R-help Mailing List
Cc: Dr Eberhard W Lisse
Betreff: [R] combining data from different datasets

Hi,

I have two tables:


 > iso
 continent code code3 codenum  country
1  EU   AD   AND  20 Andorra, Principality of
2  AS   AE   ARE 784 United Arab Emirates
3  AS   AF   AFG   4 Afghanistan, Islamic Republic of
4  NA   AG   ATG  28  Antigua and Barbuda
5  NA   AI   AIA 660 Anguilla
159AF   NA   NAM 516 Namibia, Republic of
...
246AF   ZW   ZWE 716Zimbabwe, Republic of



and

 > rawdata
idno alter  sex cctld capacity topics content speakers
1 1NAMADA  2   12
2 252M  A  3   22
3 339FNAT  2   22
...

How do I make it print out something like

alter   sex country
1   NA  M   Andorra, Principality of
2   39  F   Namibia, Republic of
...

in other words do something like the following SQL:

SELECT r.alter, r.sex, i.country
FROM iso i, rawdata r
WHERE i.code = r.cctld

or even better:

alter   sex country
1   NA  M   Andorra, Principality of
2   52  M   
3   39  F   Namibia
...

And idea (where I can read up on this)?


el
--
Dr. Eberhard W. Lisse  \/ Obstetrician & Gynaecologist (Saar)
[EMAIL PROTECTED] el108-ARIN /   *   |   Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please send DNS/NA-NiC related e-mail
Bachbrecht, Namibia ;/ to [EMAIL PROTECTED]

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

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

2008-10-24 Thread Woolner, Keith
I've noticed that RODBC seems to be an order of magnitude slower in
retrieving rows from a table than ODBC (or JDBC) access in other tools.
I'm wondering why that is, and whether there are things I can do to
improve performance beyond what I've tried.  I've checked the
documentation, and have tried the rows_at_time= and buffsize= options,
which helped a little, but it is still running much, much slower than
what I'm seeing from other querying tools.

 

I'm running R version 2.7.1 on Windows XP 32-bit,  RODBC version 1.2-3,
and connecting to SQL Server 2005 running on a separate server via an
ODBC DSN.

 

The table "mytable" has 67 columns, and about 68,000 rows, and running a
simple "select * from mytable" query

 

10 seconds  Excel 2007 (ODBC via Microsoft Query)

14 seconds  RapidMiner (Java-based data mining application,
connecting to database via JDBC)

19 seconds  Import table from ODBC source to Microsoft Access
2007

 

229 seconds   R using: system.time(my.data <- sqlQuery(my.db,
"select * from mytable"))

161 seconds   R using: system.time(my.data <- sqlQuery(my.db,
"select * from mytable", rows_at_time=1024, buffsize=7))

 

Any ideas on other things to try?  Thank you.

 

--

Keith 

 

 


[[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] Computational problems in R

2008-10-24 Thread A.Noufaily

Dear all,

I would be grateful if anyone can help me with the following:

My aim is to compute explicitely the sum S=A+B where A=sum(exp(c_i/d)),
i=1,...,n;
B, c_i, and d are real numbers with -Inf0.
The problem is that when c_i/d >710 (for some i) R is setting
exp(c_i/d) to be equal to +Inf and hence the whole summation S.
So in simple cases where for example c_i=8 (for some i), and d=0.01 the
whole summation is turning out to be infinite.
Is there a way to get round that in R?
Can anyone suggest any computational trick to calculate S when c_i/d>710
(for some i)?

Any suggestions would be much appreciated.

Regards,

Amy





-
The Open University is incorporated by Royal Charter (RC 000391), an exempt 
charity in England & Wales and a charity registered in Scotland (SC 038302).

[[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] Shading underneath a line plot.

2008-10-24 Thread Alastair Andrew

Hi,

I'm sure this should be fairly simple to do but I haven't found an example.
I have 10 data points which are plotted as a line, I want to shade under
this line with a colour. Other examples have shading under curves where
there are two sets of data use polygons. 

mydata <- c(268,251,254,250,244,246,247,243,241,243)
plot(mydata, type="o")
polygon(c(ppp$total,length(ppp$total)), col="red")

This gives me almost what I want but the line from the x-axis up to the
first point on the line is squint. Could anyone suggest how to create my
polygon so that it correctly shades underneath the line?

Thanks,
Alastair
-- 
View this message in context: 
http://www.nabble.com/Shading-underneath-a-line-plot.-tp20153115p20153115.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] Rgui.exe - Application Error

2008-10-24 Thread Rita. A

Hello All,

I get the following error when i run the following script in Rgui

Rgui.exe - Application Error

The instruction at "0x7c9109f9" referenced memory at "0x". The
memory could not be "read"
Click on OK to terminate the program

The script is

library(RODBC)
channel <- odbcConnect("curve", uid="curve", pwd="curve")
elastic <- sqlFetch(channel,"elasticband")
attach(elastic)
png(filename="e:/R/cf.png")
plot(spline(distance~stretch),type="l",xlab="Stretch",ylab="Distance")
odbcClose(channel)

I use R version 2.7.2 and using RODBC to fetch data from Oracle 10g, I would
appreciate any help

Thanks
Rita.
-- 
View this message in context: 
http://www.nabble.com/Rgui.exe---Application-Error-tp20148701p20148701.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 nonlinear regression of binomial data

2008-10-24 Thread Harborne, Alastair
Hi all,
I have a manuscript nearly ready to go looking at a factorial analysis (inside 
and outside a Caribbean marine reserve) of how the biomass of predatory fish 
affects the proportion of survey transects containing urchins (more predators 
leads to fewer urchins). I would like to add some regression analysis, but my 
linear models with binomial errors are overdispersed because the data are 
nonlinear (negative power by the look of it). I have spent some time playing 
with gnlr but have realised that it is unlikely that I will be able to get the 
analysis to a publishable standard. If anyone is interested in working with me 
to complete this analysis I would happily include them as a co-author on the 
paper. The data are appended below in case anyone wants to see it.
Thanks,
Alastair

Pred_biomassproportion of transects with urchins
372.25  0.28571
173.66  0.14286
205.00  0.28571
3436.77 0.0
862.54  0.0
387.82  0.0
385.50  0.0
345.83  0.28571
132.61  1.0

- Note there seems to be an additional wrinkle as the biomass data are 
difficult to normalise.
__

Dr Alastair Harborne

Marine Spatial Ecology Lab
School of Biosciences
Hatherly Laboratory
University of Exeter, Prince of Wales Road
Exeter, EX4 4PS, UK

Phone: 01392-263784
Fax: 01392-263700
Skype name: al_harborne
Group website: http://www.ex.ac.uk/msel
Personal website: 
http://biosciences.exeter.ac.uk/staff/profiles/profile.php?id=alastair_harborne

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


Re: [R] Error Running TinnR with R

2008-10-24 Thread bg708

Hi,

I managed to get it to work this way (changing the Rprofile.site file) with
R2.7.2. I then made the mistake of updating to R2.8, and it stopped working.
Now changing the Rprofile.site file does nothing, and sending a block of
code gives me the "Error in source(.trPaths[5], echo = T) : object
".trPaths" not found" error message. I triple checked all the additional
lines in the Rprofile.site file, path for .trPaths is correct. One point of
note is that Hmisc package appears not to be available.

Thanks for any help you could give me! Otherwise it might be wise to revert
back to R2.7.2 or use the previous Tinn-R version.

Bernardo

-- 
View this message in context: 
http://www.nabble.com/Error-Running-TinnR-with-R-tp19477151p20148106.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] combining data from different datasets

2008-10-24 Thread Barry Rowlingson
2008/10/24 Gabor Grothendieck <[EMAIL PROTECTED]>:

> NA and "NA" are not the same:
>
>> DF <- data.frame(x = c("a", "NA", NA))
>> DF
> x
> 1a
> 2   NA
> 3 
>>
>> is.na(NA)
> [1] TRUE
>> is.na("NA")
> [1] FALSE

 Yes, but unless you tell it otherwise, read.table will think Namibia
is an NA, even in a column of alphabetic strings:

1,US
2,NA
3,UK

read.table("test.dat",sep=",")
  V1   V2
1  1   US
2  2 
3  3   UK

 So you think you can use na.strings? Calling with na.strings seems to
work on both columns, and hence converts columns with real NAs into
Factors. Here's some data:

$ cat test.dat
1,US
2,NA
3,UK
NA,FR
4,PT

We need column 1 to be integer with an NA, and column 2 to be text
with a real "NA" and not a :

 Try #1 (NAive effort) reads NA(mibia) as NA(missing), keeps V1 as integers:

> read.table("test.dat",sep=",")
  V1   V2
1  1   US
2  2 
3  3   UK
4 NA   FR
5  4   PT

 = FAIL

 Try #2 reads NAmibia okay, but reads V1 as factor:

> read.table("test.dat",sep=",",na.strings="")
  V1 V2
1  1 US
2  2 NA
3  3 UK
4 NA FR
5  4 PT

> str(read.table("test.dat",sep=",",na.strings=""))
'data.frame':   5 obs. of  2 variables:
 $ V1: Factor w/ 5 levels "1","2","3","4",..: 1 2 3 5 4
 $ V2: Factor w/ 5 levels "FR","NA","PT",..: 5 2 4 1 3

  = FAIL

 #3 lets try colClasses:

 > read.table("test.dat",sep=",",colClasses=c("numeric","character"))
  V1   V2
1  1   US
2  2 
3  3   UK
4 NA   FR
5  4   PT

 = FAIL

 #4 So... lets try to specify colClasses and na.strings:

 > read.table("test.dat",sep=",",na.strings="",colClasses=c("numeric","character"))
  V1 V2
1  1 US
2  2 NA
3  3 UK
4 NA FR
5  4 PT

 - looks good:

 > str(read.table("test.dat",sep=",",na.strings="",colClasses=c("numeric","character")))
'data.frame':   5 obs. of  2 variables:
 $ V1: num  1 2 3 NA 4
 $ V2: chr  "US" "NA" "UK" "FR" ...

 = WIN!

 I'm not certain how that works. I guess the conversion of column 1 to
numeric causes the NA rather than the matching of it to the na.strings
parameter

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] movie3d function in the rgl package

2008-10-24 Thread Dani
Dear list,

I'm using the function "movie3d" in the package "rgl" to create a .gif
animation of a 3d graphic.  The program "ImageMagik" is working
properly, R packages are working, basic examples available in the
manual also working fine.

Problem Solved: when I tried to create more complex movies, i.e.
combining different views and zooming, the R-console crashed or
returned error playing the function returned by par3dinterp, using
heterogeneous parameters. When not crashing, "Error:
length(userMatrix) == 16 * length(times) is not TRUE."
Counterexample:
#rotating
v=seq(from=1,to=61,by=2.5)
for (i in 1:length(v)){
  rgl.viewpoint(270+v[i],80-(v[i]/1)) #This is a counterexample
  M <- par3d()
  lista[[k]]=M;
  k=k+1;
}
#zooming
v=seq(from=1,to=0.12,by=-0.02)
for (i in 1:length(v)){
 par3d(zoom=v[i])
 M <- par3d()
 lista[[k]]=M; k=k+1;
}
#-- Ending view
rgl.viewpoint(326,40)
par3d(zoom=1)
M <- par3d()
lista[[k]]=M; k=k+1;

p = par3dinterp(lista)
play3d(p) # or movie3d (p,12)
--
Light: after 2 weeks fighting with the function + a bag of coffee, I
found this function really helpful and I WANTED TO SHARE since I
didn't find anything like that in the web.
Step 1: set the zooming parameters to each view you want in a separate
vector (list_zooming) while accumulating the views in the
list_userMatrix
#rotating
v=seq(from=1,to=61,by=30)#2.5)
for (i in 1:length(v))
{
  rgl.viewpoint(270+v[i],80-(v[i]/1))
  M <- par3d("userMatrix")#This is an example who runs perfectly
  list_userMatrix[[k]]=M;
  k=k+1;
}
list_z=rep(1,length(v)); list_zooming=c(list_zooming,list_z)

#zooming
v=c(1,0.12)#seq(from=1,to=0.12,by=-0.2)
for (i in 1:length(v))
{
 list_zooming=c(list_zooming,v[i])
 M <- par3d("userMatrix")
 list_userMatrix[[k]]=M; k=k+1;
}
#--
rgl.viewpoint(345,30)
par3d(zoom=0.1)
M <- par3d("userMatrix")
list_userMatrix[[k]]=M; k=k+1;

p = par3dinterp( userMatrix=list_userMatrix,zoom=list_zooming)

movie3d (p,duration=12)#as.integer(length(list_userMatrix)))
#play3d(p)

Hope it was helpful! Good lucky!
--
-
Daniela

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


Re: [R] combining data from different datasets

2008-10-24 Thread Gabor Grothendieck
On Fri, Oct 24, 2008 at 11:37 AM, Dr Eberhard W Lisse <[EMAIL PROTECTED]> wrote:
>
> This looks very cool.
>
> But I must still make a plan with regards to country = "NA" (Namibia)
> or continent = "NA" (North America)
>
> But there are the vignettes.
>
> el
>

NA and "NA" are not the same:

> DF <- data.frame(x = c("a", "NA", NA))
> DF
 x
1a
2   NA
3 
>
> is.na(NA)
[1] TRUE
> is.na("NA")
[1] FALSE

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

2008-10-24 Thread Amarjit Singh Sethi
Dear all,
Through the following code, I wanted to perform correlation test repetedly 
(through loop) on different combinations of variables of a data set.

Code:

x=read.table("sample.txt",header=T,sep="\t")
out="corout.txt"
sink(out)
nm = names(x)
print(nm)
nvr=3
# nvr=Total no. of variables in the input data file
for (i in 1:(nvr-1))
{
for(j in (i+1):nvr) 
{
frm= as.formula(paste(nm[i+1],",",nm[j+1],sep=""))($$)
crl=cor.test(frm,alternative="two.sided",method="pearson") 
smr=summary(crl)
print(smr)
}
}
sink()

Sample Data:

S NoV1  V2  V3
1   15  10  4
2   6   4   7
3   10  5   2
4   8   6   6

But the code does not work; there seems to be some problem in the statement 
marked ($$) above. The message I get is:

Error in parse(text = x) : unexpected ',' in "V1,"

Kindly help to get rid of the bug

Regards

ajss


  Unlimited freedom, unlimited storage. Get it now, on 
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] unstable MA results in ARIMA?

2008-10-24 Thread Nuno Prista

Dear colleagues,

I am relatively new to R and time series and so I am experiencing 
difficulties in interpreting the output of "arima" in MA models (but not 
in AR models). I cannot make sense of the 1st innovations returned by 
"arima".


In an AR(1) model I expect data[t]=phi1*data[t-1]+a[t] and in a MA(1) 
model data[t]=a[t]+theta1*a[t-1]. My interpretation from R-help is that 
a[t] estimates are given by model$res. 


In AR models when I do

data.sim<-arima.sim(n = 60, list(ar =0.68 ),sd = sqrt(0.6))
data.fit<-arima(data.sim, order=c(1,0,0), xreg=NULL, include.mean=FALSE, 
transform.pars=TRUE, fixed=NULL, init=NULL, method="ML")

z<-rep(NA,60)
for (t in 2:60){
z[t]<-data.fit$coef*data.sim[t-1]+data.fit$res[t]
}
plot(data.sim-z, type="o", pch=19)

I see that the arima was well fitted and that all a[t] are well calculated

However, in the MA case I have experienced problems with the first set 
of residuals,


data.sim<-arima.sim(n = 60, list(ma =0.68 ),sd = sqrt(0.6))
data.fit<-arima(data.sim, order=c(0,0,1), xreg=NULL, include.mean=FALSE, 
transform.pars=TRUE, fixed=NULL, init=NULL, method="ML")

z<-rep(NA,60)
for (t in 2:60){z[t]<-data.fit$res[t]+data.fit$coef*data.fit$res[t-1]}
windows(); plot(data.sim-z, type="o", pch=19)

It seems to me that the 1st and (sometimes the 2nd) innovations are not 
correct and that a[t] are correct only for larger t. However, the value 
of sigma2 returned seems to be based on all a[t]. I made a fe more tests 
and the number of residuals which appear (to me) miss-calculated gets 
larger and larger when I test q>1. Can I trust the "arima" estimates in 
the MA case as I do in the AR case?


Thanks,

Nuno Prista
_
CO - FCUL, Lisboa, Portugal
CQFE - ODU, Norfolk, 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] Weighted LSCV 2d kernel smoothing

2008-10-24 Thread [EMAIL PROTECTED]
R List,

I am seeking help in the area of kernel smoothing. I am attempting to use LSCV 
values to conduct 2d and weighted 2d kernel smoothing (imported from an ArcMap 
shapefile), and have been unable to find tools to conduct such analysis in R. 
My biggest problem is determining the LSCV value and finding a tool that does 
weighted smoothing, as there are obviously many different packages that will 
conduct 2d kernel smoothing (kde2d{MASS} - gaussian,  (sp)kernel2d in {splaces} 
-- quartic) and even those that do weighted 1d (density{stats}). Crimestat will 
conduct the smoothing (weighted or no) if I can determine LSCV values, so 
getting past that step alone would be excellent. Hlscv{ks} would appear to 
calculate LSCV for non-weighted datasets once I can parse the example into 
working for me, but I can find nothing to smooth or calculate LSCV for a 
weighted 2d dataset. 

Any suggestions would be warmly appreciated. Thanks for your time.

Regards,

Rick
--
Alain Systems
_
Help is here! Click now for simple and easy Financial Advice.
http://thirdpartyoffers.juno.com/TGL2111/fc/Ioyw6iifSDi7tifhamLvjp48YUu1cyx56J7lRSdRWzyaDd0Ilf1cBd/?count=1234567890

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


Re: [R] combining data from different datasets

2008-10-24 Thread Dr Eberhard W Lisse

Gabor,

Thank you,

On 24 Oct 2008, at 17:16 , Gabor Grothendieck wrote:


Here are two solutions.  The first uses the R merge command
and the second uses the R sqldf package.  See ?merge
and http://sqldf.googlecode.com
Note that alter is an sql keyword so I have changed it
to alt for the second example:


merge(iso, rawdata)[c("alt", "sex", "country")]

 alter sex country
1NA   M Andorra
239   F Namibia


merge(rawdata, iso, by.x = "cctld", by.y = "code", all.x = TRUE)
[c("alter","sex", "cctld", "country")]

all.x = TRUE even pulls the cases with missing values




library(sqldf)


sqldf("select alt, sex, country from iso join rawdata  
using(country)")

 alt sex country
1  NA   M Andorra
2  39   F Namibia


This looks very cool.

But I must still make a plan with regards to country = "NA" (Namibia)
or continent = "NA" (North America)

But there are the vignettes.

el

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

2008-10-24 Thread Gustaf Rydevik
Hi all,

I'm writing a function that will automatically generate a report based
on answers to a questionnaire. The exact questions and answers to the
questionnaire can vary. One of the question types is in a "matrix"
format, where the agreement to several statements can be indicated on
a scale.

I'm planning to plot this on a multilevel barplot, and only labeling
each "bar column" once. However, I'm stuck as to how I should adjust
text size and wrapping to fit to each column.

Here's an example of what I mean:

barnames<-c("I agree completely", "I agree", "I partly agree", "I do
not agree", "I really hate this stupid question, don't you?")
answers<-data.frame(question=paste("Q",1:5,sep=""),S1=sample(1:100,5),S2=sample(1:100,5),S3=sample(1:100,5),S4=sample(1:100,5),S5=sample(1:100,5))
Width<-50
Cex<-1.5

par(mfrow=c(nrow(answers)+1,1),mar=c(0,1,1,1))
plot.new()
plot.window(xlim=c(0,1),ylim=c(0,1))
barnames.plot<-do.call("c",lapply(barnames,function(x)paste(strwrap(x,Width),collapse="\n")))
text(barnames.plot,x= (seq.int(0, 1, length.out =
length(barnames)+1)-0.5/length(barnames))[-1],y=0.5,cex=Cex)
for(i in 1:nrow(answers)){
barheight<-rep(0,length(barnames))
barheight[as.numeric(names(subQ.tables[[i]]))]<-subQ.tables[[i]]
barplot(barheight,space=0)
}

The question is, how do I figure out the appropriate "Width"  and
"Cex" parameters as a function of barnames?
That is, with varying text lengths of the barnames, varying number of
alternatives etc, and independent on which device type is used?
strwrap uses "column" as units, and I can't really figure out how to
convert that to graph units. Same goes for cex.

Many thanks in advance,

Gustaf


PS: As an alternative, if someone could come up with a better way do
display this type of data, I'd be all ears. I'm not too happy with my
current solution


-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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


Re: [R] combining data from different datasets

2008-10-24 Thread Gabor Grothendieck
Here are two solutions.  The first uses the R merge command
and the second uses the R sqldf package.  See ?merge
and http://sqldf.googlecode.com
Note that alter is an sql keyword so I have changed it
to alt for the second example:

> merge(iso, rawdata)[c("alt", "sex", "country")]
  alter sex country
1NA   M Andorra
239   F Namibia
> library(sqldf)

> sqldf("select alt, sex, country from iso join rawdata using(country)")
  alt sex country
1  NA   M Andorra
2  39   F Namibia


On Fri, Oct 24, 2008 at 11:01 AM, Dr Eberhard W Lisse <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have two tables:
>
>
>> iso
>continent code code3 codenum  country
> 1  EU   AD   AND  20 Andorra, Principality of
> 2  AS   AE   ARE 784 United Arab Emirates
> 3  AS   AF   AFG   4 Afghanistan, Islamic Republic of
> 4  NA   AG   ATG  28  Antigua and Barbuda
> 5  NA   AI   AIA 660 Anguilla
> 159AF   NA   NAM 516 Namibia, Republic of
> ...
> 246AF   ZW   ZWE 716Zimbabwe, Republic of
>
>
>
> and
>
>> rawdata
>   idno alter  sex cctld capacity topics content speakers
> 1 1NAMADA  2   12
> 2 252M  A  3   22
> 3 339FNAT  2   22
> ...
>
> How do I make it print out something like
>
>alter   sex country
> 1   NA  M   Andorra, Principality of
> 2   39  F   Namibia, Republic of
> ...
>
> in other words do something like the following SQL:
>
> SELECT r.alter, r.sex, i.country
> FROM iso i, rawdata r
> WHERE i.code = r.cctld
>
> or even better:
>
>alter   sex country
> 1   NA  M   Andorra, Principality of
> 2   52  M   
> 3   39  F   Namibia
> ...
>
> And idea (where I can read up on this)?
>
>
> el
> --
> Dr. Eberhard W. Lisse  \/ Obstetrician & Gynaecologist (Saar)
> [EMAIL PROTECTED] el108-ARIN /   *   |   Telephone: +264 81 124 6733 (cell)
> PO Box 8421 \ / Please send DNS/NA-NiC related e-mail
> Bachbrecht, Namibia ;/ to [EMAIL PROTECTED]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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

2008-10-24 Thread Dr Eberhard W Lisse

Hi,

I have two tables:


> iso
continent code code3 codenum  country
1  EU   AD   AND  20 Andorra, Principality of
2  AS   AE   ARE 784 United Arab Emirates
3  AS   AF   AFG   4 Afghanistan, Islamic Republic of
4  NA   AG   ATG  28  Antigua and Barbuda
5  NA   AI   AIA 660 Anguilla
159AF   NA   NAM 516 Namibia, Republic of
...
246AF   ZW   ZWE 716Zimbabwe, Republic of



and

> rawdata
   idno alter  sex cctld capacity topics content speakers
1 1NAMADA  2   12
2 252M  A  3   22
3 339FNAT  2   22
...

How do I make it print out something like

alter   sex country
1   NA  M   Andorra, Principality of
2   39  F   Namibia, Republic of
...

in other words do something like the following SQL:

SELECT r.alter, r.sex, i.country
FROM iso i, rawdata r
WHERE i.code = r.cctld

or even better:

alter   sex country
1   NA  M   Andorra, Principality of
2   52  M   
3   39  F   Namibia
...

And idea (where I can read up on this)?


el
--
Dr. Eberhard W. Lisse  \/ Obstetrician & Gynaecologist (Saar)
[EMAIL PROTECTED] el108-ARIN /   *   |   Telephone: +264 81 124 6733 (cell)
PO Box 8421 \ / Please send DNS/NA-NiC related e-mail
Bachbrecht, Namibia ;/ to [EMAIL PROTECTED]

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


Re: [R] Is there anyway to clip the bottom of a barplot?

2008-10-24 Thread Peter Dalgaard
Sender: [EMAIL PROTECTED]
On-Behalf-Of: [EMAIL PROTECTED]
Subject: Re: [R] Is there anyway to clip the bottom of a barplot?
Message-Id: <[EMAIL PROTECTED]>
Recipient: [EMAIL PROTECTED]




This information is being sent at the recipient's request or with their 
specific understanding. The recipient acknowledges that by sending this 
information via electronic means, there is no absolute assurance that the 
information will be free from third party access, use, or further 
dissemination. This e-mail contains information that is privileged and/or 
confidential and may be subject to legal restrictions and penalties regarding 
its unauthorized disclosure or other use. You are prohibited from copying, 
distributing or otherwise using this information if you are not the intended 
recipient. Past performance is not necessarily indicative of future results. 
This is not an offer of or the solicitation for any security which will be made 
only by private placement memorandum that may be obtained from the applicable 
hedge fund. If you have received this e-mail in error, please notify us 
immediately by return e-mail and delete this e-mail and all attachments from 
your system. Thank You.
--- Begin Message ---
Stefan Uhmann wrote:
> Dear list,
> 
> are there any (late) sugestions on this issue? I'm trying to produce a
> bad example for my students and I am not able to produce it using R!
> Would not have been a problem with SPSS. Mighty R ..

 Yes we do have the problem that occasionally we'd like to have
implementations of dubious methods. Stepwise variable selection comes to
mind.

You might have better luck with lattice and barchart() which has an
origin= argument, as we learned in another recent thread.

> Arthur Roberts schrieb, Am 29.07.2008 06:23:
>> Hi, all,
>>
>> I need to show only values in a barplot from say 4-12.  When I do 
>> this, values below 4 are not cutoff.  I would appreciate any input 
>> into how I could cut the bottom part of the bar off.


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

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


Re: [R] save an object of class "im"

2008-10-24 Thread ppaarrkk

Thanks for reply. I have worked out what it was. It was the fact that I was
creating the files within functions, doing assign() within the function and
then returning the result. I have changed it so that the image file is
assigned globally within the function and now it can be saved and loaded
properly. Before, I could plot it successfully after it was returned from
the function, but I couldn't properly save and load it. I don't quite know
why this should be the case.




Sarah Goslee wrote:
> 
> How about an example of what you did? It's difficult to provide
> suggestions
> without a workable example of the commands you used.
> 
> Sarah
> 
> On Thu, Oct 23, 2008 at 12:26 PM, ppaarrkk <[EMAIL PROTECTED]> wrote:
>>
>> I have created various "im" objects, but can't seem to save and load
>> them. I
>> can save them, but as small files of less than 1Kb. Therefore, when they
>> are
>> re-loaded, they cannot be plotted as images.
>>
>> Any ideas please.
>>
>> Thankyou.
>>
>> Simon Parker
>> Imperial College
> 
> 
> 
> -- 
> Sarah Goslee
> http://www.functionaldiversity.org
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/save-an-object-of-class-%22im%22-tp20134567p20151376.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] Mail server problem?

2008-10-24 Thread Clint Bowman
Rolf,

It must have been a Northern Hemisphere patch that conflicted with the
Coriolis effect--just put a different spin on your email and that should
correct it.

Clint

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

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

On Fri, 24 Oct 2008, Rolf Turner wrote:

>
> I keep getting repeated copies of ``R-help post acknowledgements'' in respect
> of a couple of postings that I made to the list this morning (my time).
> I only posted each posting *once*.  I hope that others are not getting
> repeated copies of my postings  I mean I *know* my postings are so
> wonderful they merit re-reading, but one does not need another copy in order
> to re-read! :-)
>
> Has anyone else experienced this phenomenon of multiple acknowledgements for
> a single post?  Are people getting multiple copies of my postings?  (If so,
> sorry 'bout that, but I don't think it's my fault.)
>
>   cheers,
>
>   Rolf Turner
>
> ##
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] plotrix and prettyR

2008-10-24 Thread Ben Bolker
Sender: [EMAIL PROTECTED]
On-Behalf-Of: [EMAIL PROTECTED]
Subject: Re: [R] plotrix and prettyR
Message-Id: <[EMAIL PROTECTED]>
Recipient: [EMAIL PROTECTED]




This information is being sent at the recipient's request or with their 
specific understanding. The recipient acknowledges that by sending this 
information via electronic means, there is no absolute assurance that the 
information will be free from third party access, use, or further 
dissemination. This e-mail contains information that is privileged and/or 
confidential and may be subject to legal restrictions and penalties regarding 
its unauthorized disclosure or other use. You are prohibited from copying, 
distributing or otherwise using this information if you are not the intended 
recipient. Past performance is not necessarily indicative of future results. 
This is not an offer of or the solicitation for any security which will be made 
only by private placement memorandum that may be obtained from the applicable 
hedge fund. If you have received this e-mail in error, please notify us 
immediately by return e-mail and delete this e-mail and all attachments from 
your system. Thank You.
--- Begin Message ---
Jim Lemon  bitwrit.com.au> writes:

> Remember, it is your whingeing and 
> moaning that have helped to make these packages what they are today.
> 
> Jim
> 

  Is there a :-) in there somewhere?

 cheers
   Ben Bolker

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


Re: [R] DSC 2009 First announcement

2008-10-24 Thread Peter Dalgaard
hadley wickham wrote:
>> Fee structure (EUR, Academic/Non-Academic/Student)
>> Early: 170/270/90
>> Full: 200/300/100
>> On the Day:  220/330/110
>> ("Students" not including Ph.D. students.)
> 
> This is new, isn't it?  I don't think PhD students make any more money
> than other students so it seems a bit unfair to penalise them like
> this. Speaking as someone who has only recently stopped being a PhD
> student, 170 euros is a lot of money!
> 
> Hadley
> 

[diverted to r-help]

It depends on where you are in the world. Around here, PhD students are
on (junior) academic salaries. For others, the general travel costs
would dwarf the potential 80 EUR savings rather quickly.  Notice also
that the fee includes the social programme and catering, which
unfortunately are rather expensive in Copenhagen.


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

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


Re: [R] multiple visualisation of a bootstrap

2008-10-24 Thread Ben Bolker
Fernando Marmolejo Ramos  adelaide.edu.au> writes:

> 
> Dear R team

> Vista offers a so-called Multiple Visualisation (MV) of the output of a
> bootstrap (it shows on the same window scatter plots for a particular variable
> showing the bootstrapped CI, a scatter plot of 
> the evolution of the bootstrapped
> mean over many sample sizes, a box plot, a QQ plot, and a histogram).
> 
> I wonder if there is any manner in which this sort of MV 
> could me mimicked by R
> in the case of bootstrap. My best guess is that I’d have to create a 3 by 2
> frame an insert each graph separately or maybe resort to Trellis 
> graphics… am I
> right? Does anyone have a more sophisticated solution?
> 
  
  I'm not sure this is the right kind of problem for Trellis graphics
(which are geared toward using the same plot type for different
subsets of the data in each panel, rather than different plot types
of the same data).  The "unsophisticated" solution (which seems
just fine), as you suggest, is to use par(mfrow) or par(mfcol)
to break up the plot window into frames, and then plot the
different bits in each window.

See http://emdbolker.wikidot.com/blog:dynamite for an example
of plotting the same data in different ways within subplots
(and 
http://emdbolker.wdfiles.com/local--files/blog:dynamite/barboxdotviolin.R
for the code).

 As far as R is concerned, "sophisticated" would mean
creating a plotting function for this so that you never
had to look at the details again ...

  Ben Bolker

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


[R] SCOUR member invite from: muhammad faisal

2008-10-24 Thread SCOUR member invite: muhammad faisal
Did you hear about Scour? It is the next gen search engine with
Google/Yahoo/MSN results and user comments all on one page. Best of all we
get rewarded for using it by collecting points with every search, comment
and vote. The points are redeemable for Visa gift cards. It's like earning
credit card or airline points just for searching. Hit the link below to join
and we will both get points!

http://scour.com/invite/mfaisal_16/

I know you'll like it!

- muhammad faisal



This message was sent to you as a friend referral to join scour.com, please
feel free to review our http://scour.com/privacy page and our
http://scour.com/communityguidelines/antispam page.
If you prefer not to receive invitations from ANY scour members,
please click here - http://www.scour.com/unsub/e/ci1oZWxwQHItcHJvamVjdC5vcmc=

Write to us at:
Scour, Inc., 15303 Ventura Blvd. Suite 860, Sherman Oaks, CA 91403, USA.

campaignid: scour200810240001
Scour.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] odfWeave error

2008-10-24 Thread Max Kuhn
Rob,

> Post-processing the contents
> Error in .Call("RS_XML_Parse", file, handlers, endElementHandlers,
> as.logical(addContext),  :
>  attempt to apply non-function

Can you do these three things?

1. Send the results of sessionInfo()?
2. Try to run the code in the code chunks outside of odfWeave and make
sure that they work.
3. Send me an odt file that reproduces the error (blind the data etc)

Thanks,

Max

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


Re: [R] plotrix and prettyR

2008-10-24 Thread Ben Bolker
Jim Lemon  bitwrit.com.au> writes:

> Remember, it is your whingeing and 
> moaning that have helped to make these packages what they are today.
> 
> Jim
> 

  Is there a :-) in there somewhere?

 cheers
   Ben Bolker

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


Re: [R] count zero or one in a list

2008-10-24 Thread Henrique Dallazuanna
Try this:

rle(y)$len[c(1, length(rle(y)$len))]

On Fri, Oct 24, 2008 at 10:34 AM, gallon li <[EMAIL PROTECTED]> wrote:

> I have a list of {0,1} values, say
>
> y<-c(0,0,0,1,1,0,0,1,0,1,1,1,1)
>
> I want to compute the first few zeros and the last few ones. So the output
> I
> expect is 3 and 4 for this vector. Is there a fast way to match the numbers
> easily?
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

[[alternative HTML version deleted]]

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


Re: [R] Is there anyway to clip the bottom of a barplot?

2008-10-24 Thread Peter Dalgaard
Stefan Uhmann wrote:
> Dear list,
> 
> are there any (late) sugestions on this issue? I'm trying to produce a
> bad example for my students and I am not able to produce it using R!
> Would not have been a problem with SPSS. Mighty R ..

 Yes we do have the problem that occasionally we'd like to have
implementations of dubious methods. Stepwise variable selection comes to
mind.

You might have better luck with lattice and barchart() which has an
origin= argument, as we learned in another recent thread.

> Arthur Roberts schrieb, Am 29.07.2008 06:23:
>> Hi, all,
>>
>> I need to show only values in a barplot from say 4-12.  When I do 
>> this, values below 4 are not cutoff.  I would appreciate any input 
>> into how I could cut the bottom part of the bar off.


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

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


[R] count zero or one in a list

2008-10-24 Thread gallon li
I have a list of {0,1} values, say

y<-c(0,0,0,1,1,0,0,1,0,1,1,1,1)

I want to compute the first few zeros and the last few ones. So the output I
expect is 3 and 4 for this vector. Is there a fast way to match the numbers
easily?

[[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] Is there anyway to clip the bottom of a barplot?

2008-10-24 Thread Stefan Uhmann

Dear list,

are there any (late) sugestions on this issue? I'm trying to produce a 
bad example for my students and I am not able to produce it using R! 
Would not have been a problem with SPSS. Mighty R ..


Regards,
Stefan

Arthur Roberts schrieb, Am 29.07.2008 06:23:

Hi, all,

I need to show only values in a barplot from say 4-12.  When I do  
this, values below 4 are not cutoff.  I would appreciate any input  
into how I could cut the bottom part of the bar off.


Best wishes,
Art Roberts
University of Washington
Department of Medicinal Chemistry

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

2008-10-24 Thread Peter Dalgaard
The sixth international workshop on 'Distributed Statistical Computing'
(DSC 2009) will take place at the the University of Copenhagen, Denmark,
13th-14th of July 2009. This conference follows on from the successful
DSC 1999, 2001, and 2003 conferences at the Vienna University of
Technology, DSC 2005 at the University of Washington in Seattle, and DSC
2007 at the University of Auckland. The workshop will focus on, but is
not limited to, open source statistical computing and aims to provide a
platform for exchanging ideas about developments in statistical
computing (rather than 'only' the usage of statistical software for
applications).

It is expected that a large proportion of participants will bring a
presentation. We particularly welcome contributions advancing
statistical computing as an independent topic.

Home page:
http://www.r-project.org/dsc-2009


Organizing committee:
Peter Dalgaard, Claus Ekstrøm, Klaus K. Holst, Søren Højsgaard
<[EMAIL PROTECTED]>

Programme committee:
Roger Bivand, Göran Broström, Jari Oksanen, Balasubramanian Narasimhan
(Naras), Peter Dalgaard

Important dates:

March 15: Submission deadline
April 15: Notification of accept/reject
May 1: Early registration ends

Fee structure (EUR, Academic/Non-Academic/Student)
Early: 170/270/90
Full: 200/300/100
On the Day:  220/330/110
("Students" not including Ph.D. students.)

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

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


[R] multiple visualisation of a bootstrap

2008-10-24 Thread Fernando Marmolejo Ramos
Dear R team

Jim Lemon recently said regarding new improvements in PrettyR and plotrix:
“Remember, it is your whingeing and moaning that have helped to make these
packages what they are today.”

So, this is my whinge: out there is a freeware called Vista, which runs, among
other things, bootstrap analyses. Most of the numerical reports given by Vista
can be done using packages such as “boot”, “bootstrap”, and “simpleboot”. I’ve
not explored all the functions in these packages thoroughly (very casually), but
the first thing I noticed is that the graphical output is majorly histograms.
Vista offers a so-called Multiple Visualisation (MV) of the output of a
bootstrap (it shows on the same window scatter plots for a particular variable
showing the bootstrapped CI, a scatter plot of the evolution of the bootstrapped
mean over many sample sizes, a box plot, a QQ plot, and a histogram).

I wonder if there is any manner in which this sort of MV could me mimicked by R
in the case of bootstrap. My best guess is that I’d have to create a 3 by 2
frame an insert each graph separately or maybe resort to Trellis graphics… am I
right? Does anyone have a more sophisticated solution?

Cheers,

Fer

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

2008-10-24 Thread Rodrigo Aluizio
Hi everybody,
well I'm trying to use barplot for the first time. I get a suitable graphic but 
I'm having a weird problem.
My graphic is generated from a matrix with several species (rowNames) and two 
abundance columns.
So each species will have two bars, and the species name should appear at left. 
Until now everything is Ok, but when a I plot it the species names (my labels) 
are cut by device limits, and only part of the names appear.
I could move them with the command "line=some negative value", but the axis (x 
and y) stay put and the things get over each other (the command 'line' works, 
but a error saying that it's not a graphic parameter appears). In addition, but 
with less importance, how could I remove the legend borders? And why, when I 
try use the 'width' command it fails to raise the width of the bars and I get 
and error saying that its not a graphic parameter (the command is in barplot 
help!!)?

I'm using R 2.8.0 at Windows XP 32 bits.

Here is the code I'm using, where MainSpp is my matrix:

barplot(MainSpp,horiz=T,beside=T,main='Main Species',xlab='%',las=1,
legend.text=T,width=5,cex.names=0.8)

Thank you for your attenction.
___
MSc. Rodrigo Aluizio
Centro de Estudos do Mar/UFPR
Laboratório de Micropaleontologia
Avenida Beira Mar s/n - CEP 83255-000
Pontal do Paraná - PR - BRASIL

[[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] write.matrix.csr(e1071) bug

2008-10-24 Thread David Meyer

Peter:

Yes, this is a bug. The line

if ([EMAIL PROTECTED] <= nrow(x))

should actually read

if (([EMAIL PROTECTED] <= length([EMAIL PROTECTED])) && ([EMAIL PROTECTED] < 
[EMAIL PROTECTED] + 1]))

--> fixed upstream.

Thanks
David



Hello,

The write.matrix.csr() function of the e1071 package contains a bug.
Try the following:

library(e1071)
m <- 1 - diag(10)
sm <- as.matrix.csr(m)
write.matrix.csr(sm)

The resulting file (out.dat) contains only the two lines below:

2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:1 10:1
1:1 3:1 4:1 5:1 6:1 7:1 8:1 9:1 10:1

This is obviously wrong as the matrix m has 90 non-zero entries.

The function is implemented as

write.matrix.csr <- function (x, file="out.dat", y=NULL) {
on.exit(sink())
if(!require("methods")) stop("Could not load package 
'methods'.")
if (!is.null(y) & (length(y) != nrow(x)))
stop(paste("Length of y (=", length(y),
") does not match number of rows of x (=",
nrow(x), ")!", sep=""))
sink(file)
for (i in 1:nrow(x)) {
if (!is.null(y)) cat (y[i],"")
if ([EMAIL PROTECTED] <= nrow(x))
for (j in [EMAIL PROTECTED]:([EMAIL PROTECTED] 
- 1))
cat([EMAIL PROTECTED], ":", [EMAIL PROTECTED], " 
", sep="")
cat("\n")
}
}

The bug is caused by the line

if ([EMAIL PROTECTED] <= nrow(x))

that is completely meaningless. In the above example nrow(x) is 10
and [EMAIL PROTECTED] is the vector

1 10 19 28 37 46 55 64 73 82 91

Entries of [EMAIL PROTECTED] has nothing to do with the number of rows in the 
matrix.

To fix the bug this line must be removed.

Best regards,

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Request: Most repeated sequence considering combinations at each row

2008-10-24 Thread Muhammad Azam
Dear friends
Hope you all are fine. Suppose we have a list of arrays.
a1=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a1=array(a1,dim=c(4,4));  
a2=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a2=array(a2,dim=c(4,4));  
a3=c(4,4,4,4,0,3,3,4,0,4,4,0,0,0,0,0); a3=array(a3,dim=c(4,4)); 
a4=c(4,4,4,4,4,0,3,3,3,3,0,4,4,4,0,0,0,0,0,0); a4=array(a4,dim=c(5,4)); 
a5=c(4,4,4,4,4,0,4,4,4,4,0,3,3,3,0,0,1,1,0,0); a5=array(a5,dim=c(5,4)); 
a6=c(4,4,4,4,4,0,1,1,1,1,0,4,4,4,0,0,3,3,0,0); a6=array(a6,dim=c(5,4)); 
a7=c(1,1,1,1,1,0,4,4,4,4,0,3,3,3,0,0,4,4,0,0); a7=array(a7,dim=c(5,4)); 
a8=c(4,4,4,4,4,0,3,3,3,3,0,1,1,1,0,0,4,4,0,0); a8=array(a8,dim=c(5,4));
l=list(a1,a2,a3,a4,a5,a6,a7,a8); 

x <- sapply(1:length(l), function(x) {
  sum(sapply(l, function(y) {
if ( nrow(l[[x]]) != nrow(y) | ncol(l[[x]]) != ncol(y) ) FALSE
else sum(y != l[[x]]) == 0
  }))
} ); l; x

Using the above function, we are able to get frequency of each most repeated 
similar components of the list. For example, [[1]] and [[2]] are most repeated 
similar out of all. But if we consider the "combinations" at each row of each 
array. Then [[3]] will be included with [[1]] and [[2]]. Also [[5]], [[6]] and 
[[8]] will be similar. How can we modify the above function to get the desired 
most repeated sequence in this case? Any help in this regard is needed. 

best regards
M.Azam   



  
[[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] naming list entries dynamically

2008-10-24 Thread Torsten Lange

Hello,

Thank you for all answers! The function works!

Torsten


fload.from.folder <- function(pattern) {

 fname <- list.files(pattern=pattern)
 flist <- sapply(fname, read.table, header=FALSE)

 for(i in seq_along(fname)) {
   flist[[i]] <- t(read.table(fname[i], header=FALSE))
   }

 invisible(flist)
}


On Thu, Oct 23, 2008 at 10:35 PM, Gábor Csárdi <[EMAIL PROTECTED]> wrote:
 


On Thu, Oct 23, 2008 at 10:29 PM,  <[EMAIL PROTECTED]> wrote:
   


Hello,

I'm new to R and I'd like to dynamically assign names to the entries of a
list.
The situation is: I load several ascii-files from a folder. The data shall
be stored within the list structure, where the file names are assigned to
the list entries.

 


flist
   


$file1.txt
[1]  1.0  1.2  1.4  1.6  1.8  2.0...
$file2.txt
[1]  1.0  1.2  1.4  1.6  1.8  2.0...

That's what I would like to see. But I got stucked coding it. Web search
doesn't helped me a lot. Here is some code I thought it somehow would work
like this:

<
flist <- list()
fname <- list.files(pattern="some_pattern.txt")
for(i in 1:length(fname)) {
 flist$"how_do_I_name_it_dynamically?" <- read.table(fname[i],
header=FALSE)
 


Do

flist[[ fname[i] ]] <- 

Btw. 1:length(fname) will fail as soon as fname will be empty. Do
seq_along(fname) instead.
   



Btw2. is is probably simpler to write

fname <- list.files(pattern="some_pattern.txt")
flist <- sapply(fname, read.table, header=FALSE)

Gabor
 



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

2008-10-24 Thread Jim Lemon

Hi folks,
Both plotrix and prettyR have been updated. plotrix now has the "Matlab" 
style dotplot that was requested not long ago on the list, provided by 
that intrepid duo, Barry Rowlingson and Rolf Turner. Mike Cheetham has 
contributed an implementation of the Piper diagram, also in response to 
a request. prettyR has finally learned how to display SPSS value labels 
in the xtab and brkdn functions if they are there. I would like to know 
if anyone finds a problem with this feature as it took some time to pick 
the low-hanging bugs out of it. Remember, it is your whingeing and 
moaning that have helped to make these packages what they are today.


Jim

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


Re: [R] pwr.2p2n.test when the ratio of n1/n2 is known

2008-10-24 Thread Chuck Cleland
On 10/24/2008 5:02 AM, Daniel Brewer wrote:
> Hi,
> 
> I am trying to do a power calculation for a difference in proportions
> test where I want to estimate the sample size required.  I know (well
> estimate) that group one (n1) is 10% of the population and group 2 (n2)
> is 90% of the population.  I know the effect size (h).  pwr.2p2n.test
> only allows one variable to be left null whereas I would like both n1
> and n2 to be determined where I know there relative proportions.  Any
> ideas how to do this?  Is there a different function?

  How about something like this?

library(pwr)

i <- 2

while(pwr.2p2n.test(h=.20, n1=i, n2=i*9)$power < .80) {i <- i + 1}

pwr.2p2n.test(h=.20, n1=i, n2=i*9)

 difference of proportion power calculation for binomial
distribution (arcsine transformation)

  h = 0.2
 n1 = 219
 n2 = 1971
  sig.level = 0.05
  power = 0.8017491
alternative = two.sided

 NOTE: different sample sizes

> Thanks
> 
> Dan 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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


Re: [R] R D COM Excel Add-Ins

2008-10-24 Thread Rahul-A.Agarwal
Also I wud like to add that in this addin the rput command never works 


Rahul Agarwal 




-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of David Seres
Sent: Friday, October 24, 2008 2:46 PM
To: r-help@r-project.org
Subject: [R] R D COM Excel Add-Ins

Hello All!

I have a question regarding the package RDCOMClient. I want to start an
Excel file with R and it works flawlessly except the fact, that Add-Ins
are not loaded. Can someone please explain me how to load one? Does it
work with ex$AddIns$Invoke?

Greetings,
David

[[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.
Visit our website at http://www.ubs.com

This message contains confidential information and is in...{{dropped:16}}

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


Re: [R] Automating citations in Sweave

2008-10-24 Thread ONKELINX, Thierry
That works just fine. 

Thank you. 

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

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

-Oorspronkelijk bericht-
Van: Charles C. Berry [mailto:[EMAIL PROTECTED] 
Verzonden: donderdag 23 oktober 2008 18:54
Aan: ONKELINX, Thierry
CC: r-help@r-project.org
Onderwerp: Re: [R] Automating citations in Sweave

On Thu, 23 Oct 2008, ONKELINX, Thierry wrote:

> Dear all,
>
> Is there an elegant way to add citations of packages when using
Sweave?
> Ideally I'd like a function which creates a Bibtex-file with the
> packagenames as keys. The idea is to use \cite{packagename} or
\cite{R}
> in LaTeX.
>
> I know you can get the Bibtex entry with
> toBibtex(citation("packagename")). But after updating R or a package
one
> needs to update the bib-file too. When trying to automate this I came
up
> with the code below. It generates a Bibtex-file, but without keys for
> each item. So I have to add those manually. Another problem is that I
> get multiple entrys for R it self.
>
> Suggestions are welcome.
>

Thierry,

How 'bout:

cite.by.name <- function(x){
 res <- toBibtex(citation(x))
 if (is.list(res)) res <- res[[1]]
 res[1] <- sub("{",paste("{",x,sep=''),res[1],fixed=TRUE)
 res
}

> cite.by.name("MASS")
@Book{MASS,
   title = {Modern Applied Statistics with S},
   author = {W. N. Venables and B. D. Ripley},
   publisher = {Springer},
   edition = {Fourth},
   address = {New York},
   year = {2002},
   note = {ISBN 0-387-95457-0},
   url = {http://www.stats.ox.ac.uk/pub/MASS4},
}
>

Then

sapply( .packages(TRUE), function(x) try( cite.by.name(x) ) )

should be close to what you want.

HTH,

Chuck


> Thierry
>
> sink("Rpackages.bib")
>tmp <- sapply(.packages(), function(x){
>entry <- toBibtex(citation(x))
>if(class(entry) == "Bibtex"){
>print(entry)
>} else {
>tmp <- sapply(entry, print)
>}
>})
> sink()
>

[snip]

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



Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

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


[R] R D COM Excel Add-Ins

2008-10-24 Thread David Seres
Hello All!

I have a question regarding the package RDCOMClient. I want to start an
Excel file with R and it works flawlessly except the fact, that Add-Ins are
not loaded. Can someone please explain me how to load one? Does it work with
ex$AddIns$Invoke?

Greetings,
David

[[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] "right" aligning loess

2008-10-24 Thread tolga . i . uzuner
Dear R Users,

Does anyone know if I can somehow "right" align the loess function, so it 
only uses data points up to a certain date, and not around it ? Sort of 
like rollmean(...align="right")  in the rollmean function.

Thanks,
Tolga


Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase & Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
[[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 simply the procedure of creating a group of data.frame?

2008-10-24 Thread markleeds

if you do below, then d[[1]] is the first, d[[2]] is the second etc.

d <- lapply(1:50,function(.index) {
   data.frame(x=factor(),y=numeric())
 })

print(d)
print(str(d))


On Fri, Oct 24, 2008 at  4:36 AM, tedzzx wrote:


Dear R users,

I want to creat a group of data frames, such as:
d1<-data.frame(x=factor(),y=numeric(),...)
d2<-data.frame(x=factor(),y=numeric(),...)
d3<-data.frame(x=factor(),y=numeric(),...)
:
:
d50<-data.frame(x=factor(),y=numeric())

How can I use the loop to simply my procedure?
Thanks advance

Ted
--
View this message in context: 
http://www.nabble.com/how-to-simply-the-procedure-of-creating-a-group-of-data.frame--tp20146344p20146344.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] how to simply the procedure of creating a group of data.frame?

2008-10-24 Thread Dimitris Rizopoulos

one way is the following:

for (i in 1:50) {
dd <- data.frame(x = gl(2, 1), y = rnorm(2))
assign(paste("d", i, sep = ""), dd)
}

However, I would suggest to put all these data.frames in list, e.g.,

df.list <- lapply(1:50, function (i) data.frame(x = gl(2, 1), y = rnorm(2)))
names(df.list) <- paste("d", seq_along(df.list), sep = "")


I hope it helps.

Best,
Dimitris

tedzzx wrote:

Dear R users,

I want to creat a group of data frames, such as:
d1<-data.frame(x=factor(),y=numeric(),...)
d2<-data.frame(x=factor(),y=numeric(),...)
d3<-data.frame(x=factor(),y=numeric(),...)
:
:
d50<-data.frame(x=factor(),y=numeric())

How can I use the loop to simply my procedure?
Thanks advance

Ted


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] pwr.2p2n.test when the ratio of n1/n2 is known

2008-10-24 Thread Daniel Brewer
Hi,

I am trying to do a power calculation for a difference in proportions
test where I want to estimate the sample size required.  I know (well
estimate) that group one (n1) is 10% of the population and group 2 (n2)
is 90% of the population.  I know the effect size (h).  pwr.2p2n.test
only allows one variable to be left null whereas I would like both n1
and n2 to be determined where I know there relative proportions.  Any
ideas how to do this?  Is there a different function?

Thanks

Dan

-- 
**
Daniel Brewer, Ph.D.

Institute of Cancer Research
Molecular Carcinogenesis
Email: [EMAIL PROTECTED]
**

The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company 
Limited by Guarantee, Registered in England under Company No. 534147 with its 
Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the a...{{dropped:2}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 simply the procedure of creating a group of data.frame?

2008-10-24 Thread tedzzx

Dear R users,

I want to creat a group of data frames, such as:
d1<-data.frame(x=factor(),y=numeric(),...)
d2<-data.frame(x=factor(),y=numeric(),...)
d3<-data.frame(x=factor(),y=numeric(),...)
:
:
d50<-data.frame(x=factor(),y=numeric())

How can I use the loop to simply my procedure?
Thanks advance

Ted
-- 
View this message in context: 
http://www.nabble.com/how-to-simply-the-procedure-of-creating-a-group-of-data.frame--tp20146344p20146344.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] xy.coords in text

2008-10-24 Thread Xavier Robin
Dear Greg,

So it appears I was wrongly (not surprising) thinking "toplef" was a
xy.coords behaviour, when it is only a legend quirk. I didn't know about
the grconvert(X|Y) functions, and they do a very nice job indeed!

So I ended up with the following:

  panel.annot <- function(x, y, ...) {
points(x, y, ...)
c <- cor.test(x, y)
text(grconvertX(0.01, "npc"), grconvertY(.99, "npc"),
 labels=substitute(rho == r,
   list(r=sprintf("%.2f",  c$estimate))),
 adj=c(0, 1))
  }

And it works perfectly!

Thanks a lot,

Xavier

Greg Snow wrote :
> The xy.coords function is a powerful function used by a lot of the plotting 
> functions because it allows the user to enter x and y coordinates as 2 
> vectors, a 2 column matrix, or a list with x and y components (and possibly 
> others), but it does not do 'topleft' and the like.  The legend function (and 
> some others) have special handling to recognize and implement strings like 
> 'topleft'.  One of the easier ways to plot something in the top left (or 
> other relative positions) is to include the following line in your panel 
> function:
> 
> usr <- par('usr')
> 
> Now the vector user will have 4 values: xleft, xright, ybottom, ytop.  To 
> place text in the topleft corner, just do:
> 
> text(usr[1], usr[4], 'your text here', adj=c(0,1) )
> 
> or something like:
> 
> text( usr[1] + (usr[2]-usr[1])/10, usr[4] - (usr[4]-usr[3])/10, 'your text' )
> 
> to center the text 10% of the way in from the topleft corner.  The other 
> corners and sides should be fairly easy to work out from the above.
> 
> Other options include using the grconvertX and grconvertY functions.
> 
> Hope this helps,
> 
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> [EMAIL PROTECTED]
> 801.408.8111
> 
> 
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> project.org] On Behalf Of Xavier Robin
>> Sent: Thursday, October 23, 2008 5:58 AM
>> To: r-help@r-project.org
>> Subject: [R] xy.coords in text
>>
>> Hello,
>>
>> I want to add text annotation about correlation on "pairs" plots. I
>> found that I could pass a function to the "panel" argument of pairs :
>>
>>   panel.annot <- function(x, y, ...) {
>> points(x, y, ...)
>> c <- cor.test(x, y)
>> legend("topleft", legend=substitute(rho == r,
>> list(r=sprintf("%.2f",
>> c$estimate))), bty="n")
>>   }
>>
>> And then :
>>
>>   dat <- data.frame(a=rnorm(100), b=runif(100), c=runif(100)) # just
>> random data
>>   pairs(dat, panel=panel.annot)
>>
>> It works fine. But what I plot is not really a legend, so I'd prefer to
>> use the text function instead of legend :
>>
>>   panel.annot <- function(x, y, ...) {
>> points(x, y, ...)
>> c <- cor.test(x, y)
>> text("topleft", labels=substitute(rho == r, list(r=sprintf("%.2f",
>> c$estimate
>>   }
>>
>> But the text is not plotted and I get warnings instead :
>>
>>   1: In xy.coords(x, y, recycle = TRUE) :
>> NAs introduced by coercion
>>
>> If I run xy.coords("topleft") directly, I can see that the y coord (and
>> ylab as well) is not defined, but I don't understand why it would work
>> with legend and not with text... Especially since ?text doc states that
>>
>>> 'y' may be missing since 'xy.coords(x,y)' is used for construction of
>> the coordinates.
>>
>> Can someone explain me this difference? And optionally how to plot text
>> in the "topleft" part of the plot without using legend?
>>
>> Thanks,
>> Xavier
>>
>> --
>> Xavier Robin
>>
>> Biomedical Proteomics Research Group (BPRG)
>> Department of Structural Biology and Bioinformatics (DBSB)
>> Geneva University Medical Center (CMU)
>> 1, rue Michel Servet - CH-1211 Genève 4 - Switzerland
>> Tel: (+41 22) 379 53 21
>> Fax: (+41 22) 379 59 84
>> [EMAIL PROTECTED]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 


-- 
Xavier Robin

Biomedical Proteomics Research Group (BPRG)
Department of Structural Biology and Bioinformatics (DBSB)
Geneva University Medical Center (CMU)
1, rue Michel Servet - CH-1211 Genève 4 - Switzerland
Tel: (+41 22) 379 53 21
Fax: (+41 22) 379 59 84
[EMAIL PROTECTED]

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


[R] following up on infinite email server loop

2008-10-24 Thread markleeds

just to add to ted's explanation in case it helps to fix the email 
server problem: below are the two Recipients  and one of the two is 
always contained in the repeated emails that I'm receiving.  Also,  of 
course i don't mean to claim that the names contained in below are 
doing anything to cause the problem .  VEC Operator is just an example. 
There are 3 or 4 others that repeat also. The repeating seems to have 
slowed down but it's still happening off and on ? Thanks.

 
-
Sender: [EMAIL PROTECTED]
On-Behalf-Of: [EMAIL PROTECTED]
Subject: Re: [R] VEC Operator in R
Message-Id: <[EMAIL PROTECTED]>
Recipient: [EMAIL PROTECTED]


ender: [EMAIL PROTECTED]
On-Behalf-Of: [EMAIL PROTECTED]
Subject: Re: [R] VEC Operator in R
Message-Id: 
<[EMAIL PROTECTED]>
Recipient: [EMAIL PROTECTED]


-


On Thu, Oct 23, 2008 at  2:37 PM, Patrick Burns wrote:

Sender: [EMAIL PROTECTED] 
   

On-Behalf-Of: [EMAIL PROTECTED]  
  
Subject: Re: [R] VEC Operator in R
Message-Id: <[EMAIL PROTECTED] 
   
 >
Recipient: [EMAIL PROTECTED] 
   




This information is being sent at the recipient's request or with their 
specific understanding. The recipient acknowledges that by sending this 
information via electronic means, there is no absolute assurance that 
the information will be free from third party access, use, or further 
dissemination. This e-mail contains information that is privileged 
and/or confidential and may be subject to legal restrictions and 
penalties regarding its unauthorized disclosure or other use. You are 
prohibited from copying, distributing or otherwise using this 
information if you are not the intended recipient. Past performance is 
not necessarily indicative of future results. This is not an offer of or 
the solicitation for any security which will be made only by private 
placement memorandum that may be obtained from the applicable hedge 
fund. If you have received this e-mail in error, please notify us 
immediately by return e-mail and delete this e-mail and all attachments 
from your system. Thank You.

--

 From: "Patrick Burns" <[EMAIL PROTECTED]>
To: "megh" <[EMAIL PROTECTED]>
Cc: r-help@r-project.org
Date: Thu Oct 23 13:24:49 CDT 2008
Subject: Re: [R] VEC Operator in R

For 'VEC' you may not need to do anything -- in
a lot of circumstances it will just work.

For 'VECH' you can write a function using the
'lower.tri' function.

But it seems to me that the assumption behind your
question is that a simple function that someone else
has written is going to be better than a simple function
that you write.  Not true (barring bugs).

R is egalitarian -- your functions have the same standing
as "official" functions. A lot of times it is faster to write
a function of your own rather than search out someone
else's even if you know such functions exist.

Patrick Burns
[EMAIL PROTECTED]    

+44 (0)20 8525 0696
http://www.burns-stat.com    

(home of S Poetry and "A Guide for the Unwilling S User")

megh wrote:
> Can anyone please tell whether there is any R function to act as "VEC" 
> and
> "VECH" operator on Matrix? Yes of course, I can write a
> user-defined-function for that or else, I can put dim(mat) <- NULL. 
> However
> I am looking for some R function.
>
> Your help will be highly appreciated.
>
> Regards,
>

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

an