[R] Grid lines

2009-07-29 Thread Chris Li

Hi everyone. I am new to R.

It will be greatly appreciated if someone can help me with the following
questions.

Here's the graph I have just produced. 
http://www.nabble.com/file/p24732839/calibration.jpeg 

(1) How can I put the legend on top of the grid lines?

(2) How can I match the grid lines with the x-axis ticks?

(3) How can I change the x-axis format from e.g. Mar, Apr...etc to
1-3-2009,1-4-2009...etc?

Many thanks! :-)

Chris
-- 
View this message in context: 
http://www.nabble.com/Grid-lines-tp24732839p24732839.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Similar package like SEM

2009-07-29 Thread Stein, Luba (AIM SE)
Yes thank you, as far as I understood your proposal it would lead to a similar 
result. Is there a good package in order to do principal component analysis?

Best wishes,
Luba






Von: Andreas Hary [mailto:andreash...@googlemail.com]
Gesendet: Mittwoch, 29. Juli 2009 18:21
An: Stein, Luba (AIM SE)
Betreff: Re: [R] Similar package like SEM

Are you trying to build forward or yield curves by any chance? Consider using 
principal components on the log-differences of your yield-curve time series. 
That sort of gives you something like latent variables. You'll get a bunch of 
stationary random processes together with factor loadings for your maturities. 
You can then draw MC-samples from these processes to simulate future yield 
curves ... if that is indeed what you are after ...

Best wishes,


Andreas



On Wed, Jul 29, 2009 at 1:20 PM, Stein, Luba (AIM SE) 
mailto:luba.st...@allianz.com>> wrote:
Hello,

is there a similar package like SEM. In fact, I am looking for a package where 
I as input several given vector variables which are part of an autoregressive 
model.
Then I would like to obtan parameters for so called latent variables.

Thank you,
Luba




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


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

2009-07-29 Thread Petr PIKAL
Many thanks to you and all others for solutions together with regular 
expressions insights.

Petr

"Chuck Taylor"  napsal dne 29.07.2009 19:45:10:

> Petr,
> 
> Here is a different approach. It, in effect, works from the end of the
> string backwards, rather than from the beginning of the string forwards.
> 
>substring(x, regexpr("[0-9]+$", x))
> 
> The regular expression "[0-9]+$" finds a string of 1 or more ("+")
> digits ("[0-9]") followed by the end of the line ("$"). The regexpr()
> function returns the position in the string x where that regular
> expression begins. Feed that to substring() and you get the desired
> result. Both substring() and regexpr() work on vectors of strings.
> 
> Best regards,
> Chuck Taylor
> TIBCO Spotfire Seattle
> 
> 
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Petr PIKAL
> Sent: Wednesday, July 29, 2009 6:10 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] regexpr virtue
> 
> Hi all
> 
> I have got something like that (actually those are column names)
> 
> [51] "X19.2.300b...80"  "X19.2.400v...80" "X19.2.400b...80" 
> "X19.2.300v...90"  "X19.2.300b...90" 
> [56] "X19.2.400v...90"  "X19.2..400b..90" "X19.2.300v...100" 
> "X19.2.300b...100" "X19.2.400v...100" 
> 
> in character vector. I would like to get last n figures from this 
> character vector but my regexpr unerstanding is inferior and I did not 
> succeed. 
> Please, is there anybody who can extract those n digits from end of each
> 
> character string? If there were only 2 digits I could use substr but
> there 
> can be one, two or three digits.
> 
> ...
> 
> Best regards
> Petr

__
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/write connections

2009-07-29 Thread Prof Brian Ripley

From the help:


 Not all modes are applicable to all connections: for example URLs
 can only be opened for reading.

You omitted to tell us your platform (and requests to include that and 
not send HTML mail are in the posting guide), and pipe() differs by 
platform.  But AFAIR pipe() is one-way in all implementations.


On Wed, 29 Jul 2009, Markus Loecher wrote:


Dear fellow R users,
I would very much like to see an example of read/write connection (open =
"r+" ) for e.g. pipe() or any other R connection.


There is an example for file() on the very same help page!


I have a standalone program which accepts input from stdin, performs some
processing and returns the results on stdout. Is it possible at all to open
a connection to that program, write to it (i.e. to stdin of that process)
and read back the results ?


Not with a conventional pipe: look up your undisclosed OS's 
documentation for what a pipe is.  E.g. mine says


  The pipe() function creates a pipe (an object that allows
  unidirectional data flow) and allocates a pair of file descriptors.
  The first descriptor connects to the read end of the pipe; the
  second connects to the write end.

Note *unidirectional*.  However 'man popen' mentions 'bidirectional 
pipes' on Mac OS X (but not on Linux).


You can probably use system() to do what you ask, including the 'silly 
example'.



As a silly example, imagine the following use of the Unix function head:

zz <- pipe(" head ", open ="r+");
cat(rnorm(10), file = zz);

Error in cat(rnorm(10), file = zz) : cannot write to this connection

While I am not surprised that this does not work, I would love to know a
solution to this general problem.

Thanks

Markus

[[alternative HTML version deleted]]


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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@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 to standardize matriz?

2009-07-29 Thread Jorge Ivan Velez
Dear Samanta,

Take a look at ?scale.

HTH,

Jorge


On Thu, Jul 30, 2009 at 12:52 AM, Sam  wrote:

> Hi,
> this is probably a very basic question but I'm just learning R and i
> cannot find  a function to standardize a data matrix..
> I'll be grateful for any tips or help you can provide me.
>
> Thank you very 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.
>

[[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] Function to standardize matriz?

2009-07-29 Thread Linlin Yan
Did you mean this:

> m <- matrix(1:12, 3, 4)
> m / max(m)
   [,1]  [,2]  [,3]  [,4]
[1,] 0.0833 0.333 0.583 0.833
[2,] 0.1667 0.417 0.667 0.917
[3,] 0.2500 0.500 0.750 1.000

On Thu, Jul 30, 2009 at 12:52 PM, Sam wrote:
> Hi,
> this is probably a very basic question but I'm just learning R and i
> cannot find  a function to standardize a data matrix..
> I'll be grateful for any tips or help you can provide me.
>
> Thank you very 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.
>

__
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 to standardize matriz?

2009-07-29 Thread Bill.Venables
scale? 

This transforms the columns of a matrix to z-scores.  That's one kind of 
standardisation.   


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Sam
Sent: Thursday, 30 July 2009 2:52 PM
To: r-help@r-project.org
Subject: [R] Function to standardize matriz?

Hi,
this is probably a very basic question but I'm just learning R and i
cannot find  a function to standardize a data matrix..
I'll be grateful for any tips or help you can provide me.

Thank you very 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.

__
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] Function to standardize matriz?

2009-07-29 Thread Sam
Hi,
this is probably a very basic question but I'm just learning R and i
cannot find  a function to standardize a data matrix..
I'll be grateful for any tips or help you can provide me.

Thank you very 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] z[i,j] = x[i,j] * y(i+j) ?

2009-07-29 Thread glen_b



Gabor Grothendieck wrote:
> 
> Try this:
> 
> z <- x * y[row(x) + col(x)]
> 

Thanks! yes, that's the ticket.

In testing out your solution, I noticed I described my problem wrongly. 

Apologies to anyone I confused.

So a clarification for anyone trying to follow this:

The index for y should have been y[i+j-1]

Gabor's solution is correct for the question as asked, and it works just
fine when I apply it to what I *should* have asked:

z <- x * y[row(x) + col(x) -1]

Glen

-- 
View this message in context: 
http://www.nabble.com/z-i%2Cj--%3D-x-i%2Cj--*-y%28i%2Bj%29---tp24731799p24732020.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] z[i,j] = x[i,j] * y(i+j) ?

2009-07-29 Thread Bill.Venables
I take it you mean

z[i,j] = x[i,j]*y[i+j-1]

(as you had it z[1,1] = x[1,1]*y[2], whereas your example suggests is should be 
y[1])

Here is a suggestion:

> z <- x * y[outer(1:nrow(x), 1:ncol(x), "+")-1]
> z
  [,1]  [,2]  [,3]
[1,] 35.20 63.22 17.28
[2,] 50.14 64.80NA
[3,] 22.68 34.98 10.50
[4,] 29.68 33.60 15.30
>  


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of glen_b
Sent: Thursday, 30 July 2009 1:57 PM
To: r-help@r-project.org
Subject: [R] z[i,j] = x[i,j] * y(i+j) ?



For the life of me I couldn't work out what to searc

I have an m*n numeric matrix x and a numeric vector y (of length m+n-1)

How do I do a calculation like this?

z[i,j] = x[i,j] * y[i+j] ?


Well, one can write a pair of loops, or write a single loop 
within which we calculate a vector at a time, but ...

is there a "neat" way to do it?

tiny example:
x<-matrix(data=c(32,46,21,28,58,60,33,32,16,NA,10,15),nrow=4)
y<-c(1.1,1.09,1.08,1.06,1.05,1.02)
z<-matrix(nrow=4,ncol=3)

z[,1]=x[,1]*y[1:4]
z[,2]=x[,2]*y[2:5]
z[,3]=x[,3]*y[3:6]
 
which produces:

> x
 [,1] [,2] [,3]
[1,]   32   58   16
[2,]   46   60   NA
[3,]   21   33   10
[4,]   28   32   15

> y
[1] 1.10 1.09 1.08 1.06 1.05 1.02

> z
  [,1]  [,2]  [,3]
[1,] 35.20 63.22 17.28
[2,] 50.14 64.80NA
[3,] 22.68 34.98 10.50
[4,] 29.68 33.60 15.30

> z/x
 [,1] [,2] [,3]
[1,] 1.10 1.09 1.08
[2,] 1.09 1.08   NA
[3,] 1.08 1.06 1.05
[4,] 1.06 1.05 1.02

(this last to indicate what each element of x was multiplied by to produce
z... well, apart from the NA)

Thanks for any pointers

Glen

-- 
View this message in context: 
http://www.nabble.com/z-i%2Cj--%3D-x-i%2Cj--*-y%28i%2Bj%29---tp24731799p24731799.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] predict

2009-07-29 Thread Bill.Venables
Your 'newdata' is a vector.  To us predict() the newdata supplied must be a 
data frame, with components having the same names as the predictors used in the 
model.  If some of the variables are factors, then the corresponding factors in 
the newdata data frame must have the same names and the same levels as the 
original factors used in fitting the model *even if* not all levels are needed 
for the prediction.

This is a precise sort of area.  You may need to study the help information in 
a bit more detail.  predict() does work, if only you use it correctly.


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of serbring
Sent: Wednesday, 29 July 2009 11:31 PM
To: r-help@r-project.org
Subject: [R] predict


I have found a regression model, and i would like to predict value in
different points. I have tried to use predict function but it doesn't work.
I have used predict function like this:

newdata<-seq(from=0.1, to=0.32,by=0.02)
data<-predict(fm,newdata)

where fm is a regression model. The predict function return me that:

Error in eval(predvars, data, env) :   numeric argument 'envir' doesn't have
unitary length

where is the error?


-- 
View this message in context: 
http://www.nabble.com/predict-tp24719362p24719362.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] z[i,j] = x[i,j] * y(i+j) ?

2009-07-29 Thread Gabor Grothendieck
Try this:

z <- x * y[row(x) + col(x)]

z2 <- x
for(i in 1:nr) for(j in 1:nc) z2[i,j] <- x[i,j] * y[i+j]

all.equal(z, z2) # TRUE



On Wed, Jul 29, 2009 at 11:56 PM, glen_b wrote:
>
>
> For the life of me I couldn't work out what to searc
>
> I have an m*n numeric matrix x and a numeric vector y (of length m+n-1)
>
> How do I do a calculation like this?
>
> z[i,j] = x[i,j] * y[i+j] ?
>
>
> Well, one can write a pair of loops, or write a single loop
> within which we calculate a vector at a time, but ...
>
> is there a "neat" way to do it?
>
> tiny example:
> x<-matrix(data=c(32,46,21,28,58,60,33,32,16,NA,10,15),nrow=4)
> y<-c(1.1,1.09,1.08,1.06,1.05,1.02)
> z<-matrix(nrow=4,ncol=3)
>
> z[,1]=x[,1]*y[1:4]
> z[,2]=x[,2]*y[2:5]
> z[,3]=x[,3]*y[3:6]
>
> which produces:
>
>> x
>     [,1] [,2] [,3]
> [1,]   32   58   16
> [2,]   46   60   NA
> [3,]   21   33   10
> [4,]   28   32   15
>
>> y
> [1] 1.10 1.09 1.08 1.06 1.05 1.02
>
>> z
>      [,1]  [,2]  [,3]
> [1,] 35.20 63.22 17.28
> [2,] 50.14 64.80    NA
> [3,] 22.68 34.98 10.50
> [4,] 29.68 33.60 15.30
>
>> z/x
>     [,1] [,2] [,3]
> [1,] 1.10 1.09 1.08
> [2,] 1.09 1.08   NA
> [3,] 1.08 1.06 1.05
> [4,] 1.06 1.05 1.02
>
> (this last to indicate what each element of x was multiplied by to produce
> z... well, apart from the NA)
>
> Thanks for any pointers
>
> Glen
>
> --
> View this message in context: 
> http://www.nabble.com/z-i%2Cj--%3D-x-i%2Cj--*-y%28i%2Bj%29---tp24731799p24731799.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] partially sorting?

2009-07-29 Thread Bill.Venables
> x <-
+ matrix(c(1239,10,10,10,10,1234,10,10,10,10,1500,11,11,11,11,1001,11,11,11,11,
+  
+ 1009,11,11,11,11,1344,12,12,12,12,1349,12,12,12,12,1458,13,13,13,13),8,5,byrow
+ = T)
> x
 [,1] [,2] [,3] [,4] [,5]
[1,] 1239   10   10   10   10
[2,] 1234   10   10   10   10
[3,] 1500   11   11   11   11
[4,] 1001   11   11   11   11
[5,] 1009   11   11   11   11
[6,] 1344   12   12   12   12
[7,] 1349   12   12   12   12
[8,] 1458   13   13   13   13
> ind <- do.call(order, data.frame(x[,c(2:5,1)]))
> xs <- x[ind, ]
> xs
 [,1] [,2] [,3] [,4] [,5]
[1,] 1234   10   10   10   10
[2,] 1239   10   10   10   10
[3,] 1001   11   11   11   11
[4,] 1009   11   11   11   11
[5,] 1500   11   11   11   11
[6,] 1344   12   12   12   12
[7,] 1349   12   12   12   12
[8,] 1458   13   13   13   13
>  


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of ashley2000
Sent: Wednesday, 29 July 2009 12:07 PM
To: r-help@r-project.org
Subject: [R] partially sorting?


Dear all,

x <-
matrix(c(1239,10,10,10,10,1234,10,10,10,10,1500,11,11,11,11,1001,11,11,11,11,
 
1009,11,11,11,11,1344,12,12,12,12,1349,12,12,12,12,1458,13,13,13,13),8,5,byrow
= T)

> x
 [,1] [,2] [,3] [,4] [,5]
[1,] 1239   10   10   10   10
[2,] 1234   10   10   10   10
[3,] 1500   11   11   11   11
[4,] 1001   11   11   11   11
[5,] 1009   11   11   11   11
[6,] 1344   12   12   12   12
[7,] 1349   12   12   12   12
[8,] 1458   13   13   13   13

I tried to sort by 1st column, but stayed the other columns as they were. I
mean



 [,1] [,2] [,3] [,4] [,5]
[2,] 1234   10   10   10   10
[1,] 1239   10   10   10   10
--
[4,] 1001   11   11   11   11
[5,] 1009   11   11   11   11
[3,] 1500   11   11   11   11
--
[6,] 1344   12   12   12   12
[7,] 1349   12   12   12   12
--
[8,] 1458   13   13   13   13



any suggestions?

thanks

ashley
-- 
View this message in context: 
http://www.nabble.com/partially-sorting--tp24711191p24711191.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.


[R] z[i,j] = x[i,j] * y(i+j) ?

2009-07-29 Thread glen_b


For the life of me I couldn't work out what to searc

I have an m*n numeric matrix x and a numeric vector y (of length m+n-1)

How do I do a calculation like this?

z[i,j] = x[i,j] * y[i+j] ?


Well, one can write a pair of loops, or write a single loop 
within which we calculate a vector at a time, but ...

is there a "neat" way to do it?

tiny example:
x<-matrix(data=c(32,46,21,28,58,60,33,32,16,NA,10,15),nrow=4)
y<-c(1.1,1.09,1.08,1.06,1.05,1.02)
z<-matrix(nrow=4,ncol=3)

z[,1]=x[,1]*y[1:4]
z[,2]=x[,2]*y[2:5]
z[,3]=x[,3]*y[3:6]
 
which produces:

> x
 [,1] [,2] [,3]
[1,]   32   58   16
[2,]   46   60   NA
[3,]   21   33   10
[4,]   28   32   15

> y
[1] 1.10 1.09 1.08 1.06 1.05 1.02

> z
  [,1]  [,2]  [,3]
[1,] 35.20 63.22 17.28
[2,] 50.14 64.80NA
[3,] 22.68 34.98 10.50
[4,] 29.68 33.60 15.30

> z/x
 [,1] [,2] [,3]
[1,] 1.10 1.09 1.08
[2,] 1.09 1.08   NA
[3,] 1.08 1.06 1.05
[4,] 1.06 1.05 1.02

(this last to indicate what each element of x was multiplied by to produce
z... well, apart from the NA)

Thanks for any pointers

Glen

-- 
View this message in context: 
http://www.nabble.com/z-i%2Cj--%3D-x-i%2Cj--*-y%28i%2Bj%29---tp24731799p24731799.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] Re : Wavelet Kernel

2009-07-29 Thread Steve Lianoglou

Hi,

On Jul 29, 2009, at 9:38 PM, Stella Sim wrote:


Dear list,

I would like to fit a wavelet SVM model. Where can I find a wavelet
kernel function? Thanks in advance.


I reckon you might have to implement that one yourself.

It seems like this MATLAB SVM toolbox has a version of them:

http://asi.insa-rouen.fr/enseignants/~arakotom/toolbox/index.html

Perhaps you can use it (MATLAB) directly, or try to port the function  
to R if that's not an option. From a bit of googling around, it seems  
that it's computational expensive to compute the wavelet kernel, so it  
might be painful to run over a large amount of data. If that's the  
case, you might consider implementing it in C down the road.


Please do keep us posted :-)

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] Tripped up by Removing Level

2009-07-29 Thread jim holtman
Try this:

> bargin$stuffnew<-bargin$stuff[bargin$stuff != "very.high", drop=TRUE]
> bargin$stuffnew
 [1] lowmiddle lowlowlowlowmiddle lowmiddle
middle middle middle middle high
[15] high   lowmiddle middle lowhigh
Levels: low middle high
>


On Wed, Jul 29, 2009 at 8:47 PM, Jason Rupert wrote:
> Code is provided below.
>
> I was trying to follow the example at the following website:
> http://www.ats.ucla.edu/stat/R/modules/factor_variables.htm
>
> Only difference is that I am working with trying to remove a level from a 
> dataframe.  In the example below, notice that "very.high" is still a level in 
> bargin$stuffnew, even though I thought I removed it.
>
> Thanks for info on what I might have overlooked to remove "very.high" level 
> and if I can do it after the fact from bargin$stuffnew.
>
> Thanks again.
>
> bargin<-NULL
> ses<-NULL
> ses <- c("low", "middle", "low", "low", "low", "low", "middle", "low", 
> "middle", "middle", "middle", "middle", "middle", "high", "high", "low", 
> "middle", "middle", "low", "high")
> bargin$stuff <- factor(ses, levels = c("low", "middle", "high"))
> bargin$stuff
> bargin$stuff<-factor(bargin$stuff, levels = c(levels(bargin$stuff), 
> "very.high"))
> bargin$stuff
> bargin$stuffnew<-bargin$stuff[bargin$stuff != "very.high"]
> bargin$stuffnew
>  [1] low    middle low    low    low    low    middle low    middle middle 
> middle middle middle high
> [15] high   low    middle middle low    high
> Levels: low middle high very.high
>
> __
> 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 that 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] Re : Wavelet Kernel

2009-07-29 Thread Stella Sim
Dear list,

I would like to fit a wavelet SVM model. Where can I find a wavelet
kernel function? Thanks in advance.

Stella Sim


DISCLAIMER:\ This email contains confidential informatio...{{dropped:11}}

__
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] USGS stream flow data automatic download R

2009-07-29 Thread stephen sefick
Instantaneous Data, mean flow data could be a start.  That would be
wonderful if you would send it to me.

Stephen Sefick

On Wed, Jul 29, 2009 at 8:20 PM,  wrote:
> Stephen,
>
> I don't have anything or know of anything in R to do this. But, we download 
> USGS streamflow data routinely. I have a Perl script that will reformat the 
> downloaded data into a R-importable format (basically two columns date/time 
> flow value). Are you interested in mean daily or instantaneous streamflow 
> data?
>
> Regards,
> Tom
>
> - Original Message -
> From: stephen sefick 
> Date: Wednesday, July 29, 2009 9:03 pm
> Subject: [R] USGS stream flow data automatic download R
>
>> I don't even know if this is the right place to ask this question.  I
>> would like to download USGS stream gauging data for a couple of gauges
>> on a daily basis- save the files to .csv files and append the nest
>> days time series to this.  Is there a way to do this automatically in
>> R?
>> thanks,
>>
>> --
>> Stephen Sefick
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>                                                               -K. Mullis
>>
>> __
>> 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.htmland provide commented, minimal, self-contained,
>> reproducible code.
>>
>



-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] USGS stream flow data automatic download R

2009-07-29 Thread Thomas . Adams
Stephen,

I don't have anything or know of anything in R to do this. But, we download 
USGS streamflow data routinely. I have a Perl script that will reformat the 
downloaded data into a R-importable format (basically two columns date/time 
flow value). Are you interested in mean daily or instantaneous streamflow data?

Regards,
Tom

- Original Message -
From: stephen sefick 
Date: Wednesday, July 29, 2009 9:03 pm
Subject: [R] USGS stream flow data automatic download R

> I don't even know if this is the right place to ask this question.  I
> would like to download USGS stream gauging data for a couple of gauges
> on a daily basis- save the files to .csv files and append the nest
> days time series to this.  Is there a way to do this automatically in
> R?
> thanks,
> 
> -- 
> Stephen Sefick
> 
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
> 
>   -K. Mullis
> 
> __
> 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.htmland 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] automatic download of USGS stream gauging data with R

2009-07-29 Thread stephen sefick
I don't even know if this is the right place to ask this question.  I
would like to download USGS stream gauging data for a couple of gauges
on a daily basis- save the files to .csv files and append the nest
days time series to this.  Is there a way to do this automatically in
R?
thanks,

-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] USGS stream flow data automatic download R

2009-07-29 Thread stephen sefick
I don't even know if this is the right place to ask this question.  I
would like to download USGS stream gauging data for a couple of gauges
on a daily basis- save the files to .csv files and append the nest
days time series to this.  Is there a way to do this automatically in
R?
thanks,

-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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/write connections

2009-07-29 Thread Markus Loecher
Dear fellow R users,
I would very much like to see an example of read/write connection (open =
"r+" ) for e.g. pipe() or any other R connection.
I have a standalone program which accepts input from stdin, performs some
processing and returns the results on stdout. Is it possible at all to open
a connection to that program, write to it (i.e. to stdin of that process)
and read back the results ?

As a silly example, imagine the following use of the Unix function head:

zz <- pipe(" head ", open ="r+");
cat(rnorm(10), file = zz);

Error in cat(rnorm(10), file = zz) : cannot write to this connection

While I am not surprised that this does not work, I would love to know a
solution to this general problem.

Thanks

Markus

[[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] Tripped up by Removing Level

2009-07-29 Thread Jason Rupert
Code is provided below.

I was trying to follow the example at the following website:
http://www.ats.ucla.edu/stat/R/modules/factor_variables.htm

Only difference is that I am working with trying to remove a level from a 
dataframe.  In the example below, notice that "very.high" is still a level in 
bargin$stuffnew, even though I thought I removed it.  

Thanks for info on what I might have overlooked to remove "very.high" level and 
if I can do it after the fact from bargin$stuffnew.

Thanks again.

bargin<-NULL
ses<-NULL
ses <- c("low", "middle", "low", "low", "low", "low", "middle", "low", 
"middle", "middle", "middle", "middle", "middle", "high", "high", "low", 
"middle", "middle", "low", "high")
bargin$stuff <- factor(ses, levels = c("low", "middle", "high"))
bargin$stuff
bargin$stuff<-factor(bargin$stuff, levels = c(levels(bargin$stuff), 
"very.high"))
bargin$stuff
bargin$stuffnew<-bargin$stuff[bargin$stuff != "very.high"]
bargin$stuffnew
 [1] lowmiddle lowlowlowlowmiddle lowmiddle middle 
middle middle middle high  
[15] high   lowmiddle middle lowhigh  
Levels: low middle high very.high

__
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] Transparency and pyramid.plot

2009-07-29 Thread ws
Hi all

Another question related to my earlier -- how might I get transparency to work 
with pyramid.plot in library(plotrix)?  I can't figure it out, and the help 
page 
says it is there but doesn't give an example.

Thanks!

__
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] Superscripts and rounding

2009-07-29 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
>
> library(RODBC)
> library(HYDAT)
> You will need to install HYDAT (the zip file) from
> http://www.geog.ubc.ca/~rdmoore/Rcode.htm
>
> Below is my current code - which works. The [[]] is the way i am accessing
> the columns from the data frame.
>
> thanks again for all your help
>
> # load HYDAT data
> par(mfrow=c(3,1))
> path <- 'c:\\HYDAT'
> wsc.id <- '11AB075'
> stn <- ReadHydatFile(path, wsc.id)  #if data in CDROM image
> # stn <- ReadHydatDatabase (path, wsc.id) #if data in database
>

I'd need access to the whole data file.  I tried exporting some data from the 
website for it but it got too complex for me!

However, it seems to me you have two chunks of data:

stn[flow] - which has daily flow data in it?
stn[metadata] which i guess is a header for the whole dataset -describing what 
it is.

So I recreated what i hope might be simillar to part of your data (using lst 
instead of stn as the vector/array/list name)

# Build an array containing a lat & long.
info <- data.frame(latitude=1.0005689, longitude=55.698754)
#display result
info
#  latitude longitude
#1 1.000569  55.69875
#create a list (called lst) with an object metadata in it containing the array
lst <- list (metadata=info)
#display result
lst
#$metadata
#  latitude longitude
#1 1.000569  55.69875

#check if can call a single piece of data using the square brackets as 
references...
lst[['metadata']][['longitude']]
#[1] 55.69875

#now try rounding that
> round (lst[['metadata']][['longitude']], digits=2)
[1] 55.7

#now try sprintf'ing that
sprintf('Seasonal station with natural streamflow - Lat: %s', round 
(lst[['metadata']][['longitude']], digits=2))
# [1] "Seasonal station with natural streamflow - Lat: 55.7"

#now try that in a plot
plot(1,1, sub=sprintf('Seasonal station with natural streamflow - Lat: %s', 
round (lst[['metadata']][['longitude']], digits=2)))
# results in a correct label ;-)

Its possible to refer to that same value in the following ways:

> lst$metadata   # same as lst[['metadata']]
  latitude longitude
1 1.000569  55.69875
> lst$metadata[['longitude']] # same as lst[['metadata']][['longitude']]
[1] 55.69875
> lst$metadata$longitude # same as lst[['metadata']][['longitude']]
[1] 55.69875
>

So I'm stumped!  without being able to see the actual structure of your data I 
can't figure out why you are getting an error!

BTW - was there a cut and paste error?  Your error message was reported as:

Error: unexpected symbol in:
"  sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s km\UB2 - Effective Area %s km\UB2,
+ round( [['metadata"
> + round( [['metadata']][['longitude']], digits = 4),
Error: unexpected '[[' in "+ round( [["

The + on + round looks like the plus was typed. + shouldn't have been typed, 
but also was there a missing quote after the \UB2.  You should have entered:

sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s km\UB2 - Effective Area %s km\UB2 ',
round( [['metadata']][['latitude']], digits=4 ),
round( [['metadata']][['longitude']], digits = 4),
round( [['metadata']][['grossarea']], digits = 4),
round( [['metadata']][['effectivearea']], digits = 4))

C





This message may contain confidential information. If yo...{{dropped:21}}

__
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] pyramid.plot: x-axis scale

2009-07-29 Thread ws
Hi R-ers

Does anyone know how if there is a way to force pyramid plot where 
you determine the bottom axis range?  I want to compare many 
different pyramids, so I am hoping to force the bottom axis range
from 0% to 10%.

Here is the code so far, if it matters:

mk.pyr = function(data, pumas=NULL, fb.class=NULL, info="") {
# Makes population pyramids
# Assumes certain columns names in data -- SEX, AGEF, PUMA

males.i = data$SEX==1
females.i = data$SEX==1

if (is.null(pumas)) {
xy.pop = 100*as.double(prop.table(xtabs(pwgtp~AGEF, 
data[males.i,])))
xx.pop = 100*as.double(prop.table(xtabs(pwgtp~AGEF, 
  data[females.i,])))
 mytitle = sprintf("Population Pyramid for all pumas. %s.", 
info)

} else {
pumas.i = data$PUMA %in% pumas
xy.pop = 100*as.double(prop.table(
   xtabs(pwgtp~AGEF, data[males.i & pumas.i,])))
xx.pop = 100*as.double(prop.table(
   xtabs(pwgtp~AGEF, data[females.i & pumas.i ,])))
mytitle = sprintf("Population Pyramid for %s", 
 paste(paste(pumas, collapse=", "), ".", info, "."))
}
  agelabels<-c("0-4","5-9","10-14","15-19","20-24",
  "25-29","30-34","35-39","40-44","45-49",
  "50-54","55-59","60-64","65-69","70-74",
   "75-79","80-44","85+")
  xycol<-color.gradient(.5,.5,.5,18)
  xxcol<-color.gradient(.5,.5,.5,18)
  par(mar=pyramid.plot(xy.pop,xx.pop,labels=agelabels,
main=mytitle,xycol=xycol,xxcol=xxcol))
}

__
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] Combining two dataframes and specifying tolerance levels

2009-07-29 Thread Mehdi Khan
I do not know if this message got through or not, but please disregard it!
Thanks!

On Wed, Jul 29, 2009 at 2:57 PM, Mehdi Khan  wrote:

> Hello everyone,
>
> I have two data frames.  One is a vector about 780 rows long consisting of
> lat long data of 780 station locations.  The other table was previously a
> shape file which I have converted into a data frame object of lat long
> coordinates and attribute data.  What I want to do is combine the
> two--assigning attribute data to each station.  The problem is, however,
> that those station locations do not have duplicate location and attribute
> data in the shape file.  So what needs to be done is that a tolerance level
> has to be used to assign attribute data from the shape file data frame to
> the particular station location.
>
> I hope this is clear enough.  I should probably post this to sig geo, but I
> figured that since we are dealing with two data frames and matrices, I can
> push for it to go to this list (since it seems to have a lot more viewers).
>
> Thanks a lot!!!
>
> Mehdi Khan
>

[[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] Determination of lag value for Box.test

2009-07-29 Thread m.gharbi

Hi,

I saw that tsdiag function doesn't provide a correct result for Ljung-Box
test. I want to use Box.test function for this, but I don't know how to
determine lag parameter for this function. 
For fitdf, as I'm using a SARIMA model (0,1,1)(0,1,1)12, I decided to set it
to 2.

Can you confirm me the value for fitdf and give me a way to determine the
lag value?

Thanks
Myriam
-- 
View this message in context: 
http://www.nabble.com/Determination-of-lag-value-for-Box.test-tp24729062p24729062.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] Problem with contrast

2009-07-29 Thread Serguei Kaniovski


Hello All,

I am trying to estimate a generalized linear model using a single dummy
variable (bilat). I want to use contr.sum, in which (please correct me if I
am wrong) the implicit coefficient on the contrast equals the negative of
the sum of all estimated coefficients.

I cannot get the contrast to work correctly. The implicit coefficient is
way to large (I checked this using the desmat - option dev - package in
Stata). I do:

contrasts(bilat) <- contr.sum(levels(bilat))
mod_1 <- gamlss(d ~ bilat, family=BEINF, data=df)

but this problem is not specific to gamlss. The same problem occurs also,
e.g. in
contrasts(bilat) <- contr.sum(levels(bilat))
mod_2 <- lm(d ~ bilat, data=df)

What am I doing wrong? Thank you for help!

Serguei


Austrian Institute of Economic Research (WIFO)

P.O.Box 91  Tel.: +43-1-7982601-231
1103 Vienna, AustriaFax: +43-1-7989386

Mail: serguei.kaniov...@wifo.ac.at
http://www.wifo.ac.at/Serguei.Kaniovski
[[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] gbm package: relationship between interaction.depth and number of features?

2009-07-29 Thread Boris Yangel
Hello. I'm currently stuck with the same "what does interaction.depth really
mean" stuff. Did you find out what the right answer is?

 

Best regards,

Boris Yangel.

 


[[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] re siduals in arima

2009-07-29 Thread m.gharbi

Hi, 

I'm working on a multivariate ARIMA model. I have 2 time series and found
for each an ARIMA model
I'd like to know how are calculated the residuals of my arima model using
residuals() function in R ?
Is it as I think predicted values (from ARIMA model) - observed values ?

Is it relevant to use the residuals of my models to realize the
cross-correlation between my 2 time series?

Thanks
Myriam
-- 
View this message in context: 
http://www.nabble.com/residuals-in-arima-tp24726955p24726955.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] Combining two dataframes and specifying tolerance levels

2009-07-29 Thread Mehdi Khan
Hello everyone,

I have two data frames.  One is a vector about 780 rows long consisting of
lat long data of 780 station locations.  The other table was previously a
shape file which I have converted into a data frame object of lat long
coordinates and attribute data.  What I want to do is combine the
two--assigning attribute data to each station.  The problem is, however,
that those station locations do not have duplicate location and attribute
data in the shape file.  So what needs to be done is that a tolerance level
has to be used to assign attribute data from the shape file data frame to
the particular station location.

I hope this is clear enough.  I should probably post this to sig geo, but I
figured that since we are dealing with two data frames and matrices, I can
push for it to go to this list (since it seems to have a lot more viewers).

Thanks a lot!!!

Mehdi Khan

[[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] Side by Side Barplot Newbie Question

2009-07-29 Thread John Kane

I think your data is set up incorrectly.  
With your data below as "xx" try this. 

# Dotcharts are often better than barplots so you might want to 
# try this



library(reshape)
mm <- melt(xx, id=c(1:2)); mm
bb <- as.matrix(cast(mm, tt ~ task, sum))
barplot(bb, beside=TRUE, col=rainbow(4))
legend("topleft", legend=row.names(bb), text.col=rainbow(4))

# Dotcharts are often better than barplots so you might want to 
# try this in place of a barplot.

dotchart(bb, col=rainbow(4))
=
--- On Wed, 7/29/09, Brindha Selvaraj  wrote:

> From: Brindha Selvaraj 
> Subject: [R] Side by Side Barplot Newbie Question
> To: r-help@r-project.org
> Received: Wednesday, July 29, 2009, 1:48 PM
> Hi,
> 
> Many apologies for sending this twice.  I accidentally
> hit the send button
> before I finished writing my mail. I am new to R and 
> I hope someone can
> help me with my problem. I am trying to draw a side by side
> barplot.
> 
> There is a main experiment and there are many sub
> experiments within the
> main experiment. I would like to draw a bar plot showing
> the number and type
> of sub_experiments done for each main_exp.  For
> instance if the Main_Exp is
> 6, I would like to group the sub exp's for the main_exp and
> show that there
> were two sub_exp's done an ELISA and a FCM and that the
> ELISA was done once
> and the FCM was done twice.  Similarly for Main_Exp 7
> I would like to show
> that for there were ELISA,FCM,qPCR,Telometry done and that
> they had a count
> of 3,3,2,5 respectively. This is what my dataset looks
> like:
> 
> Main_Exp_Name     Sub_Exp_Name 
> Sub_Exp_Count
> 1               
>             ELISA   
>              2
> 6               
>             ELISA   
>              1
> 6               
>          
>    FCM         
>          2
> 7               
>          
>    ELISA         
>        3
> 7               
>          
>    FCM         
>          3
> 7               
>          
>    Telometry       
>     2
> 7               
>          
>    qPCR         
>         5
> 
> The code that I have is
> 
> table(comparisons_new)
> barplot(as.matrix(comparisons_new$Sub_Exp_Count),xlab="Main_Exp_Name",
> ylab="Sub_Exp_Count",ylim=c(0,10),names.arg=(comparisons_new$Main_Exp_Name),beside=TRUE,legend=rownames(comparisons_new$Sub_Exp_Name),col=rainbow(5))
> 
> With this code, I am able to draw the barplot, but am
> having issues:
> 
> I am not able to group them together.  That is for
> each Main_Exp I am not
> able to group the Sub_Exp's under it. It all shows up as
> one continuous
> barplot without any spaces in between the Main_Exp's.
> 
> Also, I would like to be able to use the same colour for a
> particular
> sub_Exp_Name no matter in which ever Main_Exp it may show
> up.  But, this is
> not working for me.
> 
> Please help,
> 
> Brinda
> 
>     [[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.
> 


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

__
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 CRAN mirror is the fastest ?

2009-07-29 Thread Tal Galili
Hi dear R help group.

I was wondering how can I find out which CRAN mirror would be the fastest
for me (I leave in Israel and therefore don't have a CRAN mirror for our
country to go to by default)


Thanks,
Tal







-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[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] Object equality for S4 objects

2009-07-29 Thread Stavros Macrakis
To test two environments for object equality (Lisp EQ), I can use 'identity':

> e1 <- environment(local(function()x))
> e2 <- environment(local(function()x))
> identical(e1,e2)  # compares object identity
[1] FALSE
> identical(as.list(e1),as.list(e2))# compares values as name->value mapping
[1] TRUE# (is there a better way to do this?)

What is the corresponding function for testing whether two S4 objects
are the same object?  It appears that 'identity' for S4 objects
compares the *value*, not the *object identity*:

> setClass("simple",representation(a="logical"))
[1] "simple"
> s1 <- new("simple"); s2 <- new("simple")
> identical(s1,s1)
[1] TRUE   # not surprising
> identical(s1,s2)
[1] TRUE   # ? not comparing object identity
> s...@a <- TRUE
> s...@a <- TRUE
> identical(s1,s2)
[1] TRUE
> s...@a <- TRUE
> s...@a <- FALSE
> identical(s1,s2)
[1] FALSE

Thanks,

  -s

__
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] xtable formatting: RED for negative numbers?

2009-07-29 Thread cameron.bracken


Ken-JP wrote:
> 
> Is there a way to modify this code to generate RED numbers inside xtable
> for
> negative results in x.ts?
> 


This post would probably have been better for R-help.  Anyway, you can do it
easily by modifying print.xtable.R in the xtable package.  If it is easier,
make a copy of that file, modify it, load the xtable package, then source
your modified version.   

Basically change line 227 from 

result[i] <- gsub("-","$-$",result[i],fixed=TRUE)

to

result[i] <- gsub("-","\\color{red}$-$",result[i],fixed=TRUE)

and then your code chunk becomes:

<>= 
library(xtable)
x.ts <- ts(rnorm(100), start = c(1954, 7), frequency = 12)
x.table <- xtable( x.ts, digits = 1 ) 
print( x.table, floating = FALSE, math.style.negative = TRUE) 
@ 

Here is the patch:  http://www.nabble.com/file/p24727150/print.xtable.R.diff
print.xtable.R.diff 
Here is the output I got: 
http://www.nabble.com/file/p24727150/xtable-red.pdf xtable-red.pdf 

- Cameron

P.S. You must use the color package in latex.
-- 
View this message in context: 
http://www.nabble.com/xtable-formatting%3A-RED-for-negative-numbers--tp24712208p24727150.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] Newbie in R: Reading .txt files and storing the 'numbers' in a vector

2009-07-29 Thread Patrick Connolly
On Wed, 29-Jul-2009 at 10:29AM +0200, Patrick Schorderet wrote:

>
> Hello everybody,
>
> I'm a newbie in R and just went through an introduction class recently.

Did you get the distinction between a vector and a dataframe? 


>
> Here's my problem.
> I have 2 text files (.txt) with plain numbers ('doubles' for those who  
> know c++) ordered into 2 columns as below:
>
> coordinate1   value1
> coordinate2   value2
> coordinate3   value3
> ...   ...
> coordinateN   valueN
>
> I would like to write a small programme in which i would:
> 1. take all values of file 1 and store them in a vector

I'm fairly certain you need a dataframe, hence the recommendation to
look at read.table.



> 2. substract to those all values of file 2 (one by one) and store the  
> result in a new vector
> 3. Create a sliding window of chosen size and calculate the mathematical 
> average and store these averages in a new vector
> 4. Plot the different graphes with a bar plot

Those will follow simply once you have the first part working.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] Transporting data in different R windows

2009-07-29 Thread Patrick Connolly
On Wed, 29-Jul-2009 at 06:15AM -0700, Bogaso wrote:

|> 
|> Hi,
|> 

|> I am working with multiple R-windows opened and would like to
|> transport some variables from one to another. Is there any direct
|> way to do this without saving them in hard-disk?

With so little information given, I can't tell whether you know the
difference between a window and a directory.  If you tell us what's
different about your "windows" we might be in a position to know what
you're trying to do,

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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 programming class - Boston USA area - or online

2009-07-29 Thread Boucher, Mike

Hello -

  I am just beginning to look into R Programming and have written some basic R 
code.  Do you know of anyone in the Boston-USA area that might be offering any 
courses on R Programming?  Or possibly a course online?

  Many thanks

  Mike Boucher


Michael Boucher | Quantitative Analyst - Portfolio Manager | Fidelity Strategic 
Advisers | 82 Devonshire Street Boston MA V5D | 617-563-2691
--
FIDELITY CONFIDENTIAL INFORMATION
This e-mail, and any attachments hereto, are intended fo...{{dropped:17}}

__
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] Package with function for plots with embedded hyperlinks?

2009-07-29 Thread John Kane

Don't leave us hanging!  What is it?


--- On Wed, 7/29/09, Don MacQueen  wrote:

> From: Don MacQueen 
> Subject: Re: [R] Package with function for plots with embedded hyperlinks?
> To: r-help@r-project.org
> Received: Wednesday, July 29, 2009, 11:43 AM
> Never mind, just after I sent this I
> finally did the right search.
> 
> It is
> 
>    RSVGTipsDevice
> 
> -Don
> 
> At 8:30 AM -0700 7/29/09, Don MacQueen wrote:
> >Some years ago, if I recall correctly, I learned of a
> package that 
> >included a function that would write a plot to a file
> so that one 
> >could associate hyperlinks with elements of the plot,
> such as 
> >points. Then, when the plot was displayed in a browser,
> one could 
> >click on (for example) a point, and jump to wherever
> the hypelink 
> >pointed.
> >
> >I don't remember then name of the package or function,
> and haven't 
> >been able to find it after some searching.
> >
> >Does anyone know the name, or have a suggestion to help
> track it down?
> >
> >Thanks
> >-Don
> >--
> >--
> >Don MacQueen
> >Environmental Protection Department
> >Lawrence Livermore National Laboratory
> >Livermore, CA, USA
> >925-423-1062
> >
> >__
> >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.
> 
> 
> -- 
> --
> Don MacQueen
> Environmental Protection Department
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
> 
> __
> 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.
> 


  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share
__
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] Superscripts and rounding

2009-07-29 Thread ehux

library(RODBC)
library(HYDAT)
You will need to install HYDAT (the zip file) from
http://www.geog.ubc.ca/~rdmoore/Rcode.htm 

Below is my current code - which works. The [[]] is the way i am accessing
the columns from the data frame. 

thanks again for all your help

# load HYDAT data
par(mfrow=c(3,1))
path <- 'c:\\HYDAT'
wsc.id <- '11AB075'
stn <- ReadHydatFile(path, wsc.id)  #if data in CDROM image
# stn <- ReadHydatDatabase (path, wsc.id) #if data in database

# subset daily flow record for plotting purposes
dates <- c(as.Date('1927-01-01'), as.Date('1960-12-31'))
decade <- subset(stn[['flow']][['daily']], date >= dates[1] & date <=
dates[2])

# identify days flagged as backwater ('B') or estimated ('E')
# daily.flags is a vector of color names used to apply to points
daily.flags <- rep('NA', nrow(decade))
daily.flags[which(decade[['flag']] == 'A')] <- 'goldenrod'
daily.flags[which(decade[['flag']] == 'E')] <- 'red'
daily.flags[which(decade[['flag']] == 'B')] <- 'blue' 

 # subset daily flow record for plotting purposes
dates <- c(as.Date('1970-01-01'), as.Date('2008-12-31'))
decade <- subset(stn[['flow']][['daily']], date >= dates[1] & date <=
dates[2])

# identify days flagged as backwater ('B') or estimated ('E')
# daily.flags is a vector of color names used to apply to points
daily.flags <- rep('NA', nrow(decade))
daily.flags[which(decade[['flag']] == 'A')] <- 'goldenrod'
daily.flags[which(decade[['flag']] == 'E')] <- 'red'
daily.flags[which(decade[['flag']] == 'B')] <- 'blue'

  # last plot entire series with subtitle as a light gray line

plot (
  decade[['date']],
  decade[['value']],

  type = 'l',
  col = 'lightsteelblue4',
  ylab = 'Discharge [cms]',
  main = sprintf('%s [%s]', stn[['metadata']][['name']],
stn[['metadata']][['id']]),
  sub = sprintf('Seasonal station with natural streamflow - Lat: %s Lon: %s
Gross Area %s\km\UB2 - Effective Area %s\km\UB2',
stn[['metadata']][['latitude']],
stn[['metadata']][['longitude']],stn[['metadata']][['grossarea']],
stn[['metadata']][['effectivearea']],
  cex.sub = 1, font.sub = 3, col.sub = "black"
  ))


# overlay the points where the daily value has been flagged.
# Note the daily.flags array contains NAs for days when not flagged, so
these will not show up as
# points in the plot.
lines (
  decade[['date']],
  decade[['value']],
  type = 'p',
  cex = 0.1,
  pch = 20,
  col = daily.flags
)

# slap a legend on the plot...
legend (
  x = 'topright',
  legend = c('Partial', 'Estimated', 'Backwater', 'Not flagged (A, E or
B)'),
  lty = c(0,0,0,1),
  pch = c(20,20,20,NA),
  col = c('goldenrod','red','blue','lightsteelblue4'),
  cex = 0.75
)
-- 
View this message in context: 
http://www.nabble.com/Superscripts-and-rounding-tp24682319p24726439.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] Standard error of Median in MASS library

2009-07-29 Thread Greg Snow
Well the MASS package is support for a book, the details for most of functions 
in the package are detailed in the book, so if you really want to know, either 
look at the code, or read the book.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Lisa Wang
> Sent: Wednesday, July 29, 2009 12:05 PM
> To: r-help@r-project.org
> Subject: [R] Standard error of Median in MASS library
> 
> Dear All,
> 
> I wonder which function in MASS library calculates and output the
> standard error of median.
> 
> Thank you in advance for your help
> 
> Lisa Wang
> 
> Biostatistics, Princess Margaret hospital,
> toronto, On
> 
> __
> 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] Side by Side Barplot Newbie Question

2009-07-29 Thread Tal Galili
Hi Brindha
Does this answer your question:
http://onertipaday.blogspot.com/2007/05/make-many-barplot-into-one-plot.html
?

Cheers,
Tal



On Wed, Jul 29, 2009 at 8:48 PM, Brindha Selvaraj wrote:

> Hi,
>
> Many apologies for sending this twice.  I accidentally hit the send button
> before I finished writing my mail. I am new to R and  I hope someone can
> help me with my problem. I am trying to draw a side by side barplot.
>
> There is a main experiment and there are many sub experiments within the
> main experiment. I would like to draw a bar plot showing the number and
> type
> of sub_experiments done for each main_exp.  For instance if the Main_Exp is
> 6, I would like to group the sub exp's for the main_exp and show that there
> were two sub_exp's done an ELISA and a FCM and that the ELISA was done once
> and the FCM was done twice.  Similarly for Main_Exp 7 I would like to show
> that for there were ELISA,FCM,qPCR,Telometry done and that they had a count
> of 3,3,2,5 respectively. This is what my dataset looks like:
>
> Main_Exp_Name Sub_Exp_Name  Sub_Exp_Count
> 1ELISA 2
> 6ELISA 1
> 6 FCM   2
> 7 ELISA 3
> 7 FCM   3
> 7 Telometry2
> 7 qPCR  5
>
> The code that I have is
>
> table(comparisons_new)
> barplot(as.matrix(comparisons_new$Sub_Exp_Count),xlab="Main_Exp_Name",
>
> ylab="Sub_Exp_Count",ylim=c(0,10),names.arg=(comparisons_new$Main_Exp_Name),beside=TRUE,legend=rownames(comparisons_new$Sub_Exp_Name),col=rainbow(5))
>
> With this code, I am able to draw the barplot, but am having issues:
>
> I am not able to group them together.  That is for each Main_Exp I am not
> able to group the Sub_Exp's under it. It all shows up as one continuous
> barplot without any spaces in between the Main_Exp's.
>
> Also, I would like to be able to use the same colour for a particular
> sub_Exp_Name no matter in which ever Main_Exp it may show up.  But, this is
> not working for me.
>
> Please help,
>
> Brinda
>
>[[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.
>



-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[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] Transporting data in different R windows

2009-07-29 Thread Tal Galili
In the useR 2009 conference there was a lecture on how to use bigmemory to
create and object (a matrix I guess) - and then be able to access it from
two R sessions.

Consider searching for that :)

Tal







On Wed, Jul 29, 2009 at 4:15 PM, Bogaso  wrote:

>
> Hi,
>
> I am working with multiple R-windows opened and would like to transport
> some
> variables from one to another. Is there any direct way to do this without
> saving them in hard-disk?
>
> Thanks
> --
> View this message in context:
> http://www.nabble.com/Transporting-data-in-different-R-windows-tp24719077p24719077.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.
>



-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[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] how to skip a numeric column for averaging other columns?

2009-07-29 Thread John Kane

log.raw.data <- log(raw.data[,2:10]) I think but I don't understand the   "Data 
has the first row for variable name"  comment

--- On Wed, 7/29/09, sandsky  wrote:

> From: sandsky 
> Subject: [R]  how to skip a numeric column for averaging other columns?
> To: r-help@r-project.org
> Received: Wednesday, July 29, 2009, 3:01 PM
> 
> Data has the first row for variable name and the first
> column for sample
> name. I want to take "Log" for all data, but how to compute
> without the
> first column for sample name.
> 
> That is, 
> 
> column 1: sample ID
> column 2-10: data
> 
> I want to find an average on each column (2-10)
> 
> > log.raw_data=log(raw_data,base=2)
> Error in Math.data.frame(list(sample_id = c(1L, 2L, 3L, 4L,
> 5L, 6L, 7L,  : 
>   non-numeric variable in data frame: sample_id
> 
> Thank you in advance,
> 
> Jin
> -- 
> View this message in context: 
> http://www.nabble.com/how-to-skip-a-numeric-column-for-averaging-other-columns--tp24723210p24723210.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.
> 


  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share what yo
__
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 skip a numeric column for averaging other columns?

2009-07-29 Thread Steve Lianoglou

Hi,

On Jul 29, 2009, at 3:02 PM, sandsky wrote:



Data has the first row for variable name and the first column for  
sample
name. I want to take "Log" for all data, but how to compute without  
the

first column for sample name.

That is,

column 1: sample ID
column 2-10: data


I think one thing you could/should do in your case is to set your  
rownames to your (I assume) unique sample ID's:


rownames(raw_data) <- raw_data[,1]

Then just nuke that first column:

raw_data <- raw_data[,-1]

But even if you don't do that:


I want to find an average on each column (2-10)


apply(raw_data,2,mean)
Error in Math.data.frame(list(sample_id = c(1L, 2L, 3L, 4L, 5L, 6L,  
7L,  :

 non-numeric variable in data frame: sample_id


You can just run your function over all of the columns *except* the  
first:


apply(raw_data[,-1], 2, mean)

But in this specific case, you can use the specialized colMeans  
function:


colMeans(raw_data[,-1])

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] Standard error of Median in MASS library

2009-07-29 Thread Lisa Wang
Dear All,

I wonder which function in MASS library calculates and output the
standard error of median. 

Thank you in advance for your help

Lisa Wang

Biostatistics, Princess Margaret hospital,
toronto, On

__
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] Installing lme4 package in Windows Vista

2009-07-29 Thread Angela Radulescu

Thanks everyone!

It works now :)

Cheers,
a. 



ONKELINX, Thierry wrote:
> 
> Dear Angela,
> 
> lme() is a part of the nlme package. The lme4 package has the function
> lmer() which is the equivalent of lme() from nlme. Both function differ
> in their capabilities. Briefly: lmer() can (easly) do crossed random
> effects and GLMM, lme() can handle variance and correlation structures.
> 
> HTH,
> 
> Thierry
> 
> PS Don't for get that you need to load a package before using it! Just
> installing it is not sufficient.
> 
> library(lme4)
> ?lmer
> 
> library(nlme)
> ?lme
> 
> 
> 
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> thierry.onkel...@inbo.be
> www.inbo.be
> 
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
> 
> The plural of anecdote is not data.
> ~ Roger Brinner
> 
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
> 
> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> Namens Angela Radulescu
> Verzonden: woensdag 29 juli 2009 1:48
> Aan: r-help@r-project.org
> Onderwerp: [R] Installing lme4 package in Windows Vista
> 
> 
> Hi all,
> 
> I have a problem with package installing in Windows, on my PC machine.
> The end goal is to be able to use the lme() function. Here's what I did
> so far: 
> 
>> install.packages("lme4")
> Warning in install.packages("lme4") :
>   argument 'lib' is missing: using
> 'C:\Users\Angela\Documents/R/win-library/2.9'
> --- Please select a CRAN mirror for use in this session --- trying URL
> 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/lme4_0.999375-31.z
> ip'
> Content type 'application/zip' length 1140865 bytes (1.1 Mb) opened URL
> downloaded 1.1 Mb
> 
> package 'lme4' successfully unpacked and MD5 sums checked
> 
> The downloaded packages are in
> 
> C:\Users\Angela\AppData\Local\Temp\Rtmp1t8vjT\downloaded_packages
> updating HTML package descriptions
> Warning message:
> In file.create(f.tg) :
>   cannot create file 'C:\PROGRA~1\R\R-29~1.1/doc/html/packages.html',
> reason 'Permission denied'
> 
> I had to change permissions on some of the "library" folder before this.
> Still, after installation, R cannot find the "lme" function of interest.
> 
> 
>> lme
> Error: object 'lme' not found
> 
> Does anyone know why this is happening, and what the solution to the
> problem is? 
> 
> Many thanks,
> Angela
> --
> View this message in context:
> http://www.nabble.com/Installing-lme4-package-in-Windows-Vista-tp2470993
> 2p24709932.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.
> 
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver
> weer 
> en binden het INBO onder geen enkel beding, zolang dit bericht niet
> bevestigd is
> door een geldig ondertekend document. The views expressed in  this message 
> and any annex are purely those of the writer and may not be regarded as
> stating 
> an official position of INBO, as long as the message is not confirmed by a
> duly 
> signed document.
> 
> __
> 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/Installing-lme4-package-in-Windows-Vista-tp24709932p24723919.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] regexpr virtue

2009-07-29 Thread Chuck Taylor
Petr,

Here is a different approach. It, in effect, works from the end of the
string backwards, rather than from the beginning of the string forwards.

   substring(x, regexpr("[0-9]+$", x))

The regular expression "[0-9]+$" finds a string of 1 or more ("+")
digits ("[0-9]") followed by the end of the line ("$"). The regexpr()
function returns the position in the string x where that regular
expression begins. Feed that to substring() and you get the desired
result. Both substring() and regexpr() work on vectors of strings.

Best regards,
Chuck Taylor
TIBCO Spotfire Seattle


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Petr PIKAL
Sent: Wednesday, July 29, 2009 6:10 AM
To: r-h...@stat.math.ethz.ch
Subject: [R] regexpr virtue

Hi all

I have got something like that (actually those are column names)

[51] "X19.2.300b...80"  "X19.2.400v...80" "X19.2.400b...80"  
"X19.2.300v...90"  "X19.2.300b...90" 
[56] "X19.2.400v...90"  "X19.2..400b..90" "X19.2.300v...100"  
"X19.2.300b...100" "X19.2.400v...100" 

in character vector. I would like to get last n figures from this 
character vector but my regexpr unerstanding is inferior and I did not 
succeed. 
Please, is there anybody who can extract those n digits from end of each

character string? If there were only 2 digits I could use substr but
there 
can be one, two or three digits.

...

Best regards
Petr

__
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] Transporting data in different R windows

2009-07-29 Thread Bos, Roger
I wrote simple function to copy data from/to excel using the clipboard.
These should also work from one window to the next:

# To read from clipboard
"fromExcel" <- function() {read.table("clipboard-128", header=TRUE,
sep="\t")}
"toExcel" <- function(x) {write.table(x, "clipboard-128", sep="\t",
row.names=FALSE)} 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Bogaso
Sent: Wednesday, July 29, 2009 9:16 AM
To: r-help@r-project.org
Subject: [R] Transporting data in different R windows


Hi,

I am working with multiple R-windows opened and would like to transport
some variables from one to another. Is there any direct way to do this
without saving them in hard-disk?

Thanks
--
View this message in context:
http://www.nabble.com/Transporting-data-in-different-R-windows-tp2471907
7p24719077.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.
***

This message is for the named person's use only. It may\...{{dropped:20}}

__
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] standard error of median in MASS library

2009-07-29 Thread Lisa Wang
Hello all,

I wonder which function in MASS library is calculating the standard
error of median?

thank you very much in advance,

Lisa

__
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 compute other columns without a column for sample name

2009-07-29 Thread sandsky

Data has the first row for variable name and the first column for sample
name. I want to take "Log" for all data, but how to compute without the
first column for sample name.

> log.raw_data=log(raw_data,base=2)
Error in Math.data.frame(list(sample_id = c(1L, 2L, 3L, 4L, 5L, 6L, 7L,  : 
  non-numeric variable in data frame: sample_id

Thank you in advance,

Jin
-- 
View this message in context: 
http://www.nabble.com/how-to-compute-other-columns-without-a-column-for-sample-name-tp24723210p24723210.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] Side by Side Barplot newbie question

2009-07-29 Thread Brinda S
Hi,

 

Many apologies for sending this twice.  I accidentally hit the send
button before I finished writing my mail. I am new to R and  I hope
someone can help me with my problem. I am trying to draw a side by side
barplot.  

 

There is a main experiment and there are many sub experiments within the
main experiment. I would like to draw a bar plot showing the number and
type of sub_experiments done for each main_exp.  For instance if the
Main_Exp is 6, I would like to group the sub exp's for the main_exp and
show that there were two sub_exp's done an ELISA and a FCM and that the
ELISA was done once and the FCM was done twice.  Similarly for Main_Exp
7 I would like to show that for there were ELISA,FCM,qPCR,Telometry done
and that they had a count of 3,3,2,5 respectively. This is what my
dataset looks like:

 

Main_Exp_Name Sub_Exp_Name  Sub_Exp_Count

1ELISA 2

6ELISA 1

6 FCM   2

7 ELISA 3

7 FCM   3

7 Telometry2

7 qPCR  5

 

The code that I have is 

 

table(comparisons_new)

barplot(as.matrix(comparisons_new$Sub_Exp_Count),xlab="Main_Exp_Name",
ylab="Sub_Exp_Count",ylim=c(0,10),names.arg=(comparisons_new$Main_Exp_Na
me),beside=TRUE,legend=rownames(comparisons_new$Sub_Exp_Name),col=rainbo
w(5))

 

With this code, I am able to draw the barplot, but am having issues:

 

I am not able to group them together.  That is for each Main_Exp I am
not able to group the Sub_Exp's under it. It all shows up as one
continuous barplot without any spaces in between the Main_Exp's.

 

Also, I would like to be able to use the same colour for a particular
sub_Exp_Name no matter in which ever Main_Exp it may show up.  But, this
is not working for me.

 

Please help,

 

Brinda


[[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] Watching tune parameters for SVM?

2009-07-29 Thread Noah Silverman

Hi,

I'm switch over from RapidMiner to R.  (The learning curve is steep, but 
there is so much more I can do with R and it runs much faster overall.)


In RapidMiner, I can "tune" a parameter of my svm in a nice cross 
validation loop.  The process will print out the progress as it goes. 
So for a 5x cross tuning for the value of C with auc as my performance 
measure, I see


XVCAUC
11.5
21.48
31.51
41.52
12.52
22.54
32.53
42.52
13.6
23.61
33.6
43.59
etc...

RapidMiner then takes the average for each value of C and reports back 
the best one.


RapidMiner will even graph the progress with C on the X axis and AUC on 
the Y axis so I can see how the process is doing.  (This is nice when 
training a large range of C so I can tell if it is worth stopping the 
process early.


I can even train 2 or more variables at a time in a big "grid" of 
combination is 5x cross validation for each combo. i.e. 10 values for C 
and 10 values for gamma gives 100 combinations with 5x cross validation 
for each for a total of 500 executions.


Is there anyway to do something similar to this in R.  I've come across 
the "tune" function, but don't entirely understand all the options. 
Additionally, I don't see how to output the progress as it goes.  (also, 
setting number of XV, averaging of scores, etc.)


Does anybody have any ideas?

Thanks






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


[R] Systematic resampling (in sequential Monte Carlo)

2009-07-29 Thread Giovanni Petris


Dear all,

Here is a little coding problem. It falls in the category of "how can I do
this efficiently?" rather than "how can I do this?" (I know how to do it
inefficiently). So, if you want to take the challenge, keep reading, otherwise
just skip to the next post - I won't be offended by that ;-)

I am coding a particle filter and I want to use systematic resampling to
"regenerate" particles. Basically, what this means is the following.

1. Start with a vector of "labels", x, say, of length N and a vector of
   probabilities, w, say - w[i] is the probability attached to x[i]. 

2. Draw N equally spaced random number in (0,1) as u = (1 : N + runif(1)) / N.

3. Define a new sample of "labels", y, say, by inverting the cdf defined by
   the probabilities w. That is, set 
   y[i] = x[k] if cumsum(w)[k-1] <= u[i] < cumsum(w)[k],  i=1, ..., N.

The following is a piece of R code that implements the procedure.

> ### Systematic resampling
> set.seed(2)
> x <- LETTERS[1 : 6] # labels
> w <- rexp(6)
> w <- w / sum(w) # probabilities
> W <- c(0, cumsum(w)) # cdf
> u <- (1 : 6 + runif(1)) / 6
> indNew <- sapply(seq_along(u),
+  function(i) (sum(W[i] <= u & u < W[i + 1])))
> (y <- rep(x, indNew))
[1] "A" "B" "D" "D" "F"
> ## graphically...
> plot(stepfun(seq_along(u), W), xaxt = "n")
> axis(1, at = seq_along(u), x)
> abline(h = u, lty = "dotted")
   
The question is the following. I believe the way I compute "newInd" is of
order N^2. Is there a smart way of doing it which is of order N? (I know there
is one, I just cannot find it...)

Thanks in advance,
Giovanni

__
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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread Ian Chidister
Jim-

That did the trick- thanks so much for taking the time to help me out.

Sincerely,

Ian Chidister

On Wed, Jul 29, 2009 at 11:57 AM, Ian Chidister wrote:

> Dear List,
>
> I'm an [R] novice starting analysis of an ecological dataset containing the
> basal areas of different tree species in a number of research plots.
> Example data follow:
>
> > Trees<-data.frame(SppID=as.factor(c(rep('QUEELL',2), rep('QUEALB',3),
> 'CORAME', 'ACENEG', 'TILAME')), BA=c(907.9, 1104.4, 113.0, 143.1, 452.3,
> 638.7, 791.7, 804.3), PlotID=as.factor(c('BU3F10', rep('BU3F11',2),
> rep('BU3F12',5
> > Trees
>SppID   BA  PlotID
> 1 QUEELL  907.9  BU3F10
> 2 QUEELL  1104.4 BU3F11
> 3 QUEALB  113.0  BU3F11
> 4 QUEALB  143.1  BU3F12
> 5 QUEALB  452.3  BU3F12
> 6 CORAME  638.7 BU3F12
> 7 ACENEG  791.7 BU3F12
> 8 TILAME  804.3   BU3F12
>
> Fields are (in order): Tree Species Code, Basal Area, and Plot Code.
>
> I've been successful in computing summary statistics by species or plot
> groups using tapply():
>
> > tapply(BA, PlotID, sum)
> BU3F10 BU3F11 BU3F12
>  907.91217.42830.1
>
> *My Question* I'd like to perform a similar function that tells me how many
> species are in each plot, I thought this would be possible using something
> like:
>
> > tapply(SppID, PlotID, nlevels)
> BU3F10 BU3F11 BU3F12
>5 55
>
> however, this outputs the total number of levels for the factor SppID
> rather than the number of species in each plot category which would look
> like:
>
> BU3F10 BU3F11 BU3F12
>124
>
> I understand, from reading the archive, that this occurs because R does not
> subset factor levels, but I'm wondering if there's a simple way around this.
>
>
> Thanks for your help,
>
> Ian Chidister
>
> Environment and Resources
> The Nelson Institute for Environmental Studies
> University of Wisconsin-Madison, USA
>

[[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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread jim holtman
Or even easier:

tapply(Trees$SppID, Trees$PlotID, function(x) length(unique(na.omit(x


On Wed, Jul 29, 2009 at 2:13 PM, Ian Chidister wrote:
> Hi All-
>
> Thanks for your quick responses.  I was looking for unique instances, so
> Jim's and Daniel's suggestions got the job done.  Using "length" alone
> didn't discriminate between multiple occurrences of the same species and
> multiple species.
>
> I do have one followup question- my full data set (not the example data) has
> a number of NAs in the SppID column, and [r] is currently counting the NAs
> as species occurrences.  Using Jim's code, I tried:
>
>>tapply(SppID, PlotID, function(Trees, na.rm=T) length(unique(Trees,
> na.rm=T)))
>
> and alternately:
>
>>tapply(SppID, PlotID, function(Trees) length(unique(Trees)), na.rm=T)
>
> which doesn't seem to convince [r] to ignore the NAs.  What am I doing
> wrong?
>
> Thanks,
>
> Ian
>
>        [[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 that 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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread jim holtman
One way is to exclude the NAs from consideration by creating a new
object without NAs in that column:

newTrees <- Trees[!is.na(Trees$SppID),]
tapply(newTrees$SppID, newTrees$PlotID, function(x) length(unique(x)))

On Wed, Jul 29, 2009 at 2:13 PM, Ian Chidister wrote:
> Hi All-
>
> Thanks for your quick responses.  I was looking for unique instances, so
> Jim's and Daniel's suggestions got the job done.  Using "length" alone
> didn't discriminate between multiple occurrences of the same species and
> multiple species.
>
> I do have one followup question- my full data set (not the example data) has
> a number of NAs in the SppID column, and [r] is currently counting the NAs
> as species occurrences.  Using Jim's code, I tried:
>
>>tapply(SppID, PlotID, function(Trees, na.rm=T) length(unique(Trees,
> na.rm=T)))
>
> and alternately:
>
>>tapply(SppID, PlotID, function(Trees) length(unique(Trees)), na.rm=T)
>
> which doesn't seem to convince [r] to ignore the NAs.  What am I doing
> wrong?
>
> Thanks,
>
> Ian
>
>        [[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 that 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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread Ian Chidister
Hi All-

Thanks for your quick responses.  I was looking for unique instances, so
Jim's and Daniel's suggestions got the job done.  Using "length" alone
didn't discriminate between multiple occurrences of the same species and
multiple species.

I do have one followup question- my full data set (not the example data) has
a number of NAs in the SppID column, and [r] is currently counting the NAs
as species occurrences.  Using Jim's code, I tried:

>tapply(SppID, PlotID, function(Trees, na.rm=T) length(unique(Trees,
na.rm=T)))

and alternately:

>tapply(SppID, PlotID, function(Trees) length(unique(Trees)), na.rm=T)

which doesn't seem to convince [r] to ignore the NAs.  What am I doing
wrong?

Thanks,

Ian

[[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] Determine the dimension-names of an element in an array in R

2009-07-29 Thread Poersching
Hey,
i have forgotten to generalize the code so

Correl<-Correl[1:4,,,]

must be

Correl<-Correl[1:length(c),,,]

it's because the comparison levels. I think you don't want the
correlation betweeen A1, B1, D1 and A2, C1, D1 ,
but between A1, B1, D1 and A1, C1, D1 or between A1, B1, D1 and A1, C2, D1.
So the "1:length(c)" writes only the correlation between the B and C out
of the whole correlation array.
That's also why the sequence in the second apply function is changed.

Regards Christian.

Poersching schrieb:
> Hey,
> I think I have a solution for your problem:
>
> Correl<-apply(DataArray_1,1:3, function(d1)
>   apply(DataArray_2,c(2,1,3), function(d) cor(d1,d))
> )
> Correl<-Correl[1:4,,,]
> dimnames(Correl)[[1]]<-c
> Correl<-aperm(Correl,c(2,3,1,4))
>
> This one should work. :-)
>
> Best Regards,
> Christian
>
> Sauvik De schrieb:
>   
>> Hi there,
>>
>> Thanks again for your reply. I know for-loop is always a solution to
>> my problem and I had already coded using for-loop. But the number of
>> levels for each dimension is large enough in actual problem and hence
>> it was time-consuming.
>> So, I was just wondering if there are any other alternative way-outs
>> to solving my problem. That's why I tried with apply functions
>> (sapply)assuming that this might work out faster even fractionally as
>> compared to for-loop.
>>
>> Cheers,
>> Sauvik
>>
>> On Mon, Jul 27, 2009 at 12:28 AM, Poersching > > wrote:
>>
>> Sauvik De schrieb:
>> 
>>> Hi:
>>> Lots of thanks for your valuable time!
>>>
>>> But I am not sure how you would like to use the function in this
>>> situation.
>>>
>>> As I had mentioned that the first element of my output array
>>> should be like:
>>>
>>> 
>>> cor(DataArray_1[dimnames(Correl)[[1]][1],dimnames(Correl)[[2]][1],dimnames(Correl)[[4]][1],],DataArray_2[dimnames(Correl)[[1]][1],dimnames(Correl)[[3]][1],dimnames(Correl)[[4]][1],],use="pairwise.complete.obs")
>>>
>>> in my below code.
>>>
>>> and
>>>
>>> the output array of correlation I wish to get using "sapply" as
>>> follows:
>>>
>>> Correl = sapply(Correl,function(d)
>>> cor(DataArray_1[...],DataArray_2[...],
>>> use="pairwise.complete.obs"))
>>>
>>> So it would be of great help if you could kindly specify how to
>>> utilise your function "findIndex" in ...
>>>
>>> Apologies for all this!
>>>
>>> Thanks & Regards,
>>> Sauvik
>>>
>>>   
>> Hey,
>> sorry, I haven't understood your problem last time, but now this
>> solution should solve your problem, so I hope. :-)
>> It's only a for to loop, but an apply function may work too. I
>> will think about this, but for now...  ;-)
>>
>> la<-length(a)
>> lb<-length(b)
>> lc<-length(c)
>> ld<-length(d)
>> for (ia in 1:la) {
>>   for (ib in 1:lb) {
>> for (ic in 1:lc) {
>>   for (id in 1:ld) {
>> Correl[ia,ib,ic,id]<-cor(
>>  DataArray_1[dimnames(Correl)[[1]][ia],
>>  dimnames(Correl)[[2]][ib],
>>  dimnames(Correl)[[4]][id],]
>>  ,
>>  DataArray_2[dimnames(Correl)[[1]][ia],
>>   dimnames(Correl)[[3]][ic],
>>   dimnames(Correl)[[4]][id],]
>>  ,
>>  use="pairwise.complete.obs")
>>   }
>> }
>>   }
>> }
>> ## with function findIndex you can find the dimensions with
>> ## i.e. cor values greater 0.5 or smaller -0.5, like:
>> findIndex(Correl,Correl[Correl>0.5])
>> findIndex(Correl,Correl[Correl<(-0.5)])
>>
>> I have changed the code of the function findIndex in line which
>> contents: el[j]<-which(is.element(data,element[j]))
>>
>> Rigards,
>> Christian
>>
>> 
>>> On Sun, Jul 26, 2009 at 3:54 PM, Poersching>> > wrote:
>>> > Sauvik De schrieb:
>>> >
>>> > Hi Gabor:
>>> > Many thanks for your prompt reply!
>>> > The code is fine. But I need it in more general form as I had
>>> mentioned that
>>> > I need to input any 0 to find its dimension-names.
>>> >
>>> > Actually, I was using "sapply" to calculate correlation and
>>> this idea was
>>> > required in the middle of correlation calculation.
>>> > I am providing the way I tried my calculation.
>>> >
>>> > a= c("A1","A2","A3","A4","A5")
>>> > b= c("B1","B2","B3")
>>> > c= c("C1","C2","C3","C4")
>>> > d= c("D1","D2")
>>> > e= c("E1","E2","E3","E4","E5","E6","E7","E8")
>>> >
>>> > DataArray_1 = array(c(rnorm(240)),dim=c(length(a),length(b),
>>> > length(d),length(e)),dimnames=list(a,b,d,e))
>>> > DataArray_2 = array(c(rnorm(320)), dim=c(length(a),length(c),
>>> > length(d),length(e)),dimnames=list(a,c,d,e))
>>> >
>>> > #Defining an empty array which will contain the correlation
>>> values (output
>>> > array)
>>> > Correl = array(NA, dim=c(length(a),lengt

[R] Side by Side Barplot Newbie Question

2009-07-29 Thread Brindha Selvaraj
Hi,

Many apologies for sending this twice.  I accidentally hit the send button
before I finished writing my mail. I am new to R and  I hope someone can
help me with my problem. I am trying to draw a side by side barplot.

There is a main experiment and there are many sub experiments within the
main experiment. I would like to draw a bar plot showing the number and type
of sub_experiments done for each main_exp.  For instance if the Main_Exp is
6, I would like to group the sub exp's for the main_exp and show that there
were two sub_exp's done an ELISA and a FCM and that the ELISA was done once
and the FCM was done twice.  Similarly for Main_Exp 7 I would like to show
that for there were ELISA,FCM,qPCR,Telometry done and that they had a count
of 3,3,2,5 respectively. This is what my dataset looks like:

Main_Exp_Name Sub_Exp_Name  Sub_Exp_Count
1ELISA 2
6ELISA 1
6 FCM   2
7 ELISA 3
7 FCM   3
7 Telometry2
7 qPCR  5

The code that I have is

table(comparisons_new)
barplot(as.matrix(comparisons_new$Sub_Exp_Count),xlab="Main_Exp_Name",
ylab="Sub_Exp_Count",ylim=c(0,10),names.arg=(comparisons_new$Main_Exp_Name),beside=TRUE,legend=rownames(comparisons_new$Sub_Exp_Name),col=rainbow(5))

With this code, I am able to draw the barplot, but am having issues:

I am not able to group them together.  That is for each Main_Exp I am not
able to group the Sub_Exp's under it. It all shows up as one continuous
barplot without any spaces in between the Main_Exp's.

Also, I would like to be able to use the same colour for a particular
sub_Exp_Name no matter in which ever Main_Exp it may show up.  But, this is
not working for me.

Please help,

Brinda

[[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] side-by-side Barplot newbie question

2009-07-29 Thread Brindha Selvaraj
Hi,

I am new to R and  I hope someone can help me with my problem. I am trying
to draw a side by side barplot.

There is a main experiment and there are many sub experiments within the
main experiment. I would like to draw a bar plot showing the number of
sub_experiments done for each main_exp.  For instance if the Main_Exp is 6,
I would like to group the sub exp's for the main_exp and show that there
were two sub_exp's done an ELISA and a FCM and that the ELISA was done once
and the FCM was done twice.  Similarly for Main_Exp 7 I would like to show
that for there were ELISA,FCM,qPCR,Telometry done and that they had a count
of 3,3,2,5 respectively. This is what my dataset looks like:

Task  Datatype  Count
1ELISA 2
6ELISA 1
6 FCM   2
7 ELISA 3
7 FCM   3
7 Telometry2
7 qPCR  5

The code that I have is

table(comparisons_new)

barplot(as.matrix(comparisons_new$Sub_Exp_Count),xlab="Main_Exp_Name",
ylab="Sub_Exp_Count",ylim=c(0,10),names.arg=(comparisons_new$Main_Exp_Name),beside=TRUE,legend=rownames(compariso
ns_new$Sub_Exp_Name),col=rainbow(5))

[[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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread Daniel Malter
does "length" instead of "nlevels" do what you want to do?

with(Trees,tapply(SppID,PlotID,unique))

daniel 


-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Ian Chidister
Gesendet: Wednesday, July 29, 2009 12:57 PM
An: r-help@r-project.org
Betreff: [R] - counting factor occurrences within a group: tapply()

Dear List,

I'm an [R] novice starting analysis of an ecological dataset containing the
basal areas of different tree species in a number of research plots.
Example data follow:

> Trees<-data.frame(SppID=as.factor(c(rep('QUEELL',2), rep('QUEALB',3),
'CORAME', 'ACENEG', 'TILAME')), BA=c(907.9, 1104.4, 113.0, 143.1, 452.3,
638.7, 791.7, 804.3), PlotID=as.factor(c('BU3F10', rep('BU3F11',2),
rep('BU3F12',5
> Trees
   SppID   BA  PlotID
1 QUEELL  907.9  BU3F10
2 QUEELL  1104.4 BU3F11
3 QUEALB  113.0  BU3F11
4 QUEALB  143.1  BU3F12
5 QUEALB  452.3  BU3F12
6 CORAME  638.7 BU3F12
7 ACENEG  791.7 BU3F12
8 TILAME  804.3   BU3F12

Fields are (in order): Tree Species Code, Basal Area, and Plot Code.

I've been successful in computing summary statistics by species or plot
groups using tapply():

> tapply(BA, PlotID, sum)
BU3F10 BU3F11 BU3F12
 907.91217.42830.1

*My Question* I'd like to perform a similar function that tells me how many
species are in each plot, I thought this would be possible using something
like:

> tapply(SppID, PlotID, nlevels)
BU3F10 BU3F11 BU3F12
   5 55

however, this outputs the total number of levels for the factor SppID rather
than the number of species in each plot category which would look like:

BU3F10 BU3F11 BU3F12
   124

I understand, from reading the archive, that this occurs because R does not
subset factor levels, but I'm wondering if there's a simple way around this.


Thanks for your help,

Ian Chidister

Environment and Resources
The Nelson Institute for Environmental Studies University of
Wisconsin-Madison, USA

[[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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread jim holtman
This is probably what you want; you need to count the number of unique
instances:

> tapply(Trees$SppID, Trees$PlotID, function(x) length(unique(x)))
BU3F10 BU3F11 BU3F12
 1  2  4
>


On Wed, Jul 29, 2009 at 12:57 PM, Ian Chidister wrote:
> Dear List,
>
> I'm an [R] novice starting analysis of an ecological dataset containing the
> basal areas of different tree species in a number of research plots.
> Example data follow:
>
>> Trees<-data.frame(SppID=as.factor(c(rep('QUEELL',2), rep('QUEALB',3),
> 'CORAME', 'ACENEG', 'TILAME')), BA=c(907.9, 1104.4, 113.0, 143.1, 452.3,
> 638.7, 791.7, 804.3), PlotID=as.factor(c('BU3F10', rep('BU3F11',2),
> rep('BU3F12',5
>> Trees
>   SppID       BA      PlotID
> 1 QUEELL  907.9  BU3F10
> 2 QUEELL  1104.4 BU3F11
> 3 QUEALB  113.0  BU3F11
> 4 QUEALB  143.1  BU3F12
> 5 QUEALB  452.3  BU3F12
> 6 CORAME  638.7 BU3F12
> 7 ACENEG  791.7 BU3F12
> 8 TILAME  804.3   BU3F12
>
> Fields are (in order): Tree Species Code, Basal Area, and Plot Code.
>
> I've been successful in computing summary statistics by species or plot
> groups using tapply():
>
>> tapply(BA, PlotID, sum)
> BU3F10 BU3F11 BU3F12
>  907.9    1217.4    2830.1
>
> *My Question* I'd like to perform a similar function that tells me how many
> species are in each plot, I thought this would be possible using something
> like:
>
>> tapply(SppID, PlotID, nlevels)
> BU3F10 BU3F11 BU3F12
>           5             5            5
>
> however, this outputs the total number of levels for the factor SppID rather
> than the number of species in each plot category which would look like:
>
> BU3F10 BU3F11 BU3F12
>           1            2            4
>
> I understand, from reading the archive, that this occurs because R does not
> subset factor levels, but I'm wondering if there's a simple way around this.
>
>
> Thanks for your help,
>
> Ian Chidister
>
> Environment and Resources
> The Nelson Institute for Environmental Studies
> University of Wisconsin-Madison, USA
>
>        [[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 that 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] Re : vector thank you it works

2009-07-29 Thread Inchallah Yarab
I'm very impressed by the quick replies on the mailer. Thanks a lot for your
> suggestions. They worked very well.





De : Linlin Yan 

Cc : r-help@r-project.org
Envoyé le : Mercredi, 29 Juillet 2009, 18h26mn 32s
Objet : Re: [R] vector

rep(A, each=2)

On Thu, Jul 30, 2009 at 12:15 AM, Inchallah

> Hi ,
>
> i have a vector A=(a1,a2,a3,a4) and i want to create another vector B[[elided 
> Yahoo spam]]
[[elided Yahoo spam]]
>
[[elided Yahoo spam]]
>
>
>
>        [[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.
>



  
[[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] (senza oggetto)

2009-07-29 Thread Jorge Ivan Velez
Caro Sabrina,
Take a look at ?options, especially the max.print parameter.

Ciao,

Jorge


2009/7/29 

> Ciao,
> ho aperto con R un file di classe data frame con 15000 righe e 29 colonne.
> Nella console perň sono visualizzate solo la prime e l'ultima colonna e le
> ultime 8000 righe circa.
> E' possibile una visualizzazione completa?
> Grazie
> Sabrina
>
>[[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.
>
>

[[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] Summarising Data for Forrest Plots

2009-07-29 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
>> What I want to do is do a forrest (forest) plot for subgroups within my 
>> single dataset as a test of heterogeniety. I have a dataset who received 
>> either full dose(FD) or reduced dose(RD) treatment, and a number of 
>> characteristics about those subjects: age, sex, renal function, weight, 
>> toxicity.  And I have survival data (censored).  they are in standard 
>> columnar data.
>>
> Is there an *easy* way to transform them into something like this:
>>
>> SubGroupn.FDn.RDsurv.FD surv.RD
>> 1   Age >65
>> 2   Age <= 65
>> 3   Male
>> ...
>> 9   Grade 0-2 Tox
>> 10  Grade 3/4 Tox

>>
>Hi Calum,
>Have you tried subsetting the dataset like this:
>
>meta.DSL(...,data=mydataset[mydataset$age <= 65,],...)
>
>Jim

Hi Jim,

I'm not sure that I understand!  But my understanding was that meta.DSL wants 4 
bits of information number treated (Full Dose in my case), Number in control 
(reduced dose in my case), Number of events in the twoi groups... which is what 
I was trying to describe above - although possibly not very well..

Then it will do the work for me.

My challenge is taking a load of data in columns and getting it summarised by 
the subgroups so that it takes Age > 65 and counts how many had full dose, 
howmany had reduced dose and populates the field then does the same for Age < 
65 etc etc...  (I may be back with questions about the survival value - but 
even knowing how to get it to summarise like I describe would be a start.  I 
guess its a bit like a pivot table in excel?


But perhaps its something to do with the mydataset[mydataset$age <=65,] bit?  
That seems to give me a data table with only the 65 and unders which makes 
sense.  But then how do I get it to populate a table with the numbers in the 
two groups?



This message may contain confidential information. If yo...{{dropped:21}}

__
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] - counting factor occurrences within a group: tapply()

2009-07-29 Thread Ian Chidister
Dear List,

I'm an [R] novice starting analysis of an ecological dataset containing the
basal areas of different tree species in a number of research plots.
Example data follow:

> Trees<-data.frame(SppID=as.factor(c(rep('QUEELL',2), rep('QUEALB',3),
'CORAME', 'ACENEG', 'TILAME')), BA=c(907.9, 1104.4, 113.0, 143.1, 452.3,
638.7, 791.7, 804.3), PlotID=as.factor(c('BU3F10', rep('BU3F11',2),
rep('BU3F12',5
> Trees
   SppID   BA  PlotID
1 QUEELL  907.9  BU3F10
2 QUEELL  1104.4 BU3F11
3 QUEALB  113.0  BU3F11
4 QUEALB  143.1  BU3F12
5 QUEALB  452.3  BU3F12
6 CORAME  638.7 BU3F12
7 ACENEG  791.7 BU3F12
8 TILAME  804.3   BU3F12

Fields are (in order): Tree Species Code, Basal Area, and Plot Code.

I've been successful in computing summary statistics by species or plot
groups using tapply():

> tapply(BA, PlotID, sum)
BU3F10 BU3F11 BU3F12
 907.91217.42830.1

*My Question* I'd like to perform a similar function that tells me how many
species are in each plot, I thought this would be possible using something
like:

> tapply(SppID, PlotID, nlevels)
BU3F10 BU3F11 BU3F12
   5 55

however, this outputs the total number of levels for the factor SppID rather
than the number of species in each plot category which would look like:

BU3F10 BU3F11 BU3F12
   124

I understand, from reading the archive, that this occurs because R does not
subset factor levels, but I'm wondering if there's a simple way around this.


Thanks for your help,

Ian Chidister

Environment and Resources
The Nelson Institute for Environmental Studies
University of Wisconsin-Madison, USA

[[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] Summarising Data for Forrest Plots

2009-07-29 Thread Polwart Calum (County Durham and Darlington NHS Foundation Trust)
> Are n.FD and n.RD the number of people who received the full/reduced dose
Yes - but I don't have the data structured like that YET - thats what I want to 
get to because thats what forest plot seems to be wanting.

> and surv.FD and surv.RD the number of people that survived?
Mmm... was more thinking of something like median survival?  ALthough the brain 
hasn't kicked into gear yet tonight and it might actually be mean to be a 
hazard ratio?

>And are the people who received the full dose different from the people who 
>received the reduced dose?
Yes

> And what exactly is it that you want to plot in the forest plot?
Subgroups - see below

>From the way you have arranged the table, it seems as if you want some kind of 
>effect size measure that contrasts the survival rate of the full versus 
>reduced dose in the various subgroups. Is that correct?
Yip that sounds right

>And are you just trying to figure out how to draw the forest plot once you 
>have the data in the table form as shown in your post or are you also trying 
>to figure out how to create that table to begin with?
I *think* I can draw the plot once I have the data structured right.  But at 
the moment my data is structured like this:

PatientID  FullDose   Survival  Censored  Age Sex   Normal Renal Func   
Grade of Toxicity

001  Y125 N   75   F   Y
 1
002  N55   Y   55   M  N
 4
003  N65  Y78   F   Y   
  2

I want to eventually get to a forest plot that looks a bit like this:

Age:
< 65|-#---||
>= 65 |-#|   |
   |
Sex:|
M|-#--|---|
F  |---#-|   |
   |
Renal Fucn:   |
Normal   |---#-|
Abnormal   |---#-|
   |
Grade of Toxicity:  |
0-1 |  
|---#---|
2  |-#--||
3-4  |--#|  |
  |
Overall:  <>   |


Which I believe I can achieve using the metaplot or forrest plot functions, 
replacing the studies with the relevant sub groups.  But my challenge has been 
converting the patient data above down to list subgroups.  Other than by 
running a survival analysis individually on an individual subgroup recording 
the results and building up a table.

Calum



This message may contain confidential information. If yo...{{dropped:21}}

__
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] visualizing columns

2009-07-29 Thread Greg Snow
Try the View function (note capitol V), does that do what you want?

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of sabrina.michie...@alice.it
> Sent: Wednesday, July 29, 2009 10:18 AM
> To: R-help@r-project.org
> Subject: [R] visualizing columns
> 
> hi,
> i've opened a file with R which data are data.frame. It has 15000 rows
> and 29 columns.
> On the console i only can see the first and the last columns and the
> last 8000 rows.
> Is it possible to visualize the entire data set?
> Thanks
> Sabrina
> 
> 
> 
> Da: sabrina.michie...@alice.it
> Inviato: mer 29/07/2009 17.37
> A: R-help@r-project.org
> Oggetto:
> 
> 
> Ciao,
> ho aperto con R un file di classe data frame con 15000 righe e 29
> colonne.
> Nella console però sono visualizzate solo la prime e l'ultima colonna e
> le ultime 8000 righe circa.
> E' possibile una visualizzazione completa?
> Grazie
> Sabrina
> 
>   [[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] dot plot with several points for 2 categories

2009-07-29 Thread Steve Lianoglou

Hi,

On Jul 29, 2009, at 12:11 PM, jaregi wrote:



Hi Michael, Steve, and 1Rnwb,

I'm very impressed by the quick replies on the mailer. Thanks a lot  
for your

suggestions. They worked very well.

In general, I have to say that I'm a bit disappointed that in R,  
like in
Excel, one basically needs to hack to get a dot blot with categories  
by
adding an artificial x value. I was hoping this common type of  
diagram could

be generated using a standard function like dotplot or dotchart.


Is it really that disappointing?

I've never used excel for anything serious, so I don't know what life  
is like there, but in R you can make your own functions in order to  
encapsulate functionality you find useful. So, for instance, let's  
take the code I used before and wrap it up a bit nicer:


dotplot <- function(..., labels=NULL, cols=NULL, main="My Awesome  
Dotplot") {

  stuff <- list(...)
  lower <- min(sapply(stuff, min))
  upper <- max(sapply(stuff, max))

  if (is.null(cols)) {
cols <- rainbow(length(stuff))
  }
  plot(jitter(rep(1, length(stuff[[1]]))), stuff[[1]],  
ylim=c(lower,upper),

   xlim=c(0.5,length(stuff)+0.5), xlab=NULL, xaxt='n', col=cols[1],
   main=main)

  if (length(stuff) > 1) {
for (i in 2:length(stuff)) {
  points(jitter(rep(i, length(stuff[[i]]))), stuff[[i]],  
col=cols[i])

}
  }

  if (is.null(labels)) {
labels <- paste("Group", seq(stuff))
  }
  axis(1, seq(stuff), labels=labels)
}

Copy that function up there and either (i) paste it into your R  
workspace, or (ii) save it to a file and source('/path/to/dotplot.R').


Now look at the difference between these two:

dotplot(rnorm(20,10,2), rnorm(20,15,1), rnorm(10,15,0.1))
dotplot(rnorm(20,10,2), rnorm(20,15,1), rnorm(10,15,0.1),  
cols=c('red','green','blue'), labels=c('A', 'B', 'C'), main="Custom  
Colors")


See ?plot ?title ?par to tweak the plotting functionality as you wish.

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
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] Drawing lines in margins

2009-07-29 Thread Greg Snow
In addition to Benjamin's response (which is the best way that I know of), you 
may also want to look at the grconvertX and grconvertY functions for ways to 
find the coordinates in the margins to plot at.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Nutter, Benjamin
> Sent: Wednesday, July 29, 2009 8:56 AM
> To: Alan Cohen
> Cc: r-help@r-project.org
> Subject: Re: [R] Drawing lines in margins
> 
> Look at the xpd option in ?par.  If you set par(xpd=TRUE) you should be
> able to add a segment for what you want.  But please let me know if
> someone gives you a better way to do this.
> 
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org]
> On Behalf Of Alan Cohen
> Sent: Wednesday, July 29, 2009 10:22 AM
> To: r-help@r-project.org
> Subject: [R] Drawing lines in margins
> 
> Hi all,
> 
> Quick question: What function can I use to draw a line in the margin of
> a plot?  segments() and lines() both stop at the margin.
> 
> In case the answer depends on exactly what I'm trying to do, see below.
> I'm using R v. 2.8.1 on Windows XP.
> 
> Cheers,
> Alan
> 
> I'm trying to make a horizontal barplot with a column of numbers on the
> right side.  I'd like to put a line between the column header and the
> numbers.  The following reconstructs the idea - just copy and paste it
> in:
> aa <- 1:10
> plot.mtx2<-cbind(aa,aa+1)
> colnames(plot.mtx2)<-c("Male","Female")
> lci2<- cbind(aa-1,aa)
> uci2<- cbind(aa+1,aa+2)
> par(mar=c(5,6,4,5))
> cols <- c("grey79","grey41")
> bplot2<-barplot(t(plot.mtx2),beside=TRUE,xlab="Malaria death rates per
> 100,000",
> names.arg=paste("state",aa,sep=""),legend.text=F,las=1,xlim=c(0,13),
> horiz=T, col=cols,
> main="Malaria death rates by state and sex")
> legend(8,6,legend=c("Female","Male"),fill=cols[order(2:1)])
> segments(y0=bplot2, y1=bplot2, x0=t(lci2), x1=t(uci2))
> mtext(10*(aa+1),side=4,line=4,at=seq(3,3*length(aa),by=3)-
> 0.35,padj=0.5,
> adj=1,las=1,cex=0.85)
> mtext(10*aa,side=4,line=4,at=seq(2,3*length(aa)-1,by=3)-
> 0.65,padj=0.5,ad
> j=1,las=1,cex=0.85)
> mtext("Estimated",side=4,line=3,at=3*length(aa)+2.75,padj=0.5,adj=0.5,l
> a
> s=1,cex=0.85)
> mtext("Deaths",side=4,line=3,at=3*length(aa)+1.25,padj=0.5,adj=0.5,las=
> 1
> ,cex=0.85)
> 
> __
> 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.
> 
> 
> ===
> 
> P Please consider the environment before printing this e-mail
> 
> Cleveland Clinic is ranked one of the top hospitals
> in America by U.S. News & World Report (2008).
> Visit us online at http://www.clevelandclinic.org for
> a complete listing of our services, staff and
> locations.
> 
> 
> Confidentiality Note:  This message is intended for
> use\...{{dropped:13}}
> 
> __
> 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] Adding picture to graph?

2009-07-29 Thread Greg Snow
In addition to the other responses, you may want to look at the subplot 
function in the TeachingDemos package for a way to place the image at a 
location within the plot (the other answers so far use the image as a full 
background), see the last example on the help page for a way to use the R logo 
as a plotting symbol.  

If you want to define your own symbols for plotting, look at the my.symbols 
function in the TeachingDemos package.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Rainer M Krug
> Sent: Wednesday, July 29, 2009 2:27 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Adding picture to graph?
> 
> Hi
> 
> while teaching R, the question came up if it would be possible to add
> a picture (saved on the HDD) to a graph (generated by plot()), which
> we could not answer.
> 
> 
> 
> It might easily kill a clean graph, but: is there a way of doing this,
> even one should not do it?
> 
> 
> On a similar line of thought: is it possibe to define own symbols so
> that they can be used in the plot function with pch=?
> 
> 
> Rainer
> 
> --
> Rainer M. Krug, Centre of Excellence for Invasion Biology,
> Stellenbosch University, South Africa
> 
> __
> 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] vector

2009-07-29 Thread Linlin Yan
rep(A, each=2)

On Thu, Jul 30, 2009 at 12:15 AM, Inchallah
Yarab wrote:
> Hi ,
>
> i have a vector A=(a1,a2,a3,a4) and i want to create another vector 
> B=(a1,a1,a2,a2,a3,a3,a4,a4) !!!
> i know that it is simple but i begin with R so i nned your help!!
>
> thank you for your help !!!
>
>
>
>        [[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.


[R] visualizing columns

2009-07-29 Thread sabrina.michielin
hi,
i've opened a file with R which data are data.frame. It has 15000 rows and 29 
columns.
On the console i only can see the first and the last columns and the last 8000 
rows.
Is it possible to visualize the entire data set?
Thanks
Sabrina



Da: sabrina.michie...@alice.it
Inviato: mer 29/07/2009 17.37
A: R-help@r-project.org
Oggetto: 


Ciao,
ho aperto con R un file di classe data frame con 15000 righe e 29 colonne.
Nella console però sono visualizzate solo la prime e l'ultima colonna e le 
ultime 8000 righe circa.
E' possibile una visualizzazione completa?
Grazie
Sabrina

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

2009-07-29 Thread Inchallah Yarab
Hi ,

i have a vector A=(a1,a2,a3,a4) and i want to create another vector 
B=(a1,a1,a2,a2,a3,a3,a4,a4) !!!
i know that it is simple but i begin with R so i nned your help!!

thank you for your help !!!


  
[[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] Add a line in a Pairs2 and mark the axis length

2009-07-29 Thread Greg Snow
I am not sure what you mean by "mark the length on each sub plot y axis", but 
here is an example of the other parts (and if you know how to mark the length 
on a single regular plot, then just add that code to the panel function):

pairs2( iris[,1], iris[,2:4], panel=function(x,y,...) {
points(x,y,...)
abline(0,1, col='blue')
abline(lm(y~x), col='green')
} )

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

From: Jose Narillos de Santos [mailto:narillosdesan...@gmail.com]
Sent: Wednesday, July 29, 2009 5:10 AM
To: petr.pi...@precheza.cz; Greg Snow; r-help@r-project.org
Subject: Add a line in a Pairs2 and mark the axis length

Hi,

I have finally installed TeachingDemos trough zip file and installed on lbrary.

One new question:

I want to draw a line (like abline) on diagonal or the result of running a ols.

How can I do it.

On the other hand, I want to mark the length on each sub plot y axis.

It is possible?

My function is


sca<-function(){

z2<-read.table("Ase.txt",header=T)

z3<-read.table("Ase2.txt",header=T)

pairs2(z2,z3)

}





Ase.txt cointains




3653

4617

4177

3907

3975

3651

3031

2912

3018






Ase2.txt contains

ant g t



 219390 8740 17220
301510 8530 17550
316970 8640 17650
 364220 9360 21420
 387390 9960 23410
  430180 11040 25820
 499930 12240 27620
595010 13800 31670
 661870 14760 37170


2009/7/28, Petr PIKAL mailto:petr.pi...@precheza.cz>>:
r-help-boun...@r-project.org napsal dne 
28.07.2009 15:39:03:

>
> Have you installed it first?
> First:
> install.packages("TeachingDemos")

Or if you have problems with correct setting through corporate network
rules (like myself) you can download a zip (for Windows) version and unzip
it to library subdirectory.

> Then:
> library(TeachingDemos)

shall be executed without problem

Regards
Petr


>
>
> --- On Tue, 7/28/09, Jose Narillos de Santos
mailto:narillosdesan...@gmail.com>> wrote:
>
> > From: Jose Narillos de Santos 
> > mailto:narillosdesan...@gmail.com>>
> > Subject: Re: [R] pairs plot
> > To: "Petr PIKAL" mailto:petr.pi...@precheza.cz>>, 
> > r-help@r-project.org,
greg.s...@imail.org
> > Received: Tuesday, July 28, 2009, 8:24 AM
> > Hi,
> >
> > I tried to load typing library(TeachingDemos)
> >
> > But the message "can´t find package TeachingDemos) occurs.
> > I use versión
> > R 2.9 on windows.
> >
> > Can you please guide me?
> >
> > Sorry¡¡¡
> >
> >
> >
> >
> >
> > 2009/7/28, Petr PIKAL 
> > mailto:petr.pi...@precheza.cz>>:
> > >
> > > Hi
> > >
> > > r-help-boun...@r-project.org
> > napsal dne 28.07.2009 09:55:11:
> > >
> > > > Hi Greg I saw, read, the TeachingDemos you
> > suggesttef but when run
> > > pairs2
> > > > function on my R module says "Can´t find
> > function pairs2"
> > > >
> > > > How can I load the module or function pairs2?
> > >
> > > Did you do
> > >
> > > library(TeachingDemos)?
> > >
> > > Regards
> > > Petr
> > >
> > >
> > > >
> > > > Thanks in advance for your help.
> > > >
> > > > You are the best.
> > > >
> > > > 2009/7/27, Greg Snow mailto:greg.s...@imail.org>>:
> > > > >
> > > > > Look at the pairs2 function in the
> > TeachingDemos package.
> > > > >
> > > > > --
> > > > > Gregory (Greg) L. Snow Ph.D.
> > > > > Statistical Data Center
> > > > > Intermountain Healthcare
> > > > > greg.s...@imail.org
> > > > > 801.408.8111
> > > > >
> > > > >
> > > > > > -Original Message-
> > > > > > From: 
> > > > > > r-help-boun...@r-project.org
> > [mailto:r-help-boun...@r-
> > > > > > project.org] On Behalf Of Jose Narillos
> > de Santos
> > > > > > Sent: Monday, July 27, 2009 9:02 AM
> > > > > > To: r-help@r-project.org
> > > > > > Subject: [R] pairs plot
> > > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I want to plot trough pairs() plot a
> > matrix with 4 columns. I want
> > > to
> > > > > > make a
> > > > > > trhee plot in a graph. Plotting pairs
> > colum 2,3,4 on y axis and 1 on
> > > X
> > > > > > axis.
> > > > > >
> > > > > > You mean (a plot with three graphs)
> > ommitting the first pair with
> > > > > > itself.
> > > > > > And only the pairs with colum 1 with
> > the other not all pairs.
> > > > > >
> > > > > > I. e. this matrix
> > > > > >
> > > > > > 4177 289390 8740 17220
> > > > > > 3907 301510 8530 17550
> > > > > > 3975 316970 8640 17650
> > > > > > 3651 364220 9360 21420
> > > > > > 3031 387390 9960 23410
> > > > > > 2912 430180 11040 25820
> > > > > > 3018 499930 12240 27620
> > > > > > 2685 595010 13800 31670
> > > > > > 2884 661870 14760 37170
> > > > > >
> > > > > > Thanks in advance.
> > > > > >
> > > > > >
> >[[alternative HTML version deleted

Re: [R] dot plot with several points for 2 categories

2009-07-29 Thread jaregi

Hi Michael, Steve, and 1Rnwb,

I'm very impressed by the quick replies on the mailer. Thanks a lot for your
suggestions. They worked very well. 

In general, I have to say that I'm a bit disappointed that in R, like in
Excel, one basically needs to hack to get a dot blot with categories by
adding an artificial x value. I was hoping this common type of diagram could
be generated using a standard function like dotplot or dotchart.

Best, j



Michael Knudsen-2 wrote:
> 
> On Fri, Jul 17, 2009 at 7:17 PM, jaregi wrote:
> 
>> I'm trying to wean myself off the very limited capabilities of Excel and
>> Oo.
>> Currently, I am trying to make a plot showing several values for 2
>> categories in a dot blot (see
>> http://www.nabble.com/file/p24538360/Picture%2B1.png Picture+1.png
>>  except
>> that the x axis should contain the category not a number, which was the
>> only
>> way to coax Excel into displaying a plot like this).
> 
> Let y1 be a vector containing the values in the first category, and
> let y2 contain those of the second. The you could do like this:
> 
> x1 = rep(1,times=length(y1))
> x2 = rep(2,times=length(y2))
> plot(c(x1,x2),c(y1,y2),xaxt="n")
> axis(side=1,at=c(1,2),labels=c("label1","label2"))
> 
> It looks like a hack, but it should work.
> 
> -- 
> Michael Knudsen
> micknud...@gmail.com
> http://lifeofknudsen.blogspot.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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/dot-plot-with-several-points-for-2-categories-tp24538360p24722548.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] regexpr virtue

2009-07-29 Thread Gabor Grothendieck
dot means any character and * repeats it for as many times
as possible so it replaces eveything (.*) up to the last
dot (\\.) with nothing.

On Wed, Jul 29, 2009 at 9:43 AM, Petr PIKAL wrote:
> Thank you
>
> Gabor Grothendieck  napsal dne 29.07.2009
> 15:20:40:
>
>> Here are a couple of possibilities:
>>
>> sub(".*\\.", "", s)
>
> This seems to be the target. Can you be so kind and translate for me what
> it really does?
>
> ".* matches several dots?
> \\. what is this?
>
> I thought sub finds a match and replaces "replacement" in a string. But
> from this solution it seems that the command replaces all characters in a
> string with empty string and leave only value after three or two dots? Am
> I right?
>
> Best regards
> Petr
>
>
>
>>
>> library(gsubfn)
>> strapply(s, "[0-9]*$", simplify = c)
>>
>>
>>
>> On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL
> wrote:
>> > Hi all
>> >
>> > I have got something like that (actually those are column names)
>> >
>> > [51] "X19.2.300b...80"          "X19.2.400v...80" "X19.2.400b...80"
>> > "X19.2.300v...90"          "X19.2.300b...90"
>> > [56] "X19.2.400v...90"          "X19.2..400b..90" "X19.2.300v...100"
>> > "X19.2.300b...100"         "X19.2.400v...100"
>> >
>> > in character vector. I would like to get last n figures from this
>> > character vector but my regexpr unerstanding is inferior and I did not
>> > succeed.
>> > Please, is there anybody who can extract those n digits from end of
> each
>> > character string? If there were only 2 digits I could use substr but
> there
>> > can be one, two or three digits.
>> >
>> > I tried several variations of
>> >
>> > gsub("0:9$", "\\1" ,names(foto)[10])
>> >
>> > but either got whole string or an error.
>> >
>> > Best regards
>> > Petr
>> >
>> > __
>> > 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] Make my plots bigger and reduce white space around panels?

2009-07-29 Thread Greg Snow
It still was not attached, but you can reduce the white space by reducing the 
margins using par(mar=c(...)).

If you do par(mar=c(0,0,0,0)), then there will be no space between the plots, 
using values larger than 0 will give space.  But beware, you need to either 
suppress the plotting of axis labels/ticks or make them smaller and closer to 
the axes, or you will end up with the axis label for one plot inside of another.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Mark Na
> Sent: Tuesday, July 28, 2009 4:53 PM
> To: r-help@r-project.org
> Subject: Re: [R] Make my plots bigger and reduce white space around
> panels?
> 
> The plot is attached this time...
> 
> On Tue, Jul 28, 2009 at 4:47 PM, Mark Na  wrote:
> 
> > Hi,
> >
> > I have made a plot with panels (attached) using R code (below) and
> I'd like
> > to increase the size of each panel and decrease the white space,
> especially
> > the white space between:
> >
> > 1. rows of panels
> > 2. the top panel and its title (which contains info on r2 and N)
> > 3. each panel and its x label.
> >
> > I've dug around in the plot help files but can't seem to find how to
> do
> > this.
> >
> > Any help much appreciated, thanks!
> >
> > Mark Na
> >
> >
> >
> >
> > #ELEPHANT SPECIES RICHNESS
> > par(mfrow=c(3,4),oma=c(0,0,2,0))
> > models<-list(data$SR.elephant.obs~data$AREA,
> >  log(data$SR.elephant.obs+1,10)~log(data$AREA,10),
> >  data$SR.elephant.obs~log(data$AREA,10),
> >  log(data$SR.elephant.obs+1,10)~data$AREA)
> > for (i in 1:length(models)){ #SCATTERPLOT
> > model<-lm(models[[i]])
> > plot(models[[i]],ylab="Elephant SR");
> >
> abline(model);title(main=paste("r2=",round(summary(model)$r.squared,dig
> its=3),",
> > N=",dim(data)[1]))
> > }
> > for (i in 1:length(models)){#RESIDUALS VS FITTED VALUES PLOT
> > model<-lm(models[[i]])
> > plot.lm(model,which=1,sub.caption=NA)
> > }
> > for (i in 1:length(models)){#Q-Q PLOT
> > model<-lm(models[[i]])
> > plot.lm(model,which=2,sub.caption=NA)
> > }
> > title(main="ELEPHANT SPECIES RICHNESS",outer=TRUE);
> > savePlot("SR_elephant.emf",type="emf"); dev.off()
> >
> 
> 
> 
> --
> Mark Na
> University of Saskatchewan
> Saskatoon, Canada

__
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] (senza oggetto)

2009-07-29 Thread Uwe Ligges
Um Antwort von der R Mailinglite zu bekommen, verwenden Sie bitte eine 
aussagekräftige Betreff-Zeile und formulieren Sie Ihre Anfrage in 
*Englisch* - nachdem Sie den "posting guide" gelesen haben.


MfG,
Uwe Ligges



sabrina.michie...@alice.it wrote:

Ciao,
ho aperto con R un file di classe data frame con 15000 righe e 29 colonne.
Nella console però sono visualizzate solo la prime e l'ultima colonna e le 
ultime 8000 righe circa.
E' possibile una visualizzazione completa?
Grazie
Sabrina

[[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] Package with function for plots with embedded hyperlinks?

2009-07-29 Thread Don MacQueen

Never mind, just after I sent this I finally did the right search.

It is

  RSVGTipsDevice

-Don

At 8:30 AM -0700 7/29/09, Don MacQueen wrote:
Some years ago, if I recall correctly, I learned of a package that 
included a function that would write a plot to a file so that one 
could associate hyperlinks with elements of the plot, such as 
points. Then, when the plot was displayed in a browser, one could 
click on (for example) a point, and jump to wherever the hypelink 
pointed.


I don't remember then name of the package or function, and haven't 
been able to find it after some searching.


Does anyone know the name, or have a suggestion to help track it down?

Thanks
-Don
--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

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



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
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] n-way table of aggregate statistics

2009-07-29 Thread Yoav Kessler
Hi,
I'm doing my first steps in R.
I wonder how can I create an n-way table of aggregate statistics, something like
what aggregate.table does, but with an unlimited number of grouping factors.

Thanks,
Yoav Kessler

__
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] (senza oggetto)

2009-07-29 Thread sabrina.michielin
Ciao,
ho aperto con R un file di classe data frame con 15000 righe e 29 colonne.
Nella console però sono visualizzate solo la prime e l'ultima colonna e le 
ultime 8000 righe circa.
E' possibile una visualizzazione completa?
Grazie
Sabrina

[[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] Package with function for plots with embedded hyperlinks?

2009-07-29 Thread Don MacQueen
Some years ago, if I recall correctly, I learned of a package that 
included a function that would write a plot to a file so that one 
could associate hyperlinks with elements of the plot, such as points. 
Then, when the plot was displayed in a browser, one could click on 
(for example) a point, and jump to wherever the hypelink pointed.


I don't remember then name of the package or function, and haven't 
been able to find it after some searching.


Does anyone know the name, or have a suggestion to help track it down?

Thanks
-Don
--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
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] visualizzazione colonne

2009-07-29 Thread sabrina.michielin
ciao,
ho aperto un file in R di classe data frame di 15000 righe e 29 colonne.
Nella console però sono visualizzate solo la prima e l'ultima colonna e le 
ultime 8000 righe circa.
E' possibile una visualizzazione completa?
Grazie 
Sabrina

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

2009-07-29 Thread David Winsemius
You need to create the variable names in newdata (which is generally a  
dataframe)  that match those used in constructing fm. Surely there  
must be a worked example that illustrates this on the help page?


On Jul 29, 2009, at 9:30 AM, serbring wrote:



I have found a regression model, and i would like to predict value in
different points. I have tried to use predict function but it  
doesn't work.

I have used predict function like this:

newdata<-seq(from=0.1, to=0.32,by=0.02)
data<-predict(fm,newdata)

where fm is a regression model. The predict function return me that:

Error in eval(predvars, data, env) :   numeric argument 'envir'  
doesn't have

unitary length

where is the error?


Hard to tell what other errors at work might be at work since no  
reproducible example (and not even the original code to construct fm)  
was offered. Please re-read the Posting Guide.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] predict

2009-07-29 Thread ONKELINX, Thierry
Newdata needs to be a dataframe with the same variable names as the
explanatory variables in your models.

Model <- lm(y ~ x, data = dataset) 
Newdata <- data.frame(x = seq(from=0.1, to=0.32,by=0.02))
Newdata$y <- predict(Model, newdata = Newdata)

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens serbring
Verzonden: woensdag 29 juli 2009 15:31
Aan: r-help@r-project.org
Onderwerp: [R] predict


I have found a regression model, and i would like to predict value in
different points. I have tried to use predict function but it doesn't
work.
I have used predict function like this:

newdata<-seq(from=0.1, to=0.32,by=0.02)
data<-predict(fm,newdata)

where fm is a regression model. The predict function return me that:

Error in eval(predvars, data, env) :   numeric argument 'envir' doesn't
have
unitary length

where is the error?


--
View this message in context:
http://www.nabble.com/predict-tp24719362p24719362.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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
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] Package norm has been removed. What to use for Maximum Likelihood Missing Data Imputation?

2009-07-29 Thread KathyKlein

Hello,

I also used the norm-package for data with missing values. Are there no
possibilities to fix it (its not under GPL?), or is here anyone able to get
the negotiation for the maintainership for this package?

Another question: I have read, taht "mice" would be an alternative instead
of using "norm". Is it also possible to the EM-Algorithm for imputation of
missing values in multivariate normal data? Or are there better
possibilities?
(Besides:the package "mvnmle" is not possible for me, because my data matrix
is too big...)

I would be pleased to get anwers from you!

Katharina Klein



Uwe Ligges-3 wrote:
> 
> 
> Achim Zeileis wrote:
>> On Fri, 17 Jul 2009, Daniel Abbott wrote:
>> 
>>> Hello,
>>>
>>> I apologize if an answer to my questions is available, or if I
>>> submitted this question incorrectly. I have read the mailing lists, as
>>> well as the R Project and CRAN homepages. However, I may have missed
>>> something.
>>>
>>> I noticed the package 'norm' has been removed. Its page
>>> http://cran.r-project.org/web/packages/norm/index.html now reads:
>>>
>>> "Package ?norm? was removed from the CRAN repository.
>>>
>>> Formerly available versions can be obtained from the archive."
>>>
>>> My questions are:
>>>
>>> 1. Why was norm removed? I used the package and found it to be very
>>> useful. Is there a serious error in the package or another problem?
>> 
>> What do you consider to be a serious error?
>> 
>> Typical reasons for removing a package from the active CRAN repository 
>> are that the package does not pass CRAN checks and/or that the package 
>> maintainer is irresponsive. (norm, specifically, hadn't been updated 
>> since 2002.) This is serious enough to make all automatic CRAN features 
>> such as daily package checks and building of binary packages too 
>> cumbersome.
>> 
>> But if you do not consider this to be serious, you can keep on using 
>> "norm", it is still in CRAN's package archives. Or, even better, you 
>> could adopt it, fix it, and release a new version to CRAN (although it 
>> is not quite clear to me whether the norm's license allows this).
> 
> 
> Oh yes, indeed.
> 
> Please ignore my former message, I haven't looked at the license 
> carefully enough. And since the license is rather special (not GPL'ed as 
> I assumed in my message), you cannot take over maintainership without 
> negotiation with the former maintainer, I fear.
> 
> Best,
> Uwe Ligges
> 
> 
> 
>> (Note that CRAN runs no checks whether the methods implemented are 
>> reasonable or well-suited for the problem they are trying to address
>> etc.)
>> 
>>> 2. If norm should no longer be removed, what is another good package
>>> for ML (maximum likelihood) missing data imputation? I have seen
>>> several recommendations online, but I wonder which one is currently
>>> the "reigning champ."
>> 
>> The "Multivariate" and the "SocialSciences" task views have sections 
>> about missing data
>>   http://CRAN.R-project.org/view=Multivariate
>>   http://CRAN.R-project.org/view=SocialSciences
>> 
>> Additionally, I can recall that there is the Amelia II package:
>>   http://CRAN.R-project.org/package=Amelia
>> and potentially others.
>> 
>> hth,
>> Z
>> 
>>> Thank you very much. I appreciate your time!
>>>
>>> __
>>> 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-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/Package-norm-has-been-removed.-What-to-use-for-Maximum-Likelihood-Missing-Data-Imputation--tp24531976p24718866.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] predict

2009-07-29 Thread serbring

I have found a regression model, and i would like to predict value in
different points. I have tried to use predict function but it doesn't work.
I have used predict function like this:

newdata<-seq(from=0.1, to=0.32,by=0.02)
data<-predict(fm,newdata)

where fm is a regression model. The predict function return me that:

Error in eval(predvars, data, env) :   numeric argument 'envir' doesn't have
unitary length

where is the error?


-- 
View this message in context: 
http://www.nabble.com/predict-tp24719362p24719362.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] Drawing lines in margins

2009-07-29 Thread Nutter, Benjamin
Look at the xpd option in ?par.  If you set par(xpd=TRUE) you should be
able to add a segment for what you want.  But please let me know if
someone gives you a better way to do this.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Alan Cohen
Sent: Wednesday, July 29, 2009 10:22 AM
To: r-help@r-project.org
Subject: [R] Drawing lines in margins

Hi all,

Quick question: What function can I use to draw a line in the margin of
a plot?  segments() and lines() both stop at the margin.

In case the answer depends on exactly what I'm trying to do, see below.
I'm using R v. 2.8.1 on Windows XP.

Cheers,
Alan

I'm trying to make a horizontal barplot with a column of numbers on the
right side.  I'd like to put a line between the column header and the
numbers.  The following reconstructs the idea - just copy and paste it
in:
aa <- 1:10
plot.mtx2<-cbind(aa,aa+1)
colnames(plot.mtx2)<-c("Male","Female")
lci2<- cbind(aa-1,aa)
uci2<- cbind(aa+1,aa+2)
par(mar=c(5,6,4,5))
cols <- c("grey79","grey41")
bplot2<-barplot(t(plot.mtx2),beside=TRUE,xlab="Malaria death rates per
100,000",
names.arg=paste("state",aa,sep=""),legend.text=F,las=1,xlim=c(0,13),
horiz=T, col=cols,
main="Malaria death rates by state and sex")
legend(8,6,legend=c("Female","Male"),fill=cols[order(2:1)])
segments(y0=bplot2, y1=bplot2, x0=t(lci2), x1=t(uci2))
mtext(10*(aa+1),side=4,line=4,at=seq(3,3*length(aa),by=3)-0.35,padj=0.5,
adj=1,las=1,cex=0.85)
mtext(10*aa,side=4,line=4,at=seq(2,3*length(aa)-1,by=3)-0.65,padj=0.5,ad
j=1,las=1,cex=0.85)
mtext("Estimated",side=4,line=3,at=3*length(aa)+2.75,padj=0.5,adj=0.5,la
s=1,cex=0.85)
mtext("Deaths",side=4,line=3,at=3*length(aa)+1.25,padj=0.5,adj=0.5,las=1
,cex=0.85)

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


===

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2008).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}

__
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] R Packages and Permanent Datasets creation

2009-07-29 Thread Philipp Pagel
On Tue, Jul 28, 2009 at 11:13:11PM -0700, rajclinasia wrote:
> Actually while opening R console and R commander we see some packages like
> car and datasets. In these packages we have default datasets. 
> For example: "Women" and "Prestige" so on. Now we created a "Sales" dataset
> importing either from excel, xml or text file. Now we are trying to store
> that dataset permanently  in any one of the packages mentioned above (car or
> datasets). I am able to create them temporarily untill that pirticular
> session.
>  
> But once we close the session and try to log into R Console and R Commander.
> We are not able to find the earlier created datasets "Sales" in the packages
> (Car and Datasets). Kindly suggest how to create permanent datasets in
> packages and also suggest how to create our own packages. 

A similar question has been asked very recently by someone else - are
you guys related in any way? (e.g. takeing the same class or
something). 

Gavin already pointed out that adding to other peoples packages can
(should) not be done - at least not cleanly. He has also pointed out
save and load so your problem is probably solved. On the other hand,
there could be more to your question, so I'd like to ask WHY you would
like to add your own dataset to an exisiting package. Are you simply
interested in having you data available in the next session or do you
have something else in mind (e.g. distributing the data to others).

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

__
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] (no subject)

2009-07-29 Thread Philipp Pagel
On Wed, Jul 29, 2009 at 03:12:02PM +0200, Øistein Harsem wrote:
> HiI am contacting you regarding a problem with downloading R. I
> cannot seen to manage because my computer language is in Norwegian.
> DO you know if there is R that can deal with Norwegian letters?

I have never seen a download to fail because of locales. Or do you
mean you have trouble with using non-ASCII characters in a sucessfully
downloaded/installed R? My installation of R seems to have no issues
with the non-Ascii chars I have used so far (R 2.9.1, LINUX, utf8
locale).

In any case, you need to be a bit more specific about the problem you
have: What version of R, what OS, what exaclty are you trying to do
and what happens when you try?

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://webclu.bio.wzw.tum.de/~pagel/

__
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] R Packages and Permanent Datasets creation

2009-07-29 Thread Gavin Simpson
On Tue, 2009-07-28 at 23:13 -0700, rajclinasia wrote:
> Our Query:
>  
> Actually while opening R console and R commander we see some packages like
> car and datasets. In these packages we have default datasets. 
> For example: "Women" and "Prestige" so on. Now we created a "Sales" dataset
> importing either from excel, xml or text file. Now we are trying to store
> that dataset permanently  in any one of the packages mentioned above (car or
> datasets). I am able to create them temporarily untill that pirticular
> session.
>  
> But once we close the session and try to log into R Console and R Commander.
> We are not able to find the earlier created datasets "Sales" in the packages
> (Car and Datasets). Kindly suggest how to create permanent datasets in
> packages and also suggest how to create our own packages. 
>  
> If possible please send us the code it will be very helpful for us. 

You *can't* do this (well, not easily, without compiling your own
version of R or the car package).

I don't know how the R Commander package works but I'm fairly certain it
isn't restricted to datasets that come in packages.

Lets take RCmdr our of the equation for a moment. You have an object
'Sales' in your R session. To save this as an R object for reuse in
later sessions, just do

save(Sales, file = "my_Sales_obj.rda")

Next session, before you start RCmdr, do

load(file = "my_Sales_obj.rda")

That will make it available for use.

The filenames I use can be whatever you want and should include the full
path to where you want it saving if not in the current working
directory.

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
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] Adding picture to graph?

2009-07-29 Thread David Winsemius
I'm not sure if you can consider grid graphics. If so, then Murrell  
has some nice worked examples in:


http://www.stat.auckland.ac.nz/~paul/Talks/gddg.pdf


On Jul 29, 2009, at 4:27 AM, Rainer M Krug wrote:


while teaching R, the question came up if it would be possible to add
a picture (saved on the HDD) to a graph (generated by plot()), which
we could not answer.

It might easily kill a clean graph, but: is there a way of doing this,
even one should not do it?

On a similar line of thought: is it possibe to define own symbols so
that they can be used in the plot function with pch=?

Rainer
--
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] Drawing lines in margins

2009-07-29 Thread Alan Cohen
Hi all,

Quick question: What function can I use to draw a line in the margin of a plot? 
 segments() and lines() both stop at the margin.

In case the answer depends on exactly what I'm trying to do, see below.  I'm 
using R v. 2.8.1 on Windows XP.

Cheers,
Alan

I'm trying to make a horizontal barplot with a column of numbers on the right 
side.  I'd like to put a line between the column header and the numbers.  The 
following reconstructs the idea - just copy and paste it in:
aa <- 1:10
plot.mtx2<-cbind(aa,aa+1)
colnames(plot.mtx2)<-c("Male","Female")
lci2<- cbind(aa-1,aa)
uci2<- cbind(aa+1,aa+2)
par(mar=c(5,6,4,5))
cols <- c("grey79","grey41")
bplot2<-barplot(t(plot.mtx2),beside=TRUE,xlab="Malaria death rates per 100,000",
names.arg=paste("state",aa,sep=""),legend.text=F,las=1,xlim=c(0,13), horiz=T, 
col=cols,
main="Malaria death rates by state and sex")
legend(8,6,legend=c("Female","Male"),fill=cols[order(2:1)])
segments(y0=bplot2, y1=bplot2, x0=t(lci2), x1=t(uci2))
mtext(10*(aa+1),side=4,line=4,at=seq(3,3*length(aa),by=3)-0.35,padj=0.5,adj=1,las=1,cex=0.85)
mtext(10*aa,side=4,line=4,at=seq(2,3*length(aa)-1,by=3)-0.65,padj=0.5,adj=1,las=1,cex=0.85)
mtext("Estimated",side=4,line=3,at=3*length(aa)+2.75,padj=0.5,adj=0.5,las=1,cex=0.85)
mtext("Deaths",side=4,line=3,at=3*length(aa)+1.25,padj=0.5,adj=0.5,las=1,cex=0.85)

__
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] regexpr virtue

2009-07-29 Thread Petr PIKAL
Thank you

Gabor Grothendieck  napsal dne 29.07.2009 
15:20:40:

> Here are a couple of possibilities:
> 
> sub(".*\\.", "", s)

This seems to be the target. Can you be so kind and translate for me what 
it really does?

".* matches several dots?
\\. what is this?

I thought sub finds a match and replaces "replacement" in a string. But 
from this solution it seems that the command replaces all characters in a 
string with empty string and leave only value after three or two dots? Am 
I right?

Best regards
Petr



> 
> library(gsubfn)
> strapply(s, "[0-9]*$", simplify = c)
> 
> 
> 
> On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL 
wrote:
> > Hi all
> >
> > I have got something like that (actually those are column names)
> >
> > [51] "X19.2.300b...80"  "X19.2.400v...80" "X19.2.400b...80"
> > "X19.2.300v...90"  "X19.2.300b...90"
> > [56] "X19.2.400v...90"  "X19.2..400b..90" "X19.2.300v...100"
> > "X19.2.300b...100" "X19.2.400v...100"
> >
> > in character vector. I would like to get last n figures from this
> > character vector but my regexpr unerstanding is inferior and I did not
> > succeed.
> > Please, is there anybody who can extract those n digits from end of 
each
> > character string? If there were only 2 digits I could use substr but 
there
> > can be one, two or three digits.
> >
> > I tried several variations of
> >
> > gsub("0:9$", "\\1" ,names(foto)[10])
> >
> > but either got whole string or an error.
> >
> > Best regards
> > Petr
> >
> > __
> > 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] Subtract matrices within arrays along indices

2009-07-29 Thread Etienne B. Racine

Hi Christian,

Christian Langkamp wrote:
> 
> I have the following array: 3 dimensional object, one dimension being
> year. Object is 3*3*3
> 
> library(plyr, reshape)
> 
# reshape won't be loaded that way, use separate library()

Christian Langkamp wrote:
> 
> a1<-rep(c(2007,2008,2009),9)
> a2<-c(rep("a",9),rep("b",9),rep("c",9))
> a3<-c(rep(c(rep(1,3),rep(2,3),rep(3,3)),3))
> a4 <- rnorm(27)
> A<-data.frame(cbind(comp=a2,val=a3, year=a1, a4))
> 
# here, a4 have been switched to factor.
# you can use
str(A) #to check that
#so use nlevels(),
A$a4 <- as.numeric(a4)

Christian Langkamp wrote:
> 
> A1<-melt(A, id=c("year", "comp", "val"))
> A2<-cast(A1, comp~val~year)
> 
> I would now like to look for changes from one year to the other, i.e.
> 
> "for(i in levels(A$year))
> A2[,,i]-A2[,,i-1]"
> and put that into A3.
> 
# levels will return characters, but you can't substract 1 from it
# so use nlevels instead,

A3 <-array(dim=dim(A2))

for(i in 2:nlevels(A$year)) 
A3[,,i]<-A2[,,i]-A2[,,i-1]

Hope this help,
Etienne

Christian Langkamp wrote:
> 
> Which should work except for the first one, i.e. giving me a 3*3*2 object
> A3.
> 
> The more abstract formulation would possibly be cellwise operation within
> adjacent matrices of the array. I have however searched the forum for the
> key words and there is not much.
> 
> Any help even in form of a reference would be appreciated.
> 

-- 
View this message in context: 
http://www.nabble.com/Subtract-matrices-within-arrays-along-indices-tp24717178p24719544.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] regexpr virtue

2009-07-29 Thread Petr PIKAL
Thanks

If somebody does not come with more elaborated solution I will adapt 
yours. After strsplit I can get not only 3 but several chunks. If the last 
chunk is every time the one I need then

sapply(strsplit(names(foto),"\\..."), length)
 [1] 2 6 6 6 6 5 5 6 5 3 3 3 3 3 3 3 3 3 3 4 3 3 4 4 3 3 3 3 4 3 3 3 3 3 3 
3 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 3 3 3 3 3 4 3 3 3 3 3 3 4 4 3 4 3 3
>
gives me number of chunks which I can use for  selection.

Best regards




Jorge Ivan Velez  napsal dne 29.07.2009 
15:18:33:

> Dear Petr,
> 
> How about this strsplit()ing them up?
> 
> > x
> [1] "X19.2.400v...80"
> > strsplit(x,"\\...")[[1]][3]
> [1] "80"
> 
> HTH,
> 
> Jorge
> 

> On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL  
wrote:
> Hi all
> 
> I have got something like that (actually those are column names)
> 
> [51] "X19.2.300b...80"  "X19.2.400v...80" "X19.2.400b...80"
> "X19.2.300v...90"  "X19.2.300b...90"
> [56] "X19.2.400v...90"  "X19.2..400b..90" "X19.2.300v...100"
> "X19.2.300b...100" "X19.2.400v...100"
> 
> in character vector. I would like to get last n figures from this
> character vector but my regexpr unerstanding is inferior and I did not
> succeed.
> Please, is there anybody who can extract those n digits from end of each
> character string? If there were only 2 digits I could use substr but 
there
> can be one, two or three digits.
> 
> I tried several variations of
> 
> gsub("0:9$", "\\1" ,names(foto)[10])
> 
> but either got whole string or an error.
> 
> Best regards
> Petr
> 
> __
> 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] regexpr virtue

2009-07-29 Thread Gabor Grothendieck
Here are a couple of possibilities:

sub(".*\\.", "", s)

library(gsubfn)
strapply(s, "[0-9]*$", simplify = c)



On Wed, Jul 29, 2009 at 9:10 AM, Petr PIKAL wrote:
> Hi all
>
> I have got something like that (actually those are column names)
>
> [51] "X19.2.300b...80"          "X19.2.400v...80" "X19.2.400b...80"
> "X19.2.300v...90"          "X19.2.300b...90"
> [56] "X19.2.400v...90"          "X19.2..400b..90" "X19.2.300v...100"
> "X19.2.300b...100"         "X19.2.400v...100"
>
> in character vector. I would like to get last n figures from this
> character vector but my regexpr unerstanding is inferior and I did not
> succeed.
> Please, is there anybody who can extract those n digits from end of each
> character string? If there were only 2 digits I could use substr but there
> can be one, two or three digits.
>
> I tried several variations of
>
> gsub("0:9$", "\\1" ,names(foto)[10])
>
> but either got whole string or an error.
>
> Best regards
> Petr
>
> __
> 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.


  1   2   >