Re: [R] Populate a matrix

2011-10-05 Thread Samuel Le
mat - matrix(ncol = length(x), nrow = length(y)) for(i in 1:length(x)) { mat[,i] = y} HTH, Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of fernando.cabr...@nordea.com Sent: 05 October 2011 17:11 To: r-help@r-project.org

Re: [R] check availability of a file in R

2011-09-07 Thread Samuel Le
Does file.exists answer to your question? file.exists(.RData) If you are not sure of the exact name of the file but know it contains .RData, you can try: List.files(directory,.RData) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf

[R] convert an xml object into a list on R 2.13

2011-08-16 Thread Samuel Le
Hi, I am manipulating xml objects using the package xml. With the version 2.10.1 this package included the function xmlToList that was converting the xml into a list straight away. This function seems to have gone when I moved to 2.13.0. Does someone has an equivalent for it? Thanks,

Re: [R] execute r-code stored in a string variable

2011-08-02 Thread Samuel Le
Yes, you can use: eval(parse(text=c)) On the other hand I would not recommend to use c as a variable name as it is the name of a very important function in the R language to aggregate data. HTH, Samuel -Original Message- From: r-help-boun...@r-project.org

[R] formula used by R to compute the t-values in a linear regression

2011-08-01 Thread Samuel Le
Hello, I was wondering if someone knows the formula used by the function lm to compute the t-values. I am trying to implement a linear regression myself. Assuming that I have K variables, and N observations, the formula I am using is: For the k-th variable, t-value= b_k/sigma_k With

Re: [R] formula used by R to compute the t-values in a linear regression

2011-08-01 Thread Samuel Le
Exactly. My formula holds only for k=1, this is how I generated it. Do you have any references concerning the rather more careful algorithms? Thanks, Samuel -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: 01 August 2011 14:45 To: Samuel Le Cc: r-h

Re: [R] formula used by R to compute the t-values in a linear regression

2011-08-01 Thread Samuel Le
Yes, that's what I was looking for. Many thanks, Samuel -Original Message- From: S Ellison [mailto:s.elli...@lgcgroup.com] Sent: 01 August 2011 15:16 To: Samuel Le; r-h...@stat.math.ethz.ch Subject: RE: formula used by R to compute the t-values in a linear regression -Original

Re: [R] set.seed and for loop

2011-06-09 Thread Samuel Le
What about: set.seed(1001) total - 0 data - vector(list, 30) for(i in 1:30) { data[[i]] - runif(50) } set.seed(1001) data[[23]] - runif(50) HTH Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Soyeon Kim Sent: 09 June 2011

[R] converting a matrix or data.frame into an html table

2011-05-09 Thread Samuel Le
Dear all, Is there a function in R to convert a matrix or a data.frame into an html table? Many thanks, Samuel [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

[R] help needed with LU decomposition: problem with sparse

2011-04-28 Thread Samuel Le
Dear all, I have a problem with the function lu to do LU decomposition: it seems that the algorithm multiplies the matrix I input by a permutation matrix for efficiency reasons -hence the sparse in the output. Does someone know whether it is possible to specify not to use any permutation

Re: [R] converting call objects into character

2011-04-05 Thread Samuel Le
To: Douglas Bates Cc: Samuel Le; r-help@r-project.org Subject: Re: [R] converting call objects into character On Apr 3, 2011, at 1:22 PM, Douglas Bates wrote: On Sun, Apr 3, 2011 at 11:42 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 3, 2011, at 12:14 PM, Samuel Le wrote: Dear all

[R] converting call objects into character

2011-04-03 Thread Samuel Le
Dear all, I would like to log the calls to my functions. I am trying to do this using the function match.call(): fTest-function(x) { theCall-match.call() print(theCall) return(x) } fTest(2) fTest(x = 2) [1] 2 I can see theCall printed into the console, but I

[R] controlling the labels width of a barplot

2011-04-01 Thread Samuel Le
Dear all, I am trying the barplot command but some of the labels are disappearing as there is not enough place on the graph to put them all. Here is an example of code that doesn't show all the labels: barplot(sort(runif(9,0,0.2),decreasing=TRUE),xlim=c(0,20),width=2,names.arg=c(first

Re: [R] text file problem-Help needed

2011-02-08 Thread Samuel Le
Hello, Make sure you have your file in your workspace directory (you can get it on your R console with the command getwd()). HTH, Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of George Pantop Sent: 08 February 2011 13:19

Re: [R] Matrix' with Functions

2011-02-03 Thread Samuel Le
Hello, Here is a quick suggestion: F-function(i,j,a,b,c,d) { res-eval(parse(text=paste(f,i,j,(a,b,c,d),sep=))) return(res) } HTH, Samuel -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Alaios Sent: 03 February

Re: [R] Constrained Regression

2011-01-20 Thread Samuel Le
Hello, Your problem is y=bX+epsilon It can be transformed into: epsilon^2=(y-bX)^2 Standard (unconstrained) regressions are about minimizing the variance of epsilon, ie (y-bX)^2. In your case, you need to minimize again the quantity (y-bX)^2 with your constraints on b=(b1,...,b5). Solve.QP

Re: [R] Integral of PDF

2010-12-03 Thread Samuel Le
Hi, You need to be careful with -Inf and Inf in R, I suppose they are some large numbers arbitrarily chosen by R, but not infinite quantities. So the function integrate can return errors if the function to integrate doesn't have negligible values beyond those large numbers. I ran the following

[R] t-stat for the coefficients of an ARIMA model

2010-11-25 Thread Samuel Le
Dear all, I am fitting a time series using the following command: Ts.arima-arima(x,c(2,1,2)) where x is a time series. What the function returns is perfectly fine but I was wondering if I could access to the t-stat of the coefficients I got from the arima function. Any help would be

[R] t-stat for the coefficients of an ARIMA model

2010-11-25 Thread Samuel Le
Dear all, I am fitting a time series using the following command: Ts.arima-arima(x,c(2,1,2)) where x is a time series. What the function returns is perfectly fine but I was wondering if I could access to the t-stat of the coefficients I got from the arima function. Any help would be