[R] Matrix multiplication (with multidimensional array)

2007-06-24 Thread Tong Wang
Hi All,
 I am wondering if there is an efficient  way to do the following matrix 
multiplication,
a[1,,]   1, 2
3, 4

a[2,,]   4, 3
2, 1
 
b[1,,]5,6
 7,8

b[2,,]8,7
 6,5

I need the result c, with

c[1,,] = a[1,,] %*% b[1,,]
c[2,,] = a[2,,] %*% b[2,,] 

Thanks in advance for any help.

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


[R] Problem with dgamma ?

2007-04-22 Thread Tong Wang
Hi All, 
 Here 's what I got using dgamma function : 

> nu<-.2
> nu*log(nu)-log(gamma(nu))+(nu-1)*log(1)-nu*(1)
[1] -2.045951

> dgamma(1,nu,nu,1)
[1] 0.0801333

> dgamma(1,nu,nu,0)
[1] NaN
Warning message:
NaNs produced in: dgamma(x, shape, scale, log) 

Could anyone tell me what is wrong here ?
I am using R-2.4.1 on windows XP.

Thanks a lot.

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


[R] Problem with saving R plot in Emacs

2007-04-09 Thread Tong Wang
Hi, 
I am having problem with saving figures when I use R in Emacs (ESS).  
Whenever I try to save a plot, the Emacs freezes
and I have to close it. 
I am using Win XP  , R binaries,  Emacs for windows.
Somebody got the same problem ? Can I get some suggestions ?

thanks a lot

tong

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


Re: [R] Compiling C codes in Windows

2007-04-03 Thread Tong Wang
Thank you all for the help . It seems I only need to change the back slash to 
forward slash to get things work .

As to using Cygwin as the shell, I couldn't find an instruction dedicated to 
Cygwin, should I just follow the " Installing 
R under Unix-alikes " ?  Is there an easier way, like making use of the 
installed binaries.

I will post future questions to R-devel.  

Thanks again.

tong 

- Original Message -
From: Duncan Murdoch <[EMAIL PROTECTED]>
Date: Monday, April 2, 2007 9:21 am
Subject: Re: [R] Compiling C codes in Windows
To: Martin Morgan <[EMAIL PROTECTED]>
Cc: Tong Wang <[EMAIL PROTECTED]>, R help 

> On 4/2/2007 4:53 AM, Martin Morgan wrote:
> > Tong Wang <[EMAIL PROTECTED]> writes:
> > 
> >> Hi All,
> > [...]
> >> After I followed all the instructions in " Building R for 
> Windows" 
> > [...]
> >>  Anyway, I assumed that I need to run this command in Cygwin
> > 
> > No, do this from a DOS shell. 
> 
> Cygwin is fine as a shell (it's what I use), but the rest of your 
> advice 
> is correct:
> 
> > The usual problems are either missing
> > components from the installation steps outlined in Building R for
> > Windows, or an incorrect PATH variable so that windows or cygwin
> > versions of programs are used rather than MinGW / Rtools.
> 
> Duncan Murdoch
> 
> > 
> > Also, this question belongs on the R-devel list, where those doing
> > development work are more likely to see and respond to your
> > questions.
> > 
> > Hope that helps,
> > 
> > Martin Morgan
> >>
> >> $ make all recommended
> >> make: ./Rpwd.exe: Command not found
> >> make[1]: ./Rpwd.exe: Command not found
> >> make --no-print-directory -C front-ends Rpwd
> >> make -C ../../include -f Makefile.win version
> >> make Rpwd.exe
> >> gcc  -O3 -Wall -pedantic -I../../include  -c rpwd.c -o rpwd.o
> >> rpwd.c:22:20: direct.h: No such file or directory
> >> rpwd.c: In function `main':
> >> rpwd.c:42: warning: implicit declaration of function `chdir'
> >> rpwd.c:45: warning: implicit declaration of function `getcwd'
> >> make[3]: *** [rpwd.o] Error 1
> >> make[2]: *** [Rpwd] Error 2
> >> make[1]: *** [front-ends/Rpwd.exe] Error 2
> >> make: *** [all] Error 2 
> >>
> >>
> >> Can I get some help with my quesitons , and some suggestions 
> concerning the best way to solve the whole problem ?
> >>
> >> THanks a lot  for your help..
> >>
> >> tong
> >>
> >> __
> >> R-help@stat.math.ethz.ch mailing list
> >> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compiling C codes in Windows

2007-04-02 Thread Tong Wang
Hi All,
  I have been struggling to figure out how to compile c codes for R use.
I am using Win XP + Cygwin + R binaries. 
After I followed all the instructions in " Building R for Windows" from 
Murdoch's website, I tried to Run something like :  
R CMD SHLIB C:\R\test.c  , but still didn't get any output.  
 My first question is, does this mean I already did something wrong ?

 Anyway, I assumed that I need to run this command in Cygwin, so I started 
to reinstall R in Cygwin by compiling the source (I assume it is not possible 
to call the precompiled binaries from Cygwin).  But I ran into the following 
problem when I ran  "make all recommended"   in src/gnuwin32/

$ make all recommended
make: ./Rpwd.exe: Command not found
make[1]: ./Rpwd.exe: Command not found
make --no-print-directory -C front-ends Rpwd
make -C ../../include -f Makefile.win version
make Rpwd.exe
gcc  -O3 -Wall -pedantic -I../../include  -c rpwd.c -o rpwd.o
rpwd.c:22:20: direct.h: No such file or directory
rpwd.c: In function `main':
rpwd.c:42: warning: implicit declaration of function `chdir'
rpwd.c:45: warning: implicit declaration of function `getcwd'
make[3]: *** [rpwd.o] Error 1
make[2]: *** [Rpwd] Error 2
make[1]: *** [front-ends/Rpwd.exe] Error 2
make: *** [all] Error 2 


Can I get some help with my quesitons , and some suggestions concerning the 
best way to solve the whole problem ?

THanks a lot  for your help..

tong

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


[R] Problem with Cygwin

2007-04-01 Thread Tong Wang
Hi All ,
   I am trying to compile some c codes with R CMD SHLIB on Cygwin. But I got 
the following error 
   
   WARNING: ignoring environment value of R_HOME
   ERROR: R_HOME ('/home/Owner/r/R-2.0.1') not found

   I have set the environment variable R_HOME pointing to the current R 
installation, but the R command
still looks in the old directory,   Could someone help me out here ?

Thanks a lot .

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


Re: [R] Keep R packages in the R installation

2007-04-01 Thread Tong Wang
Hi,
   Yes, I am using Windows XP.  Thanks a lot for your help.

tong


- Original Message -
From: Robert Duval <[EMAIL PROTECTED]>
Date: Sunday, April 1, 2007 5:29 pm
Subject: Re: [R] Keep R packages in the R installation
To: Tong Wang <[EMAIL PROTECTED]>
Cc: R help 

> You don't say which OS you're using. But I infer from your other
> posting that is MS Windows.
> 
> In which case you can follow the instructions in the FAQ's for Windows
> 
> http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-
> the-best-way-to-upgrade_003f
> 
> ... and also read the mailing list posting guide
> 
> best
> robert
> 
> On 4/1/07, Tong Wang <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I just got a quick question here,  when I install a new 
> version of R , is there an easy to keep the installed R packages ?
> >
> >
> > Thanks a lot for any help.
> >
> > tong
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Compile C codes for R use.

2007-04-01 Thread Tong Wang
Hi, all
I was learning to compile C code for use in R, but I got stuck on the first 
step. 
I am using the R in windows ( 2.4.1 binary) , I opened the command prompt (Run) 
in windows and issued : 

R CMD SHLIB C:\cygwin\home\Owner\R\test.c

but no object file was created , could someone tell me what is wrong ? 
And is there a more convenient way to isssue the the above command, it is 
really troublesome to have to 
open the windows command prompt all the time. 

Thanks a lot for your help\

tong

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Keep R packages in the R installation

2007-04-01 Thread Tong Wang
Hi,
I just got a quick question here,  when I install a new version of R , is 
there an easy to keep the installed R packages ?


Thanks a lot for any help.

tong

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Really need help here

2007-02-12 Thread Tong Wang
Hi there,
 I had a serious problem here . Consider the following Bayesian 
model(discretized variance gamma):
#Likelihood
  J[i]<-lambda*G[i]+sigma*sqrt(G[i])*rnorm(0,1)
  G[i]<-rgamma(1/nu,1/nu)

#Prior:   
 nu<-rinvgamma(m,M)

# Parameters 
 lambda=-.04 ; sigam=.38; nu=6.48; m=10,M=10 ; T=5000 (length of data)
An author claimed that he got posterior distribution of nu with standard 
deviation .0965 

But I could only get posterior sd=.84 with the same setting. I have been 
working on my code for quite a while
, but still don't see what is wrong with it.  I would really appreciate it if 
any body could fit this model and let me
know if you can get it and how ? I attached my R code with data generating and 
posterior simulating functions, 
I used the slice sampler to do it ,  you could use your own version of slice 
sampler or other generic samplers. 

Again , I would really appreciate any help that could save me from the pain. 


vg <- function(T=5000,nu=6.48,n.iter=1000,beta=-.04,sig=.38,m=10,M=10){

#--- Data Generating -#

  G <- rgamma(T,1/nu,1/nu)
  J <- rnorm(T,beta*G,sig*sqrt(G))

#--- Gibbs Sampler ---#

  nu.stor <- rep(NA,n.iter)
  for(i in 1:n.iter){
  G <- MCslice1D(dgamma(x,1/nu,1/nu,log=TRUE)+dnorm(J, beta*x, 
sig*sqrt(x),log=TRUE),w=20,m=10,x0=G)
  nu <- 
MCslice1D(log(dinvgamma(x,m,M))-T*log(x)*1/x-T*log(gamma(1/x))+(1/x-1)*sum(log(G))-sum(G)/x,
 w=3,m=12, x0=nu)

  nu.stor[i] <- nu
}

  return(list(nu=nu.stor))

}

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


[R] problem with rinvgamma ?

2007-02-11 Thread Tong Wang
Hi,
By  rinvgamma(1,1.33,2.33) ,   am I supposed to get a var=3 ?   Tried 
it many times , not even close.  Why is this?
thanks a lot .

best

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] slice sampler

2007-02-08 Thread Tong Wang
Hi there,  
 I wrote a slice sampler (one dimension) ,  After testing it, I found it 
working well on some standard distributions, but problematic with others.  I 
have thought about it but really can't figure out how to improve it, so I 
attached the code here
and hope that someone here is willing to try it out and give me some feedback. 
I would really appreciate it. 
 I basicly followed neal 03 to write the code. The code might looks a 
little strange as I allowed sampling a vector of parameters  ,   that is , it 
could update multiple targets with different parameter but same form of 
distribution. A example
of usage is as follows:
  output[i] <- slice1d(dnorm(x,1,1,log=TRUE), 
x0=output[i-1],w=2,m=6,trunc=c(-Inf,Inf),prec=1e-4) 
 things to notice here are: expression has to be on LOG scale, w is the 
expanding wideth, m is the # of expanding trials,
prec is the precision, this is used to control against those distributions with 
huge kurtosis (with very sharp peak),  so that the sampler wouldn't spend a lot 
of time approaching the right value. 

One example that it doesn't work well on isdgamma(x,.1,.1,log=TRUE)

Thanks a lot in advance. 
best,

CODE: 

slice1d <- function (expr,x0=NULL,w,m,trunc=c(-Inf,Inf),prec=.0001){
sexpr <- substitute(expr)
if (!(is.call(sexpr) && match("x", all.vars(sexpr), nomatch = 0))) 
  stop("'expr' must be a function or an expression containing 'x'")
expr <- sexpr

y.log <- eval(expr, envir=list(x=x0),enclos = if(is.null(list(...)$env)) 
parent.frame() else list(...)$env)-rexp(1)
k <- length(y.log)
if(k!=length(x0))
  stop("The dimension of y.log and x0 have to agree")

U <- runif(k)
L <- x0-w*U
R <- L+w
U <- runif(k)
J <- floor(m*U)
K <- m-1-J

temp <- (L0)&(y.logtrunc[2])   
R <- as.vector(R)
R[temp] <- trunc[2]
vec.cond <- rep(!temp,k)

while(sum(vec.cond)!=0)
  {vec.cond <- ((K>0)&(y.logtrunc[2])
   R[temp] <- trunc[2]
   K[temp] <- 0
   K[vec.cond] <- K[vec.cond]-1}

vec.cond <- rep(FALSE,k)
x1 <- rep(NA,k)
count <- 0
repeat{
  U <- runif((k-sum(vec.cond)))
  x1[!vec.cond] <- L[!vec.cond]+U*(R[!vec.cond]-L[!vec.cond])
  vec.cond <- ((y.logx0] <- x1[x1>x0]
  count <- count+1
  if (count>=1) stop("dead loop")
}
  }

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


[R] Question on computing mv-norm density

2007-02-05 Thread Tong Wang
Hi, 
I am trying to figure out how to evaluate the density function of 
multivariate normal efficiently for a large data set, the 
data set should look like this (take d=2 for example): 
  
   datamean 
 sigma

   2.131, 3.000   1.000,1.000   
  1   0

0   1

   1.231,5.1412.000,2.000   
   .5  -.1
. . 
 -.1 .4

 .

that is , I need   SUM_i (log(dmvnorm(d[i], mu[i], sigma[i])). tried to 
rewrite the dmvnorm function from mvtnorm 
package, but could not find a satisfactory method to avoid using loops.  ( 
using those "apply" functions seem to be slower
than loops) .  May I get some suggestion on this ? Thanks a lot in advance. 

best

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] A question about dput

2007-02-01 Thread Tong Wang
Hi, 
   I am trying to output a R data set for use in WinBugs,  I used
 dput(list(x=rnorm(100),N=100),file="bug.dat") 
But I can't get the intended format:list(x=c(...),N=100), instead, I 
got 
something like this (copied the first two lines):

[]737472756374757265286C6973742878
structure(list(x
[0010]203D2063282D302E3336333136313033
=c(-0.36316103

Did I do something wrong here ?  Thanks a lot for any help

tong

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


[R] Question about the xgobi package

2007-01-25 Thread Tong Wang
Hi,
   When I tried an example of the xgobi function, I got the following error.  
Could someone explain to me
what is wrong ?  Thanks a lot. 

xgobi(crabs,colors=c("SkyBlue","SlateBlue","Orange","Red")[rep(1:4,each=50)])

c:/PROGRA~1/R/R-23~1.1/library/xgobi/scripts/xgobi.bat -vtitle 'crabs' -std mmx 
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/Rtmp1FVirb/xgobi-crabs2c3b6032 
The system cannot find the path specified.



tong

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Questions about paste and assign

2007-01-13 Thread Tong Wang
Hi,
I would like to assign a value to a member b  of the list  a  in position 
3,   by calling:  

assign( target, 2.34, 3)

My question is what the "target" should be.   I tried target <- paste("a", $, 
"b")   and something else, 
but haven't got the right answer yet.  

BTW, if I attached a list named  "mylist" in position 3,  to refer to this 
environment, besides 3, what's the 
right name ?

Thanks a lot for any help

tong

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] What command does the "cin >> " in R ?

2007-01-12 Thread Tong Wang
Hi all,
  Sorry about the simple question,  but I have searched the web with " 
prompt , input " etc.  and never got the answer .

thanks a lot

tong

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


Re: [R] A question about R environment

2007-01-09 Thread Tong Wang
Hi,
   Thanks a lot for your response,   but it is strange that when I do attach() 
, I got the follow error: 
  Error in attach(e) : attach only works for lists and data frames

Any suggestions on this?


tong

- Original Message -
From: Henrik Bengtsson <[EMAIL PROTECTED]>
Date: Monday, January 8, 2007 10:40 pm
Subject: Re: [R] A question about R environment
To: Gabor Grothendieck <[EMAIL PROTECTED]>
Cc: Tong Wang <[EMAIL PROTECTED]>, R help 

> sourceTo() in R.utils will allow you to source() a file into an 
> environment.
> /Henrik
> 
> On 1/9/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> > Try this:
> >
> > > e <- new.env()
> > > e$f <- function(x)x
> > > attach(e)
> > > search()
> >  [1] ".GlobalEnv""e" "package:stats"
> >  [4] "package:graphics"  "package:grDevices" "package:utils"
> >  [7] "package:datasets"  "package:methods"   "Autoloads"
> > [10] "package:base"
> > > f
> > function(x)x
> >
> > On 1/8/07, Tong Wang <[EMAIL PROTECTED]> wrote:
> > > Hi  all,
> > >
> > > I created environment  "mytoolbox" by :   mytoolbox <- 
> new.env(parent=baseenv())> > Is there anyway I put it in the search 
> path ?
> > >
> > > If you need some background :
> > >  In a project, I often write some small functions,  and load 
> them into my workspace directly,   so when I list the objects
> > >  with ls(), it looks pretty messy.  So I am wondering if it is 
> possible to creat an environment,  and put these tools into
> > >  this environment.  For example,  I have functionsfun1(), 
> fun2() ..and creat an environment  mytoolbox  which
> > >  contains all these functions.  And it should be somewhere in 
> the search path:   ".GlobalEnv""mytoolbox"  
>  "package:methods"  
> > >
> > > __
> > > R-help@stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] A question about R environment

2007-01-09 Thread Tong Wang
Francois (sorry can't type the right letter) , thanks a million for the 
detailed response,  you have really cool functions there !

Philippe :  I will definitely follow your advice later,  but I got some time 
pressure from the current project, so have to go with the easy sol. now ,   
thanks a lot. 

Happy new year every one!

cheers

tong

- Original Message -
From: Philippe Grosjean <[EMAIL PROTECTED]>
Date: Monday, January 8, 2007 10:09 pm
Subject: Re: [R] A question about R environment
To: François Pinard <[EMAIL PROTECTED]>, Tong Wang <[EMAIL PROTECTED]>, R help 


> Please, don't reinvent the wheel: putting functions in a dedicated 
> environment is one of the things done by R packages (together with 
> a 
> good documentation of the function, and making them easily 
> installable 
> on any R implementation). So, this is probably the time for you to 
> read 
> the "Writing R extensions" manual, and to start implementing your 
> own R 
> package!
> Best,
> 
> Philippe Grosjean
> 
> François Pinard wrote:
> > [Tong Wang]
> > 
> >> I created environment "mytoolbox" by : mytoolbox <- 
> >> new.env(parent=baseenv()).  Is there anyway I put it in the 
> search 
> >> path?  In a project, I often write some small functions, and 
> load them 
> >> into my workspace directly, so when I list the objects with 
> ls(), it 
> >> looks pretty messy.  So I am wondering if it is possible to 
> creat an 
> >> environment, and put these tools into this environment.  For 
> example, 
> >> I have functions fun1(), fun2() ... and creat an environment 
> mytoolbox 
> >> which contains all these functions.  And it should be somewhere 
> in the 
> >> search path:  ".GlobalEnv" "mytoolbox" "package:methods".
> > 
> > Here is a trick, shown as a fairly simplified copy of my 
> ~/.Rprofile.  
> > It allows for a few simple functions always available, yet 
> without 
> > having to create a package, and leaving ls() and any later .RData 
> file 
> > unencumbered.
> > 
> > The idea is to use local() to prevent any unwanted clutter to 
> leak out 
> > (my real ~/.Rprofile holds more than shown below and use 
> temporary 
> > variables), to initialise a list meant to hold a bunch of 
> functions or 
> > other R things, and to save that list on the search path.
> > 
> > This example also demonstrate a few useful functions for when I 
> read the 
> > R mailing list.  I often need to transfer part of emails containing
> > code excerpts within the window where R executes, while removing 
> > quotation marks, white lines and other noise.  I merely highlight-
> select 
> > part of the message with the mouse, and then, within R, do things 
> like:> 
> >xs()   source the highlighted region
> >xd()   read in a data.frame
> >xm()   read in a matrix
> >xe()   evaluate and print an expression
> >xv()   read a list of values as a vector
> > 
> > The list above in decreasing order of usefulness (for me).  
> Except for 
> > xs(), which has no automatic printout, you may either let the 
> others 
> > print what they got, or assign their value to some variable.  
> Arguments 
> > are also possible, for example like this:
> > 
> >xd(T)  read in a data.frame when the first line holds column 
> names> 
> > 
> > 
> > if (interactive()) {
> > local({
> > 
> > fp.etc <- list()
> > 
> > fp.etc$xsel.vector <- function (...) {
> > connexion <- textConnection(xselection())
> > on.exit(close(connexion))
> > scan(connexion, ...)
> > }
> > fp.etc$xsel.dataframe <- function (...) {
> > connexion <- textConnection(xselection())
> > on.exit(close(connexion))
> > read.table(connexion, ...)
> > }
> > fp.etc$xsel.matrix <- function (...) {
> > connexion <- textConnection(xselection())
> > on.exit(close(connexion))
> > data.matrix(read.table(connexion, ...))
> > }
> > fp.etc$xsel.eval <- function (...) {
> > connexion <- textConnection(xselection())
> > on.exit(close(connexion))
> > eval(parse(connexion, ...))
> > }
> > fp.etc$xsel.source <- function (...) {
> > connexion <- textConnection(xselection())
> > on.exit(close(con

[R] A question about R environment

2007-01-08 Thread Tong Wang
Hi  all,
 
I created environment  "mytoolbox" by :   mytoolbox <- new.env(parent=baseenv())
Is there anyway I put it in the search path ?

If you need some background :
  In a project, I often write some small functions,  and load them into my 
workspace directly,   so when I list the objects 
  with ls(), it looks pretty messy.  So I am wondering if it is possible to 
creat an environment,  and put these tools into 
  this environment.  For example,  I have functionsfun1(), fun2() ..
and creat an environment  mytoolbox  which 
  contains all these functions.  And it should be somewhere in the search path: 
  ".GlobalEnv""mytoolbox""package:methods"  


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

2007-01-04 Thread Tong Wang
I think I have figured out part of the answer,  when I entered a debugger, the 
calling environment (parent frame) 
refers to the debugger program, instead of the mainfun( ).   But is there 
anyway to solve this problem ? 

thanks 

- Original Message -
From: Tong Wang <[EMAIL PROTECTED]>
Date: Wednesday, January 3, 2007 9:30 pm
Subject: need help with debug package
To: R help 

> Hi all, 
>  I met a problem while using the debug package,  I have the 
> following program: 
> 
> mainfun<- function(){
>   beta<-1
>   result<-subfun(beta+x)
> }
> 
> subfun<-function(expr){
>   y <- eval(expr, envir=list(x=c(1,2)),enclos = 
> parent.frame())  return(y)
> }
> 
> I have no problem using this program without calling the debug 
> package.   but once 
> I mtrace(subfun),  the debugger can't find all the beta after 
> entering subfun , and give 
> the message : "Error in beta : non-numeric argument to binary 
> operator"
> Is there anyway to get around ?
> 
> thanks a lot 
> happy new year
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 with debug package

2007-01-03 Thread Tong Wang
Hi all, 
  I met a problem while using the debug package,  I have the following 
program: 

mainfun<- function(){
   beta<-1
   result<-subfun(beta+x)
}
 
subfun<-function(expr){
   y <- eval(expr, envir=list(x=c(1,2)),enclos = parent.frame())
  return(y)
}

I have no problem using this program without calling the debug package.   but 
once 
I mtrace(subfun),  the debugger can't find all the beta after entering subfun , 
and give 
the message : "Error in beta : non-numeric argument to binary operator"

Is there anyway to get around ?

thanks a lot 
happy new year

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] A question about debug package

2006-12-19 Thread Tong Wang
Hi all,
 I am using the debug package, and I would like some commands executed 
automatically as I quit by qqq( ),  
I tried the on.exit( ) , but it doesn't work in this case.   Any suggestions on 
this?   
 
thanks a lot .

tong

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] A quesiton on data manipulation

2006-10-28 Thread Tong Wang
Hi, 
I have a data set (data frame) describing some features of  the students in 
a high school  in the following format:

Stu IDYear feature 1  feature 2  . 
1001 1990 
1001 1991
1001 1992
1002 1990
1002 1991
1002 1992
  

   Some features of  a few of these students are missing,   I would like to 
ignore those students in my  analysis, but
I really can' t figure out a neat way to do this in R.   I need to remove all 
the info. of a student (indicated by ID no.) if there 
are NA's in his/her features.  

Could someone give me a quick tutorial on this ?

I would really appreciate. 

best

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


[R] Question about managing searching path

2006-10-17 Thread Tong Wang
Hi all,
 I'm having sometrouble with managing the seach path, in a function , I 
need to attach some data set at the begining
and detach them at the end,  say, myfunction<- function() { attach(mylist); 
 .detach(mylist) } ,
the problem is, since I am still debugging this code,  sometimes it got error 
and ended before reaching the end, thus
the data is left in the searching path.  
  What 's the right way to make mylist detached no matter what ?

Thanks a lot.

best

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 make the debuger stop at the warnings

2006-10-09 Thread Tong Wang
Hi,
I am using the debug package,  is there any way I can tell the debuger to 
stop when a warning message come out ?
Thanks a lot. 


best

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

2006-10-02 Thread Tong Wang
Hi, 
Thanks you guys for all the help. I learned a lot from it.  
It looks using apply() is not an efficient way, since all it does is 
looping through 
each row(or col) , which would be slow for large matrix, right ? 

cheers

- Original Message -
From: Gabor Grothendieck <[EMAIL PROTECTED]>
Date: Saturday, September 30, 2006 4:54 am
Subject: Re: [R] How to repeat vectors ?
To: Tong Wang <[EMAIL PROTECTED]>
Cc: r-help@stat.math.ethz.ch

> Here are 4 approaches in order from most compact
> to least.  #1 only works for numeric matrices, # 2 is
> a shorter versio of your solution using rep.vec and # 3
> is from Alex's post and is likely what I would
> use in practice.
> 
> m <- matrix(1:4, 2) # test matrix
> 
> # 1 - m must be numeric for this one to work
> kronecker(m, rep(1,2))
> 
> # 2
> apply(m, 2, rep, each = 2) # 2
> 
> # 3 - from Alex's post
> m[rep(1:nrow(m), each = 2),]
> 
> # 4
> matrix(rbind(c(m), c(m)), nc = ncol(m))
> 
> On 9/30/06, Tong Wang <[EMAIL PROTECTED]> wrote:
> > I just figured out a way to do this:
> >  rep.vec <- function(X,n)
> return(t(array(rep(X,n),c(length(X),n>
> >   Then,apply(MyMatrix, 2, rep.vec,2)
> >
> > Is there a better way ?  Is there an internal function to repeat 
> a vector or matrix ?
> >
> > Thanks a lot.
> >
> >
> > - Original Message -
> > From: Tong Wang <[EMAIL PROTECTED]>
> > Date: Friday, September 29, 2006 11:23 pm
> > Subject: How to repeat vectors ?
> > To: r-help@stat.math.ethz.ch
> >
> > > Hi,
> > >If I have a matrix  , say   a11   a12
> > >   a21  a22
> > >Is there a routine to get:  a11  a12
> > > a11  a12
> > > a21   a22
> > > a21   a22
> > >
> > > Thanks a lot for any help.
> > >
> > > best
> > >
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Can I avoid loops here ?

2006-10-01 Thread Tong Wang
Thanks Gabor,  I will be more specific next time.

best

- Original Message -
From: Gabor Grothendieck <[EMAIL PROTECTED]>
Date: Saturday, September 30, 2006 10:38 pm
Subject: Re: [R] Can I avoid loops here ?
To: Tong Wang <[EMAIL PROTECTED]>
Cc: R help 

> Try:
> 
> mapply("%*%", mylist1, mylist2, SIMPLIFY = FALSE)
> 
> Please provide self-contained examples as requested on
> the last line of every message to r-help.  That means the
> data for X1, X2, Y1, Y2 should be included so one can
> run the code you post.
> 
> On 10/1/06, Tong Wang <[EMAIL PROTECTED]> wrote:
> > Hi,
> >  I have two lists of matrices, and I  would like to get  a 
> list of term by term product, say,
> >  mylist1<- list( X1,X2);  mylist2<-list(Y1,Y2)
> >
> > Need: mylist3<-list(X1%*%Y1,X2%*%Y2)
> >
> > Is there a way that allows me to do this without loops ?
> >
> > Thanks a lot.
> >
> > best
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can I avoid loops here ?

2006-09-30 Thread Tong Wang
Hi,
  I have two lists of matrices, and I  would like to get  a list of term by 
term product, say,
 mylist1<- list( X1,X2);  mylist2<-list(Y1,Y2)

Need: mylist3<-list(X1%*%Y1,X2%*%Y2)

Is there a way that allows me to do this without loops ?

Thanks a lot. 

best

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

2006-09-29 Thread Tong Wang
I just figured out a way to do this: 
  rep.vec <- function(X,n)return(t(array(rep(X,n),c(length(X),n

   Then,apply(MyMatrix, 2, rep.vec,2)

Is there a better way ?  Is there an internal function to repeat a vector or 
matrix ?

Thanks a lot.


- Original Message -
From: Tong Wang <[EMAIL PROTECTED]>
Date: Friday, September 29, 2006 11:23 pm
Subject: How to repeat vectors ?
To: r-help@stat.math.ethz.ch

> Hi,
>If I have a matrix  , say   a11   a12
>   a21  a22
>Is there a routine to get:  a11  a12
> a11  a12
> a21   a22
> a21   a22
> 
> Thanks a lot for any help.
> 
> best
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 repeat vectors ?

2006-09-29 Thread Tong Wang
Hi,
If I have a matrix  , say   a11   a12
   a21  a22
Is there a routine to get:  a11  a12
 a11  a12
 a21   a22
 a21   a22

 Thanks a lot for any help.

best

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


Re: [R] strange warning message

2006-09-29 Thread Tong Wang
Hi Duncan:
 Thank you for your help last time,  since I do not use NULL to indicate 
empty enviroment, I think I'm fine. 
And yes, I did upgrade my R version recently,  but how comes I still get this 
warning for new files created
and saved after that update ? Is there anyway to get rid of this message ?
 Thanks a lot . 

best  

- Original Message -
From: Duncan Murdoch <[EMAIL PROTECTED]>
Date: Saturday, September 23, 2006 5:59 pm
Subject: Re: [R] strange  warning message
To: Tong Wang <[EMAIL PROTECTED]>
Cc: r-help@stat.math.ethz.ch

> On 9/23/2006 7:15 PM, Tong Wang wrote:
> > Hi Everyone,
> > I recently start to get this warning message,  while loading 
> files in to R.   Could someone tell me what does it mean ?
> > I am using R 2.3.0 with Emacs on WinXP.
> > 
> > use of NULL environment is deprecated 
> 
> The files were saved in an earlier version of R, which used NULL to 
> indicate the base environment.  R is telling you that NULL is not a 
> legal environment.  It should be automatically converted to baseenv().
> 
> In a number of cases, people used NULL to indicate an empty 
> environment 
> (even though there was no such thing when NULL was used); if that's 
> true 
> for your code, then you'll need to fix it.  emptyenv() now gives 
> you an 
> empty environment if that's what you really want.
> 
> Duncan Murdoch
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 pass expression as an argument

2006-09-27 Thread Tong Wang
Hi,
 I am writing a function and need to pass a function expression as an 
argument,   for instance, 
myfun <-  function( express) {
   x<- c(1,2,3)
  y<-express
 }

if I call the above function by myfun( x*2 ), I get  2  as the result,  
instead of  2,4,6 ,  could someone help me to 
fix this problem ? 
Furthermore,  is that possible to operate this expression on different 
variables?  for example, in myfun(), I 
might want to get  u*2,  z*2,  etc. without having to say x<-u, x<-z to match 
the expression.

Thanks a lot for your help.

best

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


[R] strange warning message

2006-09-23 Thread Tong Wang
Hi Everyone,
I recently start to get this warning message,  while loading files in to R. 
  Could someone tell me what does it mean ?
I am using R 2.3.0 with Emacs on WinXP.

use of NULL environment is deprecated 



Thanks a lot for any help

best

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 generating diagnal blocks ?

2006-09-20 Thread Tong Wang
Hi,
 I am trying to creat a matrix with diagnal blocks, say, I have a matrix X 
of any dimension (nxm) ,and would like to have:
   
X
X
X
  .
otherwise space filled with 0's.   Is there a handy way to do this ?

Thanks a lot in advance.

best

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 with dataset formation problem

2006-09-19 Thread Tong Wang
Hi, 
I have a data set , say, X  :  [1][2]
 mean  0  .8
 sd1   3

 I need to use it in do.call() ,   so when I refer to the first col of X, I 
need it to be a list with members mean, sd.
thus I constructed X as a list of list :  X[[1]]<- list(mean=0, sd=1),   
X[[2]]<-..  But this dataset is useless in other
cases, for example, I can't pull out all the means as a vector.
 Can I get some suggestions on what's the best way to handle it? (except 
preparing two copies of this data with different formats)

Thanks a lot in advance. 

best

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


[R] Question about do.call()

2006-09-11 Thread Tong Wang
Hi,
I'm writing a function f()  which includes probability density function 
computation,  I would like to make this generic, that is , I will specify  the 
density when I call f(),   here's what I wrote:  do.call(den, args=list(d, 
arg)) 
the question is , say, if I let den=dnorm, I have to replace arg with  
mean=??, sd=??, etc.  but I tried arg=c(mean=..,sd=..)
and arg="mean=..,sd=..",  neither of these worked.   What is the right way to 
do this ?

Thanks a lot

tong

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


Re: [R] What is the matrix version of min()

2006-09-06 Thread Tong Wang
Hi, 
   THANK YOU ALL for the prompt reply. 

cheers.

- Original Message -
From: Robin Hankin <[EMAIL PROTECTED]>
Date: Wednesday, September 6, 2006 1:42 am
Subject: Re: [R] What is the matrix version of min()
To: Tong Wang <[EMAIL PROTECTED]>
Cc: R help 

> Tong
> 
> you need to use apply().  The second argument specifies whether
> you want to work with rows or columns.  The point of this is that
> min() and max() operate on vectors and give a single value,
> and you want to "apply" this function to all rows or all columns:
> 
> > a <- matrix(rnorm(30),5,6)
> > apply(a,2,max)
> [1] 2.6413241 0.9842076 1.7989560 0.6999855 2.0542201 0.1162821
> > apply(a,1,max)
> [1] 1.1771370 0.9811693 2.6413241 0.9842076 2.0542201
> >
> 
> HTH
> 
> rksh
> 
> 
> On 6 Sep 2006, at 09:37, Tong Wang wrote:
> 
> > Hi,
> > Is there a function which operates on a matrix and return a  
> > vector of min/max of each rol/col ?
> > say,  X=  2,  1
> > 3,  4
> > min.col(X)=c(2,1)
> >
> > thanks a lot.
> >
> > tong
> >
> > __
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> 
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>  tel  023-8059-7743
> 
> 
> 
> 
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] What is the matrix version of min()

2006-09-06 Thread Tong Wang
Hi, 
Is there a function which operates on a matrix and return a vector of 
min/max of each rol/col ?
say,  X=  2,  1
3,  4 
min.col(X)=c(2,1)

thanks a lot.

tong

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


Re: [R] A question about gc()

2006-09-06 Thread Tong Wang
Yes, I am using R in windows, sorry for not being specific. 
You are right, I have stored too much stuff, and I need to trash some data in 
the process. 
Problem solved for me, Thank you very much. 

tong

- Original Message -
From: Prof Brian Ripley <[EMAIL PROTECTED]>
Date: Tuesday, September 5, 2006 3:42 am
Subject: Re: [R] A question about gc()
To: Tong Wang <[EMAIL PROTECTED]>
Cc: R help 

> On Tue, 5 Sep 2006, Tong Wang wrote:
> 
> > Hi everyone, 
> 
> > I am doing some intensive computation:  5 regressions of 
> the 
> > form Y~X with each y of size (1,1000) , even if I break invoke 
> gc() for 
> > a few time in the loop, it still breaks down at some point with 
> the 
> > error message:
> 
> gc() does not reclaim memory for you beyond what R has already done.
> 
> > Error in .signalSimpleWarning("Reached total allocation of 
> 1024Mb: see help(memory.size)",  : 
> > recursive default argument reference
> 
> >  After getting this, even if I call gc() and resume the 
> computation, it 
> > won't move at all. May I get some suggestions what should I do to 
> get 
> > around this problem ?
> 
> Consult the rw-FAQ (since you seem to be using Windows without 
> telling us) 
> and the help page the message mentions.
> 
> It looks as if you are trying to store too many objects.  If you 
> have lots 
> of RAM you can increase that limit (see the previous para), but you 
> are 
> getting uncomfortably close to the address space limit of your OS.
> 
> Perhaps you can only save the part of the fit you need, or save() 
> the 
> objects to separate files and rm() them, and postprocess them in a 
> later 
> session?
> 
> -- 
> Brian D. Ripley,  [EMAIL PROTECTED]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595
>

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


Re: [R] Quick question about lm()

2006-09-06 Thread Tong Wang
Thanks a lot for your help. 

tong

- Original Message -
From: Christos Hatzis <[EMAIL PROTECTED]>
Date: Monday, September 4, 2006 10:54 pm
Subject: RE: [R] Quick question about lm()
To: 'Tong Wang' <[EMAIL PROTECTED]>, r-help@stat.math.ethz.ch

> Say,
> 
> my.lm <- lm(y ~ x, data=my.data)
> 
> Then if you try:
> 
> names(summary(my.lm)) 
> 
> you will see the components of the summary.lm object.  The 
> coefficients and
> t-statistics can be extracted by
> 
> summary(my.lm)$coefficients
> 
> and similarly for the r-squared and other statistics provided in 
> the summary
> report.
> 
> -Christos
> 
> 
> -----Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Tong Wang
> Sent: Tuesday, September 05, 2006 1:35 AM
> To: r-help@stat.math.ethz.ch
> Subject: [R] Quick question about lm()
> 
> Hi, 
> Feel awkward to ask , but really couldn't find a answer 
> anywhere,   How
> could I extract the R^2 and t-stat. from the 
> result of lm()?
> Thanks a lot. 
> 
> best
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.htmland provide commented, minimal, self-contained, 
> reproducible code.
> 
> 
> 
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] A question about gc()

2006-09-05 Thread Tong Wang
Hi everyone, 
I am doing some intensive computation:  5 regressions of the form Y~X 
with each y of size (1,1000) ,
even if I break invoke gc() for a few time in the loop, it still breaks down at 
some point with the error message:

Error in .signalSimpleWarning("Reached total allocation of 1024Mb: see 
help(memory.size)",  : 
recursive default argument reference
 
After getting this, even if I call gc() and resume the computation, it won't 
move at all.
May I get some suggestions what should I do to get around this problem ?
Thanks a lot. 

tong

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Quick question about lm()

2006-09-04 Thread Tong Wang
Hi, 
 Feel awkward to ask , but really couldn't find a answer anywhere,   How 
could I extract the R^2 and t-stat. from the 
result of lm()?
 Thanks a lot. 

best

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] identify high dimension data point

2006-05-10 Thread Tong Wang
Hi there, 
I am having some trouble with the Identify() function,  it looks that 
the identify() function only works on the plot of 2-dimension data set.  In 
high-dimension case , if I use pairs() + identify() in hope to observe all the 
components of the data point I selected, I get error message.  Is there anyway 
to get around this ? Plus,  I also need it to actually compare all the 
components of the picked data point with "mydataset" to choose the closest one. 
Thanks million in advance. 

best

tong

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


[R] How to change the label in plot.ts ?

2006-03-16 Thread Tong Wang
Hi you guys:
  I have been wondering if there is any way to change the labeling in 
plot.ts( ),  for example , if I plot two sequences,
i always got y labels as "series1", "series2", I tried to use 
ylab=c((expression(mu_1)),(expression(mu_2))), but it 
doesn't work.
  thanks in advance for any help

best.

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


[R] How to import data as numeric array?

2005-06-28 Thread tong wang
Did some search but couldn't find useful result.

I am trying to read a n*m dimension data with read.table,  what i need is a 
numeric array, 
is there any efficient way to allow me get this array directly instead of a 
list? 
I tried to use as.array() to change the mode, but seems it doesn't work and i 
got this error message:

"Error in "dimnames<-.data.frame"(`*tmp*`, value = list(function (M)  : 
invalid dimnames given for data frame "
 
what's wrong with the dimension names , should i delete them? how can i do that?

Thanks a lot for any help.

tong wang

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


[R] How to search an element in matrix ?

2005-04-10 Thread tong wang
Hi you guys,
 I know this might be too simple a question to post, but i searched a lot 
still couldn't find it.
Just want to find an element in matrix and return its index , i think there 
should be some matrix version of "match" which 
only works for vector to me.
 thanks in advance for your help.

best,
tong

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