Re: [R] Likelihood optimization numerically

2008-01-26 Thread Bill.Venables
You asked for a hint.

> library(MASS)
> x <-  c(20.0, 23.9, 20.9, 23.8, 25.0, 24.0, 
 21.7, 23.8, 22.8, 23.1, 23.1, 23.5, 
 23.0, 23.0)
> fitdistr(x, "gamma")
 shape rate   
  316.56387213.780766 
 (119.585534) (  5.209952) 

To do it with more general and elementary tools, look at ?optim

nls(...)?  Not relevant at all, no matter how it feels.


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Mohammad Ehsanul Karim
Sent: Sunday, 27 January 2008 4:48 PM
To: r-help@r-project.org
Subject: [R] Likelihood optimization numerically

Dear List,

I am not sure how should i optimize a log-likelihood numerically:
Here is a Text book example from Statistical Inference by George
Casella, 2nd
Edition Casella and Berger, Roger L. Berger (2002, pp. 355, ex. 7.4 #
7.2.b):

data = x =  c(20.0, 23.9, 20.9, 23.8, 25.0, 24.0, 21.7, 23.8, 22.8,
23.1, 23.1, 23.5, 23.0, 23.0)
n <- length(x)

# likelihood from a 2 parameter Gamma(alpha, beta), both unknown
llk = -n*log(gamma(alpha)) - n*alpha*log(beta) + (alpha -
1)*(sum(log(x))) - (sum(x))/beta

# analytic 1st derivative solution w.r.t alpha, assuming beta known
# by putting MLE of beta = sum(x)/(n*alpha) 
# (to simplify as far as possible analytically)
llk.1st = - n*digamma(alpha) -n*(log(sum(x)/(n*alpha))+1) +
(sum(log(x))) 

It feels like i should use 
nls(... ,  trace=T, start=c(alpha=...),nls.control(maxiter=100,tol=.1))
but not sure "how".

Can anyone provide me hint?
Thank you for your time.

Ehsan
http://www.youtube.com/profile_play_list?user=wildsc0p



> R.Version()
$platform
[1] "i386-pc-mingw32"
$arch
[1] "i386"
$os
[1] "mingw32"
$system
[1] "i386, mingw32"
$status
[1] ""
$major
[1] "2"
$minor
[1] "6.1"
$year
[1] "2007"
$month
[1] "11"
$day
[1] "26"
$`svn rev`
[1] "43537"
$language
[1] "R"
$version.string
[1] "R version 2.6.1 (2007-11-26)"





 


Be a better friend, newshound, and

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

2008-01-26 Thread Mohammad Ehsanul Karim
Dear List,

I am not sure how should i optimize a log-likelihood numerically:
Here is a Text book example from Statistical Inference by George Casella, 2nd
Edition Casella and Berger, Roger L. Berger (2002, pp. 355, ex. 7.4 # 7.2.b):

data = x =  c(20.0, 23.9, 20.9, 23.8, 25.0, 24.0, 21.7, 23.8, 22.8, 23.1, 23.1, 
23.5, 23.0, 23.0)
n <- length(x)

# likelihood from a 2 parameter Gamma(alpha, beta), both unknown
llk = -n*log(gamma(alpha)) - n*alpha*log(beta) + (alpha - 1)*(sum(log(x))) - 
(sum(x))/beta

# analytic 1st derivative solution w.r.t alpha, assuming beta known
# by putting MLE of beta = sum(x)/(n*alpha) 
# (to simplify as far as possible analytically)
llk.1st = - n*digamma(alpha) -n*(log(sum(x)/(n*alpha))+1) + (sum(log(x))) 

It feels like i should use 
nls(... ,  trace=T, start=c(alpha=...),nls.control(maxiter=100,tol=.1))
but not sure "how".

Can anyone provide me hint?
Thank you for your time.

Ehsan
http://www.youtube.com/profile_play_list?user=wildsc0p



> R.Version()
$platform
[1] "i386-pc-mingw32"
$arch
[1] "i386"
$os
[1] "mingw32"
$system
[1] "i386, mingw32"
$status
[1] ""
$major
[1] "2"
$minor
[1] "6.1"
$year
[1] "2007"
$month
[1] "11"
$day
[1] "26"
$`svn rev`
[1] "43537"
$language
[1] "R"
$version.string
[1] "R version 2.6.1 (2007-11-26)"





  

Be a better friend, newshound, and

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

2008-01-26 Thread song xin
Hi, all. 
  I need help on improving the efficiency of my R
simulations. Below is a function that simulates a
change point model. It first generates a sequence of
three dimensional ARMA(1,1) observations, then
calculates the one step ahead prediction errors, some
statistic is calcualted and compared with threshold
values in the end. As you can see in the function,
there are 5 for loops, which makes the simulation long
and inefficient. Can anyone help me improve it? 


simfun<-function(b){
for(l in 1:20)
{
qq<-matrix(0,2,40)
for (w in 1:40)
{
x2 <- matrix(rep(0,6000),nr=3)
epsilonzero2<-(mvrnorm(n=1,mu=c(0,0,0),Sigma=residsigma))
x2[,1:2]<-c(0,0,0)
for (i in 3:550)
{
epsilonone<-(mvrnorm(n=1,mu=c(0,0,0),Sigma=residsigma))
  x2[,i] <-
phi%*%x2[,i-1]+epsilonone-theta%*%epsilonzero2
epsilonzero2<-epsilonone
}
residsigma3<-matrix(c(0.789,0.2143,0.171,0.2143,1.4394,-0.229,0.171,-0.229,0.6649),nrow=3,byrow=T)
epsilonzero3<-epsilonzero2
for (i in 551:2000) 
{
epsilonone<-(mvrnorm(n=1,mu=c(0,0,0),Sigma=residsigma3))
  x2[,i] <-
phi%*%x2[,(i-1)]+epsilonone-theta%*%epsilonzero3
epsilonzero3<-epsilonone
}
inno2<-matrix(0,3,2000)
inno2[,1]<-c(0,0,1)
for ( i in 2:2000) 
{
inno2[,i]<-x2[,i]-phi%*%x2[,(i-1)]+
theta%*%inno2[,(i-1)]
}
sampeigen4<-matrix(0,3,(2000-nnumber[l]))
for ( i in (nnumber[l]+1):2000)
{
var1<-matrix(0,3,3)
for ( j in 1:(nnumber[l]))
{
var1<-var1+j^{b}*inno2[,i-nnumber[l]-1+j]%*%t(inno2[,i-nnumber[l]-1+j])/(sum(c(1:nnumber[l])^{b}))
var1<-var1
}
sampeigen4[,(i-nnumber[l])]<-(eigen(var1)$values-eigen(residsigma)$values)
}
chisqstat<-rep(0,(2000-nnumber[l]))
for(i in 1:(2000-nnumber[l]))
{
chisqstat[i]<-((nnumber[l]-1)/2)*t(sampeigen4[,i])%*%(diag(eigen(residsigma)$values)^2)%*%(sampeigen4[,i])
}
normstat<-apply((sampeigen4+eigen(residsigma)$values),2,prod)
qq[1,w]<-vp(chisqstat[(550-nnumber[l]):(2000-nnumber[l])])
qq[2,w]<-vp1(normstat[(550-nnumber[l]):(2000-nnumber[l])])
}
inarl2[,l]<-apply(qq,1,mean)
}
inarl2
}



Thanks

XS



  

Looking for last minute shopping deals?

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

2008-01-26 Thread miaox
Hi,

I’m using the gls function to fit a model with autoregressive 
residuals. Does anyone know how to do weighted least squares with 
autoregressive residuals in gls?

Thanks,

Sincerely,

Xiaopeng

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


Re: [R] need help opening a file

2008-01-26 Thread David Winsemius
"Sudhindra Gadagkar" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> Hi, I can't believe I am unable to do this.  I just installed R
> (never used it before, but want to learn it).  At present, though.
> all I want to do is export a data file (specifically "crabs" in the
> MASS library) to a text file for use in SPSS.  It allows me to peek
> into the dataset, using the command head(crabs) but I can neither
> view the entire file nor can I seem to export it to a text file. I
> have been trying to get help from the online help for several hours
> now!  Maybe I just don't know what to search for. Frustrating!  Help
> would be much appreciated.  Thx, S. 
> 
>  [[alternative HTML version deleted]]

write.table should provide the basic function. It is designed to write 
datafames:

 write.table(crabs, file="crab.out.csv", sep=",")

... will give you a comma separated file:
... first five lines 
"sp","sex","index","FL","RW","CL","CW","BD"
"1","B","M",1,8.1,6.7,16.1,19,7
"2","B","M",2,8.8,7.7,18.1,20.8,7.4
"3","B","M",3,9.2,7.8,19,22.4,7.7
"4","B","M",4,9.6,7.9,20.1,23.1,8.2
.
.
.

If you are working in Windows, and want to specify a directory, you 
need to use forward slashes in the full filename. The backslash 
character has special meaning in *NIX systems, which is where R was 
developed.

If you want to "see" the dataframe, crabs, just type the name. You 
should see 200 lines of data.


-- 
David Winsemius

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


Re: [R] need help opening a file

2008-01-26 Thread Charles C. Berry

Sudhindra,

You should read the Posting Guide before asking for help:

http://www.R-project.org/posting-guide.html

It has greats hints on how to solve problems like this yourself, and you 
should try them before posting.

It might suggest that this is a good thing to run in R if you need help 
with data 'export':

RSiteSearch("export")

The first hit produced is the manual 'R Data Import/Export', which is 
provided along with your installation.

When you look there you will find this section:

1.2 Export to text files

RSiteSearch() also gives hits from this newslist from people like yourself 
who could not figure out how to export their data. Reading those should 
help you.

HTH,

Chuck

On Sat, 26 Jan 2008, Sudhindra Gadagkar wrote:

> Hi, I can't believe I am unable to do this.  I just installed R (never used
> it before, but want to learn it).  At present, though. all I want to do is
> export a data file (specifically "crabs" in the MASS library) to a text file
> for use in SPSS.  It allows me to peek into the dataset, using the command
> head(crabs) but I can neither view the entire file nor can I seem to export
> it to a text file. I have been trying to get help from the online help for
> several hours now!  Maybe I just don't know what to search for.
> Frustrating!  Help would be much appreciated.  Thx, S.
>
>   [[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.
>

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

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


Re: [R] need help opening a file

2008-01-26 Thread Wensui Liu
first of all, which is your code to export the data in R? did you use
write.table?
secondly, it is totally a waste of time to export data from R for use
in spss. for whatever can be done by spss, r can handle better.

On Jan 26, 2008 9:38 PM, Sudhindra Gadagkar <[EMAIL PROTECTED]> wrote:
> Hi, I can't believe I am unable to do this.  I just installed R (never used
> it before, but want to learn it).  At present, though. all I want to do is
> export a data file (specifically "crabs" in the MASS library) to a text file
> for use in SPSS.  It allows me to peek into the dataset, using the command
> head(crabs) but I can neither view the entire file nor can I seem to export
> it to a text file. I have been trying to get help from the online help for
> several hours now!  Maybe I just don't know what to search for.
> Frustrating!  Help would be much appreciated.  Thx, S.
>
> [[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.
>



-- 
===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)

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

2008-01-26 Thread Sudhindra Gadagkar
Hi, I can't believe I am unable to do this.  I just installed R (never used
it before, but want to learn it).  At present, though. all I want to do is
export a data file (specifically "crabs" in the MASS library) to a text file
for use in SPSS.  It allows me to peek into the dataset, using the command
head(crabs) but I can neither view the entire file nor can I seem to export
it to a text file. I have been trying to get help from the online help for
several hours now!  Maybe I just don't know what to search for.
Frustrating!  Help would be much appreciated.  Thx, S.

[[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] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread jim holtman
Here is a test I did with a data frame that had only  100 rows, but
the factors has 7000 and 4000 levels.  I had to limit it to this
because with 7000 and 1 (which was your data size) I ran out of
physical memory on my system (1GB).  You can see the amount of memory
that it was using which is dependent on the products of the levels
being used, and definitely not the size of the data (100 rows).  So
the real problem is the number of levels you have in your factors and
the way that R does aggregate (it calls 'tapply' internally).  So you
probably need to run with a database to handle data with this many
levels.

> n <- 100
> x <- data.frame(A=factor(sample(1:10,n,TRUE), levels=1:7000),
+ B=factor(sample(1:20,n,TRUE), levels=1:4000),
+
+ data=runif(n))
> gc()
 used (Mb) gc trigger (Mb) max used (Mb)
Ncells 150963  4.1 35  9.4   35  9.4
Vcells 104706  0.8 786432  6.0   479077  3.7
> system.time(x.ta <- tapply(x$data, list(x$A, x$B), mean))
   user  system elapsed
   4.170.565.50
> gc()
   used  (Mb) gc trigger  (Mb) max used  (Mb)
Ncells   151374   4.1 35   9.4   35   9.4
Vcells 28110297 214.5   46770568 356.9 42128199 321.5
>

2008/1/26 zhihuali <[EMAIL PROTECTED]>:
>
> thanks, Jim.
>
> My system has a RAM of 1 GB. I guess the computed matrix is close to the 
> limit of the memory and that's what caused the problem.  I think I'll take 
> Wensui's suggestion and use a relational database system to handle the huge 
> data.
>
>
>
> > Date: Sat, 26 Jan 2008 20:40:51 -0500
>
> > From: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > Subject: Re: [R] Comparison of aggregate in R and group by in mysql
> > CC: [EMAIL PROTECTED]
> >
> > I think with your data you will be computing a matrix that is 7049 x
> > 11704.  This will require about 700MB of memory.  What size system do
> > you have (how much memory)?  How big is the dataframe? (do 'str' and
> > report what it says).  This will require a lot more resources and
> > given that you have about 80M possible combinations, I would assume
> > that a lot of them are probably empty.  It is having to 'split' the
> > data into the groups and then summarize.  Maybe you should use a
> > database with this combination of data.
> >
> > 2008/1/26 zhihuali <[EMAIL PROTECTED]>:
> > >
> > > I repeated your experiment:
> > > > n <- 100
> > > > x <- data.frame(A=sample(LETTERS,n,TRUE), 
> > > > B=sample(letters[1:4],n,TRUE),C=sample(LETTERS[1:4], n, TRUE), 
> > > > data=runif(n))
> > > > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
> > >   user  system elapsed
> > >  1.824   0.212   2.038
> > >
> > >
> > > Now I use my own data:
> > > > length(levels(group))
> > > [1] 7049
> > > > length(levels(type))
> > > [1] 11704
> > > > y<-data.frame(group,type,signal)
> > > > system.time(y.agg <- aggregate(y$signal, list(y$group,y$type), mean))
> > >   (I killed it after 30 minutes)
> > >
> > >
> > >
> > > > Date: Sat, 26 Jan 2008 19:55:51 -0500
> > > > From: [EMAIL PROTECTED]
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: [R] Comparison of aggregate in R and group by in mysql
> > > > CC: [EMAIL PROTECTED]
> > >
> > > >
> > > > How large is your dataframe?  How much memory do you have on your
> > > > system?  Are you paging?  Here is a test I ran with a data frame with
> > > > 1,000,000 entries and it seems to be fast:
> > > >
> > > > > n <- 100
> > > > > x <- data.frame(A=sample(LETTERS,n,TRUE), 
> > > > > B=sample(letters[1:4],n,TRUE),
> > > > + C=sample(LETTERS[1:4], n, TRUE), data=runif(n))
> > > > > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
> > > >user  system elapsed
> > > >2.650.343.00
> > > > >
> > > >
> > > > On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > Hi, netters,
> > > > >
> > > > > First of all, thanks a lot for all the prompt replies to my earlier 
> > > > > question about "merging" data frames in R.
> > > > > Actually that's an equivalence to the "join" clause in mysql.
> > > > >
> > > > > Now I have another question. Suppose I have a data frame X with lots 
> > > > > of columns/variables:
> > > > > Name, Age,Group, Type, Salary.
> > > > > I wanna do a subtotal of salaries:
> > > > > aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
> > > > >
> > > > > When the levels of Group and Type are huge, it took R forever to 
> > > > > finish the aggregation.
> > > > > And I used gc to find that the memory usage was big too.
> > > > >
> > > > > However, in mysql, it took seconds to finish a similar job:
> > > > > select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
> > > > >
> > > > > Is it because mysql is superior in doing such kind of things? Or my R 
> > > > > command is not efficient enough? Why did R have to consume huge 
> > > > > memories to do the aggregation?
> > > > >
> > > > > Thanks again!
> > > > >
> > > > > Zhihua Li
> > > > >
> > > > > _

Re: [R] scatterplot3d with categorical data

2008-01-26 Thread Geoff Russell
On Jan 26, 2008 11:23 PM, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>
> On 26/01/2008 5:24 AM, Geoff Russell wrote:
> > Dear users,
> >
> > I'm trying to produce a 3d bar plot but the x and y dimensions have 
> > categorical
> > data -- so I only want 3 points on each axis. So I try:
> >
> >
> > require(scatterplot3d)
> >
> >mymat<-data.frame(
> >x=c(1,1,1,2,2,2,3,3,3),
> >y=c(1,2,3,1,2,3,1,2,3),
> >z=c(1,2,3,4,5,6,7,8,9))
> >scatterplot3d(mymat,
> >type="h", lwd=5, pch=" ",
> >xlab="xlabel", ylab="ylabel", zlab="zlabel",
> >xlim=c(1,3), ylim=c(1,3),
> >lab=c(3,3),
> >x.ticklabs=c("Low","Medium","High"), 
> > y.ticklabs=c("Green","Blue","Black"),
> >main="My Bar Plot")
> >
> > But I still get x ticks at 1, 1.5, 2, 2.5, 3 on both x and y axes. I
> > thought lab
> > controlled this (according to the documentation).
> >
> > What am I doing wrong, or is there some restriction on the way the
> > function works?
>
> I don't know the answer about scatterplot3d, but you can get
> approximately what you want with the rgl package using
>
>
>plot3d(mymat,
>  type="h",
>  xlab="xlabel", ylab="ylabel", zlab="zlabel",
>  xlim=c(1,3), ylim=c(1,3),
>  size=5,
>  axes=FALSE,
>  main="My Bar Plot")
>
>  axis3d("x", at=1:3, labels=c("Low","Medium","High"))
>  axis3d("y", at=1:3, labels=c("Green","Blue","Black"))
>  grid3d("z", n=3)

I couldn't install rgl due to the following problems:

g++ -I/usr/local/lib/R/include -I/usr/local/lib/R/include -DHAVE_PNG_H
-Iext -I/usr/local/include-fPIC   -c par3d.cpp -o par3d.o
par3d.cpp: In function 'void Specify(const char*, SEXPREC*)':
par3d.cpp:128: error: invalid conversion from 'const char*' to 'char*'
par3d.cpp:128: error:   initialising argument 1 of 'Rboolean
Rf_psmatch(char*, char*, Rboolean)'
par3d.cpp:135: error: invalid conversion from 'const char*' to 'char*'
par3d.cpp:135: error:   initialising argument 1 of 'Rboolean
Rf_psmatch(char*, char*, Rboolean)'
make: *** [par3d.o] Error 1
chmod: cannot access `/usr/local/lib/R/library/rgl/libs/*': No such
file or directory
ERROR: compilation failed for package 'rgl'

But Uwe's suggestion with scatterplot3d gives a better result than I had.  But I
might use multiple 2d plots instead.

Many thanks,

Geoff.



>
> You might prefer to change the mouse controls to
>
>  par3d(mouseMode=c("zAxis","zoom","fov"))
>
> so that the main mouse button does rotation about the vertical axis,
> rather than completely general rotation.
>
> Duncan Murdoch
>
>



-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069

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


Re: [R] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread zhihuali

thanks, Jim.

My system has a RAM of 1 GB. I guess the computed matrix is close to the limit 
of the memory and that's what caused the problem.  I think I'll take Wensui's 
suggestion and use a relational database system to handle the huge data.



> Date: Sat, 26 Jan 2008 20:40:51 -0500
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: [R] Comparison of aggregate in R and group by in mysql
> CC: [EMAIL PROTECTED]
> 
> I think with your data you will be computing a matrix that is 7049 x
> 11704.  This will require about 700MB of memory.  What size system do
> you have (how much memory)?  How big is the dataframe? (do 'str' and
> report what it says).  This will require a lot more resources and
> given that you have about 80M possible combinations, I would assume
> that a lot of them are probably empty.  It is having to 'split' the
> data into the groups and then summarize.  Maybe you should use a
> database with this combination of data.
> 
> 2008/1/26 zhihuali <[EMAIL PROTECTED]>:
> >
> > I repeated your experiment:
> > > n <- 100
> > > x <- data.frame(A=sample(LETTERS,n,TRUE), 
> > > B=sample(letters[1:4],n,TRUE),C=sample(LETTERS[1:4], n, TRUE), 
> > > data=runif(n))
> > > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
> >   user  system elapsed
> >  1.824   0.212   2.038
> >
> >
> > Now I use my own data:
> > > length(levels(group))
> > [1] 7049
> > > length(levels(type))
> > [1] 11704
> > > y<-data.frame(group,type,signal)
> > > system.time(y.agg <- aggregate(y$signal, list(y$group,y$type), mean))
> >   (I killed it after 30 minutes)
> >
> >
> >
> > > Date: Sat, 26 Jan 2008 19:55:51 -0500
> > > From: [EMAIL PROTECTED]
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [R] Comparison of aggregate in R and group by in mysql
> > > CC: [EMAIL PROTECTED]
> >
> > >
> > > How large is your dataframe?  How much memory do you have on your
> > > system?  Are you paging?  Here is a test I ran with a data frame with
> > > 1,000,000 entries and it seems to be fast:
> > >
> > > > n <- 100
> > > > x <- data.frame(A=sample(LETTERS,n,TRUE), B=sample(letters[1:4],n,TRUE),
> > > + C=sample(LETTERS[1:4], n, TRUE), data=runif(n))
> > > > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
> > >user  system elapsed
> > >2.650.343.00
> > > >
> > >
> > > On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi, netters,
> > > >
> > > > First of all, thanks a lot for all the prompt replies to my earlier 
> > > > question about "merging" data frames in R.
> > > > Actually that's an equivalence to the "join" clause in mysql.
> > > >
> > > > Now I have another question. Suppose I have a data frame X with lots of 
> > > > columns/variables:
> > > > Name, Age,Group, Type, Salary.
> > > > I wanna do a subtotal of salaries:
> > > > aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
> > > >
> > > > When the levels of Group and Type are huge, it took R forever to finish 
> > > > the aggregation.
> > > > And I used gc to find that the memory usage was big too.
> > > >
> > > > However, in mysql, it took seconds to finish a similar job:
> > > > select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
> > > >
> > > > Is it because mysql is superior in doing such kind of things? Or my R 
> > > > command is not efficient enough? Why did R have to consume huge 
> > > > memories to do the aggregation?
> > > >
> > > > Thanks again!
> > > >
> > > > Zhihua Li
> > > >
> > > > _
> > > > ÌìÁ¹ÁË£¬ÌíÒÂÁË£¬ÐĶ¯ÁË£¬"Æß¼þ"ÁË
> > > > http://get.live.cn
> > > >[[alternative HTML version deleted]]
> > > >
> > > >
> > > > __
> > > > R-help@r-project.org mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > > PLEASE do read the posting guide 
> > > > http://www.R-project.org/posting-guide.html
> > > > and provide commented, minimal, self-contained, reproducible code.
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Jim Holtman
> > > Cincinnati, OH
> > > +1 513 646 9390
> > >
> > > What is the problem you are trying to solve?
> >
> > _
> > MSNÊ¥µ®ÀñÎï»ðÈȵdz¡£¬Ãâ·Ñ·¢·ÅÖУ¬¿ìÀ´ÁìÈ¡°É£¡
> > http://im.live.cn/emoticons/?ID=18
> >[[alternative HTML version deleted]]
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem you are trying to solve?

_
ÌìÁ¹ÁË£¬ÌíÒÂÁË£¬ÐĶ¯ÁË£¬¡°Æß¼þ¡±ÁË 
http://get.live.cn
[[alternative HTML version deleted]]

___

Re: [R] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
hi Gabor and Duncan,

I make a test and I find that the key of problem
is the setwd() command in my Rprofile.site

I don't understand this behaviour yet! :-(


Cleber







___ 

Experimente já e veja as novidades.

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

2008-01-26 Thread tom soyer
Thanks Henrik. I am using Rgui. Restart works. I was thinking about ways to
save the session, or prevent it from happening, in case this happens again.
I guess once it goes bad, nothing works except a hard restart. Is there an
auto save function in R?

On 1/26/08, Henrik Bengtsson <[EMAIL PROTECTED]> wrote:
>
> When and how does this happen?  In Rgui or Rterm?  How do you launch
> R?  Have you tried the obvious and restarted R?  If you share the
> startup messages, sessionInfo() and everything else you think could be
> helpful, someone might be able to help you.  There is a "vanilla"
> options to start R, e.g.
>
> Rterm --vanilla
>
> that you might wanna try.
>
> /Henrik
>
>
>
> On Jan 26, 2008 3:54 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > My R just froze. I can't get it to do anything. It gives "Error: band
> value"
> > message to everything I type. Does anyone know if R has a safe mode that
> I
> > could check for errors and perform diagnostics? I am using R 2.6.1 on
> > Windows XP.
> > > ls()
> > Error: bad value
> > > search()
> > Error: bad value
> > > ?ls
> > Error: bad value
> > > q()
> > Error: bad value
> >
> > --
> > Tom
> >
> > [[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.
> >
>



-- 
Tom

[[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] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread jim holtman
I think with your data you will be computing a matrix that is 7049 x
11704.  This will require about 700MB of memory.  What size system do
you have (how much memory)?  How big is the dataframe? (do 'str' and
report what it says).  This will require a lot more resources and
given that you have about 80M possible combinations, I would assume
that a lot of them are probably empty.  It is having to 'split' the
data into the groups and then summarize.  Maybe you should use a
database with this combination of data.

2008/1/26 zhihuali <[EMAIL PROTECTED]>:
>
> I repeated your experiment:
> > n <- 100
> > x <- data.frame(A=sample(LETTERS,n,TRUE), 
> > B=sample(letters[1:4],n,TRUE),C=sample(LETTERS[1:4], n, TRUE), 
> > data=runif(n))
> > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
>   user  system elapsed
>  1.824   0.212   2.038
>
>
> Now I use my own data:
> > length(levels(group))
> [1] 7049
> > length(levels(type))
> [1] 11704
> > y<-data.frame(group,type,signal)
> > system.time(y.agg <- aggregate(y$signal, list(y$group,y$type), mean))
>   (I killed it after 30 minutes)
>
>
>
> > Date: Sat, 26 Jan 2008 19:55:51 -0500
> > From: [EMAIL PROTECTED]
> > To: [EMAIL PROTECTED]
> > Subject: Re: [R] Comparison of aggregate in R and group by in mysql
> > CC: [EMAIL PROTECTED]
>
> >
> > How large is your dataframe?  How much memory do you have on your
> > system?  Are you paging?  Here is a test I ran with a data frame with
> > 1,000,000 entries and it seems to be fast:
> >
> > > n <- 100
> > > x <- data.frame(A=sample(LETTERS,n,TRUE), B=sample(letters[1:4],n,TRUE),
> > + C=sample(LETTERS[1:4], n, TRUE), data=runif(n))
> > > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
> >user  system elapsed
> >2.650.343.00
> > >
> >
> > On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi, netters,
> > >
> > > First of all, thanks a lot for all the prompt replies to my earlier 
> > > question about "merging" data frames in R.
> > > Actually that's an equivalence to the "join" clause in mysql.
> > >
> > > Now I have another question. Suppose I have a data frame X with lots of 
> > > columns/variables:
> > > Name, Age,Group, Type, Salary.
> > > I wanna do a subtotal of salaries:
> > > aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
> > >
> > > When the levels of Group and Type are huge, it took R forever to finish 
> > > the aggregation.
> > > And I used gc to find that the memory usage was big too.
> > >
> > > However, in mysql, it took seconds to finish a similar job:
> > > select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
> > >
> > > Is it because mysql is superior in doing such kind of things? Or my R 
> > > command is not efficient enough? Why did R have to consume huge memories 
> > > to do the aggregation?
> > >
> > > Thanks again!
> > >
> > > Zhihua Li
> > >
> > > _
> > > 天凉了,添衣了,心动了,"七件"了
> > > http://get.live.cn
> > >[[alternative HTML version deleted]]
> > >
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide 
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> > >
> >
> >
> >
> > --
> > Jim Holtman
> > Cincinnati, OH
> > +1 513 646 9390
> >
> > What is the problem you are trying to solve?
>
> _
> MSN圣诞礼物火热登场,免费发放中,快来领取吧!
> http://im.live.cn/emoticons/?ID=18
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



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

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


Re: [R] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
hi Duncan,

Rename my Rprofile.site and then
this experiment works fine! because:
...
...
[Previously saved workspace restored]

but R --vanilla is not the same approach??

I try with 2 different files Rprofile.site,
the 2 Rprofile.site are many different
and the 2 has functions

with double-clicked in first Rprofile, I don't restore the variable..
with double-clicked in second, all works fine...
[Previously saved workspace restored]
The problematic Rprofile follow in attach...

by the way, I make the file association correct now
I make several modifications in my regedit...


C:\R\etc>assoc .Rdata
.Rdata=RWorkspace

C:\R\etc>ftype RWorkspace
RWorkspace="C:\R\bin\RGui.exe" "%1"

C:\R\etc>


Thank
Cleber


>
> You might want to temporarily rename that file so that it is not run; 
> I don't think it should interfere, but maybe it does...
>
> Duncan Murdoch
>




___ 

Experimente já e veja as novidades.

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

2008-01-26 Thread Max Kuhn
Well, I hesitate to discuss things like this on Rhelp, but I can tell
you about my experiences with them.

I have worked with them a bit. They have done R programming for my
company. For example, when odfWeave moved from heavy grepping to using
the xml package, they wrote the state-based xml parsing code (which
was not simple).  I've been pretty happy with their work.

I think that their strong suit are their parallel processing libraries
(see the nws package). I have been using those for a while now (see
the caretNWS package for example) and they work well. They also have
commercial versions of packages apart from nws.

I don't have any information about their commercially supported version of R

John - if you like, I can forward this thread to my contacts there.

(These are my opinions and not those of my company; I don't work for
them, etc etc.)

Max

On Jan 26, 2008 7:47 PM, John Kane <[EMAIL PROTECTED]> wrote:
> http://www.revolution-computing.com/revolution_company.html
>
> seems to lead to something albeit vague.
>
> Lots of apparently big names but no indication of what
> added value the company might bring to an R user.
>
>
> --- John Maindonald <[EMAIL PROTECTED]>
> wrote:
>
>
> > Does anyone know any more than is in the following
> > press release
> > about REvolution Computing and their
> > commercialization of R?
> >
> >
> http://www.intel.com/capital/news/releases/080122.htm
> >
> > "Intel Capital, the global investment arm of Intel
> > Corporation, today
> > announced that it has invested in the Series A
> > financing of REvolution
> > Computing, creator of parallel computing software
> > for computational
> > statistics"
> >
> > "R has become the de-facto statistical language and
> > REvolution
> > Computing's R-based solutions provide the necessary
> > scale and support
> > for its growing commercial usage,� said Andre M.
> > Boisvert, Revolution
> > Computing board member. �With this investment,
> > Revolution Computing
> > can deliver the type of performance that has been
> > missing in existing
> > computational statistics offerings."
> >
> > "For more information on Revolution Computing, RPro,
> > and ParallelR,
> > visit
> > www.revolution-computing.com"
> >
> > At present though, unless you have better success
> > than me, all you
> > will get from the Revolution Computing site is a
> > revolutionary song!
> >
> > John Maindonald email:
> > [EMAIL PROTECTED]
> > phone : +61 2 (6125)3473fax  : +61 2(6125)5549
> > Centre for Mathematics & Its Applications, Room
> > 1194,
> > John Dedman Mathematical Sciences Building (Building
> > 27)
> > Australian National University, Canberra ACT 0200.
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>



-- 

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] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread zhihuali

I repeated your experiment:
> n <- 100
> x <- data.frame(A=sample(LETTERS,n,TRUE), 
> B=sample(letters[1:4],n,TRUE),C=sample(LETTERS[1:4], n, TRUE), data=runif(n))
> system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
   user  system elapsed
  1.824   0.212   2.038


Now I use my own data:
> length(levels(group))
[1] 7049
> length(levels(type))
[1] 11704
> y<-data.frame(group,type,signal)
> system.time(y.agg <- aggregate(y$signal, list(y$group,y$type), mean))
   (I killed it after 30 minutes)



> Date: Sat, 26 Jan 2008 19:55:51 -0500
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: [R] Comparison of aggregate in R and group by in mysql
> CC: [EMAIL PROTECTED]
> 
> How large is your dataframe?  How much memory do you have on your
> system?  Are you paging?  Here is a test I ran with a data frame with
> 1,000,000 entries and it seems to be fast:
> 
> > n <- 100
> > x <- data.frame(A=sample(LETTERS,n,TRUE), B=sample(letters[1:4],n,TRUE),
> + C=sample(LETTERS[1:4], n, TRUE), data=runif(n))
> > system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
>user  system elapsed
>2.650.343.00
> >
> 
> On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
> >
> > Hi, netters,
> >
> > First of all, thanks a lot for all the prompt replies to my earlier 
> > question about "merging" data frames in R.
> > Actually that's an equivalence to the "join" clause in mysql.
> >
> > Now I have another question. Suppose I have a data frame X with lots of 
> > columns/variables:
> > Name, Age,Group, Type, Salary.
> > I wanna do a subtotal of salaries:
> > aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
> >
> > When the levels of Group and Type are huge, it took R forever to finish the 
> > aggregation.
> > And I used gc to find that the memory usage was big too.
> >
> > However, in mysql, it took seconds to finish a similar job:
> > select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
> >
> > Is it because mysql is superior in doing such kind of things? Or my R 
> > command is not efficient enough? Why did R have to consume huge memories to 
> > do the aggregation?
> >
> > Thanks again!
> >
> > Zhihua Li
> >
> > _
> > ÌìÁ¹ÁË£¬ÌíÒÂÁË£¬ÐĶ¯ÁË£¬"Æß¼þ"ÁË
> > http://get.live.cn
> >[[alternative HTML version deleted]]
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem you are trying to solve?

_
MSNÊ¥µ®ÀñÎï»ðÈȵdz¡£¬Ãâ·Ñ·¢·ÅÖУ¬¿ìÀ´ÁìÈ¡°É£¡
http://im.live.cn/emoticons/?ID=18
[[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] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread jim holtman
How large is your dataframe?  How much memory do you have on your
system?  Are you paging?  Here is a test I ran with a data frame with
1,000,000 entries and it seems to be fast:

> n <- 100
> x <- data.frame(A=sample(LETTERS,n,TRUE), B=sample(letters[1:4],n,TRUE),
+ C=sample(LETTERS[1:4], n, TRUE), data=runif(n))
> system.time(x.agg <- aggregate(x$data, list(x$A, x$B, x$C), mean))
   user  system elapsed
   2.650.343.00
>

On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
>
> Hi, netters,
>
> First of all, thanks a lot for all the prompt replies to my earlier question 
> about "merging" data frames in R.
> Actually that's an equivalence to the "join" clause in mysql.
>
> Now I have another question. Suppose I have a data frame X with lots of 
> columns/variables:
> Name, Age,Group, Type, Salary.
> I wanna do a subtotal of salaries:
> aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
>
> When the levels of Group and Type are huge, it took R forever to finish the 
> aggregation.
> And I used gc to find that the memory usage was big too.
>
> However, in mysql, it took seconds to finish a similar job:
> select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
>
> Is it because mysql is superior in doing such kind of things? Or my R command 
> is not efficient enough? Why did R have to consume huge memories to do the 
> aggregation?
>
> Thanks again!
>
> Zhihua Li
>
> _
> 天凉了,添衣了,心动了,"七件"了
> http://get.live.cn
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



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

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


Re: [R] interactive menu in scripts

2008-01-26 Thread Henrique Dallazuanna
On 26/01/2008, WCD <[EMAIL PROTECTED]> wrote:
>
> Yes, the switch function works fine.
> To store generated values in some variable I just use:
>   switch(menu(c("Normal", "Uniform")), a<-rnorm(5), a<-runif(5))
>
> But why does not work this? (I know there is waste of variables, but in
> principle):
>   b<-numeric(10)
>   switch(menu(c("Normal", "Uniform")), a<-1, a<-2)
>   if(a==1) {b<-rnorm(10)} else {b<-runif(10)}
> When I run these commands from a script, the choice is offered after the
> condition is performed, so "b" stores ten zeros.
>

 b <- switch(menu(c("Normal", "Uniform")), rnorm(10), runif(10))


> Also readline() function seems to be what I am looking for. But I did not
> manage to use it for my reason;  this does not work too:
>   var<-numeric(5) #Is not necessary
>   rdf<-function() {
>   x<-readline("Enter 1 for normal, 2 for uniform distribution ")
>   if (x==1) {var<-rnorm(5)} else {var<-runif(5)}
>   }
>   rdf()

You need return the var object in the function
rdf<-function() {
   x<-readline("Enter 1 for normal, 2 for uniform distribution ")
   if (x==1) {var<-rnorm(5)} else {var<-runif(5)}
   return(var)
}
 rdf()


> Even this does not work (object "x" is not found):
>   rdf2<-function() {
>   x<-readline("enter your year of birth ")
>   }
>   rdf2()

The same that the previous, in this case return(x)

> Can you see what am I doing wrong?
>
> Anyway, I am sorry for my maybe bizzar explanations. I am quitr new to R and
> R forum.
> My aim is to write an R script, where the user can make some choices or set
> some parameters via the R console. Filip Kral.
>
>
> Henrique Dallazuanna wrote:
> >
> > Try like this:
> >
> > switch(menu(c("Normal", "Poisson")), rnorm(5), rpois(5, 3))
> >
> >
> > On 25/01/2008, WCD <[EMAIL PROTECTED]> wrote:
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >
> > --
> > Henrique Dallazuanna
> > Curitiba-Paraná-Brasil
> > 25° 25' 40" S 49° 16' 22" O
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> --
> View this message in context: 
> http://www.nabble.com/interactive-menu-in-scripts-tp15095049p15111894.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.
>


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

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


Re: [R] REvolution

2008-01-26 Thread John Kane
http://www.revolution-computing.com/revolution_company.html

seems to lead to something albeit vague. 

Lots of apparently big names but no indication of what
added value the company might bring to an R user.


--- John Maindonald <[EMAIL PROTECTED]>
wrote:

> Does anyone know any more than is in the following
> press release
> about REvolution Computing and their
> commercialization of R?
> 
>
http://www.intel.com/capital/news/releases/080122.htm
> 
> "Intel Capital, the global investment arm of Intel
> Corporation, today  
> announced that it has invested in the Series A
> financing of REvolution  
> Computing, creator of parallel computing software
> for computational  
> statistics"
> 
> "R has become the de-facto statistical language and
> REvolution  
> Computing's R-based solutions provide the necessary
> scale and support  
> for its growing commercial usage,� said Andre M.
> Boisvert, Revolution  
> Computing board member. �With this investment,
> Revolution Computing  
> can deliver the type of performance that has been
> missing in existing  
> computational statistics offerings."
> 
> "For more information on Revolution Computing, RPro,
> and ParallelR,  
> visit
> www.revolution-computing.com"
> 
> At present though, unless you have better success
> than me, all you  
> will get from the Revolution Computing site is a
> revolutionary song!
> 
> John Maindonald email:
> [EMAIL PROTECTED]
> phone : +61 2 (6125)3473fax  : +61 2(6125)5549
> Centre for Mathematics & Its Applications, Room
> 1194,
> John Dedman Mathematical Sciences Building (Building
> 27)
> Australian National University, Canberra ACT 0200.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Gabor Grothendieck
On Jan 26, 2008 7:24 PM, Cleber Nogueira Borges <[EMAIL PROTECTED]> wrote:
> hi Gabor,
>
> Now, seems an light, because...
>
> C:\R\etc>assoc .Rdata
> .Rdata=RWorkspace
>
> C:\R\etc>ftype RWorkspace
> Tipo de arquivo 'RWorkspace' não encontrado ou nenhum comando open
> associado a ele.
> *File type 'RWorkspace' not found or none command open associated for it*.
>
> seems something with error here...
>
> but in regedit:
>
> HKEY_CLASSES_ROOT\RWorkspace\shell\open\comand
> tipo=REG_SZ
> *{{{type}}}*
> dados = "C:\R\bin\RGui.exe" "%1" *{{{data}}}*
>
> How to modify a ftype association?
>

Google for
  modify file type association

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Duncan Murdoch
On 26/01/2008 5:31 PM, Cleber Nogueira Borges wrote:
> Gabor Grothendieck wrote:
>> Please clarify.  What happens?
> 
> ok!
> I start up the R, load my file by win menu: "Load Workspace",
> ls() show-me variables!
> Then, I save my workspace with other name (test2.rdata, for example) and 
> close my E session.
> 
> When I start up R by double-click in my new RData file (test2.rdata) and 
> prompted the command ls(),
> this show-me:
>  > ls()
> character(0)
>  >
> and I don't see my variables...
> 
> One information that I don't mentioned:
> 
> My Rprofile.site have dozen of personal functions, but all *very simple 
> functions*,
> I don't make change in defaults settings...
> 

You might want to temporarily rename that file so that it is not run; I 
don't think it should interfere, but maybe it does...

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] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
hi Gabor,

Now, seems an light, because...

C:\R\etc>assoc .Rdata
.Rdata=RWorkspace

C:\R\etc>ftype RWorkspace
Tipo de arquivo 'RWorkspace' não encontrado ou nenhum comando open 
associado a ele.
*File type 'RWorkspace' not found or none command open associated for it*.

seems something with error here...

but in regedit:

HKEY_CLASSES_ROOT\RWorkspace\shell\open\comand
tipo=REG_SZ   
*{{{type}}}*
dados = "C:\R\bin\RGui.exe" "%1" *{{{data}}}*

How to modify a ftype association?


Cleber



> Try entering this at the Windows console:
>
> assoc .Rdata
>
> assuming the answer is:
> .Rdata=RWorkspace
> try this:
>
> ftype RWorkspace
>
> That will show you what command is executed when you double
> click on an Rdata file.  Perhaps you need to change that.
>   





___ 

Experimente já e veja as novidades.

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

2008-01-26 Thread Henrik Bengtsson
When and how does this happen?  In Rgui or Rterm?  How do you launch
R?  Have you tried the obvious and restarted R?  If you share the
startup messages, sessionInfo() and everything else you think could be
helpful, someone might be able to help you.  There is a "vanilla"
options to start R, e.g.

Rterm --vanilla

that you might wanna try.

/Henrik



On Jan 26, 2008 3:54 PM, tom soyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> My R just froze. I can't get it to do anything. It gives "Error: band value"
> message to everything I type. Does anyone know if R has a safe mode that I
> could check for errors and perform diagnostics? I am using R 2.6.1 on
> Windows XP.
> > ls()
> Error: bad value
> > search()
> Error: bad value
> > ?ls
> Error: bad value
> > q()
> Error: bad value
>
> --
> Tom
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread Gabor Grothendieck
How does the it compare if you read it into R and then do your
aggregate with sqldf:

library(sqldf)

# example using builtin data set CO2
CO2agg <- sqldf("select Plant, Type, Treatment, avg(conc) from CO2
group by Plant, Type, Treatment")

# or using your data:

Xagg <- sqldf("select Group, Age, Type, avg(Salary) from X group by
Group, Age, Type")


On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
>
> Hi, netters,
>
> First of all, thanks a lot for all the prompt replies to my earlier question 
> about "merging" data frames in R.
> Actually that's an equivalence to the "join" clause in mysql.
>
> Now I have another question. Suppose I have a data frame X with lots of 
> columns/variables:
> Name, Age,Group, Type, Salary.
> I wanna do a subtotal of salaries:
> aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
>
> When the levels of Group and Type are huge, it took R forever to finish the 
> aggregation.
> And I used gc to find that the memory usage was big too.
>
> However, in mysql, it took seconds to finish a similar job:
> select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
>
> Is it because mysql is superior in doing such kind of things? Or my R command 
> is not efficient enough? Why did R have to consume huge memories to do the 
> aggregation?
>
> Thanks again!
>
> Zhihua Li
>
> _
> 天凉了,添衣了,心动了,"七件"了
> http://get.live.cn
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread Wensui Liu
huali,
if i were you, i will create a view on the MySql server to aggregate
the data first and then use R to pull the data through this created
view. This is not only applicable to R but also a general guideline in
similar situation.
Per my understanding and experience, R is able to do data manipulation
reasonably well. However, we should always use the right tool to do
the right thing.

On Jan 26, 2008 6:45 PM, zhihuali <[EMAIL PROTECTED]> wrote:
>
> Hi, netters,
>
> First of all, thanks a lot for all the prompt replies to my earlier question 
> about "merging" data frames in R.
> Actually that's an equivalence to the "join" clause in mysql.
>
> Now I have another question. Suppose I have a data frame X with lots of 
> columns/variables:
> Name, Age,Group, Type, Salary.
> I wanna do a subtotal of salaries:
> aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)
>
> When the levels of Group and Type are huge, it took R forever to finish the 
> aggregation.
> And I used gc to find that the memory usage was big too.
>
> However, in mysql, it took seconds to finish a similar job:
> select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type
>
> Is it because mysql is superior in doing such kind of things? Or my R command 
> is not efficient enough? Why did R have to consume huge memories to do the 
> aggregation?
>
> Thanks again!
>
> Zhihua Li
>
> _
> 天凉了,添衣了,心动了,"七件"了
> http://get.live.cn
> [[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.
>
>



-- 
===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)
===
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: C stack usage is too close to the limit

2008-01-26 Thread Maarten Blaauw
Sorry, indeed I forgot to put some of the factors in the code. Here it  
is again, now updated:

calcurve <- cbind(1:2e4, 1:2e4, rep(100, length=2e4));

caldist <- function(cage, error, sdev=2, times=5, By=1)
  {
   calcurve <- calcurve[which((calcurve[,2]+calcurve[,3]) >=  
cage-(times*error)),];
   calcurve <- calcurve[which((calcurve[,2]-calcurve[,3]) <=  
cage+(times*error)),];
   theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);

   interpolate <- function(th, col)
{
 if(th==calcurve[1,1]) {calcurve[1,col]}else
 if(th==calcurve[nrow(calcurve),1]) {calcurve[nrow(calcurve),col]}else
  {
   k <- min(which(calcurve[,1] > th));
   slope <-  
(calcurve[k-1,col]-calcurve[k,col])/(calcurve[k-1,1]-calcurve[k,1]);
   calcurve[k-1,col] + slope*(th-calcurve[k-1,1]);
  }
}

   mu <- c();
   cerror <- c();
   for(i in 1:length(theta))
{
 mu[i] <- interpolate(theta[i],2);
 cerror[i] <- interpolate(theta[i],3);
}

   caldist <- dnorm(mu, cage, (error^2+cerror^2)^.5);
   cbind(theta, caldist/sum(caldist));
  }

caldist(2450,50);

Strangely enough the stacking error message seems not to happen every  
time. It also has happened on the WinXP partition of the same Toshiba  
laptop. So it is not as reproducible as I first hoped/feared.

-- 
Dr. Maarten Blaauw
School of Geography, Archaeology & Palaeoecology
Queen's University Belfast, U.K.
On leave from Department of Earth Sciences
Uppsala University, Sweden
[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] Is there a safe mode?

2008-01-26 Thread tom soyer
Hi,

My R just froze. I can't get it to do anything. It gives "Error: band value"
message to everything I type. Does anyone know if R has a safe mode that I
could check for errors and perform diagnostics? I am using R 2.6.1 on
Windows XP.
> ls()
Error: bad value
> search()
Error: bad value
> ?ls
Error: bad value
> q()
Error: bad value

-- 
Tom

[[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] double-click in RData file versus load( file )

2008-01-26 Thread Gabor Grothendieck
Try entering this at the Windows console:

assoc .Rdata

assuming the answer is:
.Rdata=RWorkspace
try this:

ftype RWorkspace

That will show you what command is executed when you double
click on an Rdata file.  Perhaps you need to change that.


On Jan 26, 2008 6:40 PM, Cleber Nogueira Borges <[EMAIL PROTECTED]> wrote:
> hi Gabor,
>
> I try it:
> in *MS-DOS*:
> C:\R\etc>Rgui --vanilla
> In *R*:
> a=1
> b=2
> c=3
> save.image("c:\\R\\etc\\test.rdata")
> q('no')
>
>
> then I "double-clicked' in 'test.rdata' (in c:\R\etc folder)
> The R start without my variables: a,b,c
>
> If I make again: R -- vanilla, and then load file, the variables are there!
>
> It is intrigant for me! :-(
>
>
> Cleber
>
> > You could try
> >
> > Rgui --vanilla
> >
> > so that it does not run the scripts you have set up.
> >
> >
>
>
>
>
>
>
> ___
> Yahoo! Mail - Sempre a melhor opção para você!
> Experimente já e veja as novidades.
> http://br.yahoo.com/mailbeta/tudonovo/
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Comparison of aggregate in R and group by in mysql

2008-01-26 Thread zhihuali

Hi, netters,

First of all, thanks a lot for all the prompt replies to my earlier question 
about "merging" data frames in R.
Actually that's an equivalence to the "join" clause in mysql.

Now I have another question. Suppose I have a data frame X with lots of 
columns/variables:
Name, Age,Group, Type, Salary.
I wanna do a subtotal of salaries:
aggregate(X$Salary, by=list(X$Group,X$Age,X$Type),Fun=mean)

When the levels of Group and Type are huge, it took R forever to finish the 
aggregation.
And I used gc to find that the memory usage was big too.

However, in mysql, it took seconds to finish a similar job:
select Group,Age,Type ,avg(Salary)  from X group by  Group,Age,Type

Is it because mysql is superior in doing such kind of things? Or my R command 
is not efficient enough? Why did R have to consume huge memories to do the 
aggregation?

Thanks again!

Zhihua Li

_
ÌìÁ¹ÁË£¬ÌíÒÂÁË£¬ÐĶ¯ÁË£¬¡°Æß¼þ¡±ÁË 
http://get.live.cn
[[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] REvolution

2008-01-26 Thread John Maindonald
Does anyone know any more than is in the following press release
about REvolution Computing and their commercialization of R?

http://www.intel.com/capital/news/releases/080122.htm

"Intel Capital, the global investment arm of Intel Corporation, today  
announced that it has invested in the Series A financing of REvolution  
Computing, creator of parallel computing software for computational  
statistics"

"R has become the de-facto statistical language and REvolution  
Computing's R-based solutions provide the necessary scale and support  
for its growing commercial usage,” said Andre M. Boisvert, Revolution  
Computing board member. “With this investment, Revolution Computing  
can deliver the type of performance that has been missing in existing  
computational statistics offerings."

"For more information on Revolution Computing, RPro, and ParallelR,  
visit
www.revolution-computing.com"

At present though, unless you have better success than me, all you  
will get from the Revolution Computing site is a revolutionary song!

John Maindonald email: [EMAIL PROTECTED]
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
hi Gabor,

I try it:
in *MS-DOS*:
C:\R\etc>Rgui --vanilla
In *R*:
a=1
b=2
c=3
save.image("c:\\R\\etc\\test.rdata")
q('no')


then I "double-clicked' in 'test.rdata' (in c:\R\etc folder)
The R start without my variables: a,b,c

If I make again: R -- vanilla, and then load file, the variables are there!

It is intrigant for me! :-(


Cleber

> You could try
>
> Rgui --vanilla
>
> so that it does not run the scripts you have set up.
>
>   





___ 

Experimente já e veja as novidades.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Gabor Grothendieck
You could try

Rgui --vanilla

so that it does not run the scripts you have set up.

On Jan 26, 2008 5:31 PM, Cleber Nogueira Borges <[EMAIL PROTECTED]> wrote:
> Gabor Grothendieck wrote:
> > Please clarify.  What happens?
>
> ok!
> I start up the R, load my file by win menu: "Load Workspace",
> ls() show-me variables!
> Then, I save my workspace with other name (test2.rdata, for example) and
> close my E session.
>
> When I start up R by double-click in my new RData file (test2.rdata) and
> prompted the command ls(),
> this show-me:
>  > ls()
> character(0)
>  >
> and I don't see my variables...
>
> One information that I don't mentioned:
>
> My Rprofile.site have dozen of personal functions, but all *very simple
> functions*,
> I don't make change in defaults settings...
>
> Cleber
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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: C stack usage is too close to the limit

2008-01-26 Thread jim holtman
Your function has 4 parameters and you are only calling with two.  The
first statement:

caldist <- function(cage=Cage, error=Error, sdev=Sdev, times=Times, By=By)
 {
  theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);

use "By" which is not defined.

On Jan 26, 2008 4:29 PM, Maarten Blaauw <[EMAIL PROTECTED]> wrote:
> Lately R has been behaving strange on my Linux (Ubuntu 7.10) machine,
> with occasional segfaults. Today something else and reproducible
> happened:
>
> If I type the code below (meant for calibrating data), I get the error
> message that "the C stack usage is too close to the limit".
>
> calcurve <- cbind(1:2e4, 1:2e4, 1:2e3); #dummy curve, real one is more complex
>
> caldist <- function(cage=Cage, error=Error, sdev=Sdev, times=Times, By=By)
>  {
>   theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);
>
>   interpolate <- function(th, col)
>{
> if(th==calcurve[1,1]) {calcurve[1,col]}else
> if(th==calcurve[nrow(calcurve),1]) {calcurve[nrow(calcurve),col]}else
>  {
>   k <- min(which(calcurve[,1] > th));
>   slope <-
> (calcurve[k-1,col]-calcurve[k,col])/(calcurve[k-1,1]-calcurve[k,1]);
>   calcurve[k-1,col] + slope*(th-calcurve[k-1,1]);
>  }
>}
>
>   mu <- c();
>   cerror <- c();
>   for(i in 1:length(theta))
>{
> mu[i] <- interpolate(theta[i],2);
> cerror[i] <- interpolate(theta[i],3);
>}
>
>   caldist <- dnorm(mu, cage, (error^2+cerror^2)^.5);
>   cbind(theta, caldist/sum(caldist));
>  }
>
> caldist(1e3,1e2);
>
> Unfortunately I am no huge computer wizard. Has anyone got any idea
> why this happens? Is it reproducible on other machines? How can I
> solve this problem?
>
> My R:
> R version 2.6.1 (2007-11-26)
> i486-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] rcompgen_0.1-17
>
> Cstack_info()
>   sizecurrent  direction eval_depth
>8388608   2404  1  2
>
> Many thanks,
>
> Maarten Blaauw
>
> --
> Dr. Maarten Blaauw
> School of Geography, Archaeology & Palaeoecology
> Queen's University Belfast, U.K.
> On leave from Department of Earth Sciences
> Uppsala University, Sweden
> [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.
>



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

What is the problem you are trying to solve?

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


Re: [R] How to apply the wilcox_test function to subsets ?

2008-01-26 Thread David Winsemius
"Dupouey Jean-Luc" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

On my system wilcox.test() exists, whereas wilcox_test() did not.  
Help.search("wilcox_test") does not produce any clues. If you are using 
a test from another package, you should specify which package the test 
comes from. Web searching produces links to package coin.

Have you tried?

wtest <- by(mydata, mydata$myindice, function (x) {
 wilcox_test(value~fact, data=x)})

slight modification to the wilcox_test example data--
> mydata
 pd age grp
1  0.80 At term   1
2  0.83 At term   2
3  1.89 At term   1
4  1.04 At term   2
5  1.45 At term   1
6  1.38 At term   2
7  1.91 At term   1
8  1.64 At term   2
9  0.73 At term   1
10 1.46 At term   2
11 1.15 12-26 Weeks   1
12 0.88 12-26 Weeks   2
13 0.90 12-26 Weeks   1
14 0.74 12-26 Weeks   2
15 1.21 12-26 Weeks   1
16 1.10 12-26 Weeks   2
> wilcoxtest <- by(mydata, mydata$grp, function(x)
+ {wilcox_test(pd~age, data=x)}
+ )
> wilcoxtest

Asymptotic Wilcoxon Mann-Whitney Rank Sum Test

data:  pd by age (12-26 Weeks, At term) 
Z = -0.4472, p-value = 0.6547
alternative hypothesis: true mu is not equal to 0 

---

Asymptotic Wilcoxon Mann-Whitney Rank Sum Test

data:  pd by age (12-26 Weeks, At term) 
Z = -1.3416, p-value = 0.1797
alternative hypothesis: true mu is not equal to 0 

-- 
David Winsemius


> I want to apply a Wilcoxon test on subsets of the data frame mydata,
> splitted using the myindice variable. When I send :
> 

> wilcoxtest <- by(mydata, mydata$myindice, function(x)
> {wilcox_test(x$value~x$fact)})
> 

> I get :
> 
> Error in eval(expr, envir, enclos) : object "x" not found
> 
> whereas 
>
> wilcoxtest <- by(mydata, mydata$myindice, function(x)
> {wilcox.test(x$value~x$fact)})

> works !

> Why does it fail with the wilcox_test only? And, most important, how
> can I apply the wilcox_test function to subsets of mydata splitted
> according to mydata$myindice ?
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
Gabor Grothendieck wrote:
> Please clarify.  What happens?

ok!
I start up the R, load my file by win menu: "Load Workspace",
ls() show-me variables!
Then, I save my workspace with other name (test2.rdata, for example) and 
close my E session.

When I start up R by double-click in my new RData file (test2.rdata) and 
prompted the command ls(),
this show-me:
 > ls()
character(0)
 >
and I don't see my variables...

One information that I don't mentioned:

My Rprofile.site have dozen of personal functions, but all *very simple 
functions*,
I don't make change in defaults settings...

Cleber








___ 

Experimente já e veja as novidades.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Gabor Grothendieck
Please clarify.  What happens?

On Jan 26, 2008 5:02 PM, Cleber Nogueira Borges <[EMAIL PROTECTED]> wrote:
>
> hi,
> I tried this approach, but don't work too!
> (Duncan Murdoch make this suggestion)
>
> Cleber
>
> > OK.  The system only knows about one R version.
> >
> > What about the answer to my original second question.
> > If you start up R and then load the .Rdata file (which you
> > previously indicated works) and then
> > save your workspace using a different name from the original
> > Rdata file and then double click on that new Rdata file does
> > that get you the variables in the new Rdata file?
> >
>
>
>
>
> ___
>
> Yahoo! Mail - Sempre a melhor opção para você!
> Experimente já e veja as novidades.
> http://br.yahoo.com/mailbeta/tudonovo/
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An R clause to bind dataframes under certain contions

2008-01-26 Thread John Kane
Have a look at rbind.fill() in the reshape library. 
This will return a data.frame not a matrix but you can
always convert it to a matrix.


--- zhihuali <[EMAIL PROTECTED]> wrote:

> 
> Hi netters,
> Suppose I have two data frames X and Y. X has three
> colnames A, B and C. Y has three colnames A,B and D.
> 
> I want to combine them into one matrix, joining the
> rows having the same A and B values (X$A==Y$A and
> X$B = Y$B). So the resulting dataframe has four
> variables/columns: A,B,C and D.
> 
> I was wondering what's the best way to do it in R. 
> Could anyone give me some advice?
> 
> Thanks!
> 
> Zhihua Li
> 
> 
>
_
> ÊÖ»úÒ²ÄÜÉÏ MSN ÁÄÌìÁË£¬¿ìÀ´ÊÔÊÔ°É£¡
> 
>   [[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] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges

hi,
I tried this approach, but don't work too!
(Duncan Murdoch make this suggestion)

Cleber

> OK.  The system only knows about one R version.
>
> What about the answer to my original second question.
> If you start up R and then load the .Rdata file (which you
> previously indicated works) and then
> save your workspace using a different name from the original
> Rdata file and then double click on that new Rdata file does
> that get you the variables in the new Rdata file?
>   




___ 

Experimente já e veja as novidades.

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


[R] Error: C stack usage is too close to the limit

2008-01-26 Thread Maarten Blaauw
Lately R has been behaving strange on my Linux (Ubuntu 7.10) machine,  
with occasional segfaults. Today something else and reproducible  
happened:

If I type the code below (meant for calibrating data), I get the error  
message that "the C stack usage is too close to the limit".

calcurve <- cbind(1:2e4, 1:2e4, 1:2e3); #dummy curve, real one is more complex

caldist <- function(cage=Cage, error=Error, sdev=Sdev, times=Times, By=By)
  {
   theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);

   interpolate <- function(th, col)
{
 if(th==calcurve[1,1]) {calcurve[1,col]}else
 if(th==calcurve[nrow(calcurve),1]) {calcurve[nrow(calcurve),col]}else
  {
   k <- min(which(calcurve[,1] > th));
   slope <-  
(calcurve[k-1,col]-calcurve[k,col])/(calcurve[k-1,1]-calcurve[k,1]);
   calcurve[k-1,col] + slope*(th-calcurve[k-1,1]);
  }
}

   mu <- c();
   cerror <- c();
   for(i in 1:length(theta))
{
 mu[i] <- interpolate(theta[i],2);
 cerror[i] <- interpolate(theta[i],3);
}

   caldist <- dnorm(mu, cage, (error^2+cerror^2)^.5);
   cbind(theta, caldist/sum(caldist));
  }

caldist(1e3,1e2);

Unfortunately I am no huge computer wizard. Has anyone got any idea  
why this happens? Is it reproducible on other machines? How can I  
solve this problem?

My R:
R version 2.6.1 (2007-11-26)
i486-pc-linux-gnu

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

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

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17

Cstack_info()
   sizecurrent  direction eval_depth
8388608   2404  1  2

Many thanks,

Maarten Blaauw

-- 
Dr. Maarten Blaauw
School of Geography, Archaeology & Palaeoecology
Queen's University Belfast, U.K.
On leave from Department of Earth Sciences
Uppsala University, Sweden
[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] [R-pkgs] RSQLite 0.6-7 -- changes to dbGetQuery semantics

2008-01-26 Thread Seth Falcon
RSQLite 0.6-7 has been uploaded to CRAN and should hit a mirror near
you in the next few days.

This version changes the behavior of the dbGetQuery method to make it
more consistent with dbSendQuery.  Specifically:

1. dbGetQuery now closes a complete result set as dbSendQuery does.

2. If there is an incomplete result set open, dbGetQuery still opens a
   new temporary connection, but now issues a warning.  It is best
   practice to explicitly close open result sets before issuing
   further queries.

These changes are in response to the following discussion on the
r-sig-db list:

https://stat.ethz.ch/pipermail/r-sig-db/2008q1/000399.html

+ seth

-- 
Seth Falcon | [EMAIL PROTECTED] | blog: http://userprimary.net/user/

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

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


Re: [R] double-click in RData file versus load( file )

2008-01-26 Thread Gabor Grothendieck
OK.  The system only knows about one R version.

What about the answer to my original second question.
If you start up R and then load the .Rdata file (which you
previously indicated works) and then
save your workspace using a different name from the original
Rdata file and then double click on that new Rdata file does
that get you the variables in the new Rdata file?

On Jan 26, 2008 4:23 PM, Cleber Nogueira Borges <[EMAIL PROTECTED]> wrote:
> hello Gabor,
>
> the result in combobox is:
>
> R version 2.6.1 (2007-11-26) - C:\R
>
> I not have Perl installed! I remember that I deleted it!
>
>
> > Just double click on Rversions.hta from Windows Explorer.
> > Alternately place it anywhere in your path and then enter
> > its name in the Windows console without arguments:
> >
> > Rversions.hta
> >
> > Rversions.bat and all the other utilities wor the same way.  Neither
> > Rversions.hta nor any of the other programs require that you be in
> > the R directory and, in fact, its probably better that you are not since
> > if you are then it ignores the registry and assumes the version of
> > R you are in is your current version.
> >
> > Rfind.bat could not find Perl.  It looks in a few common places.  Its still
> > possible you have Perl installed but its not in the places it knows
> > about.
> >
> > There is some info in the README also at http://batchfiles.googlecode.com
> >
> >
>
>
>
>
> ___
>
> Yahoo! Mail - Sempre a melhor opção para você!
> Experimente já e veja as novidades.
> http://br.yahoo.com/mailbeta/tudonovo/
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
hello Gabor,

the result in combobox is:

R version 2.6.1 (2007-11-26) - C:\R

I not have Perl installed! I remember that I deleted it!


> Just double click on Rversions.hta from Windows Explorer.
> Alternately place it anywhere in your path and then enter
> its name in the Windows console without arguments:
>
> Rversions.hta
>
> Rversions.bat and all the other utilities wor the same way.  Neither
> Rversions.hta nor any of the other programs require that you be in
> the R directory and, in fact, its probably better that you are not since
> if you are then it ignores the registry and assumes the version of
> R you are in is your current version.
>
> Rfind.bat could not find Perl.  It looks in a few common places.  Its still
> possible you have Perl installed but its not in the places it knows
> about.
>
> There is some info in the README also at http://batchfiles.googlecode.com
>
>   




___ 

Experimente já e veja as novidades.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An R clause to bind dataframes under certain contions

2008-01-26 Thread Henrique Dallazuanna
On 26/01/2008, David Winsemius <[EMAIL PROTECTED]> wrote:
> "Henrique Dallazuanna" <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]:
>
> > Try this:
> > merge(x, y, all=T)
>
> That will give 's in the non-matching rows, which may be what the
> OP wanted. If, on the otherhand, only the rows with matches were
> desired, the usage might be:

In this case omit 'all' argument.

mymerge1 <- merge(mymat, mymat2)

> A.B <- merge(X, Y, by = c("A","B"))
> A.B
>
> mymat<-data.frame(
> x=c(1,1,1,2,2,2,3,3,3),
> y=c(1,2,3,1,2,3,1,2,3),
> z=c(1,2,3,4,5,6,7,8,9))
>
>  mymat2<-data.frame(
> x=c(1,1,1,2,2,2,3,3,3),
> y=c(1,2,3,1,2,3,1,4,3),
> zz=c(1,7,3,5,5,6,10,8,20))
>
>  mymerge1 <- merge(mymat, mymat2, all=TRUE)
>
> > mymerge1
>x y  z zz
> 1  1 1  1  1
> 2  1 2  2  7
> 3  1 3  3  3
> 4  2 1  4  5
> 5  2 2  5  5
> 6  2 3  6  6
> 7  3 1  7 10
> 8  3 2  8 NA
> 9  3 3  9 20
> 10 3 4 NA  8
>
> mymerge2 <- merge(mymat, mymat2, by=c("x","y"))
>
> > mymerge2
>   x y z zz
> 1 1 1 1  1
> 2 1 2 2  7
> 3 1 3 3  3
> 4 2 1 4  5
> 5 2 2 5  5
> 6 2 3 6  6
> 7 3 1 7 10
> 8 3 3 9 20
>
>
> --
> David Winsemius
>
> >
> > On 26/01/2008, zhihuali <[EMAIL PROTECTED]> wrote:
> >>
> >> Hi netters,
> >> Suppose I have two data frames X and Y. X has three colnames A, B
> >> and C. Y has three colnames A,B and D.
> >>
> >> I want to combine them into one matrix, joining the rows having the
> >> same A and B values (X$A==Y$A and X$B = Y$B). So the resulting
> >> dataframe has four variables/columns: A,B,C and D.
> >>
> >> I was wondering what's the best way to do it in R.  Could anyone
> >> give me some advice?
> >>
> >> Thanks!
> >>
> >> Zhihua Li
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

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


Re: [R] An R clause to bind dataframes under certain contions

2008-01-26 Thread David Winsemius
"Henrique Dallazuanna" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> Try this:
> merge(x, y, all=T)

That will give 's in the non-matching rows, which may be what the 
OP wanted. If, on the otherhand, only the rows with matches were 
desired, the usage might be:

A.B <- merge(X, Y, by = c("A","B"))
A.B

mymat<-data.frame(
x=c(1,1,1,2,2,2,3,3,3),
y=c(1,2,3,1,2,3,1,2,3),
z=c(1,2,3,4,5,6,7,8,9))

 mymat2<-data.frame(
x=c(1,1,1,2,2,2,3,3,3),
y=c(1,2,3,1,2,3,1,4,3),
zz=c(1,7,3,5,5,6,10,8,20))

 mymerge1 <- merge(mymat, mymat2, all=TRUE)

> mymerge1
   x y  z zz
1  1 1  1  1
2  1 2  2  7
3  1 3  3  3
4  2 1  4  5
5  2 2  5  5
6  2 3  6  6
7  3 1  7 10
8  3 2  8 NA
9  3 3  9 20
10 3 4 NA  8

mymerge2 <- merge(mymat, mymat2, by=c("x","y"))

> mymerge2
  x y z zz
1 1 1 1  1
2 1 2 2  7
3 1 3 3  3
4 2 1 4  5
5 2 2 5  5
6 2 3 6  6
7 3 1 7 10
8 3 3 9 20


-- 
David Winsemius

> 
> On 26/01/2008, zhihuali <[EMAIL PROTECTED]> wrote:
>>
>> Hi netters,
>> Suppose I have two data frames X and Y. X has three colnames A, B
>> and C. Y has three colnames A,B and D. 
>>
>> I want to combine them into one matrix, joining the rows having the
>> same A and B values (X$A==Y$A and X$B = Y$B). So the resulting
>> dataframe has four variables/columns: A,B,C and D. 
>>
>> I was wondering what's the best way to do it in R.  Could anyone
>> give me some advice? 
>>
>> Thanks!
>>
>> Zhihua Li

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 apply the wilcox_test function to subsets ?

2008-01-26 Thread Dupouey Jean-Luc
Dear R-forumites,

 

I want to apply a Wilcoxon test on subsets of the data frame mydata,
splitted using the myindice variable. When I send :

 

wilcoxtest <- by(mydata, mydata$myindice, function(x)
{wilcox_test(x$value~x$fact)})

 

I get :

 

Error in eval(expr, envir, enclos) : object "x" not found

 

whereas 

 

wilcoxtest <- by(mydata, mydata$myindice, function(x)
{wilcox.test(x$value~x$fact)})

 

works !

 

Why does it fail with the wilcox_test only? And, most important, how can I
apply the wilcox_test function to subsets of mydata splitted according to
mydata$myindice ?

 

Thanks in advance,

 

Jean-Luc Dupouey

Forest Ecology and Ecophysiology Unit

INRA

54280 Champenoux

France

 

mail: [EMAIL PROTECTED]

 


[[alternative HTML version deleted]]

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


Re: [R] An R clause to bind dataframes under certain contions

2008-01-26 Thread Wensui Liu
Hi, Huali,
there is another way to do so

library(sqldf)
wanted <- sqldf("select * from X inner join Y on X.A = Y.A and X.B = Y.A")

2008/1/26 zhihuali <[EMAIL PROTECTED]>:
>
> Hi netters,
> Suppose I have two data frames X and Y. X has three colnames A, B and C. Y 
> has three colnames A,B and D.
>
> I want to combine them into one matrix, joining the rows having the same A 
> and B values (X$A==Y$A and X$B = Y$B). So the resulting dataframe has four 
> variables/columns: A,B,C and D.
>
> I was wondering what's the best way to do it in R.  Could anyone give me some 
> advice?
>
> Thanks!
>
> Zhihua Li
>
>
> _
> 手机也能上 MSN 聊天了,快来试试吧!
>
> [[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.
>
>



-- 
===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)
===
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An R clause to bind dataframes under certain contions

2008-01-26 Thread Henrique Dallazuanna
Try this:

merge(x, y, all=T)


On 26/01/2008, zhihuali <[EMAIL PROTECTED]> wrote:
>
> Hi netters,
> Suppose I have two data frames X and Y. X has three colnames A, B and C. Y 
> has three colnames A,B and D.
>
> I want to combine them into one matrix, joining the rows having the same A 
> and B values (X$A==Y$A and X$B = Y$B). So the resulting dataframe has four 
> variables/columns: A,B,C and D.
>
> I was wondering what's the best way to do it in R.  Could anyone give me some 
> advice?
>
> Thanks!
>
> Zhihua Li
>
>
> _
> 手机也能上 MSN 聊天了,快来试试吧!
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tutorial specific for R + unix

2008-01-26 Thread Wensui Liu
dear liviu,
first of all, i appreciate your insight.
i've been used r on windows for years and might use it on unix. i
understand r is similar across OSs. However, per my understanding,
still there is nontrivial difference between running on unix and
running on windows.
have a nice weekend.

On Jan 26, 2008 2:43 PM, Liviu Andronic <[EMAIL PROTECTED]> wrote:
> Hello,
>
>
> On 1/26/08, Wensui Liu <[EMAIL PROTECTED]> wrote:
> > dear all,
> > is there a tutorial specifically teaching how to use R under unix? it
> > seems most of them are about using r under window.
> > thank you so much!
>
> What exactly are you interested in: installing or using R? If it is
> the latter, R is "remarkably similar" on all platforms it runs on. As
> for the tutorials, you might be interested in these introductory
> (progressively more advanced) materials [1], [2] and [3].
>
> Liviu
>
> [1] http://oit.utk.edu/scc/RforSAS&SPSSusers.pdf
> [2] http://zoonek2.free.fr/UNIX/48_R/all.html
> [3] http://cran.at.r-project.org/doc/contrib/Farnsworth-EconometricsInR.pdf
>



-- 
===
WenSui Liu
Statistical Project Manager
ChoicePoint Precision Marketing
(http://spaces.msn.com/statcompute/blog)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Read stata file from internet?

2008-01-26 Thread Frank E Harrell Jr
Henrique Dallazuanna wrote:
> Try this:
> 
> tmpfile <- tempfile()
> download.file('http://www.stat.ucla.edu/projects/datasets/risk_project.dta',
> tmpfile)
> risk2 <- read.dta(tmpfile)
> unlink(tmpfile)

The stata.get function in the Hmisc package will automatically fetch 
from http://... and provides other features such as conversion of dates 
and using variable labels.

Frank

> 
> 
> On 26/01/2008, Michael Kubovy <[EMAIL PROTECTED]> wrote:
>> Dear R-helpers,
>>
>> I would like to have my students read into R an online Stata dataset: 
>> 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
>>
>> I was able to read it into R after downloading it and converting it
>> with StatTransfer (http://www.stattransfer.com/).
>>
>> Here is what happens when I use read.dta() as I would use read.table():
>>
>>> require(foreign)
>>> risk2 <- 
>>> read.dta('http://www.stat.ucla.edu/projects/datasets/risk_project.dta')
>>> Error in 
>>> read.dta("http://www.stat.ucla.edu/projects/datasets/risk_project.dta
>>> ") :
>>>   unable to open file
>> Then I try:
>>
>>> riskTmp <- 
>>> read.table('http://www.stat.ucla.edu/projects/datasets/risk_project.dta')
>>> Warning message:
>>> In read.table("http://www.stat.ucla.edu/projects/datasets/risk_project.dta
>>> ") :
>>>   incomplete final line found by readTableHeader on 
>>> 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
>>> head(riskTmp)
>>>  V1
>>> 1 l\001\001\300
>>> 2.%9.0g
>>> 3 \342CNTL%8.0g
 risk2 <- read.dta(riskTmp)
>>> Error in read.dta(riskTmp) : first argument must be a file name
>> So I tried to save riskTmp as a file, and read it in using read.dta():
>>
>>> save(riskTmp, file = 'risk.dta')
>>> risk2 <- read.dta('risk.dta')
>>> Error in read.dta("risk.dta") : not a Stata version 5-8 .dta file
>> But that presumably garbled the file. (Indeed, StatTransfer told me so.)
>>
>> Would it be appropriate to request this as a feature of
>> foreign::read.dta()? (Thomas Lumley is the author.)
>> _
>> Professor Michael Kubovy
>> University of Virginia
>> Department of Psychology
>> USPS: P.O.Box 400400Charlottesville, VA 22904-4400
>> Parcels:Room 102Gilmer Hall
>>  McCormick RoadCharlottesville, VA 22903
>> Office:B011+1-434-982-4729
>> Lab:B019+1-434-982-4751
>> Fax:+1-434-982-4766
>> WWW:http://www.people.virginia.edu/~mk9y/
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] An R clause to bind dataframes under certain contions

2008-01-26 Thread zhihuali

Hi netters,
Suppose I have two data frames X and Y. X has three colnames A, B and C. Y has 
three colnames A,B and D.

I want to combine them into one matrix, joining the rows having the same A and 
B values (X$A==Y$A and X$B = Y$B). So the resulting dataframe has four 
variables/columns: A,B,C and D.

I was wondering what's the best way to do it in R.  Could anyone give me some 
advice?

Thanks!

Zhihua Li


_
ÊÖ»úÒ²ÄÜÉÏ MSN ÁÄÌìÁË£¬¿ìÀ´ÊÔÊÔ°É£¡

[[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] interactive menu in scripts

2008-01-26 Thread WCD

Yes, the switch function works fine.
To store generated values in some variable I just use:
  switch(menu(c("Normal", "Uniform")), a<-rnorm(5), a<-runif(5))

But why does not work this? (I know there is waste of variables, but in
principle):
  b<-numeric(10)
  switch(menu(c("Normal", "Uniform")), a<-1, a<-2)
  if(a==1) {b<-rnorm(10)} else {b<-runif(10)}
When I run these commands from a script, the choice is offered after the
condition is performed, so "b" stores ten zeros.

Also readline() function seems to be what I am looking for. But I did not
manage to use it for my reason;  this does not work too:
  var<-numeric(5)
  rdf<-function() {
  x<-readline("Enter 1 for normal, 2 for uniform distribution ")
  if (x==1) {var<-rnorm(5)} else {var<-runif(5)}
  }
  rdf()

Even this does not work (object "x" is not found):
  rdf2<-function() {
  x<-readline("enter your year of birth ")
  }
  rdf2()

Can you see what am I doing wrong?

Anyway, I am sorry for my maybe bizzar explanations. I am quitr new to R and
R forum.
My aim is to write an R script, where the user can make some choices or set
some parameters via the R console. Filip Kral.


Henrique Dallazuanna wrote:
> 
> Try like this:
> 
> switch(menu(c("Normal", "Poisson")), rnorm(5), rpois(5, 3))
> 
> 
> On 25/01/2008, WCD <[EMAIL PROTECTED]> wrote:
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/interactive-menu-in-scripts-tp15095049p15111894.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] tutorial specific for R + unix

2008-01-26 Thread Liviu Andronic
Hello,

On 1/26/08, Wensui Liu <[EMAIL PROTECTED]> wrote:
> dear all,
> is there a tutorial specifically teaching how to use R under unix? it
> seems most of them are about using r under window.
> thank you so much!

What exactly are you interested in: installing or using R? If it is
the latter, R is "remarkably similar" on all platforms it runs on. As
for the tutorials, you might be interested in these introductory
(progressively more advanced) materials [1], [2] and [3].

Liviu

[1] http://oit.utk.edu/scc/RforSAS&SPSSusers.pdf
[2] http://zoonek2.free.fr/UNIX/48_R/all.html
[3] http://cran.at.r-project.org/doc/contrib/Farnsworth-EconometricsInR.pdf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Any numeric differentiation routine in R for boundary points?

2008-01-26 Thread Gabor Grothendieck
Reparameterize to

f(x, y) = sqrt(x*x) * exp(y*y)

On Jan 26, 2008 1:11 PM, roger chan <[EMAIL PROTECTED]> wrote:
>
> Hi, I have a scalar valued function with several variables. One of the
> variables is restricted to be non-negative. For example,
> f(x,y)=sqrt(x)*exp(y), then x should be non-negative. I need the
> gradient and hessian for some vector (0,y), i.e., I need the gradient and
> hessian at the boudary of parameter space.
>
> The "numderiv" package does not work, even for f(x)=sqrt(x), if you
> do "genD(f,x=0)", warning message comes out.
>
> I need the one sided derivatives.
>
> Thanks if you could provide some help.
> --
> View this message in context: 
> http://www.nabble.com/Any-numeric-differentiation-routine-in-R-for-boundary-points--tp15110811p15110811.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] Read stata file from internet?

2008-01-26 Thread Henrique Dallazuanna
Try this:

tmpfile <- tempfile()
download.file('http://www.stat.ucla.edu/projects/datasets/risk_project.dta',
tmpfile)
risk2 <- read.dta(tmpfile)
unlink(tmpfile)


On 26/01/2008, Michael Kubovy <[EMAIL PROTECTED]> wrote:
> Dear R-helpers,
>
> I would like to have my students read into R an online Stata dataset: 
> 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
>
> I was able to read it into R after downloading it and converting it
> with StatTransfer (http://www.stattransfer.com/).
>
> Here is what happens when I use read.dta() as I would use read.table():
>
> > require(foreign)
> > risk2 <- 
> > read.dta('http://www.stat.ucla.edu/projects/datasets/risk_project.dta')
> > Error in 
> > read.dta("http://www.stat.ucla.edu/projects/datasets/risk_project.dta
> > ") :
> >   unable to open file
>
> Then I try:
>
> > riskTmp <- 
> > read.table('http://www.stat.ucla.edu/projects/datasets/risk_project.dta')
> > Warning message:
> > In read.table("http://www.stat.ucla.edu/projects/datasets/risk_project.dta
> > ") :
> >   incomplete final line found by readTableHeader on 
> > 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
> > head(riskTmp)
> >  V1
> > 1 l\001\001\300
> > 2.%9.0g
> > 3 \342CNTL%8.0g
> > > risk2 <- read.dta(riskTmp)
> > Error in read.dta(riskTmp) : first argument must be a file name
>
> So I tried to save riskTmp as a file, and read it in using read.dta():
>
> > save(riskTmp, file = 'risk.dta')
> > risk2 <- read.dta('risk.dta')
> > Error in read.dta("risk.dta") : not a Stata version 5-8 .dta file
>
> But that presumably garbled the file. (Indeed, StatTransfer told me so.)
>
> Would it be appropriate to request this as a feature of
> foreign::read.dta()? (Thomas Lumley is the author.)
> _
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> USPS: P.O.Box 400400Charlottesville, VA 22904-4400
> Parcels:Room 102Gilmer Hall
>  McCormick RoadCharlottesville, VA 22903
> Office:B011+1-434-982-4729
> Lab:B019+1-434-982-4751
> Fax:+1-434-982-4766
> WWW:http://www.people.virginia.edu/~mk9y/
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

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


Re: [R] double-click in RData file versus load( file )

2008-01-26 Thread Gabor Grothendieck
When you double click it does it start up the same version of R
as when you manually start R?

If you manually start R, load it, save it under another name and
then exit R and double click the new name does that work?

On Jan 26, 2008 1:01 PM, Cleber Nogueira Borges <[EMAIL PROTECTED]> wrote:
> hello all,
>
> when I start up the R and I execute o follow code:
>
>  > ls()
> character(0)
>  > x=123
>  > assign("test_x", x, envir = .GlobalEnv )
>  > ls()
> [1] "test_x" "x"
>  > setwd('C:\\R\\etc')
>  > save.image('TEST.RData')
>  > q('no')
>
> I have two different behaviours:
>
> (a) - when I start up R again by "double click" in the file TEST.RData;
> (b) - when I start up R and load the file TEST.RData by window menu in
> Rgui or
> invoke by command ' load('C:\\R\\etc\\TEST.RData')
>
>
> In case (a): I can't see my previous variables anymore!
>  > ls()
> character(0)
>
>
> In case (b): I get my previous variables again!
>  > load('C:\\R\\etc\\test.rdata')
>  > ls()
> [1] "test_x" "x"
>  >
>
> Is it the correct behaviour?
> the two way don't must be the same?
>
>
> Thank for explanations...
>
> Cleber Borges
>
>
>
>
>
>
>
>
>
>
> ___
>
> Experimente já e veja as novidades.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Any numeric differentiation routine in R for boundary points?

2008-01-26 Thread roger chan

Hi, I have a scalar valued function with several variables. One of the
variables is restricted to be non-negative. For example, 
f(x,y)=sqrt(x)*exp(y), then x should be non-negative. I need the 
gradient and hessian for some vector (0,y), i.e., I need the gradient and
hessian at the boudary of parameter space. 

The "numderiv" package does not work, even for f(x)=sqrt(x), if you 
do "genD(f,x=0)", warning message comes out.

I need the one sided derivatives.

Thanks if you could provide some help.
-- 
View this message in context: 
http://www.nabble.com/Any-numeric-differentiation-routine-in-R-for-boundary-points--tp15110811p15110811.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] tutorial specific for R + unix

2008-01-26 Thread Wensui Liu
dear all,
is there a tutorial specifically teaching how to use R under unix? it
seems most of them are about using r under window.
thank you so much!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )

2008-01-26 Thread Duncan Murdoch
On 26/01/2008 1:01 PM, Cleber Nogueira Borges wrote:
> hello all,
> 
> when I start up the R and I execute o follow code:
> 
>  > ls()
> character(0)
>  > x=123
>  > assign("test_x", x, envir = .GlobalEnv )
>  > ls()
> [1] "test_x" "x" 
>  > setwd('C:\\R\\etc')
>  > save.image('TEST.RData')
>  > q('no')
> 
> I have two different behaviours:
> 
> (a) - when I start up R again by "double click" in the file TEST.RData;
> (b) - when I start up R and load the file TEST.RData by window menu in 
> Rgui or
> invoke by command ' load('C:\\R\\etc\\TEST.RData')
> 
> 
> In case (a): I can't see my previous variables anymore!

Which version of R are you using?  It works fine for me in 2.6.1.

What do you see when R starts?  It should display something like

> 
> R version 2.6.1 (2007-11-26)
> Copyright (C) 2007 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
> 
>   Natural language support but running in an English locale
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 
> [Previously saved workspace restored]



and the last line indicates the attempt to load the saved data.

Duncan Murdoch

>  > ls()
> character(0)
> 
> 
> In case (b): I get my previous variables again!
>  > load('C:\\R\\etc\\test.rdata')
>  > ls()
> [1] "test_x" "x"
>  >
> 
> Is it the correct behaviour?
> the two way don't must be the same?
> 
> 
> Thank for explanations...
> 
> Cleber Borges
> 
> 
> 
>  
> 
> 
>   
> 
>   
>   
> ___ 
> 
> Experimente já e veja as novidades.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Function for translation of a list into a matrix as used by ordination?

2008-01-26 Thread Henrique Dallazuanna
Try this also:

 noquote(tapply(x$Abundance, list(x$Plot, x$Species), paste))

On 25/01/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello.
>
> Does anyone know of an existing function that takes a list in the form of:
>
> Plot1 Species1Abundance1
> Plot1 Species2Abundance2
> Plot2 Species1Abundance1
> Plot2 Species3Abundance3
> .
> .
> .
> PlotN SpeciesNAbundanceN
>
> and translates into a matrix in the form of
>
>   Species1Species2  SpeciesN
> Plot1 Abundance1  Abundance2... AbundanceN
> Plot2 Abundance1  Abundance2... AbundanceN
> .
> .
>
> .
> PlotN AbundanceN  AbundanceN... AbundanceN
>
>
> This is a basic operation used in the initial stages of ordination etc of
> ecological data (vegetation or other species) that is usually stored in a
> database or flatfile in the list format above. It is similar to a cross
> tabulation like the function xtabs(), however its useful to be able to
> control whether a measured abundance for a taxa is included or a boolean
> (presence/absence) for the taxa in a given plot.
>
> Im new to such analyses in R, but before writing it myself hope or suspect
> that such a function or library is out there (although I dont see it after
> some quick searching in things like Vegan or BiodivesityR or labdsv).
>
>
> Thanks
> billy
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

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


[R] double-click in RData file versus load( file )

2008-01-26 Thread Cleber Nogueira Borges
hello all,

when I start up the R and I execute o follow code:

 > ls()
character(0)
 > x=123
 > assign("test_x", x, envir = .GlobalEnv )
 > ls()
[1] "test_x" "x" 
 > setwd('C:\\R\\etc')
 > save.image('TEST.RData')
 > q('no')

I have two different behaviours:

(a) - when I start up R again by "double click" in the file TEST.RData;
(b) - when I start up R and load the file TEST.RData by window menu in 
Rgui or
invoke by command ' load('C:\\R\\etc\\TEST.RData')


In case (a): I can't see my previous variables anymore!
 > ls()
character(0)


In case (b): I get my previous variables again!
 > load('C:\\R\\etc\\test.rdata')
 > ls()
[1] "test_x" "x"
 >

Is it the correct behaviour?
the two way don't must be the same?


Thank for explanations...

Cleber Borges



 






___ 

Experimente já e veja as novidades.

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

2008-01-26 Thread Henrique Dallazuanna
Try like this:

switch(menu(c("Normal", "Poisson")), rnorm(5), rpois(5, 3))


On 25/01/2008, WCD <[EMAIL PROTECTED]> wrote:
>
> Hello, I would like to make my R script more interactive. Well, I want the
> script to work like this:
>
> I run the script from R Console and it offers me some options (press 1 for
> something, or press 2 for something else). After pressing 1 or 2, do
> corresponding procedure.
>
> I am not able to find out how to do this. I guess the functions menu() or
> switch() are the keys, but I didn't manage to use them properly. Can you
> help me? Are there some more practical examples on the web?
> Tahnks, Filip Kral.
> --
> View this message in context: 
> http://www.nabble.com/interactive-menu-in-scripts-tp15095049p15095049.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.
>


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

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


Re: [R] interactive menu in scripts

2008-01-26 Thread Michał Bojanowski

Hi,

Not going into the reason why would you like to do such a thing anyway, I
would suggest:

1. Creating an R file that would  contain all the functionality coded in
functions.

2. The only executed code would be a function that calls the menu() and
executes the appropriate functions.

Sources of existing packages provide a good reference. Have a look for
example on the sources of plot.eff.list in the package 'effects'.

HTH,

Michal




Sources of existing packa



WCD wrote:
> 
> Hello, I would like to make my R script more interactive. Well, I want the
> script to work like this:
> 
> I run the script from R Console and it offers me some options (press 1 for
> something, or press 2 for something else). After pressing 1 or 2, do
> corresponding procedure.
> 
> I am not able to find out how to do this. I guess the functions menu() or
> switch() are the keys, but I didn't manage to use them properly. Can you
> help me? Are there some more practical examples on the web?
> Tahnks, Filip Kral.
> 


-

Michal Bojanowski
ICS / Department of Sociology
Utrecht University
Heidelberglaan 2; 3584 CS Utrecht
The Netherlands
m.j.bojanowski at uu dot nl
http://www.fss.uu.nl/soc/bojanowski/
http://bojan.3e.pl/

-- 
View this message in context: 
http://www.nabble.com/interactive-menu-in-scripts-tp15095049p15110587.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] Which R version created a package?

2008-01-26 Thread Charles Annis, P.E.
Many thanks to all.  These methods all provide the needed info:

library(help= lattice)

packageDescription("lattice ", fields="Built")

packageDescription("lattice")$Built

The first method produces nore complete information, should that also be
interesting.


Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Gabor Csardi
Sent: Saturday, January 26, 2008 12:05 PM
To: Charles Annis, P.E.
Cc: 'RHelp'
Subject: Re: [R] Which R version created a package?

> library(help=lattice)
[...]
Built: R 2.6.0; i486-pc-linux-gnu; 2008-01-23 13:52:49; unix
[...]

G.

On Sat, Jan 26, 2008 at 11:44:53AM -0500, Charles Annis, P.E. wrote:
> Greetings, R-ians:
> 
>  
> 
> I would like to know which version or R was used to create a given
package.
> I think I remember seeing that topic discussed recently but cannot find it
> among my notes.  Can anyone tell me how to determine which version of R
> created a package?
> 
>  
> 
> Thanks.
> 
>  
> 
> Charles Annis, P.E.
> 
>  
> [EMAIL PROTECTED]
> phone: 561-352-9699
> eFax:  614-455-3265
>  
> http://www.StatisticalEngineering.com
> 
>  
> 
>  
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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

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

2008-01-26 Thread Uwe Ligges
hits=-2.6 tests=BAYES_00
X-USF-Spam-Flag: NO

Dear Geoff,

scatterplot3d was never intended to draw a plot for categorical data, 
but you can tweak it as follows:


-  Note that the help page says (stolen from ?par) "The values of x and 
y give the (approximate) number of tickmarks on the x and y axes." where 
"approximate" is stressed in this context. It works for me to use lab = 
c(2,2)

-  add argument mar = c(3,3,3,3)

-  add argument y.margin.add = 0.15,


Best,
Uwe

Geoff Russell wrote:
> Dear users,
> 
> I'm trying to produce a 3d bar plot but the x and y dimensions have 
> categorical
> data -- so I only want 3 points on each axis. So I try:
> 
> 
> require(scatterplot3d)
> 
>mymat<-data.frame(
>x=c(1,1,1,2,2,2,3,3,3),
>y=c(1,2,3,1,2,3,1,2,3),
>z=c(1,2,3,4,5,6,7,8,9))
>scatterplot3d(mymat,
>type="h", lwd=5, pch=" ",
>xlab="xlabel", ylab="ylabel", zlab="zlabel",
>xlim=c(1,3), ylim=c(1,3),
>lab=c(3,3),
>x.ticklabs=c("Low","Medium","High"), y.ticklabs=c("Green","Blue","Black"),
>main="My Bar Plot")
> 
> But I still get x ticks at 1, 1.5, 2, 2.5, 3 on both x and y axes. I
> thought lab
> controlled this (according to the documentation).
> 
> What am I doing wrong, or is there some restriction on the way the
> function works?
> 
> Cheers,
> Geoff Russell
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Which R version created a package?

2008-01-26 Thread Duncan Murdoch
On 26/01/2008 11:44 AM, Charles Annis, P.E. wrote:
> Greetings, R-ians:
> 
>  
> 
> I would like to know which version or R was used to create a given package.
> I think I remember seeing that topic discussed recently but cannot find it
> among my notes.  Can anyone tell me how to determine which version of R
> created a package?

You can see which version was used to build the package by looking in 
the DESCRIPTION file; that information is available in R via something like

  packageDescription("graphics", fields="Built")

Duncan Murdoch
>  
> 
> Thanks.
> 
>  
> 
> Charles Annis, P.E.
> 
>  
> [EMAIL PROTECTED]
> phone: 561-352-9699
> eFax:  614-455-3265
>  
> http://www.StatisticalEngineering.com
> 
>  
> 
>  
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Which R version created a package?

2008-01-26 Thread Gabor Grothendieck
These also works should you need to capture it:

packageDescription("lattice")$Built

On Jan 26, 2008 12:04 PM, Gabor Csardi <[EMAIL PROTECTED]> wrote:
> > library(help=lattice)
> [...]
> Built: R 2.6.0; i486-pc-linux-gnu; 2008-01-23 13:52:49; unix
> [...]
>
> G.
>
>
> On Sat, Jan 26, 2008 at 11:44:53AM -0500, Charles Annis, P.E. wrote:
> > Greetings, R-ians:
> >
> >
> >
> > I would like to know which version or R was used to create a given package.
> > I think I remember seeing that topic discussed recently but cannot find it
> > among my notes.  Can anyone tell me how to determine which version of R
> > created a package?
> >
> >
> >
> > Thanks.
> >
> >
> >
> > Charles Annis, P.E.
> >
> >  
> > [EMAIL PROTECTED]
> > phone: 561-352-9699
> > eFax:  614-455-3265
> >  
> > http://www.StatisticalEngineering.com
> >
> >
> >
> >
> >
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> --
> Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Which R version created a package?

2008-01-26 Thread Gabor Csardi
> library(help=lattice)
[...]
Built: R 2.6.0; i486-pc-linux-gnu; 2008-01-23 13:52:49; unix
[...]

G.

On Sat, Jan 26, 2008 at 11:44:53AM -0500, Charles Annis, P.E. wrote:
> Greetings, R-ians:
> 
>  
> 
> I would like to know which version or R was used to create a given package.
> I think I remember seeing that topic discussed recently but cannot find it
> among my notes.  Can anyone tell me how to determine which version of R
> created a package?
> 
>  
> 
> Thanks.
> 
>  
> 
> Charles Annis, P.E.
> 
>  
> [EMAIL PROTECTED]
> phone: 561-352-9699
> eFax:  614-455-3265
>  
> http://www.StatisticalEngineering.com
> 
>  
> 
>  
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <[EMAIL PROTECTED]>UNIL DGM

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


[R] Which R version created a package?

2008-01-26 Thread Charles Annis, P.E.
Greetings, R-ians:

 

I would like to know which version or R was used to create a given package.
I think I remember seeing that topic discussed recently but cannot find it
among my notes.  Can anyone tell me how to determine which version of R
created a package?

 

Thanks.

 

Charles Annis, P.E.

 
[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
 
http://www.StatisticalEngineering.com

 

 


[[alternative HTML version deleted]]

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


[R] how to use anova() to test the sum of coefficients in nlme package

2008-01-26 Thread shirley zhang
Dear R-help,

In nlme package, anova () can be used to test the difference between
two coefficients as shown on page 225
of "Mixed Effects Models in S and S-Plus":

anova(fm2BW.lme, L = c("Time:Diet2" = 1, "Time:Diet3" = -1))

Now my question is instead of test the difference between two
coefficients, can I use anova to test the significance of the sum of
two coefficients, like

anova(fm2BW.lme, L = c("Time:Diet2" = 1, "Time:Diet3" = 1))

Thanks,

Shirley

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

2008-01-26 Thread Gabor Grothendieck
Try this (adding 0 converts the logicals to numeric):

rowsum((X > 0)+0, group)


On Jan 26, 2008 9:13 AM, Anders Bjørgesæter <[EMAIL PROTECTED]> wrote:
> Hello
>
> Is there an analogous function to "rowsum" that count the numbers
> according to a given vector (preferably larger than a given value)
> instead of summing them?
>
> E.g. rowsum(x, group)
>
> X is the dataframe, A   B   C
>5   0   0
>1   3   3
>0   1   12
> and group is the vector; 1,1,2
>
> rowsum gives:   A   B   C
>1   6   3   3
>2   0   1   12
>
>
> I want: A   B   C
>1   2   1   1
>2   0   1   1
>
> for e.g. count all > 0.
>
> Best Regards
> Anders
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Capturing info from system calls in Windows

2008-01-26 Thread Duncan Murdoch
On 26/01/2008 9:17 AM, Dennis Fisher wrote:
> Colleagues,
> 
> I am preparing scripts that will be used by others on both Windows and  
> Linux/OSX platforms.  The scripts call an existing Fortran  
> application.  The user may have any of a a variety of Fortran  
> compilers - my goal is to determine whether or not the test command  
> returns "no input files" or "command not found" (i.e., so that I can  
> confirm which Fortran they are using).
> 
> In OS X and Linux, I can do the following:
>>> TEST <- system("g77 2>&1", intern=TRUE)
>>> TEST
>> [1] "g77: no input files"
>>
>>> TEST <- system("f77 2>&1", intern=TRUE)
>>> TEST
>> [1] "sh: f77: command not found"
> I can then use grep to determine which of the two strings was returned.
> 
> In Windows:
>>> TEST <- system("g95 2>&1")
>> g95: 2>&1: Invalid argument
>>> TEST
>> [1] 0
>> attr(, "exec.status"):
>> [1] 0
>> attr(, "exit.status"):
>> [1] 0
>>> TEST <- system("g95")
>> g95: no input files
>>> TEST
>> [1] 0
>> attr(, "exec.status"):
>> [1] 0
>> attr(, "exit.status"):
>> [1] 0
> 
> As you can see, Windows replies "no input files"; however, that info  
> is not captured in TEST.  I presume that this is because standard  
> error is dealt with different in Windows compared to Unix-line  
> platforms.  Any thoughts on how to capture standard error in Windows?

See ?system.  You want intern=TRUE there, too.

 > system("gcc")
gcc.exe: no input files
 > system("gcc", intern=TRUE)
[1] "gcc.exe: no input files"


Duncan Murdoch

> 
> Dennis
> 
> 
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone: 1-866-PLessThan (1-866-753-7784)
> Fax: 1-415-564-2220
> www.PLessThan.com
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

2008-01-26 Thread jim holtman
Is this what you are looking for in doing computations on the columns
of a dataframe?

> x <- 
> data.frame(group=sample(1:2,10,TRUE),A=sample(1:4,10,TRUE),B=sample(1:5,10,TRUE),
+ C=sample(1:3,10,TRUE))
> x
   group A B C
1  1 2 4 1
2  2 4 1 2
3  1 3 2 1
4  2 3 2 2
5  2 4 2 2
6  1 2 5 1
7  2 1 5 2
8  1 1 5 3
9  1 4 3 2
10 2 2 1 1
> # sum in each column
> aggregate(x[,-1], list(x$group), sum)
  Group.1  A  B C
1   1 12 19 8
2   2 14 11 9
> # count greater than 2
> aggregate(x[,-1], list(x$group),function(.col) sum(.col>2))
  Group.1 A B C
1   1 2 4 1
2   2 3 1 0
>
>


On Jan 26, 2008 9:13 AM, Anders Bjørgesæter <[EMAIL PROTECTED]> wrote:
> Hello
>
> Is there an analogous function to "rowsum" that count the numbers
> according to a given vector (preferably larger than a given value)
> instead of summing them?
>
> E.g. rowsum(x, group)
>
> X is the dataframe, A   B   C
>5   0   0
>1   3   3
>0   1   12
> and group is the vector; 1,1,2
>
> rowsum gives:   A   B   C
>1   6   3   3
>2   0   1   12
>
>
> I want: A   B   C
>1   2   1   1
>2   0   1   1
>
> for e.g. count all > 0.
>
> Best Regards
> Anders
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem you are trying to solve?

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


[R] Capturing info from system calls in Windows

2008-01-26 Thread Dennis Fisher
Colleagues,

I am preparing scripts that will be used by others on both Windows and  
Linux/OSX platforms.  The scripts call an existing Fortran  
application.  The user may have any of a a variety of Fortran  
compilers - my goal is to determine whether or not the test command  
returns "no input files" or "command not found" (i.e., so that I can  
confirm which Fortran they are using).

In OS X and Linux, I can do the following:
> > TEST <- system("g77 2>&1", intern=TRUE)
> > TEST
> [1] "g77: no input files"
>
> > TEST <- system("f77 2>&1", intern=TRUE)
> > TEST
> [1] "sh: f77: command not found"
I can then use grep to determine which of the two strings was returned.

In Windows:
> > TEST <- system("g95 2>&1")
> g95: 2>&1: Invalid argument
> > TEST
> [1] 0
> attr(, "exec.status"):
> [1] 0
> attr(, "exit.status"):
> [1] 0
> >
> > TEST <- system("g95")
> g95: no input files
> > TEST
> [1] 0
> attr(, "exec.status"):
> [1] 0
> attr(, "exit.status"):
> [1] 0

As you can see, Windows replies "no input files"; however, that info  
is not captured in TEST.  I presume that this is because standard  
error is dealt with different in Windows compared to Unix-line  
platforms.  Any thoughts on how to capture standard error in Windows?

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com


[[alternative HTML version deleted]]

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


[R] rowsum- is there a countsum

2008-01-26 Thread Anders Bjørgesæter
Hello

Is there an analogous function to ”rowsum” that count the numbers 
according to a given vector (preferably larger than a given value) 
instead of summing them?

E.g. rowsum(x, group)

X is the dataframe, A   B   C
5   0   0
1   3   3
0   1   12
and group is the vector; 1,1,2

rowsum gives:   A   B   C
1   6   3   3
2   0   1   12


I want: A   B   C
1   2   1   1
2   0   1   1

for e.g. count all > 0.

Best Regards
Anders

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


Newsletter: Vielen dank f�r ihre Anmeldung!

2008-01-26 Thread steinfeuerfred
Hallo,

Ihre E-Mailadresse "[EMAIL PROTECTED]" wurde in den Newsletterverteiler 
hinzugefügt.

URL: http://www.fueralles.de/cgi-bin/nsl_pro/newsletter.cgi?id=steinfeuerfred

Mit freundlichen Grüssen Ihr Newsletter-Team

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 facet_grid() from ggplot2 with additional text in labels

2008-01-26 Thread Rainer M Krug
Hi

I am using ggplot2 at the moment and I must say it is definitely better 
then ggplot - good work.

My problem is that I am using facet_grid() in the following way:

 > p <- ggplot(ssq, aes(x=year, y=-log(ssq)))
 > p + geom_point() + facet_grid(me*gi~cs*rz)

and it works nicely, except that I would like to have, in naddition to 
the values of me, gi, cs and rz the name of the variable. I.e: if gi is 
1, 2 and 3 I would like to have "gi = 1:", "gi = 2" and "gi = 3" as 
labels of the p[anels. I did it with ggplot, but I don't remember and I 
have lost the code ...

Just a small comment on the package: as I am using emacs with ess, I 
have to press "_" twice to get the underscore in the commands (as the 
first one is replaced with "->" and then reverted to "_") - would it be 
possible to change these in the next release with "." (but still provide 
an alias with "_")?

Thanks a lot

Rainer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sending the same e-mail many times (was "no subject")

2008-01-26 Thread Martin Maechler
Dear Alyaa,

you've now sent this message in many different forms to the
R-help mailing list.

The fact that you did not get a response may very well be
related to the way you asked your question,
but also that it probably is not an easy question to answer.

But sending your e-mail repeatedly to *several thousand*
people is considered *very* impolite.


> "aw" == alyaa wakf <[EMAIL PROTECTED]>
> on Sat, 26 Jan 2008 02:12:25 -0800 (PST) writes:

aw> Hi,   The following code, from Angelo Canty article on line 
"Resampling Methods in R: the boot Package, 2002",  works fine for Angelo Canty 
using  R 2.6.0 on Windows XP.   
aw> It also works for me using  R 1.2.1 and S-PLUS 2000 on  Windows XP 
after installing the S-PLUS  bootstrap library, with slight differences in my 
outputs.
   
[.]


the footer here tells us that you still don't follow the posting
guide (namely, not sending HTML) even though you may have
started doing so  by trying to produce reproducible code.

Regards,
Martin Maechler, ETH Zurich

aw> -

aw> [[alternative HTML version deleted]]

aw> __
aw> R-help@r-project.org mailing list
aw> https://stat.ethz.ch/mailman/listinfo/r-help
aw> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
aw> 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] Who can tell me how I adjust the R code for bootstrapping the Cox model?

2008-01-26 Thread alyaa wakf
Hi,
   
  The following code, from Angelo Canty article on line "Resampling Methods in 
R: the boot Package, 2002",  works fine for Angelo Canty using  R 2.6.0 on 
Windows XP.   
  It also works for me using  R 1.2.1 and S-PLUS 2000 on  Windows XP after 
installing the S-PLUS  bootstrap library, with slight differences in my outputs.
   
  > library(boot)
> library(survival)
> set.seed(12345)
  > mel <- melanoma[melanoma$ulcer==1,]
  > mel$cens <- 1*(mel$status==1)
  > mel.cox <- coxph(Surv(time, status==1)~thickness,
  + data=mel)
  > mel.surv <- survfit(mel.cox)
  > mel.cens <- survfit(Surv(time-0.001*(status==1),status!=1)~1,
  + data=mel)
  > mel.fun <- function(d) {
  + cox <- coxph(Surv(time, status==1)~thickness,
  + data=d)
  + cox$coefficients}
  > mel.boot.con <- censboot(mel, mel.fun, R=999, sim="cond", 
  + F.surv=mel.surv, G.surv=mel.cens,
  + cox=mel.cox, index=c(1,8))
  > mel.boot.con
   
  CONDITIONAL BOOTSTRAP FOR CENSORED DATA

Call:
censboot(data = mel, statistic = mel.fun, R = 999, F.surv = mel.surv, 
G.surv = mel.cens, sim = "cond", cox = mel.cox, index = c(1, 
8))

Bootstrap Statistics :
  original biasstd. error
t1* 0.09967665 0.03579701  0.04973614

   
  I want to apply the Fast bootstrap method from Salibian-Barrera and Zamar 
(2003) and  Salibian-Barrera, M., Van Aels, S. and Willems, G. (2007) to the 
previous example, i.e., to produce a confidence interval for the exponent of 
the coefficient of tumour thickness in the Melanoma dataset .  Moreover,  I 
want to compare the performance of the Fast bootstrap with that of the 
classical bootstrap, which requires of course computing power and time. How  I 
can adjust the previous code to do what I want. I asked Angelo Canty for 
helping me to do this, but he told me that he is afraid that he does not know 
anything about the Fast Bootstrap to which I refer. He suspects that one could 
force his boot package to do something like this but he is not sure if that 
would be possible through censboot or not.  Although my problem does seem 
interesting for him, he is afraid that he is not currently in a position to 
take on any new collaborations.  He remains available to answer any
 questions about the boot package itself as it is currently written, he just 
does not have the time to consider including new elements into the library at 
this time. 
   I think that the paper of Salibian-barrera and Zamar (2003) is not published 
till now.  Now I do not have an electronic copy of this paper draft but I have 
a hard copy. And so I can send you an attachment including  some written 
sections from this paper  "Fast and Stable Bootstrap Methods for Statistics 
Defined by Estimating Equations, Salibian-Barrera and Zamar  (2003)".  Please 
tell me If you want to send you this  attachment, which can also includes what 
I want to do, and what I suggest.
  I need the adjusted code bad. I hope you help me. If you can not help me, 
please guide me to anyone who can help me. Thank you in advance.
   
  Alyaa Mohammad El-wakf
  Assistant Lecturer
  Department of Applied Statistics and Insurance
  Faculty of Commerce 
  Mansoura University
  Egypt





  

   
-

[[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] Read stata file from internet?

2008-01-26 Thread Michael Kubovy
Dear R-helpers,

I would like to have my students read into R an online Stata dataset: 
'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'

I was able to read it into R after downloading it and converting it  
with StatTransfer (http://www.stattransfer.com/).

Here is what happens when I use read.dta() as I would use read.table():

> require(foreign)
> risk2 <- 
> read.dta('http://www.stat.ucla.edu/projects/datasets/risk_project.dta')
> Error in 
> read.dta("http://www.stat.ucla.edu/projects/datasets/risk_project.dta 
> ") :
>   unable to open file

Then I try:

> riskTmp <- 
> read.table('http://www.stat.ucla.edu/projects/datasets/risk_project.dta')
> Warning message:
> In read.table("http://www.stat.ucla.edu/projects/datasets/risk_project.dta 
> ") :
>   incomplete final line found by readTableHeader on 
> 'http://www.stat.ucla.edu/projects/datasets/risk_project.dta'
> head(riskTmp)
>  V1
> 1 l\001\001\300
> 2.%9.0g
> 3 \342CNTL%8.0g
> > risk2 <- read.dta(riskTmp)
> Error in read.dta(riskTmp) : first argument must be a file name

So I tried to save riskTmp as a file, and read it in using read.dta():

> save(riskTmp, file = 'risk.dta')
> risk2 <- read.dta('risk.dta')
> Error in read.dta("risk.dta") : not a Stata version 5-8 .dta file

But that presumably garbled the file. (Indeed, StatTransfer told me so.)

Would it be appropriate to request this as a feature of   
foreign::read.dta()? (Thomas Lumley is the author.)
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

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

2008-01-26 Thread Geoff Russell
Dear users,

I'm trying to produce a 3d bar plot but the x and y dimensions have categorical
data -- so I only want 3 points on each axis. So I try:


require(scatterplot3d)

   mymat<-data.frame(
   x=c(1,1,1,2,2,2,3,3,3),
   y=c(1,2,3,1,2,3,1,2,3),
   z=c(1,2,3,4,5,6,7,8,9))
   scatterplot3d(mymat,
   type="h", lwd=5, pch=" ",
   xlab="xlabel", ylab="ylabel", zlab="zlabel",
   xlim=c(1,3), ylim=c(1,3),
   lab=c(3,3),
   x.ticklabs=c("Low","Medium","High"), y.ticklabs=c("Green","Blue","Black"),
   main="My Bar Plot")

But I still get x ticks at 1, 1.5, 2, 2.5, 3 on both x and y axes. I
thought lab
controlled this (according to the documentation).

What am I doing wrong, or is there some restriction on the way the
function works?

Cheers,
Geoff Russell

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


[R] (no subject)

2008-01-26 Thread alyaa wakf
Hi,   The following code, from Angelo Canty article on line 
"Resampling Methods in R: the boot Package, 2002",  works fine for Angelo Canty 
using  R 2.6.0 on Windows XP.   
  It also works for me using  R 1.2.1 and S-PLUS 2000 on  Windows XP after 
installing the S-PLUS  bootstrap library, with slight differences in my outputs.
   
  > library(boot)
> library(survival)
> set.seed(12345)
  > mel <- melanoma[melanoma$ulcer==1,]
  > mel$cens <- 1*(mel$status==1)
  > mel.cox <- coxph(Surv(time, status==1)~thickness,
  + data=mel)
  > mel.surv <- survfit(mel.cox)
  > mel.cens <- survfit(Surv(time-0.001*(status==1),status!=1)~1,
  + data=mel)
  > mel.fun <- function(d) {
  + cox <- coxph(Surv(time, status==1)~thickness,
  + data=d)
  + cox$coefficients}
  > mel.boot.con <- censboot(mel, mel.fun, R=999, sim="cond", 
  + F.surv=mel.surv, G.surv=mel.cens,
  + cox=mel.cox, index=c(1,8))
  > mel.boot.con
   
  CONDITIONAL BOOTSTRAP FOR CENSORED DATA

Call:
censboot(data = mel, statistic = mel.fun, R = 999, F.surv = mel.surv, 
G.surv = mel.cens, sim = "cond", cox = mel.cox, index = c(1, 
8))

Bootstrap Statistics :
  original biasstd. error
t1* 0.09967665 0.03579701  0.04973614

   
  I want to apply the Fast bootstrap method from Salibian-Barrera and Zamar 
(2003) and  Salibian-Barrera, M., Van Aels, S. and Willems, G. (2007) to the 
previous example, i.e., to produce a confidence interval for the exponent of 
the coefficient of tumour thickness in the Melanoma dataset .  Moreover,  I 
want to compare the performance of the Fast bootstrap with that of the 
classical bootstrap, which requires of course computing power and time. How  I 
can adjust the previous code to do what I want. I asked Angelo Canty for 
helping me to do this, but he told me that he is afraid that he does not know 
anything about the Fast Bootstrap to which I refer. He suspects that one could 
force his boot package to do something like this but he is not sure if that 
would be possible through censboot or not.  Although my problem does seem 
interesting for him, he is afraid that he is not currently in a position to 
take on any new collaborations.  He remains available to answer any
 questions about the boot package itself as it is currently written, he just 
does not have the time to consider including new elements into the library at 
this time. 
   I think that the paper of Salibian-barrera and Zamar (2003) is not published 
till now.  Now I do not have an electronic copy of this paper draft but I have 
a hard copy. And so I can send you an attachment including  some written 
sections from this paper  "Fast and Stable Bootstrap Methods for Statistics 
Defined by Estimating Equations, Salibian-Barrera and Zamar  (2003)".  Please 
tell me If you want to send you this  attachment, which can also includes what 
I want to do, and what I suggest.
  I need the adjusted code bad. I hope you help me. If you can not help me, 
please guide me to anyone who can help me. Thank you in advance.
   
  Alyaa Mohammad El-wakf
  Assistant Lecturer
  Department of Applied Statistics and Insurance
  Faculty of Commerce 
  Mansoura University
  Egypt










   
-

[[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 me to adjust the R code

2008-01-26 Thread alyaa wakf
Hi,  The following code, from Angelo Canty article on line "Resampling 
Methods in R: the boot Package, 2002",  works fine for Angelo Canty using  R 
2.6.0 on Windows XP.   
  It also works for me using  R 1.2.1 and S-PLUS 2000 on  Windows XP after 
installing the S-PLUS  bootstrap library, with slight differences in my outputs.
   
  > library(boot)
> library(survival)
> set.seed(12345)
  > mel <- melanoma[melanoma$ulcer==1,]
  > mel$cens <- 1*(mel$status==1)
  > mel.cox <- coxph(Surv(time, status==1)~thickness,
  + data=mel)
  > mel.surv <- survfit(mel.cox)
  > mel.cens <- survfit(Surv(time-0.001*(status==1),status!=1)~1,
  + data=mel)
  > mel.fun <- function(d) {
  + cox <- coxph(Surv(time, status==1)~thickness,
  + data=d)
  + cox$coefficients}
  > mel.boot.con <- censboot(mel, mel.fun, R=999, sim="cond", 
  + F.surv=mel.surv, G.surv=mel.cens,
  + cox=mel.cox, index=c(1,8))
  > mel.boot.con
   
  CONDITIONAL BOOTSTRAP FOR CENSORED DATA

Call:
censboot(data = mel, statistic = mel.fun, R = 999, F.surv = mel.surv, 
G.surv = mel.cens, sim = "cond", cox = mel.cox, index = c(1, 
8))

Bootstrap Statistics :
  original biasstd. error
t1* 0.09967665 0.03579701  0.04973614

   
  I want to apply the Fast bootstrap method from Salibian-Barrera and Zamar 
(2003) and  Salibian-Barrera, M., Van Aels, S. and Willems, G. (2007) to the 
previous example, i.e., to produce a confidence interval for the exponent of 
the coefficient of tumour thickness in the Melanoma dataset .  Moreover,  I 
want to compare the performance of the Fast bootstrap with that of the 
classical bootstrap, which requires of course computing power and time. How  I 
can adjust the previous code to do what I want. I asked Angelo Canty for 
helping me to do this, but he told me that he is afraid that he does not know 
anything about the Fast Bootstrap to which I refer. He suspects that one could 
force his boot package to do something like this but he is not sure if that 
would be possible through censboot or not.  Although my problem does seem 
interesting for him, he is afraid that he is not currently in a position to 
take on any new collaborations.  He remains available to answer any
 questions about the boot package itself as it is currently written, he just 
does not have the time to consider including new elements into the library at 
this time.   Salibian-Barrera and Zamar ( 2003) have studied in their paper the 
problem of estimating the distribution of statistics defined by estimating 
equations. In particular, they have considered two cases: robust regression 
estimates and quasi-likelihood estimates.Their approach applies in principle to 
the wider class of estimates defined by estimating equations. The Fast 
bootstrap povides an inference procedure that is notably faster than the 
classical bootstrap (where the estimating equations have to be fully solved for 
each bootstrap sample).  Salibian-Barrera and Zamar  simulation studies have 
shown that this Fast bootstrap method is more efficient and more robust to 
model departures. I think that the paper of Salibian-barrera and Zamar (2003) 
is not published till now.  Now I do not have an electronic copy of
 this paper draft but I have a hard copy. And so I can send you an attachment 
including  some written sections from this paper  "Fast and Stable Bootstrap 
Methods for Statistics Defined by Estimating Equations, Salibian-Barrera and 
Zamar  (2003)".  Please tell me If you want to send you this  attachment, which 
can also includes what I want to do, and what I suggest.
  I need the adjusted code bad. I hope you help me. If you can not help me, 
please guide me to anyone who can help me. Thank you in advance.
   
  Alyaa Mohammad El-wakf
  Assistant Lecturer
  Department of Applied Statistics and Insurance
  Faculty of Commerce 
  Mansoura University
  Egypt









   
-

[[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] increasing smoothing in GAMM (package mgcv)

2008-01-26 Thread J. Scott Olsson
Is there a way in GAMM to increase the amount of smoothing (something like
min.sp in GAM)?

This is a large-data problem with binomial response.  I can get something
like the desired effect by
using very few knots, but this seems like a kludge.


thanks!
Scott Olsson

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