Re: [R] strange split behavior?

2009-09-23 Thread Peter Dalgaard

Peng Yu wrote:

Hi,

Please see the command with a comment below. I don't find
'A630039F22Rik' in y. But 'A630039F22Rik' is in z. Can somebody let me
know what the problem is?


Most obvious guess is that your  factor y has a level that is not 
present in data. That is perfectly normal, even desirable in some cases.


e.g., (sorry about the different names)

 f - factor(rep(1,4),levels=0:1)
 y - 1:4
 split(y,f)
$`0`
integer(0)

$`1`
[1] 1 2 3 4

 table(f)
f
0 1
0 4



Regards,
Peng


str(x)

 int [1:365494] 6 7 8 14 15 18 19 21 25 29 ...

str(y)

 Factor w/ 29904 levels 0610005C13Rik,..: 17261 28617 15927 15462
8988 23500 16577 20250 27911 13981 ...

z=split(x,y)
str(z[5529])

List of 1
 $ A630039F22Rik: int(0)

which(y=='A630039F22Rik')#it is weird

integer(0)

str(z[1])

List of 1
 $ 0610005C13Rik: int [1:5] 592506 735015 958481 979622 1124670

which(y=='0610005C13Rik')

[1] 181073 224717 292981 299543 343964

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



--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
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] use of class variable in r as in Proc means of sas

2009-09-23 Thread Girish A.R.

Here's the code that does the job for quartiles (0,25,50,75,100). To get to
your objective of (5,10,25,75,90) is left as an exercise. There are several
well-written introductory books in R, in addition to the freely available
presentations and other online resources. I think you should spend some time
going thru' them.
--
library(doBy)
Lines - zip   price
6 567000
60001 478654
60004  485647
60001  2783958
60005  97845848
60006  378383478
60002  397895735
60001  487587575
60002  478848
60003  49847874
60004  467648
60005   567489
60006   4776746
60004   4843949 
DF - read.table(con- textConnection(Lines), skip = 1)
close(con)
names(DF) - scan(textConnection(Lines), what = , nlines = 1) 
qfun - function(x, digits=3,sci=F,...){
  c(q=quantile(x, ...))
}
summaryBy(price~zip,data=DF,FUN=qfun,na.rm=TRUE)
--

cheers,
-Girish

===

premmad wrote:
 
 Hi,everyone i need to calculate quartile values of a variable grouped by
 the other variable .
 same as in aggregate function(only median,mean or functions is possible-i
 think so)
 Could you please help me to achieve the  same for other quartile
 values(5,10,25,75,90) as for median using aggregate.
 Thanks in advance.
 data :
 zip price
 6 567000  
 60001 478654
 60004  485647
 60001  2783958
 60005  97845848
 60006  378383478
 60002  397895735
 60001  487587575
 60002  478848
 60003  49847874
 60004  467648
 60005   567489
 60006   4776746
 60004   4843949
 what i want is quartile values of price grouped by zip
 

-- 
View this message in context: 
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas-tp25530654p25530997.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] BLUP with missing data

2009-09-23 Thread Marcio Resende

hello guys, I need to do a BLUP in the simplest model
y = Xm + Zg + e
however I have missing data in the analysis which I can´t consider as
0(zero). So I need to generate the matrix X'Z, Z'X and Z'Z step by step; I
can´t use 
crossprod(x) #neither
X'X - t(x)%*%x

because I should skip the elements with missing data in the matrix

I´ll try to be more clear,
supposing
a matrix x and a z
dim (t(x)) = 2275 788
dim (z) = 788 1

but I have in my matrix the effect 0(zero) which is not missing, therefore I
can´t just replace the missing values by 0(zero) and i can´t just remove it
from the matrix because it would unbalance it

A way to do it could be generate Z'X step by step e.g
Z'X [1, 1] is equal the sum of the product between the elements in the first
collumn of X and the first collumn of Z skipping the elements whenever there
is a missing data

However I can´t do this in R

Does anybody know how to do it this way or an easier way to do it?
-- 
View this message in context: 
http://www.nabble.com/BLUP-with-missing-data-tp25530949p25530949.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] reading web log file into R

2009-09-23 Thread Sebastian Kruk
If I have a web log file as follows:

#Software: Microsoft Internet Information Services 5.0
#Version: 1.0
#Date: 2007-12-03 13:50:17
#Fields: date time c-ip cs-username s-ip s-port cs-method cs-uri-stem
cs-uri-query sc-status sc-bytes cs-bytes time-taken cs(User-Agent)
cs(Cookie) cs(Referer)
2007-12-03 13:50:17 200.40.203.197 - 200.40.51.20 80 GET
/localidades/img/nada.gif - 200 328 447 0
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
ASPSESSIONIDSQCBSQAB=JOLECDCCBFCKPOFLGDLHMENA
http://www.teatro.com/localidades/localidades.asp;
2007-12-03 13:50:17 200.40.203.197 - 200.40.51.20 80 GET
/localidades/img/cargando.gif - 200 1150 451 0
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
ASPSESSIONIDSQCBSQAB=JOLECDCCBFCKPOFLGDLHMENA
http://www.teatro.com/localidades/localidades.asp;
2007-12-03 13:50:18 200.40.203.197 - 200.40.51.20 80 GET
/localidades/img/cerrar.png - 200 450 449 0
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)

how can I turn it into a dataframe with 3 rows, and 16 columns named
date time c-ip cs-username s-ip s-port cs-method cs-uri-stem
cs-uri-query sc-status sc-bytes cs-bytes time-taken cs(User-Agent)
cs(Cookie) cs(Referer) skiping lines begining with #?

Thanks,

Sebastián.

__
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] BLUP with missing data

2009-09-23 Thread Marcio Resende

Sorry, I sent it quickly and forgot to thank in advance
Marcio



Marcio Resende wrote:
 
 hello guys, I need to do a BLUP in the simplest model
 y = Xm + Zg + e
 however I have missing data in the analysis which I can´t consider as
 0(zero). So I need to generate the matrix X'Z, Z'X and Z'Z step by step; I
 can´t use 
 crossprod(x) #neither
 X'X - t(x)%*%x
 
 because I should skip the elements with missing data in the matrix
 
 I´ll try to be more clear,
 supposing
 a matrix x and a z
 dim (t(x)) = 2275 788
 dim (z) = 788 1
 
 but I have in my matrix the effect 0(zero) which is not missing, therefore
 I can´t just replace the missing values by 0(zero) and i can´t just remove
 it from the matrix because it would unbalance it
 
 A way to do it could be generate Z'X step by step e.g
 Z'X [1, 1] is equal the sum of the product between the elements in the
 first collumn of X and the first collumn of Z skipping the elements
 whenever there is a missing data
 
 However I can´t do this in R
 
 Does anybody know how to do it this way or an easier way to do it?
 

-- 
View this message in context: 
http://www.nabble.com/BLUP-with-missing-data-tp25530949p25530951.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] Sum of Product in a Matrix

2009-09-23 Thread Marcio Resende

Hi, 
I am new in R and I don´t know how to sum the product of two elements at the
time in a matrix

X=[ 1  5   9   13
  2  6  10  14
  3  7  11  15
  4  8  12  16]
I would like to do (1*5+2*6+3*7+4*8)
I need to do it step by step because I will further put a conditional in the
formula

It worked this way
x - matrix ( c (1 : 16),ncol = 4)  #generating my x matrix
qw - matrix (0, ncol = 4, nrow = 4) 
answer- matrix (0, ncol = 4, nrow = 4) #my final objective is to generate
this matrix
soma - function (d,q){  
(d [q, 1] * d [q, 2])   #a function to multiplicate two collumns and two
elements at a time
}
for (q in 1:4){
m - soma
qw [q, 2] - m (d, q)
}
answer - sum (qw [, 2])

However I am doing this to generate a X'X matrix (since I can´t do t(X)$*$X
because i would like to include a conditional in the formula. Threrefore
this script above is not good to me)

Could anybody help me?
Thanks in advance
-- 
View this message in context: 
http://www.nabble.com/Sum-of-Product-in-a-Matrix-tp25530977p25530977.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] Odp: Sum of Product in a Matrix

2009-09-23 Thread Petr PIKAL
Hi

I am not sure if I understand what you want but if your matrix is not so 
big you can try

 x[,1]*x[,2]
[1]  5 12 21 32
 cumsum(x[,1]*x[,2])
[1]  5 17 38 70


and than check value of cumsum according to your condition.

Regards
Petr



r-help-boun...@r-project.org napsal dne 23.09.2009 05:25:16:

 
 Hi, 
 I am new in R and I don´t know how to sum the product of two elements at 
the
 time in a matrix
 
 X=[ 1  5   9   13
   2  6  10  14
   3  7  11  15
   4  8  12  16]
 I would like to do (1*5+2*6+3*7+4*8)
 I need to do it step by step because I will further put a conditional in 
the
 formula
 
 It worked this way
 x - matrix ( c (1 : 16),ncol = 4)  #generating my x matrix
 qw - matrix (0, ncol = 4, nrow = 4) 
 answer- matrix (0, ncol = 4, nrow = 4) #my final objective is to 
generate
 this matrix
 soma - function (d,q){ 
 (d [q, 1] * d [q, 2])   #a function to multiplicate two collumns and two
 elements at a time
 }
 for (q in 1:4){
 m - soma
 qw [q, 2] - m (d, q)
 }
 answer - sum (qw [, 2])
 
 However I am doing this to generate a X'X matrix (since I can´t do 
t(X)$*$X
 because i would like to include a conditional in the formula. Threrefore
 this script above is not good to me)
 
 Could anybody help me?
 Thanks in advance
 -- 
 View this message in context: http://www.nabble.com/Sum-of-Product-in-a-
 Matrix-tp25530977p25530977.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] Ford Fulkerson

2009-09-23 Thread Gábor Csárdi
Hi,

with a different (faster) algorithm, but maximum flows are implemented
in package igraph, although for some networks only calculating the
flow value is supported, giving the flow itself is not.

Best,
Gabor

On Wed, Sep 23, 2009 at 3:37 AM, shuva gupta shuvagu...@yahoo.com wrote:
 Hi,
 Is there any R implementation of the well-known algorithm from the Operations 
 Research
 literature, the Ford-Fulkerson algorithm of maximum flow in networks with 
 capacities.
 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.




-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

__
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] Handling missing data

2009-09-23 Thread Dr. S. B. Nguah

Reproducible code.???

premmad wrote:
 
 I have to remove missing data both in character and numeric datatype.I
 tried using NA condition but it is not working ,please help me to solve
 this.
 


-
Blay S
KATH
Kumasi, Ghana.
-- 
View this message in context: 
http://www.nabble.com/Handling-missing-data-tp25530192p25531059.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] use of class variable in r as in Proc means of sas

2009-09-23 Thread Girish A.R.

Replace your qfu as follows:
qfu - function(x, digits=3,sci=F,...){
  c(q=fivenum(x, ...)
)
}

Look up fivenum function for more information.

cheers,
-Girish

=

premmad wrote:
 
 Thanks for the help.I got the required quantiles by altering ur code 
 as follows 
 
 qfu-function(x,digits=3,sci=F,...)
 {c(q=quantile(x,probs=c(5,90)/100))
 }
 and my result of the R system is different from my sas system output for
 the same function  .could anyone help me in this and what is the reason
 for difference in results .I have attached both outputs
 R output:
 zip price.q.5%  price.q.90%
 1 6   567000.0  567000
 2 60001   709184.4  390626852
 3 60002 20349692.4  358154046
 4 60003 49847874.0  49847874
 5 60004   469447.9  3972289
 6 60005  5431407.0  88118012
 7 60006 23457082.6  341022805
 
 SAS output:
  zipObs5th Ptcl   90th Pctl  

  6  1   567000.00   567000.00  
   
 
  60001  3   478654.00   487587575  
   
 
 60002  2   478848.00   397895735  
   
 
 60003  1 49847874.00 49847874.00  
   
 
 60004  3   467648.00  4843949.00  
   

 60005  2   567489.00 97845848.00  
   
 
 60006  2  4776746.00   378383478
 I have already checked that SAS and SPSS produces the same output.Do i'm
 missing anything when using the function quantile 
 

-- 
View this message in context: 
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas-tp25530654p25531060.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] Variable as a filename

2009-09-23 Thread Lucas Sevilla García

Hi R community, I have a question. I have 5 files in a directory. Each file has 
a year as a name (file 1 -2004, file 2- 2005, ...). I want to build a for 
loop where I call first file, do some calculations, go to second file, do some 
calculations, etc. Somethin like this:

year-2003
nfiles - length(dir())

for( year in 2003:nfiles)
{clima-read.csv2([year].csv, nrows=10)
}

As you see, file name has to change when I read a year, in other words, if a 
read 2004 in variable year, I need to select file 2004. Then I read 2005 in 
variable year, and then I R have to open file 2005,...That's my question, How 
can I write the order read.csv2 in a way to obtain the file correspondant to 
the year read in the for loop. Thanks in advance.

Lucas
  
_


[[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] Variable as a filename

2009-09-23 Thread baptiste auguie
Hi,

The short answer would be ?paste (as in paste(year, .csv, sep=) ),
but I'd suggest you try this instead,

lf - list.files(pattern = .csv)

lf
# [1] 2003.csv 2004.csv 2005.csv

ln - gsub(.csv, , lf)

ln
# [1] 2003 2004 2005

length(ln)

lapply(lf, read.csv)

?list.files
?lapply

HTH,

baptiste

2009/9/23 Lucas Sevilla García luckocto...@hotmail.com:

 Hi R community, I have a question. I have 5 files in a directory. Each file 
 has a year as a name (file 1 -2004, file 2- 2005, ...). I want to build a 
 for loop where I call first file, do some calculations, go to second file, do 
 some calculations, etc. Somethin like this:

 year-2003
 nfiles - length(dir())

 for( year in 2003:nfiles)
    {clima-read.csv2([year].csv, nrows=10)
    }

 As you see, file name has to change when I read a year, in other words, if a 
 read 2004 in variable year, I need to select file 2004. Then I read 2005 in 
 variable year, and then I R have to open file 2005,...That's my question, How 
 can I write the order read.csv2 in a way to obtain the file correspondant to 
 the year read in the for loop. Thanks in advance.

 Lucas

 _


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

2009-09-23 Thread stefano iacus

one implementation is in the optmatch package as far as I remember
stefano

On 23/set/09, at 03:37, shuva gupta wrote:


Hi,
Is there any R implementation of the well-known algorithm from the  
Operations Research
literature, the Ford-Fulkerson algorithm of maximum flow in networks  
with capacities.

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

2009-09-23 Thread Chris Li

Hello,

Say I have a dataset as followed:

Category Value
b1
b2
a7
a1

Then, if I:

levels(Category)

It will return:
[a], [b]

But I want to keep the original order, i.e.:
[b], [a]

Is it possible to do it in R?

Thanks in advance!

Chris
-- 
View this message in context: 
http://www.nabble.com/Sorting-tp25531007p25531007.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] use of class variable in r as in Proc means of sas

2009-09-23 Thread premmad

Thanks for the help.I got the required quantiles by altering ur code 
as follows 

qfu-function(x,digits=3,sci=F,...)
{c(q=quantile(x,probs=c(5,90)/100))
}
and my result of the R system is different from my sas system output for the
same function  .could anyone help me in this and what is the reason for
difference in results .I have attached both outputs
R output:
zip price.q.5%  price.q.90%
1 6   567000.0  567000
2 60001   709184.4  390626852
3 60002 20349692.4  358154046
4 60003 49847874.0  49847874
5 60004   469447.9  3972289
6 60005  5431407.0  88118012
7 60006 23457082.6  341022805

SAS output:
 zipObs5th Ptcl   90th Pctl  
   
 6  1   567000.00   567000.00  

  
 60001  3   478654.00   487587575  

  
60002  2   478848.00   397895735  

  
60003  1 49847874.00 49847874.00  

  
60004  3   467648.00  4843949.00  

 
60005  2   567489.00 97845848.00  

  
60006  2  4776746.00   378383478
I have already checked that SAS and SPSS produces the same output.Do i'm
missing anything when using the function quantile 
-- 
View this message in context: 
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas-tp25530654p25531047.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] Semi continous variable- define bounds using lpsolve

2009-09-23 Thread pragathichi

thank a lot it works

Hans W. Borchers wrote:
 
 But of course, it is always possible to emulate a semi-continuous variable
 by introducing a binary variable and use some big-M trick. That is, with
 a new binary variable b we add the following two conditions:
 
 x3 - 3.6 * b = 0  and
 x3 - 10 * b  = 0 # Big-M trick, here M = 10
 
 (If b = 0, then x3 = 0, and if b = 1, then x3 = 3.6 !)
 
 As I do not trust 'lpSolve' too much anymore I used package 'Rglpk' with
 the following code:
 
 #-- snip ---
 library(Rglpk)
 
 obj- c(5, 9, 7.15, 0.1, 0)
 mat - matrix(c(1,1,1,1,0, 1,0,0,1,0, 0,0,1,0,-3.6, 0,0,1,0,-10,
 0,0,0,0,1),
   byrow=TRUE, ncol=5)
 dir - c(==, =, =, =, =)
 rhs - c(9, 6.55, 0, 0, 1)
 types - c(C, C, C, C, I)
 max - FALSE
 
 Rglpk_solve_LP(obj, mat, dir, rhs, types, max = max)
 # $optimum
 # [1] 22.705
 # 
 # $solution
 # [1] 0.00 2.45 0.00 6.55 0.00
 # 
 # $status
 # [1] 0
 #-- snap ---
 
 Semi-continuous variables are sometimes preferred as with a good
 implementation the solution is reached much faster (that's why I suggested
 them), but they can always be modelled with binary variables.
 
 Hans Werner
 
 
 pragathichi wrote:
 
 How to define bounds for a semi continous variable in lp_solve.
 Min 5x1 +9x2 +7.15x3 +0.1x4
 subject to 
 x1+x2+x3+x4=6.7
 x1+x4 = 6.5
 And x3 can be 0 or greater than 3.6
 hence x3 is  a semi continous variable 
 how to define bounds as well as semicontinous function because using 
 set.semicont and set. bound simantaneously doesn't seem to work.Thanks in
 advance for the help
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Semi-continous-variable--define-bounds-using-lpsolve-tp25530668p25531004.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] use of class variable in r as in Proc means of sas

2009-09-23 Thread premmad

I tried thanks for your help and got the same result for percentile 5  95 as
in SAS.But if i need to calculate quantiles (1,5,10,99,etc.) it will not be
possible with fivenum as explained in the help page .If i need those
quantiles what is the change i need to make in the function 
qfu-function(x,digits=3,sci=F,...)
{c(q=quantile(x,probs=c(5,90)/100))
} 

or do i need to include some other function .

-- 
View this message in context: 
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas-tp25530654p25531069.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] graduation

2009-09-23 Thread MKHABELA,SN

Hi everyone

I want help in graduating the attached rates and checking for goodness  
of fit and smoothness using R please help.


Many thnk
TOo every one around the world

This message and attachments are subject to a disclaimer. Please refer
to www.it.up.ac.za/documentation/governance/disclaimer/ for full
details. / Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule
onderhewig. Volledige besonderhede is by
www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.

Age Males   females
55  0.  0.
56  0.  0.
57  0.0083  0.
58  0.  0.00803209
59  0.  0.
60  0.00901373  0.00296296
61  0.00684929  0.
62  0.00770214  0.00182648
63  0.00386847  0.00165426
64  0.00476568  0.00141543
65  0.00298507  0.00127796
66  0.00229885  0.
67  0.00203046  0.00210084
68  0.00448229  0.
69  0.00602667  0.00103252
70  0.00092208  0.
71  0.00078895  0.00105988
72  0.00537152  0.00097040
73  0.00405268  0.00219539
74  0.00434216  0.00212992
75  0.00296004  0.00117855
76  0.00707182  0.00125235
77  0.00316957  0.00126984
78  0.00665924  0.00284091
79  0.01002777  0.00404040
80  0.01138508  0.00460475
81  0.01070940  0.00162470
82  0.00995017  0.00372439
83  0.00715560  0.00198610
84  0.00701751  0.00703397
85  0.02061782  0.00232829
86  0.01508267  0.00282087
87  0.01733058  0.
88  0.02020133  0.00389863
89  0.02227078  0.
__
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] use of class variable in r as in Proc means of sas

2009-09-23 Thread ONKELINX, Thierry
You might need to change the type quantile. The default is type = 7,
whereas default for SAS is type = 3 and for SPSS type = 6. Have a look
at the helpfile of quantile() for more details on the type. 

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 premmad
Verzonden: woensdag 23 september 2009 10:56
Aan: r-help@r-project.org
Onderwerp: Re: [R] use of class variable in r as in Proc means of sas


Thanks for the help.I got the required quantiles by altering ur code as
follows 

qfu-function(x,digits=3,sci=F,...)
{c(q=quantile(x,probs=c(5,90)/100))
}
and my result of the R system is different from my sas system output for
the same function  .could anyone help me in this and what is the reason
for difference in results .I have attached both outputs R output:
zip price.q.5%  price.q.90%
1 6   567000.0  567000
2 60001   709184.4  390626852
3 60002 20349692.4  358154046
4 60003 49847874.0  49847874
5 60004   469447.9  3972289
6 60005  5431407.0  88118012
7 60006 23457082.6  341022805

SAS output:
 zipObs5th Ptcl   90th Pctl  
   
 6  1   567000.00   567000.00  


 60001  3   478654.00   487587575  


60002  2   478848.00   397895735  


60003  1 49847874.00 49847874.00  


60004  3   467648.00  4843949.00  


60005  2   567489.00 97845848.00  


60006  2  4776746.00   378383478
I have already checked that SAS and SPSS produces the same output.Do i'm
missing anything when using the function quantile
--
View this message in context:
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas
-tp25530654p25531047.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.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

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] run R script automatically by double-clicking WinXP desktopicon

2009-09-23 Thread Franzini, Gabriele [Nervianoms]
Hello Chris,
I had the same problem, and I ended up driving R Gui through an Autoit
script, see http://www.autoitscript.com/autoit3/ Regards,
Gabriele Franzini


-Original Message-
From: cr...@binghamton.edu [mailto:cr...@binghamton.edu] 
Sent: 22 September 2009 19:37
To: r-help@r-project.org
Subject: Re: [R] run R script automatically by double-clicking WinXP
desktopicon

that helps, thanks. I can put a final line in my batch file that opens a
viewer for the png graph. 

I was hoping to find a way to do make it run in the Rgui (picky, I
know.) My graph is clearer in the default graph device that pops up in
the Rgui; it's blurry in the Windows viewer for png files. I should
probably play around with the resolution in R's png device. Or maybe
it's a function of the viewer I'm stuck using.

Thanks.

--Chris 

 Original message 
Date: Tue, 22 Sep 2009 11:41:50 -0400
From: Cedrick Johnson cedr...@cedrickjohnson.com
Subject: Re: [R] run R script automatically by double-clicking WinXP 
desktop icon
To: cr...@binghamton.edu
Cc: r-help@r-project.org

Here's something I use (in a batch file):

Rterm --no-restore --file=EveningStartup.r


Change EveningStartup.r to your particular file. When you create the 
shortcut, make sure to set the working directory to where your R script

is located. Then in your file, you could have the graphs write out to a

png file in a specified directory.

hth
c




cr...@binghamton.edu wrote:
 I've written a simple script that does some surveillance analysis on
daily counts of walk-in clinic visits, for our county health department.
(Actually, Michael Hohle's surveillance package does all the work; I
just customized it a little to work with the way our data are recorded.)
The output consists of a graph and a little table.

 My colleague will run it once in a while, on continuously updated
data. She knows nothing about R, at least not yet. I want to make it as
simple as possible. Rather than have her open R and type
source(filename), I want to be able to put an icon on her WinXP
desktop, so that when she double-clicks it, R will open, run the script,
and up pops the graph.

 I've been trying to learn about R CMD BATCH, playing with the
dialogue boxes for WinXP desktop shortcuts, etc, but no luck so far. I
guess I don't know enough about Windows.

 Can anyone tell me how to do this?  Thanks.

 --Chris Ryan

 __
 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] glm analysis repeated for 900 variables

2009-09-23 Thread Christian Schulz

Hi,


nvars - 902
data -  as.data.frame(matrix(runif(100*nvars),ncol=nvars))
colnames(data)[901] - c('phenotype')
colnames(data)[902] - c('outcome')

### catch all aic values ###
res  -  matrix(nrow=900,ncol=2)
for (i in 1:(length(data)-2)) {
res[i,1] -  names(data)[i]
res[i,2] -  glm(outcome~data[,i]*phenotype, data=data)$aic
}
res




Dear R users,

Could you help my with the following problem?
I want to repeat a glm analysis with 2 independent variables for all 900
variables (snps) in my data set. So, I want to check whether snp1 has a
different effect on my outcome variable in patients and
controls(phenotype). And repeat that for snp2 to snp900.
Is there an easy way to get a summary of the data, e.g. a list of P
values of all 900 variables?

I tried something with a loop:
for (i in 1:length(data)) { print (summary (glm
(outcome~data[[i]]*phenotype, data=data))) }   # This works, but gives
900 written summaries


for (i in 1:length(data)) { coef (summary (glm
(outcome~data[[i]]*phenotype, data=data))) }   # changing print to coef
gives no output

for (i in 1:length(data)) { glm.data - glm
(outcome~data[[i]]*phenotype, data=data)) }
summary (glm.data)
# gives only output of the last variable

for (i in 1:length(data)) { glm.data[[i]] - glm
(outcome~data[[i]]*phenotype, data=data)) }
summary (glm.data[[i]])
# gives only output of the last variable

Or should I use tapply or something like that? In what way?

Thanks!

Afke Terwisscha
email: aterw...@umcutrecht.nl mailto:aterw...@umcutrecht.nl





--

De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht
ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct
te informeren door het bericht te retourneren. Het Universitair Medisch
Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W.
(Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij
de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197.

Denk s.v.p aan het milieu voor u deze e-mail afdrukt.

--

This message may contain confidential information and is...{{dropped:14}}

__
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] Evaluating expresssions as parameter values

2009-09-23 Thread Peter Ehlers

Can't you just use get()? What am I missing?

  f - function(fo, data, groups) {
  g - xyplot(as.formula(fo), groups = get(groups), data)
  print(g)
  }
  f(yield ~ variety | site, data = barley, groups = year)

Peter Ehlers

Erich Neuwirth wrote:

Thanks, that completely solves the problem.

On Sep 22, 2009, at 10:27 PM, Gabor Grothendieck wrote:


Try parse(text=...):

f - function(fo, data, groups) {
g - do.call(xyplot, list(as.formula(fo),
groups = parse(text = groups), data))
print(g)
}

f(yield ~ variety | site, data = barley, groups = year)



On Tue, Sep 22, 2009 at 4:20 PM, Erich Neuwirth
erich.neuwi...@univie.ac.at wrote:

Thank you, this works for my example.
On Sep 22, 2009, at 9:17 PM, Gabor Grothendieck wrote:

f - function(fo, data, groups) {
g - do.call(xyplot, list(as.formula(fo), groups = as.name(groups), 
data))

print(g)
}

But xyplot allows expressions for the groups parameter also,
and using as.expression instead of as.name in your example does not 
work.

What is happening?

f - function(fo, data, groups) {
g - do.call(xyplot, list(as.formula(fo), groups = 
as.expression(groups),

data))
print(g)
}

f(yield ~ variety ~ site,barley,year)
produces a very nicely labeled but empty plot.





__
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] use of class variable in r as in Proc means of sas

2009-09-23 Thread Girish A.R.

See if this works:

qfun2 - function(x, digits=3,sci=F,...){
  c(q=quantile(x, probs=c(1,5,10,95,99)/100,type=6,...)
)
}

cheers,
-Girish

===

premmad wrote:
 
 I tried thanks for your help and got the same result for percentile 5  95
 as in SAS.But if i need to calculate quantiles (1,5,10,99,etc.) it will
 not be possible with fivenum as explained in the help page .If i need
 those quantiles what is the change i need to make in the function 
 qfu-function(x,digits=3,sci=F,...)
 {c(q=quantile(x,probs=c(5,90)/100))
 } 
 
 or do i need to include some other function .
 
 

-- 
View this message in context: 
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas-tp25530654p25531097.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 in graph plotting

2009-09-23 Thread FMH
Dear All,

Let:
dp: depth of the river 
tp: temperature with respect to depth

We can have a simple scatter plot, between depth as y-axis and temperature as 
x-axis, by using a plot function as shown below.

# 
dp - c(1,4,3,2,5,7,9,8,9,2)
tp - 1:10
plot(tp,dp, type= 'l')
#
 
Could someone advice me on the way to plot the same pair of observations, but 
with depth in descending order from the origin. Instead of depth, I tried to 
simply use rev(depth), but the result was bizarre.
 
Thank you
Fir




__
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] Problem in graph plotting

2009-09-23 Thread jim holtman
try this:

 plot(tp,dp, type= 'l',ylim=rev(range(dp)))


On Wed, Sep 23, 2009 at 7:58 AM, FMH kagba2...@yahoo.com wrote:
 Dear All,

 Let:
 dp: depth of the river
 tp: temperature with respect to depth

 We can have a simple scatter plot, between depth as y-axis and temperature as 
 x-axis, by using a plot function as shown below.

 #
 dp - c(1,4,3,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp,dp, type= 'l')
 #

 Could someone advice me on the way to plot the same pair of observations, but 
 with depth in descending order from the origin. Instead of depth, I tried to 
 simply use rev(depth), but the result was bizarre.

 Thank you
 Fir




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

2009-09-23 Thread Henrique Dallazuanna
Try this:

DF$Category - factor(DF$Category, levels = c(b, a))

On Wed, Sep 23, 2009 at 4:16 AM, Chris Li chri...@austwaterenv.com.au wrote:

 Hello,

 Say I have a dataset as followed:

 Category     Value
 b                1
 b                2
 a                7
 a                1

 Then, if I:

 levels(Category)

 It will return:
 [a], [b]

 But I want to keep the original order, i.e.:
 [b], [a]

 Is it possible to do it in R?

 Thanks in advance!

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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

2009-09-23 Thread jim holtman
Here is a way of doing it

 x - read.table(textConnection(Category Value
+ b1
+ b2
+ a7
+ a1), header=TRUE, as.is=TRUE)
 # now keep level in original order
 x$Category - factor(x$Category, levels=unique(x$Category))
 str(x)
'data.frame':   4 obs. of  2 variables:
 $ Category: Factor w/ 2 levels b,a: 1 1 2 2
 $ Value   : int  1 2 7 1
 levels(x$Category)
[1] b a


On Wed, Sep 23, 2009 at 3:16 AM, Chris Li chri...@austwaterenv.com.au wrote:

 Hello,

 Say I have a dataset as followed:

 Category     Value
 b                1
 b                2
 a                7
 a                1

 Then, if I:

 levels(Category)

 It will return:
 [a], [b]

 But I want to keep the original order, i.e.:
 [b], [a]

 Is it possible to do it in R?

 Thanks in advance!

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




-- 
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] use of class variable in r as in Proc means of sas

2009-09-23 Thread premmad

Ya it works thanks for the help
-- 
View this message in context: 
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas-tp25530654p25531102.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] Problem in graph plotting

2009-09-23 Thread David Winsemius


On Sep 23, 2009, at 7:58 AM, FMH wrote:


Dear All,

Let:
dp: depth of the river
tp: temperature with respect to depth

We can have a simple scatter plot, between depth as y-axis and  
temperature as x-axis, by using a plot function as shown below.


#
dp - c(1,4,3,2,5,7,9,8,9,2)
tp - 1:10
plot(tp,dp, type= 'l')
#


Perhaps:

dp - c(1,4,3,2,5,7,9,8,9,2)
tp - 1:10
plot(tp, -dp, type= 'l')



Could someone advice me on the way to plot the same pair of  
observations, but with depth in descending order from the origin.  
Instead of depth, I tried to simply use rev(depth), but the result  
was bizarre.


Thank you
Fir




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] reading web log file into R

2009-09-23 Thread jim holtman
Here is a way to do it.  I assume that you data has each record on a
line; it came through the email as multiple lines.


 x - readLines(/tempxx.txt)
 # remove '#Fields: so it can be used as a header
 x - sub(^#Fields: , , x)
 # remove comment lines
 x - x[-grep(^#, x)]
 # remove quotes
 x - gsub('', '', x)
 # now read in the data
 input - read.table(textConnection(x), header=TRUE)

 str(input)
'data.frame':   2 obs. of  16 variables:
 $ date  : Factor w/ 1 level 2007-12-03: 1 1
 $ time  : Factor w/ 1 level 13:50:17: 1 1
 $ c.ip  : Factor w/ 1 level 200.40.203.197: 1 1
 $ cs.username   : Factor w/ 1 level -: 1 1
 $ s.ip  : Factor w/ 1 level 200.40.51.20: 1 1
 $ s.port: int  80 80
 $ cs.method : Factor w/ 1 level GET: 1 1
 $ cs.uri.stem   : Factor w/ 2 levels /localidades/img/cargando.gif,..: 2 1
 $ cs.uri.query  : Factor w/ 1 level -: 1 1
 $ sc.status : int  200 200
 $ sc.bytes  : int  328 1150
 $ cs.bytes  : int  447 451
 $ time.taken: int  0 0
 $ cs.User.Agent.: Factor w/ 1 level
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322):
1 1
 $ cs.Cookie.: Factor w/ 1 level
ASPSESSIONIDSQCBSQAB=JOLECDCCBFCKPOFLGDLHMENA: 1 1
 $ cs.Referer.   : Factor w/ 1 level
http://www.teatro.com/localidades/localidades.asp: 1 1



On Tue, Sep 22, 2009 at 9:51 PM, Sebastian Kruk residuo.so...@gmail.com wrote:
 If I have a web log file as follows:

 #Software: Microsoft Internet Information Services 5.0
 #Version: 1.0
 #Date: 2007-12-03 13:50:17
 #Fields: date time c-ip cs-username s-ip s-port cs-method cs-uri-stem
 cs-uri-query sc-status sc-bytes cs-bytes time-taken cs(User-Agent)
 cs(Cookie) cs(Referer)
 2007-12-03 13:50:17 200.40.203.197 - 200.40.51.20 80 GET
 /localidades/img/nada.gif - 200 328 447 0
 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
 ASPSESSIONIDSQCBSQAB=JOLECDCCBFCKPOFLGDLHMENA
 http://www.teatro.com/localidades/localidades.asp;
 2007-12-03 13:50:17 200.40.203.197 - 200.40.51.20 80 GET
 /localidades/img/cargando.gif - 200 1150 451 0
 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
 ASPSESSIONIDSQCBSQAB=JOLECDCCBFCKPOFLGDLHMENA
 http://www.teatro.com/localidades/localidades.asp;
 2007-12-03 13:50:18 200.40.203.197 - 200.40.51.20 80 GET
 /localidades/img/cerrar.png - 200 450 449 0
 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)

 how can I turn it into a dataframe with 3 rows, and 16 columns named
 date time c-ip cs-username s-ip s-port cs-method cs-uri-stem
 cs-uri-query sc-status sc-bytes cs-bytes time-taken cs(User-Agent)
 cs(Cookie) cs(Referer) skiping lines begining with #?

 Thanks,

 Sebastián.

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

2009-09-23 Thread baptiste auguie
yet another way,

 x - read.table(textConnection(Category Value
+  b1
+  b2
+  a7
+  a1), header=TRUE)
 y = transform(x, Category = relevel(Category, c(b)))
 str(y)
'data.frame':   4 obs. of  2 variables:
 $ Category: Factor w/ 2 levels b,a: 1 1 2 2
 $ Value   : int  1 2 7 1

HTH,

baptiste

2009/9/23 Chris Li chri...@austwaterenv.com.au:

 Hello,

 Say I have a dataset as followed:

 Category     Value
 b                1
 b                2
 a                7
 a                1

 Then, if I:

 levels(Category)

 It will return:
 [a], [b]

 But I want to keep the original order, i.e.:
 [b], [a]

 Is it possible to do it in R?

 Thanks in advance!

 Chris
 --
 View this message in context: 
 http://www.nabble.com/Sorting-tp25531007p25531007.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] strange split behavior?

2009-09-23 Thread Peng Yu
On Wed, Sep 23, 2009 at 1:24 AM, Peter Dalgaard
p.dalga...@biostat.ku.dk wrote:
 Peng Yu wrote:

 Hi,

 Please see the command with a comment below. I don't find
 'A630039F22Rik' in y. But 'A630039F22Rik' is in z. Can somebody let me
 know what the problem is?

 Most obvious guess is that your  factor y has a level that is not present in
 data. That is perfectly normal, even desirable in some cases.

 e.g., (sorry about the different names)

 f - factor(rep(1,4),levels=0:1)
 y - 1:4
 split(y,f)
 $`0`
 integer(0)

 $`1`
 [1] 1 2 3 4

 table(f)
 f
 0 1
 0 4

I see. The problem is that I extract a subset of a factor ('fdata' in
the following case). I thought that only a subset of factor levels
will be returned. But it is not.

Is there an operation on a factor to get a subset and keep only the
corresponding levels (see commented line below)?

 data=c(2,2,3,-1,1)
 fdata=factor(data)
 fdata[1:2]#Levels have all values. But I only want 2.
[1] 2 2
Levels: -1 1 2 3
 levels(fdata[1:2])
[1] -1 1  2  3

 as.vector(levels(fdata))
[1] -1 1  2  3


__
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] retrieve certain part from html

2009-09-23 Thread Rene
Dear All,

 

Can someone please guide me how to get the certain part from a long html
language?

 

e.g. 

 

tda href='2005-01.html'2005-01/a/tdtda
href='2006-01.html'2006-01/a/tdtda
href='2007-01.html'2007-01/a/tdtda
href='2008-01.html'2008-01/a/tdtda
href='2009-01.html'2009-01/a/td

 

How to get only the wording of  2005-01.html, 2006-01.html,
2007-01.html, 2008-01.html, 2009-01.html from the above html code? I
have tried to use gsub function, but not working.

 

Please guide me on this.

 

Thanks a lot.

Rene.

 


[[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] reading web log file into R

2009-09-23 Thread Jay Emerson
Sebastian,

There is rarely a completely free lunch, but fortunately for us R has
some wonderful tools
to make this possible.  R supports regular expressions with commands
like grep(),
gsub(), strsplit(), and others documented on the help pages.  It's
just a matter of
constructing and algorithm that does the job.  In your case, for
example (though please
note there are probably many different, completely reasonable approaches in R):

x - scan(logfilename, what=, sep=\n)

should give you a vector of character strings, one line per element.  Now, lines
containing GET seem to identify interesting lines, so

x - x[grep(GET, x)]

should trim it to only the interesting lines.  If you want information
from other lines, you'll
have to treat them separately.  Next, you might try

y - strsplit(x)

which by default splits on whitespace, returning a list (one component
per line) of vectors
based on the split.  Try it.  It it looks good, you might check

lapply(y, length)

to see if all lines contain the same number of records.  If so, you
can then get quickly into
a matrix,

z - matrix(unlist(strsplit(x)), ncol=K, byrow=TRUE)

where K is the common length you just observed.  If you think this is
cool, great!  If not, well...
hire a programmer, or if you're lucky Microsoft or Apache have tools
to help you with this.
There might be something in the Perl/Python world.  Or maybe there's a
package in R designed
just for this, but I encourage students to develop the raw skills...

Jay



-- 
John W. Emerson (Jay)
Associate Professor of Statistics
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

__
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] Problem in graph plotting

2009-09-23 Thread Jim Lemon

On 09/23/2009 09:58 PM, FMH wrote:

Dear All,

Let:
dp: depth of the river
tp: temperature with respect to depth

We can have a simple scatter plot, between depth as y-axis and temperature as 
x-axis, by using a plot function as shown below.

# 
dp- c(1,4,3,2,5,7,9,8,9,2)

tp- 1:10
plot(tp,dp, type= 'l')
#
  
Could someone advice me on the way to plot the same pair of observations, but with depth in descending order from the origin. Instead of depth, I tried to simply use rev(depth), but the result was bizarre.


   

Hi Fir,
I think what you mean is this:

depth.order-order(dp)
plot(dp[depth.order],tp[depth.order],
 main=Temperature by depth)

This lines up your depths on the x axis in descending order and displays 
the associated temperatures on the y axis.


Jim

__
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] retrieve certain part from html

2009-09-23 Thread Romain Francois

Hi,

The R4X package can help you. (I have wrapped your td's into one tr)

 x - xml( trtda href='2005-01.html'2005-01/a/tdtda
+ href='2006-01.html'2006-01/a/tdtda
+ href='2007-01.html'2007-01/a/tdtda
+ href='2008-01.html'2008-01/a/tdtda
+ href='2009-01.html'2009-01/a/td/tr )

 x[td/a/#]
   tdtdtdtdtd
2005-01 2006-01 2007-01 2008-01 2009-01
 x[td/a/@href]
td td td td td
2005-01.html 2006-01.html 2007-01.html 2008-01.html 2009-01.html

Romain

On 09/23/2009 02:29 PM, Rene wrote:


Dear All,

Can someone please guide me how to get the certain part from a long html
language?

e.g.



tda href='2005-01.html'2005-01/a/tdtda
href='2006-01.html'2006-01/a/tdtda
href='2007-01.html'2007-01/a/tdtda
href='2008-01.html'2008-01/a/tdtda
href='2009-01.html'2009-01/a/td



How to get only the wording of  2005-01.html, 2006-01.html,
2007-01.html, 2008-01.html, 2009-01.html from the above html code? I
have tried to use gsub function, but not working.



Please guide me on this.



Thanks a lot.

Rene.


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
|- http://tr.im/yw8E : New R package : sos
`- http://tr.im/y8y0 : search the graph gallery from R

__
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] Problem in graph plotting

2009-09-23 Thread baptiste auguie
Hi,

It's trivial with ggplot2,

library(ggplot2)
qplot(tp,dp, geom=line) + scale_y_reverse()

HTH,

baptiste

2009/9/23 David Winsemius dwinsem...@comcast.net:

 On Sep 23, 2009, at 7:58 AM, FMH wrote:

 Dear All,

 Let:
 dp: depth of the river
 tp: temperature with respect to depth

 We can have a simple scatter plot, between depth as y-axis and temperature
 as x-axis, by using a plot function as shown below.

 #
 dp - c(1,4,3,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp,dp, type= 'l')
 #

 Perhaps:

 dp - c(1,4,3,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp, -dp, type= 'l')


 Could someone advice me on the way to plot the same pair of observations,
 but with depth in descending order from the origin. Instead of depth, I
 tried to simply use rev(depth), but the result was bizarre.

 Thank you
 Fir



 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-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] Reading data

2009-09-23 Thread Ashta
Dear R-users,

 I am a new user for R. I am eager to lean about it.



I wanted to read and  summary of the  a simple data file



I used the following,





rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat, quote=,header=FALSE,sep=,col.names=

c(id,orel,nrel))

summary(rel)





Below is the error message,



rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat, quote=,header=FALSE,sep=,col.names=

+ c(id,orel,nrel))

Error in file(file, r) : cannot open the connection

In addition: Warning message:

In file(file, r) :

  cannot open file 'file=C:/Documents and Settings/sewalem/My
Documents/R_data/rel.dat': Invalid argument

 summary(rel)

Error in summary(rel) : object 'rel' not found



Does it need a library? Where can I get the library?



Any help is highly appreciated



Ashta

[[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] retrieve certain part from html

2009-09-23 Thread Henrique Dallazuanna
Try using XML package:

Lines - tda href='2005-01.html'2005-01/a/tdtda
href='2006-01.html'2006-01/a/tdtda
href='2007-01.html'2007-01/a/tdtda
href='2008-01.html'2008-01/a/tdtda
href='2009-01.html'2009-01/a/td

library(XML)
xpathApply(htmlParse(Lines), //a, xmlAttrs)

On Wed, Sep 23, 2009 at 9:29 AM, Rene kaixinma...@gmail.com wrote:
 Dear All,



 Can someone please guide me how to get the certain part from a long html
 language?



 e.g.



 tda href='2005-01.html'2005-01/a/tdtda
 href='2006-01.html'2006-01/a/tdtda
 href='2007-01.html'2007-01/a/tdtda
 href='2008-01.html'2008-01/a/tdtda
 href='2009-01.html'2009-01/a/td



 How to get only the wording of  2005-01.html, 2006-01.html,
 2007-01.html, 2008-01.html, 2009-01.html from the above html code? I
 have tried to use gsub function, but not working.



 Please guide me on this.



 Thanks a lot.

 Rene.




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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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

2009-09-23 Thread David Winsemius


On Sep 23, 2009, at 4:54 AM, MKHABELA,SN wrote:


Hi everyone

I want help in graduating the attached rates and checking for  
goodness of fit and smoothness using R please help.


Mortality rates for males and  
females.txt__


You have provided the rates but not the death counts or person-years  
of exposure that would be needed to create these rates. Such numbers  
would be useful in doing a graduation that had a statistical basis. At  
the moment I think you should be looking at the data and deciding  
whether you can model as a Gompertz function which is the canonical  
mortality law:


mrates - read.table(file=path/Mortality rates for males and  
females.txt, header=T)
with(mrates, plot(Age, log(Males+.001)))  # added 1/2 the minimum rate  
to the zero entries

with(mrates, plot(Age, log(females+.0005)))

But I do not think you have given enough information or background to  
take further steps. The plots are not entirely supportive of a  
Gompertz model and is telling you that you need to think more deeply  
about what the underlying situation really represents.


Of course, if this is homework, you have not been completely  
forthright with us and should review your educational  institution's  
regulations.


--

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] strange split behavior?

2009-09-23 Thread Philipp Pagel
On Wed, Sep 23, 2009 at 07:29:30AM -0500, Peng Yu wrote:
 On Wed, Sep 23, 2009 at 1:24 AM, Peter Dalgaard
 p.dalga...@biostat.ku.dk wrote:
  Peng Yu wrote:
 
 Is there an operation on a factor to get a subset and keep only the
 corresponding levels (see commented line below)?

Yes, there is: call factor() on your subset:

 a - factor(rep(letters[1:5], 5))
 a
 [1] a b c d e a b c d e a b c d e a b c d e a b c d e
Levels: a b c d e
 b - a[a!='b']
 b
 [1] a c d e a c d e a c d e a c d e a c d e
Levels: a b c d e
 factor(b)
 [1] a c d e a c d e a c d e a c d e a c d e
Levels: a c d e


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

2009-09-23 Thread David Winsemius


On Sep 23, 2009, at 8:44 AM, David Winsemius wrote:



On Sep 23, 2009, at 4:54 AM, MKHABELA,SN wrote:


Hi everyone

I want help in graduating the attached rates and checking for  
goodness of fit and smoothness using R please help.


Mortality rates for males and  
females.txt__


You have provided the rates but not the death counts or person-years  
of exposure that would be needed to create these rates. Such numbers  
would be useful in doing a graduation that had a statistical basis.  
At the moment I think you should be looking at the data and deciding  
whether you can model as a Gompertz function which is the canonical  
mortality law:


mrates - read.table(file=path/Mortality rates for males and  
females.txt, header=T)
with(mrates, plot(Age, log(Males+.001)))  # added 1/2 the minimum  
rate to the zero entries

with(mrates, plot(Age, log(females+.0005)))


My eyeball minimum wasn't very good and should have been done thusly:

with(mrates, plot(Age, log(females + 0.5*min(mrates$females) )) )



But I do not think you have given enough information or background  
to take further steps. The plots are not entirely supportive of a  
Gompertz model and is telling you that you need to think more  
deeply about what the underlying situation really represents.


Of course, if this is homework, you have not been completely  
forthright with us and should review your educational  institution's  
regulations.




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] Reading data

2009-09-23 Thread Keo Ormsby

Hello Ashta,
You need to use double blackslashes, liike: C:\\Documents and 
Settings\\ashta\\MyDocuments\\R_data\\rel.dat


I usually use the following to avoid writing the path:

#select file from a popup window
f - file.choose()
#read the file.  the    is Rese for any other arguments e.g. header, 
sep. quote, etc.

data - read.table(f, ...)

Good luck! and welcome to R.

Keo.

Ashta escribió:

Dear R-users,

 I am a new user for R. I am eager to lean about it.



I wanted to read and  summary of the  a simple data file



I used the following,





rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat, quote=,header=FALSE,sep=,col.names=

c(id,orel,nrel))

summary(rel)





Below is the error message,



rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat, quote=,header=FALSE,sep=,col.names=

+ c(id,orel,nrel))

Error in file(file, r) : cannot open the connection

In addition: Warning message:

In file(file, r) :

  cannot open file 'file=C:/Documents and Settings/sewalem/My
Documents/R_data/rel.dat': Invalid argument

  

summary(rel)



Error in summary(rel) : object 'rel' not found



Does it need a library? Where can I get the library?



Any help is highly appreciated



Ashta

[[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] Maximum Likelihood Est. regarding the degree of freedom of a multivariate skew-t copula

2009-09-23 Thread Ravi Varadhan
Why are you using SANN for optimizing over a smooth function of a scalar
parameter? Simulated annealing is generally quite slow, and is typically
used for nasty functions with multiple bumps and valleys.

Try `optimize' instead.

Ravi.


---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml






-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of John Reichenbächer
Sent: Wednesday, September 23, 2009 7:17 AM
To: r-help@r-project.org
Subject: [R] Maximum Likelihood Est. regarding the degree of freedom of a
multivariate skew-t copula

Hello,

I have a bigger problem in calculating the Maximum Likelihood Estimator
regarding the  degree of freedom of a multivariate skew-t copula.



First of all I would like to describe what this is all about, so that you
can understand my problem:


I have 2 time series with more than 3000 entries each. I would like to
calculate a multivariate skew-t Copula that fits this time series.

Notice: The program-code works fine, but it is too slow to deliver adequate
results in time.



I marked:

Yellow the needed calculations and definitions of the data.

 Pink the estimator oft he correlation
cyan  the loglikelihood-function of the skew-t-copula (NOTICE fort he first
consideration the skew-parameter is 0, but I want to change it later on)
Blue  the calculation of the needed quantiles by uniroot.

 und dark-blue  the value of the loglikelihood-function

 purple  the starting parameters and the optim()


PROBLEM: Executing the likelihood-function by it self takes half a minute.
The optim() even longer. But I need several iterations. (maybe 1000 or even
more) Is there a way to make it faster


THX, John Reichenbächer



PS: The attachment are the time series, that are used


data-read.table(NIKKEI.txt, header=T)
attach(data)
data-read.table(DAX.txt, header=T)
attach(data)

my_dax-mean(dax)
sd_dax-sqrt(var(dax))
my_nik-mean(nik)
sd_nik-sqrt(var(nik))

P_dax-pnorm(dax,mean=my_dax, sd=sd_dax) P_nik-pnorm(nik,mean=my_nik,
sd=sd_nik)

xi-vector(length=2)
Omega - matrix(nrow=2, ncol=2)
alpha-vector(length=2)

u1-vector(length=length(P_dax))
u2-vector(length=length(P_nik))
xi-c(0,0)
Omega-diag(2)
alpha-c(0,0)
ber1-c(-25,25)
ber2-c(-25,25)
z-vector(length=length(P_dax))


s-0
for(i in 2:length(P_dax)) {
for(j in 1:(i-1)) {
s-s+sign((P_dax[j]-P_dax[i])*(P_nik[j]-P_nik[i]))
}
}
s-s/choose(length(P_dax),2)
ndiag-sin(pi*s/2)

Omega[2,1]-Omega[1,2]-ndiag


c_density - function(v) {

df-v[1]

for(i in 1:length(P_dax)) {

f - function(z) {
pmst(z, xi[1],Omega[1,1],alpha[1],df)-P_dax[i]
}

u1[i]-uniroot(f,ber1,tol=0.01)$root

f - function(z) {
pmst(z, xi[2],Omega[2,2],alpha[2],df)-P_nik[i]
}

u2[i]-uniroot(f,ber2,tol=0.01)$root

zähler-dmst(c(u1[i],u2[i]),xi,Omega,alpha,df)[1]
nenner-dmst(u1[i], xi[1] ,Omega,alpha[1],df) * dmst(u2[i],
xi[2],Omega,alpha[2],df)
z[i]-zähler/nenner

}


lnc-log(z)
erg-(-1)*sum(lnc)
return(erg)

}


v-c(10)

optim(v,c_density, method=SANN, control=list(maxit=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.


Re: [R] any way to make it work faster (deleting rows that contain certain values)

2009-09-23 Thread Dimitri Liakhovitski
Chuck, thank you, but I am not sure I understood what you meant.
There are a lot of rows in index where at least 2 columns have equal
values and a lot of rows where column 1 has 2 and some other column
has 5 - same for 3 in column 1 and 6 in some other column, etc.
Thanks a lot for clarifying!
Dimitri

On Tue, Sep 22, 2009 at 5:36 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote:
 On Tue, 22 Sep 2009, Dimitri Liakhovitski wrote:

 Hello, dear R'ers,

 index-expand.grid(1:7,1:4,1:4,1:4,1:4,1:4,1:4,1:4,1:4,1:4,1:4)

 In this case, dim(index) is 7,340,032 (!)  and 11.
 I realize it's huge.
 Then, I am trying to get rid of the undesired combinations of columns.
 They should not contain identical values in any 2 columns.


 Right, but you have only four values in each of columns 2:11.

 And none of them can be identical.

 There are exactly

        choose(4,10)

 rows that satisfy that constraint for columns 2:11.

 The rows of your result are easily enumerated by hand. ;-)

 HTH,

 Chuck

 Also if column 1 has a value of 5, there should be no 2 in any other
 column,
 if column 1 has a value of 6, there should be no 3 in any other column,
 and
 column 1 has a value of 7, there should be no 4 in any other column.
 I worte a generic script to achieve that (below).
 However, I was wondering if it's possible to make it any faster - it
 looks like with that huge index it's going to take me days...

 Thanks a lot for any suggestion!
 Dimitri

 index-expand.grid(1:7,1:4,1:4,1:4,1:4,1:4,1:4,1:4,1:4,1:4,1:4)
 bad.pairs-matrix(c(1,1,2,2,3,3,4,4,5,2,6,3,7,4),nrow=7,ncol=2,byrow=T)
 for(i in 1:ncol(index)){                # looping through columns of the
 index
  for(pair in 1:nrow(bad.pairs)){     # looping through rows of bad.pairs
   keep-sapply(1:nrow(index), function(x){
     temp-(index[[x,i]]==bad.pairs[pair,1]) 
 (any(index[x,-i]==bad.pairs[pair,2]))
     return(temp)
   })
   index-index[!keep,]
  }
 }

 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.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.


 Charles C. Berry                            (858) 534-2098
                                            Dept of Family/Preventive
 Medicine
 E mailto:cbe...@tajo.ucsd.edu               UC San Diego
 http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901






-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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] percent data being treated as categorical

2009-09-23 Thread Larry White
I have the following data exported as a .txt file on Windows. Everything is
working fine, except that the the data in the 10th column is treated as a
factor.

Date Week Time Completed Work_Delta Mean_Delta Balance Total Total_Delta
Work Index Open_Bugs Bug_Delta Bug_Delta2
8/17/2009 4 11.8% 64 64 16 611 675 675 9.5% 0.81 333 31 -31
8/30/2009 6 17.6% 104 40 20 801 905 230 11.5% 0.65 269 32 -32
9/6/2009 7 20.6% 136 32 32 815 951 46 14.3% 0.69 265 4 -4
9/13/2009 8 23.5% 168 32 32 789 957 6 17.6% 0.75 240 25 -25
9/20/2009 9 26.5% 215 47 47 750 965 8 22.3% 0.84 219 21 -21

How can i correct this so i can plot it?

thanks
Larry

[[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] Error in package management on R 2.9.2 GUI 1.29 Tiger build 32-bit

2009-09-23 Thread Jean-Baptiste Marquette

Dear R gurus,

I use the above release on my MacPro under Leopard 10.5.8 and I have  
no more access to the package manager and the CRAN binary list on  
package installer. Error messages in the console are :


Erreur : impossible de trouver la fonction  
package.manager (impossible to find function package.manager)
Erreur : impossible de trouver la fonction browse.pkgs (impossible  
to find function browse.pkgs)


and I got a window :

Fetching Package List Failed

Any hint welcome.


Bien cordialement / Very truly yours / Mit freundlichen Gruessen,
Jean-Baptiste Marquette
Institut d'Astrophysique de Paris
CNRS - UMR 7095
Université Pierre  Marie Curie
98bis Bd Arago
75014 Paris - France
Tel +33 (0)1 4432 8196
Fax +33 (0)1 4432 8001


__
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] Fwd: confirm 60c6d87144c82778d7053d4f81d1e06f92f9f1e7

2009-09-23 Thread Tobias Erik Reiners


--
Tobias Erik Reiners
Justus Liebig University
IFZ - Department of Animal Ecology
Heinrich-Buff-Ring 26-32
D-35392 Giessen  Germany

www.uni-giessen.de/cms/fbz/fb08/biologie/tsz/tieroekologie/mitarbeiter/diplomanden-innen/tobias-erik-reiners








---BeginMessage---
Mailing list subscription confirmation notice for mailing list R-help

We have received a request from 129.132.148.130 for subscription of
your email address, tobias.rein...@bio.uni-giessen.de, to the
r-help@r-project.org mailing list.  To confirm that you want to be
added to this mailing list, simply reply to this message, keeping the
Subject: header intact.  Or visit this web page:


https://stat.ethz.ch/mailman/confirm/r-help/60c6d87144c82778d7053d4f81d1e06f92f9f1e7


Or include the following line -- and only the following line -- in a
message to r-help-requ...@r-project.org:

confirm 60c6d87144c82778d7053d4f81d1e06f92f9f1e7

Note that simply sending a `reply' to this message should work from
most mail readers, since that usually leaves the Subject: line in the
right form (additional Re: text in the Subject: is okay).

If you do not wish to be subscribed to this list, please simply
disregard this message.  If you think you are being maliciously
subscribed to the list, or have any other questions, send them to
r-help-ow...@r-project.org.
---End Message---
__
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] Reading data

2009-09-23 Thread Don MacQueen
What it is telling you is that it can't find the file. This could be 
because the file isn't there, or you've got a typo in the file name, 
that sort of thing.


In your email, you have split the filename argument between two 
lines. I don't know whether this comes from what you did in R, or 
whether it was put there by the email software. If the former, try it 
without the line break, like this:


rel - read.table(C:/Documents and Settings/ashta/My 
Documents/R_data/rel.dat,

 quote=,header=FALSE,sep=,col.names=
  c(id,orel,nrel))

NOT

rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat,
 quote=,header=FALSE,sep=,col.names=
  c(id,orel,nrel))


This is a bit of a wild guess, since I don't use R in Windows, and I 
don't know how the R GUI for Windows handles a line break in the 
filename in context of read.table(). But it could be the problem. 
Also, isn't there supposed to be a space between My and 
Documents? As best I can tell from your email, you don't have one 
-- but it's hard to tell because it's split into two lines.


-Don

At 8:42 AM -0400 9/23/09, Ashta wrote:

Dear R-users,

 I am a new user for R. I am eager to lean about it.



I wanted to read and  summary of the  a simple data file



I used the following,





rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat, quote=,header=FALSE,sep=,col.names=

c(id,orel,nrel))

summary(rel)





Below is the error message,



rel - read.table(C:/Documents and Settings/ashta/My
Documents/R_data/rel.dat, quote=,header=FALSE,sep=,col.names=

+ c(id,orel,nrel))

Error in file(file, r) : cannot open the connection

In addition: Warning message:

In file(file, r) :

  cannot open file 'file=C:/Documents and Settings/sewalem/My
Documents/R_data/rel.dat': Invalid argument


 summary(rel)


Error in summary(rel) : object 'rel' not found



Does it need a library? Where can I get the library?



Any help is highly appreciated



Ashta

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



--
--
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] mapproject returns NAs

2009-09-23 Thread Tobias Erik Reiners

Dear Helpers,

usually I try to find the answers on my own, but this one beated me.

I have to use the package Geneland which requires coordinates in  
Lambert projection.

I have latitude and longitude (please copy to an .txt and read.table() )

X   Y
3458231 5544356
3458263 5544301
3459143 5543274
3459205 5543209
3475184 5594707
3475215 5594842
3475381 5593977
3475397 5594442
3475428 5593959
3475441 5593989
3475766 5594891
3475770 5594318
3476000 5594992
3476001 5594722
3476004 5594804
3476004 5594811
3476018 5594090
3476032 5594038
3476035 5595077
3476053 5595027
3476055 5594986
3476057 5593827
3476059 5595031
3476078 5595063
3476091 5595050

When i try to use the function mapproject() i get NAs for some points

require(Geneland)

plot(coordinates,type=n,xlab=Lon,ylab=Lat,asp=1)
points(coordinates,col=2)
map(resol=0,add=TRUE)

coordinates
# convert to Lambert
mapproj.res - mapproject(x=coordinates[,1],
   y=coordinates[,2],
   projection=lambert,
   param=apply(unique(coordinates),2,mean))

coord.lamb - cbind(mapproj.res$x,mapproj.res$y)

If anyone could explain me why this happens and hopefully tell me how
to solve it.

Thanks a lot in advance
Tobias
--
Tobias Erik Reiners
Justus Liebig University
IFZ - Department of Animal Ecology
Heinrich-Buff-Ring 26-32
D-35392 Giessen  Germany

www.uni-giessen.de/cms/fbz/fb08/biologie/tsz/tieroekologie/mitarbeiter/diplomanden-innen/tobias-erik-reiners

__
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] percent data being treated as categorical

2009-09-23 Thread Larry White
Resolved. Thanks.

On Wed, Sep 23, 2009 at 9:52 AM, Larry White ljw1...@gmail.com wrote:

 I have the following data exported as a .txt file on Windows. Everything is
 working fine, except that the the data in the 10th column is treated as a
 factor.

 Date Week Time Completed Work_Delta Mean_Delta Balance Total Total_Delta
 Work Index Open_Bugs Bug_Delta Bug_Delta2
 8/17/2009 4 11.8% 64 64 16 611 675 675 9.5% 0.81 333 31 -31
 8/30/2009 6 17.6% 104 40 20 801 905 230 11.5% 0.65 269 32 -32
 9/6/2009 7 20.6% 136 32 32 815 951 46 14.3% 0.69 265 4 -4
 9/13/2009 8 23.5% 168 32 32 789 957 6 17.6% 0.75 240 25 -25
 9/20/2009 9 26.5% 215 47 47 750 965 8 22.3% 0.84 219 21 -21

 How can i correct this so i can plot it?

 thanks
 Larry


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

2009-09-23 Thread jude.ryan
Alessandro Carletti wrote:

 

Hi,

I have a problem.

I have a data frame looking like:

 

ID val

 

A? .3

B? 1.2

C? 3.4

D? 2.2

E? 2.0

 

I need to CREATE the following TABLE:

 

CASE?? DIFF

 

A-A??? 0

A-B??? -0.9

A-C??? -3.1

A-D??? -1.9

A-E??? -1.7

B-A??? ...

B-B??? ...

B-C

B-D

B-E

C-A

...

 

WHERE CASE IS THE COUPLE OF ELEMENTS CONSIDEREDM AND DIFF IS THE
computed DIFFERENCE between their values.

 

Could you give me suggestions?

 

Solution:

Besides the suggestions given by others, you can use the sqldf package
to do this (leveraging knowledge in SQL if you know SQL). If you join
your data frame with itself, without a join condition, you will get the
Cartesian product of the two data frames, which seems to be exactly what
you need. A warning is in order. Generally when you join 2 (or more)
data frames you DO NOT want the Cartesian product by want to join the
data frames by some key. The solution to your particular problem,
however, can be implemented easily using the Cartesian product.

 

mydata - data.frame(id=rep(c('A','B','C','D','E'), each=2),
val=sample(1:5, 10, replace=T))

mydata

library(sqldf)

# merge data frame with itself to create a Cartesian Product - this is
normally NOT what you want.

# Note 'case' is a key word in SQL so I use cases for the variable name.
Likewise diff is a used in R so I use diffr

mydata2 - sqldf(select a.id as id1, a.val as val1, b.id as id2, b.val
as val2, a.id || ' - ' || b.id as cases,

 a.val - b.val as diffr from mydata a, mydata b)

dim(mydata2) # check dimensions of the merged dataset

head(mydata2) # examine the first 6 records

# if you want only the columns casses and diffr, then use this SQL code

mydata3 - sqldf(select a.id || ' - ' || b.id as cases, a.val - b.val
as diffr from mydata a, mydata b)

dim(mydata3) # check dimensions of the merged dataset

head(mydata3) # examine the first 6 records

 

Hope this helps.

 

Jude

___
Jude Ryan
Director, Client Analytical Services
Strategy  Business Development
UBS Financial Services Inc.
1200 Harbor Boulevard, 4th Floor
Weehawken, NJ 07086-6791
Tel. 201-352-1935
Fax 201-272-2914
Email: jude.r...@ubs.com



Please do not transmit orders or instructions regarding a UBS 
account electronically, including but not limited to e-mail, 
fax, text or instant messaging. The information provided in 
this e-mail or any attachments is not an official transaction 
confirmation or account statement. For your protection, do not 
include account numbers, Social Security numbers, credit card 
numbers, passwords or other non-public information in your e-mail. 
Because the information contained in this message may be privileged, 
confidential, proprietary or otherwise protected from disclosure, 
please notify us immediately by replying to this message and 
deleting it from your computer if you have received this 
communication in error. Thank you. 

UBS Financial Services Inc. 
UBS International Inc. 
UBS Financial Services Incorporated of Puerto Rico 
UBS AG

 
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.__
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] strange split behavior?

2009-09-23 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 23.09.2009 14:49:38:

 On Wed, Sep 23, 2009 at 07:29:30AM -0500, Peng Yu wrote:
  On Wed, Sep 23, 2009 at 1:24 AM, Peter Dalgaard
  p.dalga...@biostat.ku.dk wrote:
   Peng Yu wrote:
  
  Is there an operation on a factor to get a subset and keep only the
  corresponding levels (see commented line below)?
 
 Yes, there is: call factor() on your subset:
 
  a - factor(rep(letters[1:5], 5))
  a
  [1] a b c d e a b c d e a b c d e a b c d e a b c d e
 Levels: a b c d e
  b - a[a!='b']

Or use drop argument

b - a[a!='b', drop=TRUE]

regards
Petr


  b
  [1] a c d e a c d e a c d e a c d e a c d e
 Levels: a b c d e
  factor(b)
  [1] a c d e a c d e a c d e a c d e a c d e
 Levels: a c d e
 
 
 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.

__
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] compute differences

2009-09-23 Thread Petr PIKAL
Hi

You can use outer. If your data are in data frame test then

DIFF - as.vector(t(outer(test$val, test$val, -)))

returns a vector, You just need to add suitable names to rows.

CASE - as.vector(t(outer(test$ID, test$ID, paste, sep=-)))

data.frame(CASE, DIFF)

will put it together.

Regards
Petr


r-help-boun...@r-project.org napsal dne 23.09.2009 16:42:45:

 Alessandro Carletti wrote:
 
 
 
 Hi,
 
 I have a problem.
 
 I have a data frame looking like:
 
 
 
 ID val
 
 
 
 A? .3
 
 B? 1.2
 
 C? 3.4
 
 D? 2.2
 
 E? 2.0
 
 
 
 I need to CREATE the following TABLE:
 
 
 
 CASE?? DIFF
 
 
 
 A-A??? 0
 
 A-B??? -0.9
 
 A-C??? -3.1
 
 A-D??? -1.9
 
 A-E??? -1.7
 
 B-A??? ...
 
 B-B??? ...
 
 B-C
 
 B-D
 
 B-E
 
 C-A
 
 ...
 
 
 
 WHERE CASE IS THE COUPLE OF ELEMENTS CONSIDEREDM AND DIFF IS THE
 computed DIFFERENCE between their values.
 
 
 
 Could you give me suggestions?
 
 
 
 Solution:
 
 Besides the suggestions given by others, you can use the sqldf package
 to do this (leveraging knowledge in SQL if you know SQL). If you join
 your data frame with itself, without a join condition, you will get the
 Cartesian product of the two data frames, which seems to be exactly what
 you need. A warning is in order. Generally when you join 2 (or more)
 data frames you DO NOT want the Cartesian product by want to join the
 data frames by some key. The solution to your particular problem,
 however, can be implemented easily using the Cartesian product.
 
 
 
 mydata - data.frame(id=rep(c('A','B','C','D','E'), each=2),
 val=sample(1:5, 10, replace=T))
 
 mydata
 
 library(sqldf)
 
 # merge data frame with itself to create a Cartesian Product - this is
 normally NOT what you want.
 
 # Note 'case' is a key word in SQL so I use cases for the variable name.
 Likewise diff is a used in R so I use diffr
 
 mydata2 - sqldf(select a.id as id1, a.val as val1, b.id as id2, b.val
 as val2, a.id || ' - ' || b.id as cases,
 
  a.val - b.val as diffr from mydata a, mydata b)
 
 dim(mydata2) # check dimensions of the merged dataset
 
 head(mydata2) # examine the first 6 records
 
 # if you want only the columns casses and diffr, then use this SQL code
 
 mydata3 - sqldf(select a.id || ' - ' || b.id as cases, a.val - b.val
 as diffr from mydata a, mydata b)
 
 dim(mydata3) # check dimensions of the merged dataset
 
 head(mydata3) # examine the first 6 records
 
 
 
 Hope this helps.
 
 
 
 Jude
 
 ___
 Jude Ryan
 Director, Client Analytical Services
 Strategy  Business Development
 UBS Financial Services Inc.
 1200 Harbor Boulevard, 4th Floor
 Weehawken, NJ 07086-6791
 Tel. 201-352-1935
 Fax 201-272-2914
 Email: jude.r...@ubs.com
 
 
 
 Please do not transmit orders or instructions regarding a UBS 
 account electronically, including but not limited to e-mail, 
 fax, text or instant messaging. The information provided in 
 this e-mail or any attachments is not an official transaction 
 confirmation or account statement. For your protection, do not 
 include account numbers, Social Security numbers, credit card 
 numbers, passwords or other non-public information in your e-mail. 
 Because the information contained in this message may be privileged, 
 confidential, proprietary or otherwise protected from disclosure, 
 please notify us immediately by replying to this message and 
 deleting it from your computer if you have received this 
 communication in error. Thank you. 
 
 UBS Financial Services Inc. 
 UBS International Inc. 
 UBS Financial Services Incorporated of Puerto Rico 
 UBS AG
 
 
 UBS reserves the right to retain all messages. Messages are protected
 and accessed only in legally justified 
 cases.__
 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] compute differences

2009-09-23 Thread jude.ryan
Thanks Petr! It is good to see multiple solutions to the same problem.

Best,

Jude

-Original Message-
From: Petr PIKAL [mailto:petr.pi...@precheza.cz] 
Sent: Wednesday, September 23, 2009 10:59 AM
To: Ryan, Jude
Cc: alxmil...@yahoo.it; r-help@r-project.org
Subject: Re: [R] compute differences

Hi

You can use outer. If your data are in data frame test then

DIFF - as.vector(t(outer(test$val, test$val, -)))

returns a vector, You just need to add suitable names to rows.

CASE - as.vector(t(outer(test$ID, test$ID, paste, sep=-)))

data.frame(CASE, DIFF)

will put it together.

Regards
Petr


r-help-boun...@r-project.org napsal dne 23.09.2009 16:42:45:

 Alessandro Carletti wrote:
 
 
 
 Hi,
 
 I have a problem.
 
 I have a data frame looking like:
 
 
 
 ID val
 
 
 
 A? .3
 
 B? 1.2
 
 C? 3.4
 
 D? 2.2
 
 E? 2.0
 
 
 
 I need to CREATE the following TABLE:
 
 
 
 CASE?? DIFF
 
 
 
 A-A??? 0
 
 A-B??? -0.9
 
 A-C??? -3.1
 
 A-D??? -1.9
 
 A-E??? -1.7
 
 B-A??? ...
 
 B-B??? ...
 
 B-C
 
 B-D
 
 B-E
 
 C-A
 
 ...
 
 
 
 WHERE CASE IS THE COUPLE OF ELEMENTS CONSIDEREDM AND DIFF IS THE
 computed DIFFERENCE between their values.
 
 
 
 Could you give me suggestions?
 
 
 
 Solution:
 
 Besides the suggestions given by others, you can use the sqldf package
 to do this (leveraging knowledge in SQL if you know SQL). If you join
 your data frame with itself, without a join condition, you will get
the
 Cartesian product of the two data frames, which seems to be exactly
what
 you need. A warning is in order. Generally when you join 2 (or more)
 data frames you DO NOT want the Cartesian product by want to join the
 data frames by some key. The solution to your particular problem,
 however, can be implemented easily using the Cartesian product.
 
 
 
 mydata - data.frame(id=rep(c('A','B','C','D','E'), each=2),
 val=sample(1:5, 10, replace=T))
 
 mydata
 
 library(sqldf)
 
 # merge data frame with itself to create a Cartesian Product - this is
 normally NOT what you want.
 
 # Note 'case' is a key word in SQL so I use cases for the variable
name.
 Likewise diff is a used in R so I use diffr
 
 mydata2 - sqldf(select a.id as id1, a.val as val1, b.id as id2,
b.val
 as val2, a.id || ' - ' || b.id as cases,
 
  a.val - b.val as diffr from mydata a, mydata b)
 
 dim(mydata2) # check dimensions of the merged dataset
 
 head(mydata2) # examine the first 6 records
 
 # if you want only the columns casses and diffr, then use this SQL
code
 
 mydata3 - sqldf(select a.id || ' - ' || b.id as cases, a.val - b.val
 as diffr from mydata a, mydata b)
 
 dim(mydata3) # check dimensions of the merged dataset
 
 head(mydata3) # examine the first 6 records
 
 
 
 Hope this helps.
 
 
 
 Jude
 
 ___
 Jude Ryan
 Director, Client Analytical Services
 Strategy  Business Development
 UBS Financial Services Inc.
 1200 Harbor Boulevard, 4th Floor
 Weehawken, NJ 07086-6791
 Tel. 201-352-1935
 Fax 201-272-2914
 Email: jude.r...@ubs.com
 
 
 
 Please do not transmit orders or instructions regarding a UBS 
 account electronically, including but not limited to e-mail, 
 fax, text or instant messaging. The information provided in 
 this e-mail or any attachments is not an official transaction 
 confirmation or account statement. For your protection, do not 
 include account numbers, Social Security numbers, credit card 
 numbers, passwords or other non-public information in your e-mail. 
 Because the information contained in this message may be privileged, 
 confidential, proprietary or otherwise protected from disclosure, 
 please notify us immediately by replying to this message and 
 deleting it from your computer if you have received this 
 communication in error. Thank you. 
 
 UBS Financial Services Inc. 
 UBS International Inc. 
 UBS Financial Services Incorporated of Puerto Rico 
 UBS AG
 
 
 UBS reserves the right to retain all messages. Messages are protected
 and accessed only in legally justified 
 cases.__
 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.

Please do not transmit orders or instructions regarding a UBS 
account electronically, including but not limited to e-mail, 
fax, text or instant messaging. The information provided in 
this e-mail or any attachments is not an official transaction 
confirmation or account statement. For your protection, do not 
include account numbers, Social Security numbers, credit card 
numbers, passwords or other non-public information in your e-mail. 
Because the information contained in this message may be privileged, 
confidential, proprietary or otherwise protected from disclosure, 
please notify us immediately by replying to this message and 
deleting it from your computer if you have received this 
communication 

[R] Fortran vs R

2009-09-23 Thread Paul Simonin

Hello R users,
 I have a basic computer programing question. I am a student 
currently taking a course that uses Fortran as the main programming 
language, but the instructors are open to students using any language 
they are familiar with. I have used R previously, and am wondering if 
there is any benefit to my learning Fortran, or whether I should stick 
with R for this class. Any advice? Are there clear benefits to using 
Fortran, or things Fortran can do that R cannot?

Thank you very much for any thoughts!
Sincerely,
Paul 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.


[R] p value from F value and dfs

2009-09-23 Thread Sascha Wolfer

Dear List,

is there an easy and fast way to compute the p value from a given F  
value and given degrees of freedom for an effect and the dfs for the  
residuals? I think of a function like this:


compute.p(F.value, numerator.dfs, denominator.dfs)

which returns the p value.

Thanks,
Sascha

__
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 check if a vector contains a given value?

2009-09-23 Thread Dimitri Liakhovitski
Dear R'rs,

is there a function that checks if a given vector contains a certain value.
E.g., x-c(1,2,3,4).
How can I get a TRUE or FALSE for whether x contains a 2?

-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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] R: Function to check if a vector contains a given value?

2009-09-23 Thread Guazzetti Stefano
?any
any(x==2)

Stefano

-Messaggio originale-
Da: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]per conto di Dimitri Liakhovitski
Inviato: mercoledì 23 settembre 2009 17.38
A: R-Help List
Oggetto: [R] Function to check if a vector contains a given value?


Dear R'rs,

is there a function that checks if a given vector contains a certain value.
E.g., x-c(1,2,3,4).
How can I get a TRUE or FALSE for whether x contains a 2?

-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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.

Rispetta l'ambiente: Se non ti è necessario, non stampare questa mail.


Le informazioni contenute nel presente messaggio di posta elettronica e in 
ogni suo allegato sono da considerarsi riservate e il destinatario della email 
è l'unico autorizzato
ad usarle, copiarle e, sotto la propria responsabilità, divulgarle. Chiunque 
riceva questo messaggio per errore senza esserne il destinatario deve 
immediatamente rinviarlo
al mittente cancellando l'originale. Eventuali dati personali e sensibili 
contenuti nel presente messaggio e/o suoi allegati vanno trattati nel rispetto 
della normativa 
in materia di privacy ( DLGS n.196/'03).


__
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] p value from F value and dfs

2009-09-23 Thread Jorge Ivan Velez
Hi Sascha,
Take a look at ?pf

HTH,
Jorge


On Wed, Sep 23, 2009 at 11:34 AM, Sascha Wolfer  wrote:

 Dear List,

 is there an easy and fast way to compute the p value from a given F value
 and given degrees of freedom for an effect and the dfs for the residuals? I
 think of a function like this:

 compute.p(F.value, numerator.dfs, denominator.dfs)

 which returns the p value.

 Thanks,
 Sascha

 __
 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 check if a vector contains a given value?

2009-09-23 Thread Jorge Ivan Velez
Hi Dimitri,
See either ?any,  ?%in%, or  ?intersect

any(x == 2)
# [1] TRUE

HTH,
Jorge

On Wed, Sep 23, 2009 at 11:37 AM, Dimitri Liakhovitski  wrote:

 Dear R'rs,

 is there a function that checks if a given vector contains a certain value.
 E.g., x-c(1,2,3,4).
 How can I get a TRUE or FALSE for whether x contains a 2?

 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.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.


[[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] Fortran vs R

2009-09-23 Thread Duncan Murdoch

On 9/23/2009 11:13 AM, Paul Simonin wrote:

Hello R users,
  I have a basic computer programing question. I am a student 
currently taking a course that uses Fortran as the main programming 
language, but the instructors are open to students using any language 
they are familiar with. I have used R previously, and am wondering if 
there is any benefit to my learning Fortran, or whether I should stick 
with R for this class. Any advice? Are there clear benefits to using 
Fortran, or things Fortran can do that R cannot?


They are very different languages.  For many things Fortran will be much 
faster than R: so much so that you might find R is too slow to use for 
some of your assignments. On the other hand, R has much better support 
for many high level things, so you will find it much easier to do some 
of those:  preparing graphs, etc.


My advice would be to use the class as an opportunity to learn Fortran. 
 Seeing things from more than one point of view is always a good thing.


This might not be relevant to this class, but it is possible to use 
Fortran to write functions which are called from R:  so you get the best 
of both worlds.  That's another reason to learn Fortran.


Duncan Murdoch

__
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] Fortran vs R

2009-09-23 Thread Charlie Sharpsteen
-- Forwarded message --
From: Charlie Sharpsteen ch...@sharpsteen.net
Date: Wed, Sep 23, 2009 at 8:47 AM
Subject: Re: [R] Fortran vs R
To: Paul Simonin paul.simo...@uvm.edu
Cc: r-h...@r-project.or



On Wed, Sep 23, 2009 at 8:13 AM, Paul Simonin paul.simo...@uvm.edu wrote:

 Hello R users,
  I have a basic computer programing question. I am a student currently
 taking a course that uses Fortran as the main programming language, but the
 instructors are open to students using any language they are familiar with.
 I have used R previously, and am wondering if there is any benefit to my
 learning Fortran, or whether I should stick with R for this class. Any
 advice? Are there clear benefits to using Fortran, or things Fortran can do
 that R cannot?
 Thank you very much for any thoughts!
 Sincerely,
 Paul S.


Hello Paul,

Like you, I learned Fortran as my first programming language. After a few
years and a few more languages I can say that the answer to this question
depends largely on what you think you may be doing with your programming
skills.

I will shamelessly use myself as an example- I am studying Environmental
Resources Engineering. One of the biggest reasons we are taught Fortran is
because the overwhelming percentage of software that solves problems in our
field of concern is written in Fortran. Most importantly, many models
produced by the US government-- such as the groundwater models maintained by
the USGS-- are written in Fortran.

The language used to write government models is significant because the
soundness of those computer programs is legally defensible in court.

Generally speaking, Fortran is used to write models of physical systems such
as the flow of water (HEC-RAS), movement of contaminants in air (CARMA),
development of tidal currents (ADCIRC) and propagation of ocean waves
(SWAN). This is because Fortran is very matrix-oriented and very fast at
what it does. Many, many toolkits for performing computations in linear
algebra are written in Fortran.

Bottom line on Fortran's area of use: if you think you will be using your
programming skills to implement numerical solutions to things such as
Partial Differential Equations, then Fortran could be a very valuable
investment.

As far as Fortran vs. R is concerned-- the two compliment each other very
well. R is very flexible and can be enhanced with just about any bell or
whistle you could possible want-- but being a scripting language, it can run
into performance issues-- especially during large loops. Fortran is a very,
very, straightforward language because it does not have many bells and
whistles to speak of-- it does one thing and one thing best and that is to
crunch absurdly large amounts of numbers as fast as it possibly can.

Fortran also happens to be one of the compiled languages that R is designed
to work with, it is amazing how easy it is to add Fortran routines to an R
package and then load and use them from within R. I usually write my
numerical computations in Fortran, load them as an R package and then:

- Use R to feed Fortran simulations with random numbers drawn from different
distributions (Monte Carlo Analysis).

- Use R to perform statistical analysis on the results of Fortran
simulations.

- Use R to aggregate, format and graph the results of Fortran simulations.

So, the decision on what languages to learn depends very much on what
problems you think will require your programming skills. R and Fortran
compliment each other extremely well-- so learning Fortran may be a wise
investment.

Hope this helps!

-Charlie

[[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 check if a vector contains a given value?

2009-09-23 Thread Dimitri Liakhovitski
Thanks a lot, Jorge!

On Wed, Sep 23, 2009 at 11:42 AM, Jorge Ivan Velez
jorgeivanve...@gmail.com wrote:
 Hi Dimitri,
 See either ?any,  ?%in%, or  ?intersect
 any(x == 2)
 # [1] TRUE

 HTH,
 Jorge

 On Wed, Sep 23, 2009 at 11:37 AM, Dimitri Liakhovitski  wrote:

 Dear R'rs,

 is there a function that checks if a given vector contains a certain
 value.
 E.g., x-c(1,2,3,4).
 How can I get a TRUE or FALSE for whether x contains a 2?

 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.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.





-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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] Fortran vs R

2009-09-23 Thread Charles Annis, P.E.
WARNING!  Biased opinion.

I'm an old guy who learned programming nearly 50 years ago when FORTRAN (IV)
was it, unless you wanted to write machine language which, being an
engineer, I was less interested in than in getting an answer so I could get
on with things.

I like FORTRAN, but I can't think of anything that R couldn't do better and
easier.  R is interpreted and thus is slower than compiled FORTRAN but
unless you have a very (very, very) specific application where you need
compiled speed, R wins by a mile.

Don't learn FORTRAN.  Invest your time in Python if you must learn another
language.  R would be my choice if I were you.

Mister Know-It-All


Charles Annis, P.E.

charles.an...@statisticalengineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Paul Simonin
Sent: Wednesday, September 23, 2009 11:13 AM
To: R Help Listserve
Subject: [R] Fortran vs R

Hello R users,
  I have a basic computer programing question. I am a student 
currently taking a course that uses Fortran as the main programming 
language, but the instructors are open to students using any language 
they are familiar with. I have used R previously, and am wondering if 
there is any benefit to my learning Fortran, or whether I should stick 
with R for this class. Any advice? Are there clear benefits to using 
Fortran, or things Fortran can do that R cannot?
Thank you very much for any thoughts!
Sincerely,
Paul 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.

__
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 parametric methods

2009-09-23 Thread Greg Snow
For power studies you need to think about what the data will look like under 
the alternative hypothesis.  Is the data shifted over a certain amount? (the 
most common assumption), or scaled? Or both? Or a completely different shape? 
Etc.

My preferred method for power studies in this case is to use simulation:

1. decide what you data is likely to look like (based on previous data, 
assumptions, ...)
2. decide how you will analyze the data (possibly iterate between 1 and 2)
3. write a function that simulates data under the alternative hypothesis, then 
analyzes it (using decisions from 1 and 2) and returns the p-value or test 
statistic.  The function will often have a parameter for sample size and a 
parameter for the size of the difference (scale, etc.).
4. use the replicate function to run your function a bunch of times.
5. the proportion of times that the above gives significant results is an 
estimate of the power.

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 Alon Ben-Ari
 Sent: Tuesday, September 22, 2009 9:35 AM
 To: r-help@r-project.org
 Subject: [R] No parametric methods
 
 Hello I am interested  in finding out a method of power analysis
 (effect
 size and sample size calculation ) using R in non parametric methods?
 
 I am running  R  2.8.1 running on linux open SUSE
 
 Any libraries or documentation , I was not bale to google up any.
 
 Thanks in Advance,
 
 Ben-Ari Alon, MD
 University of Pittsburgh.
 
   [[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] ROCR.plot methods, cross validation averaging

2009-09-23 Thread Tim Howard
Dear R-help and ROCR developers (Tobias Sing and Oliver Sander) - 

I think my first question is generic and could apply to many methods, 
which is why I'm directing this initially to R-help as well as Tobias and 
Oliver.

Question 1. The plot function in ROCR will average your cross validation
data if asked. I'd like to use that averaged data to find a best cutoff
but I can't figure out how to grab the actual data that get plotted.
A simple redirect of the plot (such as test - plot(mydata)) doesn't do it.

Question 2. I am asking ROCR to average lists with varying lengths for
each list entry. See my example below. None of the ROCR examples have data
structured in this manner. Can anyone speak to whether the averaging
methods in ROCR allow for this? If I can't easily grab the data as desired
from Question 1, can someone help me figure out how to average the lists,
by threshold, similarly?

Question 3. If my cross validation data happen to have a list entry whose
length = 2, ROCR errors out. Please see the second part of my example.
Any suggestions?

#reproducible examples exemplifying my questions
##part one##
library(ROCR)
data(ROCR.xval)
 # set up data so it looks more like my real data
sampSize - c(4, 55, 20, 75, 350, 250, 6, 120, 200, 25)
testSet - ROCR.xval
 # do the extraction
for (i in 1:length(ROCR.xval[[1]])){
  y - sample(c(1:350),sampSize[i])
  testSet$predictions[[i]] - ROCR.xval$predictions[[i]][y]
  testSet$labels[[i]] - ROCR.xval$labels[[i]][y]
  }
 # now massage the data using ROCR, set up for a ROC plot
 # if it errors out here, run the above sample again.
pred - prediction(testSet$predictions, testSet$labels)
perf - performance(pred,tpr,fpr)
 # create the ROC plot, averaging by cutoff value
plot(perf, avg=threshold)
 # check out the structure of the data
str(perf)
 # note the ragged edges of the list and that I assume averaging
 # whether it be vertical, horizontal, or threshold, somehow 
 # accounts for this?

## part two ##
# add a list entry with only two values
p...@x.values[[1]] - c(0,1)
p...@y.values[[1]] - c(0,1)
p...@alpha.values[[1]] - c(Inf,0)

plot(perf, avg=threshold)

##output results in an error with this message
# Error in if (from == to) rep.int(from, length.out) else as.vector(c(from,  :
# missing value where TRUE/FALSE needed


Thanks in advance for your help
Tim Howard
New York Natural Heritage Program

__
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 read zip file?

2009-09-23 Thread Benilton Carvalho
and note that if, instead of zip files, you were using gzip files, you  
could:


conn - gzfile(file.gz, rt)
theData - read.table(conn)
close(conn)

b

On Sep 22, 2009, at 11:21 PM, Gabor Grothendieck wrote:


Linux is a type of UNIX so follow the instructions I gave for UNIX.

On Tue, Sep 22, 2009 at 10:16 PM, Peng Yu pengyu...@gmail.com wrote:

No. My machine is a linux machine.

On Tue, Sep 22, 2009 at 9:02 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:

If you have the 7z zip utility and are on Windows
(or use 7z and grep on UNIX):

DF - read.csv(pipe(7z x myfile.zip -so | findstr $))


On Tue, Sep 22, 2009 at 9:30 PM, Peng Yu pengyu...@gmail.com  
wrote:

Hi,

Suppose that I have a csv file that is compressed with zip, is  
there a

way to read it in R without first decompressing it to a file.

Regards,
Peng

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


__
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 peated measures

2009-09-23 Thread pompon

Hi,

I am performing a repeated measures 2-way ANOVA  to assess the influence of
plant and leaf on aphid fecundity. Fecundity is measured for each aphid on a
single leaf.
Here is what I typed.

wingless - reshape(Wingless,
varying =
list(c(d0,d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16)),
v.names = c(fecundity), timevar = time,
direction = long)

wingless.aov - aov(fecundity ~ factor(time) * clip.cage * plant +
Error(factor(id)), data = wingless)

summary(wingless.aov)

and I obtained

Error: factor(id)
   Df Sum Sq Mean Sq F value  Pr(F)  
factor(time)4 56.789  14.197  3.0613 0.05925 .
clip.cage   1 14.149  14.149  3.0509 0.10621  
plant   1  3.251   3.251  0.7010 0.41880  
factor(time):clip.cage  1  0.304   0.304  0.0655 0.80240  
clip.cage:plant 1 17.114  17.114  3.6903 0.07880 .
Residuals  12 55.652   4.638  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Error: Within
  Df Sum Sq Mean Sq F value  Pr(F)
factor(time)  16 340.83   21.30 11.5222  2e-16 ***
factor(time):clip.cage16  27.341.71  0.9242 0.54195
factor(time):plant16  46.362.90  1.5673 0.07783 .  
factor(time):clip.cage:plant  16  24.501.53  0.8281 0.65304
Residuals255 471.441.85
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

I don't understand why I have the factor(time) inmy between subject results,
whereas with a similar set of data I don't. 

Thank you very much,
Julien Pompon.
-- 
View this message in context: 
http://www.nabble.com/repeated-measures-tp25531110p25531110.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] Problem in graph plotting

2009-09-23 Thread baptiste auguie
Try this,

d - na.omit(data.frame(tp,dp))
plot(d, t=l, ylim=rev(range(d$dp)))

?na.omit

HTH,

baptiste

2009/9/23 FMH kagba2...@yahoo.com:
 Thank you for the code. I found that the coding does not work if there is an 
 NA in dp variable. For instance;

 #
 dp - c(1,4,NA,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp,dp, type= 'l',ylim=rev(range(dp)))
  #

 If this is the case, how could we rewrite the coding?

 Thank you
 Fir




 - Original Message 
 From: jim holtman jholt...@gmail.com
 To: FMH kagba2...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Wednesday, September 23, 2009 1:04:21 PM
 Subject: Re: [R] Problem in graph plotting

 try this:

 plot(tp,dp, type= 'l',ylim=rev(range(dp)))


 On Wed, Sep 23, 2009 at 7:58 AM, FMH kagba2...@yahoo.com wrote:
 Dear All,

 Let:
 dp: depth of the river
 tp: temperature with respect to depth

 We can have a simple scatter plot, between depth as y-axis and temperature 
 as x-axis, by using a plot function as shown below.

 #
 dp - c(1,4,3,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp,dp, type= 'l')
 #

 Could someone advice me on the way to plot the same pair of observations, 
 but with depth in descending order from the origin. Instead of depth, I 
 tried to simply use rev(depth), but the result was bizarre.

 Thank you
 Fir




 __
 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-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] memory problems for fixed effect models

2009-09-23 Thread Jörg Schaber

Hi,

I am trying to fit a simple two-way fixed effect linear model (o ~ y + s 
- 1). However, my problem is large (length(o)=79333).

I am already using slm.fit with a dense design matrix (ddm), but still:

fit - slm.fit(ddm,o)
Error: cannot allocate vector of size 9.1 Gb

Is there a way to redefine the model or any other trick such that I do 
not run into these memory problems?


Running a mixed effect model, like
lme(o ~ y - 1 ,random = ~ 1 | s, method=REML, 
contrasts=list(s=(contr.sum)),na.action=na.exclude)

poses no problem, but I want to have both effects fixed.

Thanks,

joerg

__
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] retrieve certain part from html

2009-09-23 Thread Tony Breyal
maybe you could modify the following to suit your situation (i use
this xPath expression to get links from google):

?htmlTreeParse
?getNodeSet

 library(XML)
 link - 
 'http://www.google.co.uk/search?hl=enclient=firefox-arls=org.mozilla:en-GB:officialhs=2XRei=mxa6SojjOeaMjAfJkcDuBQsa=Xoi=spellresnum=0ct=resultcd=1q=Doctor+Whospell=1'
 html - htmlTreeParse(link, useInternalNodes = TRUE, error=function(...){})
 nodes - getNodeSet(html, //a...@href][@class='l'])
 sapply(nodes, function(x) x - xmlAttrs(x)[[1]])
 [1] http://www.bbc.co.uk/
doctorwho/
 [2] http://www.bbc.co.uk/doctorwho/
classic/
 [3] http://en.wikipedia.org/wiki/
Doctor_Who
 [4] http://www.youtube.com/watch?
v=LF2x5IKxmAQ
 [5] http://www.youtube.com/watch?
v=DnKNupdSH8g
 [6] http://www.telegraph.co.uk/culture/tvandradio/doctor-who/6199603/
Doctor-Who-Top-10-fans-vote-for-all-time-best-episode.html
 [7] http://www.google.com/hostednews/ap/article/ALeqM5i17A4FXTLhJX10-
sCbhhnhdqY9HwD9ASO6A00
 [8] http://www.telegraph.co.uk/news/newstopics/celebritynews/6200053/
Doctor-Who-star-David-Tennant-voted-pupils-dream-head-teacher.html
 [9] http://www.imdb.com/title/
tt0436992/
[10] http://www.imdb.com/title/
tt0056751/
[11] http://
www.gallifreyone.com/
[12] http://
www.doctorwho.co.uk/
[13] http://
www.drwhoguide.com/
[14] http://www.bbcamerica.com/content/123/index.jsp;



On 23 Sep, 13:29, Rene kaixinma...@gmail.com wrote:
 Dear All,

 Can someone please guide me how to get the certain part from a long html
 language?

 e.g.

 tda href='2005-01.html'2005-01/a/tdtda
 href='2006-01.html'2006-01/a/tdtda
 href='2007-01.html'2007-01/a/tdtda
 href='2008-01.html'2008-01/a/tdtda
 href='2009-01.html'2009-01/a/td

 How to get only the wording of  2005-01.html, 2006-01.html,
 2007-01.html, 2008-01.html, 2009-01.html from the above html code? I
 have tried to use gsub function, but not working.

 Please guide me on this.

 Thanks a lot.

 Rene.

         [[alternative HTML version deleted]]

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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] generating unordered combinations

2009-09-23 Thread Dan
Thanks Bryan, sorry for the late reply - I only just noticed this
post. I'm not specifically interested in that sum, but something
related to the sum so this may also be very useful.

Dan

On 18 Sep, 18:24, Bryan Keller bskel...@wisc.edu wrote:
 The combn solution offered by Bill is great.  It struck me that what you are 
 doing, in fact, is generating the null distribution of the two-sample 
 Wilcoxon test where the first group has size m and the second group has size 
 n.  In general, the length of the array has size choose(n+m-1,m) which gets 
 very big very fast.  For example,

  choose(20+20-1,20)

 [1] 68923264410

 If, on the off chance that you are interested in *summing* the unordered 
 combinations across columns, there is a very slick way to do this that takes 
 a tiny fraction of the time and memory that generating huge arrays entails.  
 If not, obviously, you already have your solution.

 Just in case, here is the code to generate the distribution of sums.  It is 
 based on an algorithm due to Harding (1984).

 f - function(m,n) {

 umax - (m*n+1)

 ifelse (umax%%2==0, umaxp - (umax/2)-1, umaxp - (umax-1)/2)
 #umaxp is analagous to “M” from Harding (1984)

 p - min((m+n),umaxp)
 q - min(m,umaxp)

 dis - c(1,numeric(umaxp))

 if ((n+1)umaxp) {

 for (i in 1:q) {                        #steps for denominator of generating 
 function
 for (j in i:umaxp) {
         dis[j+1] - (dis[j+1] + dis[(j-i)+1])
         }
         }

 } else {

 for (i in (n+1):(p)) {          #steps for numerator of generating function
 for (j in (umaxp):i) {
         dis[j+1] - (dis[j+1] - dis[(j-i)+1])
         }
         }

 for (i in 1:q) {                        #steps for denominator of generating 
 function
 for (j in i:umaxp) {
         dis[j+1] - (dis[j+1] + dis[(j-i)+1])
         }
         }

 }

 ldis - length(dis)
 ifelse(umax%%2==0,dis - c(dis,dis[ldis:1]),dis - c(dis,dis[(ldis-1):1]))
 dispr - dis/choose((n+m),n)
 ws - sum(1:m):sum((n+1):(n+m))
 lws - length(ws)
 mat3 - cbind(ws,dis,dispr,numeric(lws),numeric(lws))
 mat3[,4] - cumsum(mat3[,3])
 mat3[,5] - cumsum(mat3[,3][lws:1])[lws:1]
 colnames(mat3) - c(W,Freq,Probability,Sum up,Sum down)

 print(mat3)

 }
  system.time(f(20,20))

    user  system elapsed
    0.11    0.00    0.11

 Bryan

 That's brilliant - thanks.

 On 17 Sep 2009, at 23:36, William Dunlap wrote:





  There is a 1-1 correspondance between your n-sets
  consisting of m possible element types (0 through m-1
  in your example) and the number of n-subsets of a (n+m-1)-set.
  E.g., your example had m=3 and n=3 and subtracting
  1:3 from each column of combn(3+3-1,3) gives your result:

  t(combn(3+3-1, 3)-(1:3))
       [,1] [,2] [,3]
  [1,]    0    0    0
  [2,]    0    0    1
  [3,]    0    0    2
  [4,]    0    1    1
  [5,]    0    1    2
  [6,]    0    2    2
  [7,]    1    1    1
  [8,]    1    1    2
  [9,]    1    2    2
  [10,]    2    2    2

  Bill Dunlap
  TIBCO Software Inc - Spotfire Division
  wdunlap tibco.com

  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of DanHalligan
  Sent: Thursday, September 17, 2009 1:31 PM
  To: r-h...@r-project.org
  Subject: [R] generating unordered combinations

  Hi,

  I am trying to generate all unordered combinations of a set of
  numbers / characters, and I can only find a (very) clumsy way of  
  doing
  this using expand.grid.  For example, all unordered combinations of
  the numbers 0, 1, 2 are:
  0, 0, 0
  0, 0, 1
  0, 0, 2
  0, 1, 1
  0, 1, 2
  0, 2, 2
  1, 1, 1
  1, 1, 2
  1, 2, 2
  2, 2, 2

  (I have not included, for example, 1, 0, 0, since it is equivalent to
  0, 0, 1).

  I have found a way to generate this data.frame using expand.grid as
  follows:

  g - expand.grid(c(0,1,2), c(0,1,2), c(0,1,2))
  for(i in 1:nrow(g)) {
         g[i,] - sort(as.character(g[i,]))
  }
  o - order(g$Var1, g$Var2, g$Var3)
  unique(g[o,]).

  This is obviously quite clumsy and hard to generalise to a greater
  number of characters, so I'm keen to find any other solutions.  Can
  anyone suggest a better (more general, quicker) method?

  Cheers

  __
  r-h...@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.

 -
 Bryan Keller, Doctoral Student/Project Assistant
 Educational Psychology - Quantitative Methods
 The University of Wisconsin - Madison

 __
 r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guidehttp://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 

[R] Numerical integration problem

2009-09-23 Thread Marcus Rowcliffe
Hi there
I'm trying to construct a model of mortality risk in 2D space that
requires numerical integration of a hazard function, for which I'm using
the integrate function. I'm occasionally encountering parameter
combinations that cause integrate to terminate with error Error in
integrate... the integral is probably divergent, which I'm not sure how
to interpret. The problem only crops up for a tiny part of the input
parameter space, but if I can't get this to work for the whole space I'm
a bit stuck! Plotting the integrand shows no sign of obvious problems
such as flatness, extreme spiking or non-finite area, and a tiny tweak
to the input is enough to get the integration to work, even though the
tweaked function looks essentially the same as the one that fails. Below
is some code that demonstrates the problem on my machine running R
2.9.0. Any suggestions on what might be causing this and what I can do
to avoid it would be very gratefully received. 
Hoping for some insights
Marcus


##
#Problem example
#Works fine:
integrate(hazard, 0,Inf, v=0.1, gam=pi*232/200,
pos=list(r=5,th=atan(3/4)), a=10, b0=10, bt=0.1)

#Gives error ...integral probably divergent:
integrate(hazard, 0,Inf, v=0.1, gam=pi*231/200,
pos=list(r=5,th=atan(3/4)), a=10, b0=10, bt=0.1)

#Plot the integrands - doesn't look obviously problematic
h -
hazard(seq(0,500,0.1),0.1,pi*231/200,pos=list(r=5,th=atan(3/4)),10,10,0.
1)
plot(seq(0,500,0.1),h,type=l,col=2)
h -
hazard(seq(0,500,0.1),0.1,pi*232/200,pos=list(r=5,th=atan(3/4)),10,10,0.
1)
lines(seq(0,500,0.1),h)

#Functions used:

#hazard at a given point pos (a list of polar coordinates: distance r
and angle th); a, b0 and bt are model parameters
point.hazard - function(pos,a,b0,bt) a * exp(-(pos$r^2/(2*b0^2))) *
exp(-(pos$th^2/(2*bt^2)))

#point.hazard for a point related to input point pos by time t and speed
v
hazard - function(t, v, gam, pos, a, b0, bt)
{   pos2 - zredef(pos,-t*v,gam)
pos2$th[pos2$thpi] - 2*pi-pos2$th[pos2$thpi]
point.hazard(pos2,a,b0,bt)
}
#Returns a list of polar co-ordinates for a point defined by distance m
in direction gam from starting point pos
zredef - function(pos, m, gam)
{   x - pos$r*sin(pos$th) + m*sin(gam)
y - pos$r*cos(pos$th) + m*cos(gam)
r - (x^2 + y^2)^0.5
th - atan(x/y)
th[x==0] - 0
th[y0] - th[y0] + pi
th[x0  y0] - th[x0  y0] + 2*pi
list(r=r,th=th)
}



The Zoological Society of London is incorporated by Royal Charter
Principal Office England. Company Number RC000749
Registered address: 
Regent's Park, London, England NW1 4RY
Registered Charity in England and Wales no. 208728 

_
This e-mail has been sent in confidence to the named add...{{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.


Re: [R] Function to check if a vector contains a given value?

2009-09-23 Thread Henrique Dallazuanna
You can try this also:

is.element(2, x)

On Wed, Sep 23, 2009 at 12:37 PM, Dimitri Liakhovitski ld7...@gmail.com wrote:
 Dear R'rs,

 is there a function that checks if a given vector contains a certain value.
 E.g., x-c(1,2,3,4).
 How can I get a TRUE or FALSE for whether x contains a 2?

 --
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] Compiled Rcmdr Plugin package (zip) has no etc/menus.txt

2009-09-23 Thread Tobias Schoch

Dear Rcmdr users,
I use R-2.9.2, Rcmdr 1.5-1 and the latest Rtools bundle (and the html help
workshop) under Windows XP. I wrote a RcmdrPlugin for some important
functions of Thomas Lumley's survey package. 

Problem: Package compilation works without displaying any errors. That is
1) R CMD build ... works fine.

2) R CMD INSTALL --build... generates the zip-file (without error
message), but the folder etc and the menus.txt are missing in the zip.
Also the installed package in R-2.9.2/library/... does not contain etc and
menus.txt. Thus, I am a bit confused, because the contents of the etc
folder should actually be included into the final package (as pointed out in
writing R extensions).

Adding /etc/menus.txt to the zip-files fails since the MD5 (obviously) is
not correct any more. How can I generate packages as zip-files including the
Rcmdr-menu-structure.

Thanks
Tobias



-- 
View this message in context: 
http://www.nabble.com/Compiled-Rcmdr-Plugin-package-%28zip%29-has-no-etc-menus.txt-tp25531118p25531118.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] Problem in graph plotting

2009-09-23 Thread Henrique Dallazuanna
Try this:

plot(tp, dp, type =  'l', ylim = rev(range(dp, na.rm = TRUE)))

On Wed, Sep 23, 2009 at 1:44 PM, FMH kagba2...@yahoo.com wrote:
 Thank you for the code. I found that the coding does not work if there is an 
 NA in dp variable. For instance;

 #
 dp - c(1,4,NA,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp,dp, type= 'l',ylim=rev(range(dp)))
  #

 If this is the case, how could we rewrite the coding?

 Thank you
 Fir




 - Original Message 
 From: jim holtman jholt...@gmail.com
 To: FMH kagba2...@yahoo.com
 Cc: r-help@r-project.org
 Sent: Wednesday, September 23, 2009 1:04:21 PM
 Subject: Re: [R] Problem in graph plotting

 try this:

 plot(tp,dp, type= 'l',ylim=rev(range(dp)))


 On Wed, Sep 23, 2009 at 7:58 AM, FMH kagba2...@yahoo.com wrote:
 Dear All,

 Let:
 dp: depth of the river
 tp: temperature with respect to depth

 We can have a simple scatter plot, between depth as y-axis and temperature 
 as x-axis, by using a plot function as shown below.

 #
 dp - c(1,4,3,2,5,7,9,8,9,2)
 tp - 1:10
 plot(tp,dp, type= 'l')
 #

 Could someone advice me on the way to plot the same pair of observations, 
 but with depth in descending order from the origin. Instead of depth, I 
 tried to simply use rev(depth), but the result was bizarre.

 Thank you
 Fir




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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] Numerical integration problem

2009-09-23 Thread Ravi Varadhan
Hi Marcus,

I always use a smaller error tolerance in `integrate' than the default
value.  I generally use 1.e-07, whereas the default is only about 1.e-04.
Sometimes you may also need to increase the number of subdivisions from its
default value of 100.

Your problem disappears if you use a smaller tolerance for convergence:

 integrate(hazard, 0, Inf, v=0.1, gam=pi*231/200,
pos=list(r=5,th=atan(3/4)), rel.tol=1.e-07, a=10, b0=10, bt=0.1)
0.0002290673 with absolute error  1.9e-11
 

Ravi.

---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 





-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Marcus Rowcliffe
Sent: Wednesday, September 23, 2009 11:31 AM
To: r-help@r-project.org
Subject: [R] Numerical integration problem

Hi there
I'm trying to construct a model of mortality risk in 2D space that
requires numerical integration of a hazard function, for which I'm using
the integrate function. I'm occasionally encountering parameter
combinations that cause integrate to terminate with error Error in
integrate... the integral is probably divergent, which I'm not sure how
to interpret. The problem only crops up for a tiny part of the input
parameter space, but if I can't get this to work for the whole space I'm
a bit stuck! Plotting the integrand shows no sign of obvious problems
such as flatness, extreme spiking or non-finite area, and a tiny tweak
to the input is enough to get the integration to work, even though the
tweaked function looks essentially the same as the one that fails. Below
is some code that demonstrates the problem on my machine running R
2.9.0. Any suggestions on what might be causing this and what I can do
to avoid it would be very gratefully received. 
Hoping for some insights
Marcus


##
#Problem example
#Works fine:
integrate(hazard, 0,Inf, v=0.1, gam=pi*232/200,
pos=list(r=5,th=atan(3/4)), a=10, b0=10, bt=0.1)

#Gives error ...integral probably divergent:
integrate(hazard, 0,Inf, v=0.1, gam=pi*231/200,
pos=list(r=5,th=atan(3/4)), a=10, b0=10, bt=0.1)

#Plot the integrands - doesn't look obviously problematic
h -
hazard(seq(0,500,0.1),0.1,pi*231/200,pos=list(r=5,th=atan(3/4)),10,10,0.
1)
plot(seq(0,500,0.1),h,type=l,col=2)
h -
hazard(seq(0,500,0.1),0.1,pi*232/200,pos=list(r=5,th=atan(3/4)),10,10,0.
1)
lines(seq(0,500,0.1),h)

#Functions used:

#hazard at a given point pos (a list of polar coordinates: distance r
and angle th); a, b0 and bt are model parameters
point.hazard - function(pos,a,b0,bt) a * exp(-(pos$r^2/(2*b0^2))) *
exp(-(pos$th^2/(2*bt^2)))

#point.hazard for a point related to input point pos by time t and speed
v
hazard - function(t, v, gam, pos, a, b0, bt)
{   pos2 - zredef(pos,-t*v,gam)
pos2$th[pos2$thpi] - 2*pi-pos2$th[pos2$thpi]
point.hazard(pos2,a,b0,bt)
}
#Returns a list of polar co-ordinates for a point defined by distance m
in direction gam from starting point pos
zredef - function(pos, m, gam)
{   x - pos$r*sin(pos$th) + m*sin(gam)
y - pos$r*cos(pos$th) + m*cos(gam)
r - (x^2 + y^2)^0.5
th - atan(x/y)
th[x==0] - 0
th[y0] - th[y0] + pi
th[x0  y0] - th[x0  y0] + 2*pi
list(r=r,th=th)
}



The Zoological Society of London is incorporated by Royal Charter
Principal Office England. Company Number RC000749
Registered address: 
Regent's Park, London, England NW1 4RY
Registered Charity in England and Wales no. 208728 

_
This e-mail has been sent in confidence to the named add...{{dropped:8}}

__
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-pkgs] survey package (3.18)

2009-09-23 Thread Thomas Lumley


Version 3.18 of the survey package is now percolating through CRAN.

Since the last announcement on this list, in February, the main additions are
 - standard errors for survival curves (both Kaplan-Meier and Cox model)
 - svyciprop() for confidence intervals on proportions, especially in small 
samples or near 0 or 1.
 - predictive margins by direct standardization, with marginpred()
 - two-phase subsampling designs can now have arbitrary multistage designs at 
each phase
 - Rao-Scott-type likelihood ratio tests are now available for glms and the Cox 
model
 - a wide range of options for PPS designs without replacement

There is also experimental support for parallel processing using the 
'multicore' package.

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] any advice on web interfaces to R?

2009-09-23 Thread Mitchell Maltenfort
I saw http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces
and I'm still not sure yet which platform (Linux, Windows, etc.) I'll
be working on -- and no, it's not under my control to pick.

I was wondering if anyone out there had good advice, that would save
me time and stomach acid, on how to set up a web browser to send a
list of commands to an R and put the resulting table or graph in a web
page.

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] memory problems for fixed effect models

2009-09-23 Thread Daniel Malter
Are y and s continuous or is one of them a factor/dummy variable? From the
mle specification I grasp that s is the unit of observation and is
factor-coded. If that is so, then estimating lm(o~y+s) includes a lot of
dummy/factor variables (lots of columns of 0/1 in the X matrix), and then
there could be a problem as you describe it. To avoid this problem you may
want to use the plm library. This library conducts fixed-effects analyses
without including dummy variables to denote the unit of observation.
Instead, it demeans the data for each unit of observation and readjusts the
standard errors to account for the reduction in the degrees of freedom due
to the fixed effects.

HTH,
Daniel

-
cuncta stricte discussurus
-

-Ursprüngliche Nachricht-
Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im
Auftrag von Jörg Schaber
Gesendet: Wednesday, September 23, 2009 10:06 AM
An: r-h...@stat.math.ethz.ch
Betreff: [R] memory problems for fixed effect models

Hi,

I am trying to fit a simple two-way fixed effect linear model (o ~ y + s
- 1). However, my problem is large (length(o)=79333).
I am already using slm.fit with a dense design matrix (ddm), but still:

fit - slm.fit(ddm,o)
Error: cannot allocate vector of size 9.1 Gb

Is there a way to redefine the model or any other trick such that I do not
run into these memory problems?

Running a mixed effect model, like
lme(o ~ y - 1 ,random = ~ 1 | s, method=REML,
contrasts=list(s=(contr.sum)),na.action=na.exclude)
poses no problem, but I want to have both effects fixed.

Thanks,

joerg

__
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] Fortran vs R

2009-09-23 Thread Thomas Lumley

On Wed, 23 Sep 2009, Paul Simonin wrote:


Hello R users,
I have a basic computer programing question. I am a student currently taking 
a course that uses Fortran as the main programming language, but the 
instructors are open to students using any language they are familiar with. I 
have used R previously, and am wondering if there is any benefit to my learning 
Fortran, or whether I should stick with R for this class. Any advice? Are there 
clear benefits to using Fortran, or things Fortran can do that R cannot?



There is almost no overlap between programs that can sensibly be written in R and those that can 
sensibly be written in Fortran, and good coding styles in the two languages are very different. For 
these reasons I would take the opportunity to learn Fortran, and hope that the instructor has used 
examples for which Fortran is a sensible choice.


It's a good idea to learn some statically typed, compiled language, partly because you sometimes need 
one and partly for what it teaches you about programming. Even if you don't end up writing Fortran in 
the future, you may well up reading it -- there's lots of numerical code out there (including in R) 
written in Fortran.



 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
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] dotchart to barplots

2009-09-23 Thread Henrique Dallazuanna
Try this:

barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually represented 
 well. I tried the dotchart but I felt it was too spread out. Then I tried the 
 barplot which is good enough for me. Is there a way to give the labels for 
 the y-axis as in the dot chart? Also, I feel the grey level is confusing, so 
 is there options for designs within the bars? I cannot use color as the 
 journal wants it in black and white.  I also need to specify the key. If 
 someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] logLik() in urca function

2009-09-23 Thread karla hernandez villafuerte




Dear Group:
 
I want to get the loglik of the regresion associated to the estimation of the 
unit root test Zivot-Andrews of the package urca. I am new using R, then I 
simply tried the next sequence:
 
 A-ur.za(var,model=intercept,lag=2)
 logLik(A)
 
but the result is an error, and I think it is because A (the result of the 
function) is not class S4.
 
 class(A)
[1] ur.za
attr(,package)
[1] urca

I want to use the logLik to compare different number of lags, in order to know 
the optimal one.
 
I will be really grateful if someone can tell me how to calculate the logLik or 
the optimal number of lags.
 
Thank you very much!,
 
Karla
 



¿Cuál de estas 16 personalidades es la tuya? ¡Descubre quién eres realmente!
  
_
[[elided Hotmail 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.


[R] stripchart with pch %in% 21:25 with bg

2009-09-23 Thread Jean lobry

Dear all,

consider:

###
x - round(rnorm(50))
stripchart(x,  pch = 21, col = black, bg = pink, method = jitter)
points(0.5, 1, pch = 21, col = black, bg = pink, cex = 2)
###

Under R 2.9.0 the points produced by stripchart are not colored,
while points() gives the desidered output (magnified here by cex).
I found a simple workaround by redefining the function
graphics:::stripchart.default() so that the dot-dot-dot (...)
argument is forwarded the the function points().

I have also tried to source the code for striptchart.R in
https://svn.r-project.org/R/trunk/src/library/graphics/R/stripchart.R
with revision number 49800, but the output is unchanged.

Am I missing something here? Is there no simpler way to achieve
this goal? I have search the NEWS for stripchart and found only
an entry for R 2.7.2 stating that:

o   stripchart() now passes '...' to title() (as well as to
plot.default() and axis()). (Wish of PR#12202)

I may send a wish to R-dev, but I would like to make sure before that I
havn't miss something obvious.

Best,

Jean
--
Jean R. Lobry(lo...@biomserv.univ-lyon1.fr)
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
allo  : +33 472 43 27 56 fax: +33 472 43 13 88
http://pbil.univ-lyon1.fr/members/lobry/

__
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] dotchart to barplots

2009-09-23 Thread Nair, Murlidharan T
I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
solves part of what need. I there a way to rotate how it is written on the 
y-axis?  Also, use designs instead of gray scale and making keys for it?
Thanks for chipping in.
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: Wednesday, September 23, 2009 3:09 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Try this:

barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually represented 
 well. I tried the dotchart but I felt it was too spread out. Then I tried the 
 barplot which is good enough for me. Is there a way to give the labels for 
 the y-axis as in the dot chart? Also, I feel the grey level is confusing, so 
 is there options for designs within the bars? I cannot use color as the 
 journal wants it in black and white.  I also need to specify the key. If 
 someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] dotchart to barplots

2009-09-23 Thread Nair, Murlidharan T
Ok, I could make it perpendicular by specifying las=2

barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
las=2)

Still working on the other though. 
Cheers../Murli


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Nair, Murlidharan T
Sent: Wednesday, September 23, 2009 3:21 PM
To: Henrique Dallazuanna
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
solves part of what need. I there a way to rotate how it is written on the 
y-axis?  Also, use designs instead of gray scale and making keys for it?
Thanks for chipping in.
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: Wednesday, September 23, 2009 3:09 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Try this:

barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually represented 
 well. I tried the dotchart but I felt it was too spread out. Then I tried the 
 barplot which is good enough for me. Is there a way to give the labels for 
 the y-axis as in the dot chart? Also, I feel the grey level is confusing, so 
 is there options for designs within the bars? I cannot use color as the 
 journal wants it in black and white.  I also need to specify the key. If 
 someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] dotchart to barplots

2009-09-23 Thread Henrique Dallazuanna
Sorry, byt what you mean by 'designs'?

You can add a legend with:

barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)


On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Ok, I could make it perpendicular by specifying las=2

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)

 Still working on the other though.
 Cheers../Murli


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 3:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
 solves part of what need. I there a way to rotate how it is written on the 
 y-axis?  Also, use designs instead of gray scale and making keys for it?
 Thanks for chipping in.
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Try this:

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually 
 represented well. I tried the dotchart but I felt it was too spread out. 
 Then I tried the barplot which is good enough for me. Is there a way to give 
 the labels for the y-axis as in the dot chart? Also, I feel the grey level 
 is confusing, so is there options for designs within the bars? I cannot use 
 color as the journal wants it in black and white.  I also need to specify 
 the key. If someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] dotchart to barplots

2009-09-23 Thread Nair, Murlidharan T
What I mean by design is a black and white lines or something that is more 
distinguishing than the grey levels? 
Thanks for the legends :)
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: Wednesday, September 23, 2009 3:32 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Sorry, byt what you mean by 'designs'?

You can add a legend with:

barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)


On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Ok, I could make it perpendicular by specifying las=2

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)

 Still working on the other though.
 Cheers../Murli


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 3:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
 solves part of what need. I there a way to rotate how it is written on the 
 y-axis?  Also, use designs instead of gray scale and making keys for it?
 Thanks for chipping in.
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Try this:

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually 
 represented well. I tried the dotchart but I felt it was too spread out. 
 Then I tried the barplot which is good enough for me. Is there a way to give 
 the labels for the y-axis as in the dot chart? Also, I feel the grey level 
 is confusing, so is there options for designs within the bars? I cannot use 
 color as the journal wants it in black and white.  I also need to specify 
 the key. If someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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] Best way to arrange data

2009-09-23 Thread Jim Silverton
Hello,
I have the following data:

   gene Actualgroupsreps
11213 12
22123 23
33   2 12
44 12  2   3
51   0  1   1
62 34  2   2
73123 1   1
84  12 2   2

I want to find the best way to store this so that it can be accessed quickly
for other uses. Someone recommended an array as follows:



actual_array=array(0,c(G,T,length(nj)))
for (b in 1:length(gene)) {
 for (i in 1:max(gene))  {
 for (j in 1:max(groups))  {
  for (k in 1:max(reps)) {
  if ((gene[b]==i)  (groups[b]==j)  (replicate[b]==k))
 {
 yijk_array[i,j,k]=yijk[b]
 }
}
  }
}
 }


But this gives an array that has a lot of zeros in places where I don't have
any data. Is there a way to overcome this and present a 'shortened' version?


Jim

[[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] dotchart to barplots

2009-09-23 Thread Henrique Dallazuanna
Perhaps a white border:

barplot(t(as.matrix(intersect.data[,2:5])),
 border = 'white',
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)

Or you can use the 'col'  argument to select further colors.


On Wed, Sep 23, 2009 at 4:35 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 What I mean by design is a black and white lines or something that is more 
 distinguishing than the grey levels?
 Thanks for the legends :)
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:32 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Sorry, byt what you mean by 'designs'?

 You can add a legend with:

 barplot(t(as.matrix(intersect.data[,2:5])),
         beside = T, horiz = T, legend.text = names(intersect.data)[-1],
         names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)


 On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Ok, I could make it perpendicular by specifying las=2

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)

 Still working on the other though.
 Cheers../Murli


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 3:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
 solves part of what need. I there a way to rotate how it is written on the 
 y-axis?  Also, use designs instead of gray scale and making keys for it?
 Thanks for chipping in.
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Try this:

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually 
 represented well. I tried the dotchart but I felt it was too spread out. 
 Then I tried the barplot which is good enough for me. Is there a way to 
 give the labels for the y-axis as in the dot chart? Also, I feel the grey 
 level is confusing, so is there options for designs within the bars? I 
 cannot use color as the journal wants it in black and white.  I also need 
 to specify the key. If someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 
 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
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 

Re: [R] dotchart to barplots

2009-09-23 Thread Nair, Murlidharan T
The journal wants black and white only :)


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: Wednesday, September 23, 2009 3:41 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Perhaps a white border:

barplot(t(as.matrix(intersect.data[,2:5])),
 border = 'white',
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)

Or you can use the 'col'  argument to select further colors.


On Wed, Sep 23, 2009 at 4:35 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 What I mean by design is a black and white lines or something that is more 
 distinguishing than the grey levels?
 Thanks for the legends :)
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:32 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Sorry, byt what you mean by 'designs'?

 You can add a legend with:

 barplot(t(as.matrix(intersect.data[,2:5])),
         beside = T, horiz = T, legend.text = names(intersect.data)[-1],
         names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)


 On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Ok, I could make it perpendicular by specifying las=2

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)

 Still working on the other though.
 Cheers../Murli


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 3:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
 solves part of what need. I there a way to rotate how it is written on the 
 y-axis?  Also, use designs instead of gray scale and making keys for it?
 Thanks for chipping in.
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Try this:

 barplot(t(as.matrix(intersect.data[,2:5])),
          beside = T, horiz = T,
          names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually 
 represented well. I tried the dotchart but I felt it was too spread out. 
 Then I tried the barplot which is good enough for me. Is there a way to 
 give the labels for the y-axis as in the dot chart? Also, I feel the grey 
 level is confusing, so is there options for designs within the bars? I 
 cannot use color as the journal wants it in black and white.  I also need 
 to specify the key. If someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 
 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
    Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
    8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
 gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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




 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O


Re: [R] dotchart to barplots

2009-09-23 Thread Greg Snow
The current recommendation is to not put designs/hash lines/pictures/etc. into 
the bars, but to use a single solid color (gray in your case).  Back when a 
quality graph meant using a pen plotter, hash lines made sense as a way to 
distinguish between bars, but quality graphics no longer depend on pen plotters 
(I don't remember the last time I actually saw one) and hash lines can cause 
what is called the Moire effect or Moire vibrations (there should be an accent 
on the 'e'), which distorts the effects of the graph and can even cause nausea 
in the viewer.  Other patterns in the bars runs the risk of causing other 
optical illusions and distorting the true content of the graph.

-- 
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 Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 1:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots
 
 I had tried names.arg=c(intersect.data[,1]) so that was the problem.
 That solves part of what need. I there a way to rotate how it is
 written on the y-axis?  Also, use designs instead of gray scale and
 making keys for it?
 Thanks for chipping in.
 Cheers../Murli
 
 
 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots
 
 Try this:
 
 barplot(t(as.matrix(intersect.data[,2:5])),
   beside = T, horiz = T,
   names.arg = intersect.data[,1], cex.axis = 0.7, cex.names =
 0.7)
 
 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu
 wrote:
  Hi,
 
  I am trying to plot the following data so that it can be visually
 represented well. I tried the dotchart but I felt it was too spread
 out. Then I tried the barplot which is good enough for me. Is there a
 way to give the labels for the y-axis as in the dot chart? Also, I feel
 the grey level is confusing, so is there options for designs within the
 bars? I cannot use color as the journal wants it in black and white.  I
 also need to specify the key. If someone has done it, I would
 appreciate your input.
  Cheers../Murli
 
 
  intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L,
 11L, 12L,
  13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
  101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
  201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
  801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor =
 c(6L,
  7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
  ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
  7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
  22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
     Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
     8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X,
 MCM.Cell.vs.MCM.Tumor,
  Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell,
 Ttest.Tumor.vs.MCM.Tumor
  ), class = data.frame, row.names = c(NA, -15L))
 
  dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1],
 cex=0.5, gpch=70)
 
  barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)
 
  __
  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.
 
 
 
 
 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
 __
 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] dotchart to barplots

2009-09-23 Thread Peter Ehlers

Murli,

Two points:
1. I think you might want las=1;
2. have a look at the density= argument,
i.e. add density=c(10,20,30,40) to your call.

Peter Ehlers

Henrique Dallazuanna wrote:

Perhaps a white border:

barplot(t(as.matrix(intersect.data[,2:5])),
 border = 'white',
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)

Or you can use the 'col'  argument to select further colors.


On Wed, Sep 23, 2009 at 4:35 PM, Nair, Murlidharan T mn...@iusb.edu wrote:

What I mean by design is a black and white lines or something that is more 
distinguishing than the grey levels?
Thanks for the legends :)
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com]
Sent: Wednesday, September 23, 2009 3:32 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Sorry, byt what you mean by 'designs'?

You can add a legend with:

barplot(t(as.matrix(intersect.data[,2:5])),
beside = T, horiz = T, legend.text = names(intersect.data)[-1],
names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)


On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:

Ok, I could make it perpendicular by specifying las=2

barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T,
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)

Still working on the other though.
Cheers../Murli


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Nair, Murlidharan T
Sent: Wednesday, September 23, 2009 3:21 PM
To: Henrique Dallazuanna
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
solves part of what need. I there a way to rotate how it is written on the 
y-axis?  Also, use designs instead of gray scale and making keys for it?
Thanks for chipping in.
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com]
Sent: Wednesday, September 23, 2009 3:09 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Try this:

barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T,
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:

Hi,

I am trying to plot the following data so that it can be visually represented 
well. I tried the dotchart but I felt it was too spread out. Then I tried the 
barplot which is good enough for me. Is there a way to give the labels for the 
y-axis as in the dot chart? Also, I feel the grey level is confusing, so is 
there options for designs within the bars? I cannot use color as the journal 
wants it in black and white.  I also need to specify the key. If someone has 
done it, I would appreciate your input.
Cheers../Murli


intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
   Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
   8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
MCM.Cell.vs.MCM.Tumor,
Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
Ttest.Tumor.vs.MCM.Tumor
), class = data.frame, row.names = c(NA, -15L))

dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
gpch=70)

barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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




--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

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




--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O







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

Re: [R] Barplot+Table

2009-09-23 Thread gunksta


Marc Schwartz-3 wrote:
 
 Using the data that is in the online plot rather than the above, here  
 is a first go. Note that I am not drawing the background grid in the  
 barplot or the lines for table below it. These could be added if you  
 really need them.
 

Note: I snipped out the syntax from Marc's earlier answer because it is very
lengthy. At the end of this email I have appended an edited version of his
syntax. The part that I have added is clearly marked. This syntax runs
without error but the output is clearly not lined up.

Marc's original syntax works great, as long as X11() is left to it's default
dimensions (square). Unfortunately, after working with my report, I realized
that I need to make the barplot shorter and longer, rather than square. When
I try to change the shape of the output, I start running into problems. 

After looking through the documentation, it seemed as though X11() would
help me. I tried adding this to Marc's original syntax.

X11(height=3, width=4.5, pointsize=10)

Thus, things looked more like this:
X11(height=3, width=4.5, pointsize=10)
mp - barplot(MyData, beside = TRUE, ylim = c(0, 100),
   yaxt = n, cex.names = MyCex, col = MyCols)

Unfortunately, this results in two problems.

1) Because I have now changed the shape of the output area, the additional
text and labels are no longer shown on the plot. The barplot itself looks
great, but the labels do not.

2) I seem to be starting two separate X11() displays, although I only want
to start one.

The following syntax demonstrates what I am playing with right now. I
understand that the syntax no longer works because the labels are falling
outside of the shape set by X11(). Unfortunately, I haven't been able to
figure out how to fix it. If posible, I'd like to move the barplot to the
right, to give me more room to print out the labels, but I don't see how
this is possible.

# --
# Create  data   
MyData - matrix(c(57.1,52.3,13.5,13.9,7.9,8.8,5.4,5.6,16.1,19.4), nrow=2)  

 

  
colnames(MyData) - c(0 times, 1-2 times, 3-5 times, 6-9 Occasions,
10 or more\nOccasions)  

rownames(MyData) - c(Androscoggin, Maine)
  
# Set graph margins to make room for labels
par(mar = c(5, 8, 4, 1))

# Set colors
MyCols - c(black, grey80)

# Set label size
MyCex = 0.75

# Set lines for table data
MyLines - 2:3

# This is the part that I added.
# And it seems to mess things up, although I do want the basic shape.
# Is there a better way to get this shape?
X11(height=3, width=4.5, pointsize=10)

# do barplot, getting bar midpoints in 'mp'
mp - barplot(MyData, beside = TRUE, ylim = c(0, 100), yaxt = n, cex.names
= MyCex, col = MyCols)

# Put a box around it
box()

# Draw y axis tick marks and labels
axis(2, at = seq(0, 100, 10), las = 1)

# Draw values below plot
mtext(side = 1, text = MyData,
   at = rep(colMeans(mp), each = nrow(MyData)),
   line = MyLines, cex = MyCex)

# Get min value for the x axis. See ?par 'usr'
min.x - par(usr)[1]

# Draw categories using mtext
mtext(side = 1, line = MyLines, text = rownames(MyData),
   at = min.x - max(strwidth(rownames(MyData), cex = MyCex)),
   adj = 0, cex = MyCex)

# Draw the colored boxes
VertOff - strheight(X, cex = MyCex) * c(6, 8)
HorizOff - min.x - (0.85 * max(strwidth(rownames(MyData

# I'm sure these still exist, but they are now being drawn off-screen
points(rep(HorizOff, nrow(MyData)), par(usr)[3] - VertOff, bg = MyCols,
pch = 22, xpd = TRUE, cex = MyCex) 

-- 
View this message in context: 
http://www.nabble.com/Barplot%2BTable-tp25406046p25531279.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] glm analysis repeated for 900 variables

2009-09-23 Thread Rolf Turner


On 23/09/2009, at 11:26 PM, Christian Schulz wrote:


Hi,


nvars - 902
data -  as.data.frame(matrix(runif(100*nvars),ncol=nvars))
colnames(data)[901] - c('phenotype')
colnames(data)[902] - c('outcome')


snip

Just ***WHAT*** do you think the ``c( )'' is doing for you in
the construction ``c('phenotype')'' etc. ???

Such complete misunderstanding of what the c() does or is useful
for exasperates me, and is unfortunately very wide spread.  If people
are going to use R, why don't they learn the basic syntax?

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
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] dotchart to barplots

2009-09-23 Thread Nair, Murlidharan T
Thanks Peter. Where did you find  that option? It's really cool
Cheers../Murli


-Original Message-
From: Peter Ehlers [mailto:ehl...@ucalgary.ca] 
Sent: Wednesday, September 23, 2009 3:56 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Murli,

Two points:
1. I think you might want las=1;
2. have a look at the density= argument,
i.e. add density=c(10,20,30,40) to your call.

Peter Ehlers

Henrique Dallazuanna wrote:
 Perhaps a white border:
 
 barplot(t(as.matrix(intersect.data[,2:5])),
  border = 'white',
  beside = T, horiz = T, legend.text = names(intersect.data)[-1],
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)
 
 Or you can use the 'col'  argument to select further colors.
 
 
 On Wed, Sep 23, 2009 at 4:35 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 What I mean by design is a black and white lines or something that is more 
 distinguishing than the grey levels?
 Thanks for the legends :)
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:32 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Sorry, byt what you mean by 'designs'?

 You can add a legend with:

 barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)


 On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Ok, I could make it perpendicular by specifying las=2

 barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)

 Still working on the other though.
 Cheers../Murli


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 3:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
 solves part of what need. I there a way to rotate how it is written on the 
 y-axis?  Also, use designs instead of gray scale and making keys for it?
 Thanks for chipping in.
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Try this:

 barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually 
 represented well. I tried the dotchart but I felt it was too spread out. 
 Then I tried the barplot which is good enough for me. Is there a way to 
 give the labels for the y-axis as in the dot chart? Also, I feel the grey 
 level is confusing, so is there options for designs within the bars? I 
 cannot use color as the journal wants it in black and white.  I also need 
 to specify the key. If someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 
 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], 
 cex=0.5, gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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



 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

 __
 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 

Re: [R] Best way to arrange data

2009-09-23 Thread David Winsemius


On Sep 23, 2009, at 3:47 PM, Jim Silverton wrote:


Hello,
I have the following data:

  gene Actualgroupsreps
11213 12
22123 23
33   2 12
44 12  2   3
51   0  1   1
62 34  2   2
73123 1   1
84  12 2   2

I want to find the best way to store this so that it can be accessed  
quickly

for other uses. Someone recommended an array as follows:



actual_array=array(0,c(G,T,length(nj)))
for (b in 1:length(gene)) {
for (i in 1:max(gene))  {
for (j in 1:max(groups))  {
 for (k in 1:max(reps)) {
 if ((gene[b]==i)  (groups[b]==j)   
(replicate[b]==k))

{
yijk_array[i,j,k]=yijk[b]
}
   }
 }
   }
}


But this gives an array that has a lot of zeros in places where I  
don't have
any data. Is there a way to overcome this and present a 'shortened'  
version?



The Matrix package has a sparse array construct that may ffer what you  
seek.


--
David.




Jim

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


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] dotchart to barplots

2009-09-23 Thread Nair, Murlidharan T
Guess, I miss the argument when I  ?barplot.
Cheers../Murli


-Original Message-
From: Peter Ehlers [mailto:ehl...@ucalgary.ca] 
Sent: Wednesday, September 23, 2009 3:56 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Murli,

Two points:
1. I think you might want las=1;
2. have a look at the density= argument,
i.e. add density=c(10,20,30,40) to your call.

Peter Ehlers

Henrique Dallazuanna wrote:
 Perhaps a white border:
 
 barplot(t(as.matrix(intersect.data[,2:5])),
  border = 'white',
  beside = T, horiz = T, legend.text = names(intersect.data)[-1],
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)
 
 Or you can use the 'col'  argument to select further colors.
 
 
 On Wed, Sep 23, 2009 at 4:35 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 What I mean by design is a black and white lines or something that is more 
 distinguishing than the grey levels?
 Thanks for the legends :)
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:32 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Sorry, byt what you mean by 'designs'?

 You can add a legend with:

 barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)


 On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Ok, I could make it perpendicular by specifying las=2

 barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, 
 las=2)

 Still working on the other though.
 Cheers../Murli


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Nair, Murlidharan T
 Sent: Wednesday, September 23, 2009 3:21 PM
 To: Henrique Dallazuanna
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
 solves part of what need. I there a way to rotate how it is written on the 
 y-axis?  Also, use designs instead of gray scale and making keys for it?
 Thanks for chipping in.
 Cheers../Murli


 -Original Message-
 From: Henrique Dallazuanna [mailto:www...@gmail.com]
 Sent: Wednesday, September 23, 2009 3:09 PM
 To: Nair, Murlidharan T
 Cc: r-help@r-project.org
 Subject: Re: [R] dotchart to barplots

 Try this:

 barplot(t(as.matrix(intersect.data[,2:5])),
  beside = T, horiz = T,
  names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

 On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:
 Hi,

 I am trying to plot the following data so that it can be visually 
 represented well. I tried the dotchart but I felt it was too spread out. 
 Then I tried the barplot which is good enough for me. Is there a way to 
 give the labels for the y-axis as in the dot chart? Also, I feel the grey 
 level is confusing, so is there options for designs within the bars? I 
 cannot use color as the journal wants it in black and white.  I also need 
 to specify the key. If someone has done it, I would appreciate your input.
 Cheers../Murli


 intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 
 12L,
 13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
 101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
 201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
 801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
 7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
 ), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
 7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
 22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
 MCM.Cell.vs.MCM.Tumor,
 Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
 Ttest.Tumor.vs.MCM.Tumor
 ), class = data.frame, row.names = c(NA, -15L))

 dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], 
 cex=0.5, gpch=70)

 barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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



 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O

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

Re: [R] dotchart to barplots

2009-09-23 Thread Peter Ehlers

Well, it was easy to find: ?barplot and look at all the arguments.

But I agree with Greg that this kind of look is (and should be)
pretty much history. I'm not very fond of barplots with as many
groups as you have. Since your variable X appears to be a
discretized continuous variable, why not use a line plot,
connecting the midpoints of your X intervals. You can then use
different line types. With 4 lines, it wouldn't be too confusing.

Peter Ehlers

Nair, Murlidharan T wrote:

Thanks Peter. Where did you find  that option? It's really cool
Cheers../Murli


-Original Message-
From: Peter Ehlers [mailto:ehl...@ucalgary.ca] 
Sent: Wednesday, September 23, 2009 3:56 PM

To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Murli,

Two points:
1. I think you might want las=1;
2. have a look at the density= argument,
i.e. add density=c(10,20,30,40) to your call.

Peter Ehlers

Henrique Dallazuanna wrote:

Perhaps a white border:

barplot(t(as.matrix(intersect.data[,2:5])),
 border = 'white',
 beside = T, horiz = T, legend.text = names(intersect.data)[-1],
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)

Or you can use the 'col'  argument to select further colors.


On Wed, Sep 23, 2009 at 4:35 PM, Nair, Murlidharan T mn...@iusb.edu wrote:

What I mean by design is a black and white lines or something that is more 
distinguishing than the grey levels?
Thanks for the legends :)
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com]
Sent: Wednesday, September 23, 2009 3:32 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Sorry, byt what you mean by 'designs'?

You can add a legend with:

barplot(t(as.matrix(intersect.data[,2:5])),
beside = T, horiz = T, legend.text = names(intersect.data)[-1],
names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)


On Wed, Sep 23, 2009 at 4:26 PM, Nair, Murlidharan T mn...@iusb.edu wrote:

Ok, I could make it perpendicular by specifying las=2

barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T,
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7, las=2)

Still working on the other though.
Cheers../Murli


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Nair, Murlidharan T
Sent: Wednesday, September 23, 2009 3:21 PM
To: Henrique Dallazuanna
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

I had tried names.arg=c(intersect.data[,1]) so that was the problem. That 
solves part of what need. I there a way to rotate how it is written on the 
y-axis?  Also, use designs instead of gray scale and making keys for it?
Thanks for chipping in.
Cheers../Murli


-Original Message-
From: Henrique Dallazuanna [mailto:www...@gmail.com]
Sent: Wednesday, September 23, 2009 3:09 PM
To: Nair, Murlidharan T
Cc: r-help@r-project.org
Subject: Re: [R] dotchart to barplots

Try this:

barplot(t(as.matrix(intersect.data[,2:5])),
 beside = T, horiz = T,
 names.arg = intersect.data[,1], cex.axis = 0.7, cex.names = 0.7)

On Wed, Sep 23, 2009 at 4:01 PM, Nair, Murlidharan T mn...@iusb.edu wrote:

Hi,

I am trying to plot the following data so that it can be visually represented 
well. I tried the dotchart but I felt it was too spread out. Then I tried the 
barplot which is good enough for me. Is there a way to give the labels for the 
y-axis as in the dot chart? Also, I feel the grey level is confusing, so is 
there options for designs within the bars? I cannot use color as the journal 
wants it in black and white.  I also need to specify the key. If someone has 
done it, I would appreciate your input.
Cheers../Murli


intersect.data-structure(list(X = structure(c(1L, 3L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 2L, 4L, 5L, 6L, 7L), .Label = c(1-100, 1001-1100,
101-200, 1101-1200, 1201-1300, 1301-1400, 1401-1532,
201-300, 301-400, 401-500, 501-600, 601-700, 701-800,
801-900, 901-1000), class = factor), MCM.Cell.vs.MCM.Tumor = c(6L,
7L, 12L, 9L, 13L, 7L, 11L, 4L, 8L, 11L, 11L, 12L, 4L, 15L, 28L
), Ttest.Tumor.vs.Ttest.Cell = c(4L, 2L, 7L, 9L, 8L, 10L, 4L,
7L, 8L, 7L, 5L, 7L, 4L, 5L, 9L), Ttest.Cell.vs.MCM.Cell = c(66L,
22L, 14L, 7L, 11L, 6L, 12L, 7L, 9L, 8L, 7L, 9L, 9L, 5L, 20L),
   Ttest.Tumor.vs.MCM.Tumor = c(31L, 18L, 8L, 12L, 5L, 8L, 5L,
   8L, 9L, 8L, 10L, 12L, 13L, 8L, 18L)), .Names = c(X, 
MCM.Cell.vs.MCM.Tumor,
Ttest.Tumor.vs.Ttest.Cell, Ttest.Cell.vs.MCM.Cell, 
Ttest.Tumor.vs.MCM.Tumor
), class = data.frame, row.names = c(NA, -15L))

dotchart(as.matrix(intersect.data[-1]), labels=intersect.data[,1], cex=0.5, 
gpch=70)

barplot(t(as.matrix(intersect.data[,2:5])), beside=T, horiz=T)

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

  1   2   >