[R] ordering problem

2008-09-30 Thread Jose Luis Aznarte M.

   Hi there!
   I need some assistance here with vector orderings. I have a set 
of q vectors of length p, grouped by rows in a matrix A, q·p, that I 
need to order lexicographically 
(http://en.wikipedia.org/wiki/Lexicographical_order).
   I also have another matrix B, p·r, and a vector c, that should 
be ordered according to the order of A. So far, I was doing


   ordering <-  apply(A, 2, order)[,1]
   A <- A[ordering,]
   B <- B[ordering,]
   c <- c[ordering]

   But now I realize that this way I'm ordering by considering only 
the first dimension of the vectors in A, i.e., not considering the case 
where there are ties amongst this first dimension. Does anyone have a 
clue about properly applying the lexicographical ordering? Thanks in 
advance!



--  --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

__
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] Plots spanning columns

2008-08-28 Thread Jose Luis Aznarte M.
   Hi! I want to plot three graphs (residuals, ACF and PACF of a 
model). Ideally I would use a c(2,2) disposition where the residuals 
plot would start at position 1,1 and span to position 1,2. Then I would 
plot the ACF in position 2,1 and the PACF in position 2,2. Maybe is 
clearer like this:


--
||
|   residuals|
||
--
 -
|  | |   |
|ACF   | |   PACF|
|  | |   |
 -

Does anyone know if that is possible at all? Cheers!

--
--  --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

__
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] Combination with repetition

2008-08-15 Thread Jose Luis Aznarte M.
  Hi there! I can't find any information about creating combinations 
with repetitions in R. The function combn() does create combinations, 
but _without_ repetitions.

   Here is what I need to do:

svIter <- 1000
xx <- matrix(rnorm(m*n), c(m, n))
sequence <- seq(range(xx)[1], range(xx)[2], length.out = svIter^(1/q))
expand.grid(secuence, secuence, .../q times/..., secuence)

That is, I need a grid which covers a q-dimensional space with range 
range(xx) for each dimension, and a total number of points close to 
svIter. My problem could be solved by writting the expand.grid call at 
runtime, but I think that is not very elegant and, overall, I don't know 
how to do that. If combn() accepted repetitions, it'd be solved also.

   Any help will be greatly appreciated.
   Bests,

--          --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

__
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] A matrix multiplication

2007-09-27 Thread Jose Luis Aznarte M.
Dear all,
I'm having trouble using the 'apply' function to multiply some 
arrays. Let A be a 500x2 array and B a 500x3 array. I need a vector C 
which has 6 columns being the first three the result of A[,1] * B and 
the second three the result of A[,2] * B. What is the most efficient way 
to express that? I'm trying to use 'apply' with no success...
Thanks for your help!

 
--          --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

__
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] Percentiles in R

2007-09-11 Thread Jose Luis Aznarte M.
Ok, of course you were right. As Stefan pointed out, it was a 
problem of the type of the vector: it was a factor and hence the 
quantile was not what expected. Thank you all!!

Jose Luis Aznarte M. escribió:
> Hi there! Still struggling to translate Matlab code into R's tsDyn package.
> Here is my question: Is there in R an equivalent function to Matlab's 
> prctile()? To the moment I thought it was quantile(), but I just 
> realized I was wrong. The definition of the Matlab function:
>
> prctile
> Percentiles of a sample
> SyntaxY = prctile(X,p)
> Description
> Y = prctile(X,p) calculates a value that is greater than p percent of 
> the values in X. The values of p must lie in the interval [0 100]. For 
> instance, if p = 50 then Y is the median of X
>
> Thanks!!
>
>   


-- 
--          --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

__
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] Percentiles in R

2007-09-11 Thread Jose Luis Aznarte M.
Thank you all! But the problem is that quantile() returns "how many 
data" are greater than p percent, and not a value in the domain of the 
vector under scrutiny. For example, I have a vector

 > x
 [1] "-0,39559"  "1,1916""0,23214"   "1,656" "-0,3439"   "-0,50568"
 [7] "0,52281"   "0,96209"   "0,0087242" "-0,030727" "1,0935""0,35159" 
[13] "0,79229"   "0,81791"   "0,3186""1,0165""0,65567"   "-0,56474"
[19] "-0,34662"  "0,70435"   "-0,73285"  "-0,60452"  "-0,92526"  "-0,296"  
[25] "0,51298"   "0,38654"   "0,32469"   "-0,92555"  "0,53023"   "0,050059"
[31] "1,09"  "-0,35462"  "0,37674"   "1,1409""0,072098"  "1,4234"  
[37] "1,43"  "0,68532"   "0,078089"  "0,61944" 

and, if I want to see the 10th percentile, in Matlab I go

 >> prctile(x, 10)
ans =
   -0.4067

But in R:

 > quantile(x, probs=.1)
 10%
51.5

I need to obtain -0.4067, do you see what I mean? Thanks a lot again!!

Jose Luis Aznarte M. escribió:
> Hi there! Still struggling to translate Matlab code into R's tsDyn package.
> Here is my question: Is there in R an equivalent function to Matlab's 
> prctile()? To the moment I thought it was quantile(), but I just 
> realized I was wrong. The definition of the Matlab function:
>
> prctile
> Percentiles of a sample
> SyntaxY = prctile(X,p)
> Description
> Y = prctile(X,p) calculates a value that is greater than p percent of 
> the values in X. The values of p must lie in the interval [0 100]. For 
> instance, if p = 50 then Y is the median of X
>
> Thanks!!
>
>   


-- 
--  --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

__
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] Percentiles in R

2007-09-11 Thread Jose Luis Aznarte M.
Hi there! Still struggling to translate Matlab code into R's tsDyn package.
Here is my question: Is there in R an equivalent function to Matlab's 
prctile()? To the moment I thought it was quantile(), but I just 
realized I was wrong. The definition of the Matlab function:

prctile
Percentiles of a sample
SyntaxY = prctile(X,p)
Description
Y = prctile(X,p) calculates a value that is greater than p percent of 
the values in X. The values of p must lie in the interval [0 100]. For 
instance, if p = 50 then Y is the median of X

Thanks!!

-- 
--      --
Jose Luis Aznarte M.   http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada   Tel. +34 - 958 - 24 04 67
GRANADA (Spain)  Fax: +34 - 958 - 24 00 79

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