[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,,] =

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

[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

Re: [R] Compiling C codes in Windows

2007-04-03 Thread Tong Wang
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

[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

[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

[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

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 r-help@stat.math.ethz.ch

[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

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

[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

[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

[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

[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):

[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

[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

[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

Re: [R] A question about R environment

2007-01-09 Thread Tong Wang
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 r-help

Re: [R] A question about R environment

2007-01-09 Thread Tong Wang
, 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 r-help@stat.math.ethz.ch sourceTo() in R.utils will allow you to source() a file into an environment. /Henrik On 1/9/07, Gabor Grothendieck

[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

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

[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())

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

[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

[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

Re: [R] How to repeat vectors ?

2006-10-02 Thread Tong Wang
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

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 r-help@stat.math.ethz.ch Try

[R] How to repeat vectors ?

2006-09-30 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

Re: [R] How to repeat vectors ?

2006-09-30 Thread Tong Wang
- 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

[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

Re: [R] strange warning message

2006-09-29 Thread Tong Wang
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

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

[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] How to generating diagnal blocks ?

2006-09-21 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

[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

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

Re: [R] A question about gc()

2006-09-06 Thread Tong Wang
, September 5, 2006 3:42 am Subject: Re: [R] A question about gc() To: Tong Wang [EMAIL PROTECTED] Cc: R help r-help@stat.math.ethz.ch 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

[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

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 r-help@stat.math.ethz.ch Tong you

[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

[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

[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

[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

[R] How to import data as numeric array?

2005-06-28 Thread tong wang
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] 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