Re: [R] LOOping problem with R

2010-08-29 Thread Joshua Wiley
Hi,

I would also like to point out that you flipped the first two the
values of theta in the R vs. FORTRAN versions.  This fixes part of
your differences (and makes it easy to see that the differences occur
when j < i, as David and Mario point out).

Josh

On Sun, Aug 29, 2010 at 10:27 PM, Nam Lethanh  wrote:
> Dear Guys,
>
> I do converting codes from Fortran into R and got stuck in solving LOOPING
> procedure with R. In FORTRAN, it is (DO and END DO) for looping in the net.
> In R, it is (FOR with {   }).
>
> I believe there is something wrong with my coding in R, do hope that you can
> help me solving following problems.
>
> It seems easy, but results are not the same.
>
> ***
> WITH R
>
> theta<-c(0.08,0.06,0.09,0)
> for (i in 1:4){
> for (j in 1:4){
> a<-1.0
> for (k in i:(j-1)){
> a<-a*theta[k]
> }
> print(a)
> }
> --
> HERE GOES the results
> -
> numeric(0)
> [1] 0.08
> [1] 0.0048
> [1] 0.000432
> numeric(0)
> [1] 0.0048
> [1] 0.06
> [1] 0.0054
> numeric(0)
> [1] 0.000432
> [1] 0.0054
> [1] 0.09
> numeric(0)
> [1] 0
> [1] 0
> [1] 0
> *
> IN FORTRAN, the results is totally different.
>
> program calculating_a
> implicit none
> integer i, j, k
> double precision a, theta(4)
> theta(1)=0.06; theta(2)=0.08; theta(3)=0.09; theta(4)=0
> do i=1, 4
> do j=1, 4
> a=1
> do k=i,j-1
> a=a*theta(k)
> end do
>
> print*, a
>
> end do
> end do
> end
>
> Here goes the results with FOTRAN
>
> -
> 1
> 0.06
> 4.79E-003
> 4.31E-004
> 1
> 1
> 0.08
> 7.2E-0.03
> 1
> 1
> 1
> 0.09
> 1
> 1
> 1
> 1
> -
>
>
>
> Thank you!
>
>
>
> Nam
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] log y 'axis' of histogram

2010-08-29 Thread David Scott

On 30/08/2010 1:58 p.m., Derek M Jones wrote:

All,

I have been trying to get calls to hist(...) to be plotted
with the y-axis having a log scale.

I have tried: par(ylog=TRUE)

I have also looked at the histogram package.

Suggestions welcome.



You appear to be looking for a log-histogram function.

There is one (logHist) in my package DistributionUtils on CRAN. You 
don't need the rest of the package to use it. You could just extract 
that particular function.


David Scott

--
_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LOOping problem with R

2010-08-29 Thread Mario Valle
When j==1 for loops from i down to zero. 5:0 is valid and means c(5,4,3,2,1,0)
Hope it helps
mario

Nam Lethanh wrote:
> Dear Guys,
> 
> I do converting codes from Fortran into R and got stuck in solving LOOPING
> procedure with R. In FORTRAN, it is (DO and END DO) for looping in the net.
> In R, it is (FOR with {   }).
> 
> I believe there is something wrong with my coding in R, do hope that you can
> help me solving following problems.
> 
> It seems easy, but results are not the same.
> 
> ***
> WITH R
> 
> theta<-c(0.08,0.06,0.09,0)
> for (i in 1:4){
> for (j in 1:4){
> a<-1.0
> for (k in i:(j-1)){
> a<-a*theta[k]
> }
> print(a)
> }
> --
> HERE GOES the results
> -
> numeric(0)
> [1] 0.08
> [1] 0.0048
> [1] 0.000432
> numeric(0)
> [1] 0.0048
> [1] 0.06
> [1] 0.0054
> numeric(0)
> [1] 0.000432
> [1] 0.0054
> [1] 0.09
> numeric(0)
> [1] 0
> [1] 0
> [1] 0
> *
> IN FORTRAN, the results is totally different.
> 
> program calculating_a
> implicit none
> integer i, j, k
> double precision a, theta(4)
> theta(1)=0.06; theta(2)=0.08; theta(3)=0.09; theta(4)=0
> do i=1, 4
> do j=1, 4
> a=1
> do k=i,j-1
> a=a*theta(k)
> end do
> 
> print*, a
> 
> end do
> end do
> end
> 
> Here goes the results with FOTRAN
> 
> -
> 1
> 0.06
> 4.79E-003
> 4.31E-004
> 1
> 1
> 0.08
> 7.2E-0.03
> 1
> 1
> 1
> 0.09
> 1
> 1
> 1
> 1
> -
> 
> 
> 
> Thank you!
> 
> 
> 
> Nam
> 
>   [[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.

-- 
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] LOOping problem with R

2010-08-29 Thread David Winsemius


On Aug 30, 2010, at 1:27 AM, Nam Lethanh wrote:


Dear Guys,

I do converting codes from Fortran into R and got stuck in solving  
LOOPING
procedure with R. In FORTRAN, it is (DO and END DO) for looping in  
the net.

In R, it is (FOR with {   }).


Looking at the results  (namely  the 1's from the fortran code) it  
appears there are some conditions that cause FORTRAN not to enter the  
loop whereas in R the inner loop is always entered. The numeric(0)'s  
occur when you attempt to use a zero as an index. If you have a more  
specific question about what the indices are at times that surprise,  
then maybe you ought to put in more debugging code.




I believe there is something wrong with my coding in R, do hope that  
you can

help me solving following problems.

It seems easy, but results are not the same.

***
WITH R

theta<-c(0.08,0.06,0.09,0)
for (i in 1:4){
for (j in 1:4){
a<-1.0
for (k in i:(j-1)){
a<-a*theta[k]
}
print(a)
}
--
HERE GOES the results
-
numeric(0)
[1] 0.08
[1] 0.0048
[1] 0.000432
numeric(0)
[1] 0.0048
[1] 0.06
[1] 0.0054
numeric(0)
[1] 0.000432
[1] 0.0054
[1] 0.09
numeric(0)
[1] 0
[1] 0
[1] 0
*
IN FORTRAN, the results is totally different.

program calculating_a
implicit none
integer i, j, k
double precision a, theta(4)
theta(1)=0.06; theta(2)=0.08; theta(3)=0.09; theta(4)=0
do i=1, 4
do j=1, 4
a=1
do k=i,j-1
a=a*theta(k)
end do

print*, a

end do
end do
end

Here goes the results with FOTRAN

-
1
0.06
4.79E-003
4.31E-004
1
1
0.08
7.2E-0.03
1
1
1
0.09
1
1
1
1
-



Thank you!



Nam

[[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] Question regarding significance of a covariate in a coxme survival

2010-08-29 Thread C. Peng

What statistical measure(s) tend to be answering ALL(?) question of practical
interest? 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Re-Question-regarding-significance-of-a-covariate-in-a-coxme-survival-tp2399386p2399577.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] sum of some matrix columns

2010-08-29 Thread David Winsemius


On Aug 29, 2010, at 8:47 PM, Lorenzo Cattarino wrote:


Hi,



I have the following matrix



cc <- matrix (1:21, 3)

cc[,3:4]<- 0

cc

[,1] [,2] [,3] [,4] [,5] [,6] [,7]

[1,]1400   13   16   19

[2,]2500   14   17   20

[3,]3600   15   18   21



and I would like to sum just the values in columns 2, 3 and 4, so to
have something like



1  4  13  16  19

2  5  14  17  20

3  6  15  18  21


To take only selected columns:

> CC <-cc[,c(1,2,5,6,7)]
> CC
 [,1] [,2] [,3] [,4] [,5]
[1,]14   13   16   19
[2,]25   14   17   20
[3,]36   15   18   21

I'm having difficulty understanding the point of summing columns which  
you have just set to zero so am taking the liberty of changing the  
task to summing columns 2-4 and leaving in column 2 of the shortened  
matrix:


> CC[,2] <-apply(cc[ , 2:4], 1, sum)
> CC
 [,1] [,2] [,3] [,4] [,5]
[1,]1   21   13   16   19
[2,]2   24   14   17   20
[3,]3   27   15   18   21




Thanks



Lorenzo


[[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] Read in a all-character file and specify field separator and records separator

2010-08-29 Thread David Winsemius


On Aug 30, 2010, at 12:18 AM, Yong Wang wrote:


Dear list

I used to use python or awk do preliminary process and then feed into
R. In some circumstances, the data transmission becomes quite a pain.
I am wondering if there is a convenient way to read in R text file
(not data, text file in common sense) and specify field separator and
records separator, so the whole work can be reduced to one-stop
shopping.
or simply, is there one simple way to read in the text file with each
row in a single column. scan(sep="\n") does not work as expected.



You should not need to use sep=\n or any separator for a single column  
output. If what= is not specified you will just get a numeric vector,  
but if it's text, you need to specify "character".  Try the obvious  
modifications to this:


char.vec <- scan(file="/filepath/filename.ext", what="character" )

Multiple columns require something like what=list("character",  
"numeric", "logical"), but you could do what the rest of us use  
because it's all  wrapped up with sensible defaults (with the possible  
exception of stringsAsFactors ) in the read.table function.


--
David.
.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Read in a all-character file and specify field separator and records separator

2010-08-29 Thread Joshua Wiley
On Sun, Aug 29, 2010 at 9:18 PM, Yong Wang  wrote:
> Dear list
>
> I used to use python or awk do preliminary process and then feed into
> R. In some circumstances, the data transmission becomes quite a pain.
> I am wondering if there is a convenient way to read in R text file
> (not data, text file in common sense) and specify field separator and
> records separator, so the whole work can be reduced to one-stop
> shopping.
> or simply, is there one simple way to read in the text file with each
> row in a single column. scan(sep="\n") does not work as expected.

Do either of these do what you want?

readLines(con = file("example.txt", open = "r"))
read.table(file = "example.txt", sep = "\n")

Both throw a warning in a little text file I made, but both read each
line into one column.

Josh

>
> Thanks
>
> yong
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] LOOping problem with R

2010-08-29 Thread Nam Lethanh
Dear Guys,

I do converting codes from Fortran into R and got stuck in solving LOOPING
procedure with R. In FORTRAN, it is (DO and END DO) for looping in the net.
In R, it is (FOR with {   }).

I believe there is something wrong with my coding in R, do hope that you can
help me solving following problems.

It seems easy, but results are not the same.

***
WITH R

theta<-c(0.08,0.06,0.09,0)
for (i in 1:4){
for (j in 1:4){
a<-1.0
for (k in i:(j-1)){
a<-a*theta[k]
}
print(a)
}
--
HERE GOES the results
-
numeric(0)
[1] 0.08
[1] 0.0048
[1] 0.000432
numeric(0)
[1] 0.0048
[1] 0.06
[1] 0.0054
numeric(0)
[1] 0.000432
[1] 0.0054
[1] 0.09
numeric(0)
[1] 0
[1] 0
[1] 0
*
IN FORTRAN, the results is totally different.

program calculating_a
implicit none
integer i, j, k
double precision a, theta(4)
theta(1)=0.06; theta(2)=0.08; theta(3)=0.09; theta(4)=0
do i=1, 4
do j=1, 4
a=1
do k=i,j-1
a=a*theta(k)
end do

print*, a

end do
end do
end

Here goes the results with FOTRAN

-
1
0.06
4.79E-003
4.31E-004
1
1
0.08
7.2E-0.03
1
1
1
0.09
1
1
1
1
-



Thank you!



Nam

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

2010-08-29 Thread Joshua Wiley
Hi,

I believe what you are looking for is in the "teststat" slot

sjd.v...@teststat

sjd.v...@teststat[1] # first one
etc.

HTH,

Josh

On Sun, Aug 29, 2010 at 9:12 PM, aurumor  wrote:
>
> Hi all, I am working on exporting "Johansen test statistics" (Johansen test:
> "ca.jo" in package "urca")to Excel. The problem is that the function output
> is not a number, but like this:
>
> #
> # Johansen-Procedure Unit Root / Cointegration Test #
> #
>
> The value of the test statistic is: 2.7821 9.5965
>
> I want only (2.7821,9.5965), but I don't know how to "extract" these numbers
> from the output. The output object is of type "S4". Can anyone please help
> me? Thanks.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Johansen-test-tp2399545p2399545.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Read in a all-character file and specify field separator and records separator

2010-08-29 Thread Yong Wang
Dear list

I used to use python or awk do preliminary process and then feed into
R. In some circumstances, the data transmission becomes quite a pain.
I am wondering if there is a convenient way to read in R text file
(not data, text file in common sense) and specify field separator and
records separator, so the whole work can be reduced to one-stop
shopping.
or simply, is there one simple way to read in the text file with each
row in a single column. scan(sep="\n") does not work as expected.

Thanks

yong

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question regarding significance of a covariate in a coxme survival

2010-08-29 Thread cheng peng

What statistical measure(s) tend to be answering ALL(?) question of practical
interest? 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Re-Question-regarding-significance-of-a-covariate-in-a-coxme-survival-tp2399386p2399524.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] Making cuts on multivariate data

2010-08-29 Thread David Winsemius


On Aug 30, 2010, at 12:57 AM, David Winsemius wrote:



On Aug 29, 2010, at 10:50 PM, Erik Ramberg wrote:

I'm a newbie to R and  I was hoping someone could answer a simple  
question.  I want to read in an ASCII file with 3 columns - x,y,z.   
Let's say there is a lot of data - 100,000 entries.  I then want to  
histogram x values that pass arbitrary (and complicated) cuts on y  
and/or z.  Likewise, I want to make a scatterplot with x and y,  
with a cut on z values.  Perhaps you have to redefine the vectors  
first.


I'm thinking along the lines of
hist(x) for y>0 .and. sqrt(z)<4


If the data is in a dataframe named dta with columns x,y, and z then:

with( dta[which( dta$y > 0 & sqrt(z) < 4), ],
   hist(x)  )


Should be:
with( dta[which( dta$y > 0 & sqrt(dta$z) < 4), ],

hist(x)  )



or

plot(x,y) for x>0 .and. y>0 .and.z**2 > 100


The strategy generalizes.



I cant find this simple task in a first perusal of some of the  
tutorials.



Any suggestions you could give would be helpful.


Don't forget to read the Posting Guide.




--
David.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 some matrix columns

2010-08-29 Thread Lorenzo Cattarino
Hi,

 

I have the following matrix

 

cc <- matrix (1:21, 3)

cc[,3:4]<- 0

cc

 [,1] [,2] [,3] [,4] [,5] [,6] [,7]

[1,]1400   13   16   19

[2,]2500   14   17   20

[3,]3600   15   18   21

 

and I would like to sum just the values in columns 2, 3 and 4, so to
have something like

 

1  4  13  16  19

2  5  14  17  20

3  6  15  18  21

 

Thanks 

 

Lorenzo


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

2010-08-29 Thread aurumor

Hi all, I am working on exporting "Johansen test statistics" (Johansen test:
"ca.jo" in package "urca")to Excel. The problem is that the function output
is not a number, but like this:

# 
# Johansen-Procedure Unit Root / Cointegration Test # 
# 

The value of the test statistic is: 2.7821 9.5965 

I want only (2.7821,9.5965), but I don't know how to "extract" these numbers
from the output. The output object is of type "S4". Can anyone please help
me? Thanks.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Johansen-test-tp2399545p2399545.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] Making cuts on multivariate data

2010-08-29 Thread David Winsemius


On Aug 29, 2010, at 10:50 PM, Erik Ramberg wrote:

I'm a newbie to R and  I was hoping someone could answer a simple  
question.  I want to read in an ASCII file with 3 columns - x,y,z.   
Let's say there is a lot of data - 100,000 entries.  I then want to  
histogram x values that pass arbitrary (and complicated) cuts on y  
and/or z.  Likewise, I want to make a scatterplot with x and y, with  
a cut on z values.  Perhaps you have to redefine the vectors first.


I'm thinking along the lines of
hist(x) for y>0 .and. sqrt(z)<4


If the data is in a dataframe named dta with columns x,y, and z then:

with( dta[which( dta$y > 0 & sqrt(z) < 4), ],
hist(x)  )



or

plot(x,y) for x>0 .and. y>0 .and.z**2 > 100


The strategy generalizes.



I cant find this simple task in a first perusal of some of the  
tutorials.



 Any suggestions you could give would be helpful.


Don't forget to read the Posting Guide.




--
David.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] while loop until end of file

2010-08-29 Thread Joshua Wiley
Hi Marcel,

Not quite sure what you want the while loop for.  Does this do what you want?

mydat <- read.table(textConnection("
Pair group param1
1   D   10
1   D   10
1   R   10
1   D   10
2   D   10
2   D   10
2   D   10
2   R   10
2   R   10"), header = TRUE)
closeAllConnections()

mydat$Pair <- factor(mydat$Pair)

# Calculate the mean of param1 for each level of group AND of Pair
by(mydat$param1, list(mydat$group, mydat$Pair), mean)

# Since there are two means for each Pair, set ncol = 2 and byrow = TRUE
# That way each row in the matrix represents 1 Pair
mydat2 <- matrix(by(mydat$param1, list(mydat$group, mydat$Pair), mean),
 ncol = 2, byrow = TRUE)
mydat2 <- cbind(mydat2, mydat2[ , 2] - mydat2[ , 1])
colnames(mydat2) <- c("AveParamD", "AveParamR", "diff")
mydat2

Cheers,

Josh

On Sun, Aug 29, 2010 at 9:08 PM, Marcel Curlin
 wrote:
>
> Hi Guys,
> stumped by a simple problem. I would like to take a file of the form
>
> Pair     group     param1
> 1           D           10
> 1           D           10
> 1           R           10
> 1           D           10
> 2           D           10
> 2           D           10
> 2           D           10
> 2           R           10
> 2           R           10
> etc..
>
> and for each pair, calculate the average of param1 for group D entries,
> subtract from the average of param1 for the group R entries, and then write
> the results (ie, AveParam1D  AveParam1R dif) in a tab delimited file. Below
> is the start of my code. the difficulty i am having is in creating a while
> loop that stops once there are no more lines to read from the input file.
> also not sure of the best way to write in the results, though I think I
> should use rbind.
>
> data <- data.frame(alldata)
>
> i <- 1
> # need appropriate while loop
> {
> ss <- subset(data, Pair==i)
> ssD <- subset(ss, DR==D)
> ssR <- subset(ss, DR==R)
> p1 <- mean(ssD$Length)
> p2 <- mean(ssR$Length)
> dif <- p1-p2
> out <- rbind(data.frame(P1, P2, diff)
> i <-i + 1
> }
>
> write.table(out, file="out", quote=F, row.names=F, col.names=T, sep="\t")
>
> I have spent an absurd amount of time trying to sort this out with the
> manual and forum searches. Any suggestions appreciated.
>
> Marcel
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/while-loop-until-end-of-file-tp2399544p2399544.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] while loop until end of file

2010-08-29 Thread Bill.Venables
Eh?

## First calculate the means:

mns <- with(alldata, tapply(param1, list(Pair, group), mean))

## now put the results into a data frame

res <- data.frame(mns, dif = mns[, "D"] - mns[, "R"]) 

## Then write it out if that's your thing.



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Marcel Curlin
Sent: Monday, 30 August 2010 2:08 PM
To: r-help@r-project.org
Subject: [R] while loop until end of file


Hi Guys,
stumped by a simple problem. I would like to take a file of the form

Pair group param1
1   D   10
1   D   10
1   R   10
1   D   10
2   D   10
2   D   10
2   D   10
2   R   10
2   R   10
etc..

and for each pair, calculate the average of param1 for group D entries,
subtract from the average of param1 for the group R entries, and then write
the results (ie, AveParam1D  AveParam1R dif) in a tab delimited file. Below
is the start of my code. the difficulty i am having is in creating a while
loop that stops once there are no more lines to read from the input file.
also not sure of the best way to write in the results, though I think I
should use rbind. 

data <- data.frame(alldata)

i <- 1
# need appropriate while loop
{
ss <- subset(data, Pair==i)
ssD <- subset(ss, DR==D)
ssR <- subset(ss, DR==R)
p1 <- mean(ssD$Length)
p2 <- mean(ssR$Length)
dif <- p1-p2
out <- rbind(data.frame(P1, P2, diff)
i <-i + 1
}

write.table(out, file="out", quote=F, row.names=F, col.names=T, sep="\t")

I have spent an absurd amount of time trying to sort this out with the
manual and forum searches. Any suggestions appreciated. 

Marcel

-- 
View this message in context: 
http://r.789695.n4.nabble.com/while-loop-until-end-of-file-tp2399544p2399544.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] while loop until end of file

2010-08-29 Thread Marcel Curlin

Hi Guys,
stumped by a simple problem. I would like to take a file of the form

Pair group param1
1   D   10
1   D   10
1   R   10
1   D   10
2   D   10
2   D   10
2   D   10
2   R   10
2   R   10
etc..

and for each pair, calculate the average of param1 for group D entries,
subtract from the average of param1 for the group R entries, and then write
the results (ie, AveParam1D  AveParam1R dif) in a tab delimited file. Below
is the start of my code. the difficulty i am having is in creating a while
loop that stops once there are no more lines to read from the input file.
also not sure of the best way to write in the results, though I think I
should use rbind. 

data <- data.frame(alldata)

i <- 1
# need appropriate while loop
{
ss <- subset(data, Pair==i)
ssD <- subset(ss, DR==D)
ssR <- subset(ss, DR==R)
p1 <- mean(ssD$Length)
p2 <- mean(ssR$Length)
dif <- p1-p2
out <- rbind(data.frame(P1, P2, diff)
i <-i + 1
}

write.table(out, file="out", quote=F, row.names=F, col.names=T, sep="\t")

I have spent an absurd amount of time trying to sort this out with the
manual and forum searches. Any suggestions appreciated. 

Marcel

-- 
View this message in context: 
http://r.789695.n4.nabble.com/while-loop-until-end-of-file-tp2399544p2399544.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] Making cuts on multivariate data

2010-08-29 Thread Erik Ramberg
I'm a newbie to R and  I was hoping someone could answer a simple question.  I 
want to read in an ASCII file with 3 columns - x,y,z.  Let's say there is a lot 
of data - 100,000 entries.  I then want to histogram x values that pass 
arbitrary (and complicated) cuts on y and/or z.  Likewise, I want to make a 
scatterplot with x and y, with a cut on z values.  Perhaps you have to redefine 
the vectors first.

I'm thinking along the lines of
hist(x) for y>0 .and. sqrt(z)<4

or

plot(x,y) for x>0 .and. y>0 .and.z**2 > 100

I cant find this simple task in a first perusal of some of the tutorials.  Any 
suggestions you could give would be helpful.

Thanks in advance.
Erik Ramberg

Erik Ramberg


[[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] log y 'axis' of histogram

2010-08-29 Thread Joshua Wiley
Hi Derek,

Here is an option using the package ggplot2:

library(ggplot2)
x <- sample(x = 10:50, size = 50, replace = TRUE)
qplot(x = x, geom = "histogram") + scale_y_log()

However, the log scale is often inappropriate for histograms, because
the y-axis represents counts, which could potentially be 0, and
therefore undefined (R outputs -Inf).  Another option using base
graphics would be something along the lines (no pun intended) of:

temp <- hist(x, plot = FALSE) #get histogram data
plot(x = temp$mids, y = log(temp$counts), type = "h")

HTH,

Josh

On Sun, Aug 29, 2010 at 6:58 PM, Derek M Jones  wrote:
> All,
>
> I have been trying to get calls to hist(...) to be plotted
> with the y-axis having a log scale.
>
> I have tried: par(ylog=TRUE)
>
> I have also looked at the histogram package.
>
> Suggestions welcome.
>
> --
> Derek M. Jones                         tel: +44 (0) 1252 520 667
> Knowledge Software Ltd                 mailto:de...@knosof.co.uk
> Source code analysis                   http://www.knosof.co.uk
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] complete list of Sweave tags (control sequences)

2010-08-29 Thread heyi xiao




Hello
all,

Is
there a complete list of Sweave tags (control sequences) and their usage? For 
instance,
I know a few blow. But I don’t really know how to use them. It seems to me 
that
there is nowhere to find further information. I would really appreciate any
input. Thanks!

Heyi

 

The
few things I’ve heard of, but not sure about the usage many of them.

\Sexpr{}

\Rpackage{}

\SweaveOpts{}

\SweaveInput{}

\SweaveSyntax{}

\Scoderef{}

\Rcode{}




  
[[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] log y 'axis' of histogram

2010-08-29 Thread John Sorkin
How about computing the log of you variable and calling hist() on the log data. 
logy <- log(y)
Hhist(logy)
John
John Sorkin
Chief Biostatistics and Informatics
Univ. of Maryland School of Medicine
Division of Gerontology and Geriatric Medicine
jsor...@grecc.umaryland.edu 
-Original Message-
From: Derek M Jones 
To:  

Sent: 8/29/2010 9:58:35 PM
Subject: [R] log y 'axis' of histogram

All,

I have been trying to get calls to hist(...) to be plotted
with the y-axis having a log scale.

I have tried: par(ylog=TRUE)

I have also looked at the histogram package.

Suggestions welcome.

-- 
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:de...@knosof.co.uk
Source code analysis   http://www.knosof.co.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] log y 'axis' of histogram

2010-08-29 Thread Derek M Jones

All,

I have been trying to get calls to hist(...) to be plotted
with the y-axis having a log scale.

I have tried: par(ylog=TRUE)

I have also looked at the histogram package.

Suggestions welcome.

--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:de...@knosof.co.uk
Source code analysis   http://www.knosof.co.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Using termplot() with transformations of x

2010-08-29 Thread David Winsemius


On Aug 26, 2010, at 7:10 PM, Peter Dunn wrote:


Hi all

I was playing with termplot(), and came across what appears to be an  
inconsistency.


It would appreciate if someone could enlighten me:


# First, generate some data:
y <- rnorm(100)
x <- runif(length(y),1,2)



# Now find the log of x:
logx <- log(x)

# Now fit two models that are exactly the same, but specified  
differently:

m1 <- lm(y~log(x)) # Using log in the call
m2 <- lm(y~logx) # Using the variable logx

# The two termplots() are different:
par(mfrow=c(1,2))
termplot(m1)
termplot(m2)



I see two models that are identical, but produce different  
termplot()s.  In both cases, the independent variable is log(x), but  
is just specified differently.


If this is intended, what is the logic?  Or am I missing something?


I don't understand your complaint, The two termplots are both on the  
scale of the x-variable offered via the data argument (or in this case  
the formula argument) . In one case you offered it a transformed  
value; in the other you offered it an untransformed value and did the  
transformation within the lm function.   termplot() "knew" or was able  
to discern what was going on in the second instance and had no way of  
"knowing" that a transformation had been done in the first. Where is  
the puzzle? (Forgive the anthropomophisation.)


str(m1)
.
.
.
$ terms:Classes 'terms', 'formula' length 3 y ~ log(x)
  .. ..- attr(*, "variables")= language list(y, log(x))
  .. ..- attr(*, "factors")= int [1:2, 1] 0 1
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : chr [1:2] "y" "log(x)"
  .. .. .. ..$ : chr "log(x)"
  .. ..- attr(*, "term.labels")= chr "log(x)"

--
David.


Thanks.

P.


sessionInfo()

R version 2.11.1 (2010-05-31)
x86_64-apple-darwin9.8.0

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base



David Winsemius, MD
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] Putting legend *outside* plotting area

2010-08-29 Thread Ben Tupper
Hi,

On Aug 29, 2010, at 8:00 PM, Worik R wrote:

> Is there  a simple way to put a legend outside the plot area for a  
> simple
> plot?
>
> I found... (at http://www.harding.edu/fmccown/R/)
>
> # Expand right side of clipping rect to make room for the legend
> *par(xpd=T, mar=par()$mar+c(0,0,0,4))*
>
> # Graph autos (transposing the matrix) using heat colors,
> # put 10% of the space between each bar, and make labels
> # smaller with horizontal y-axis labels
> barplot(*t*(autos_data), main="Autos", ylab="Total",
>   col=*heat.colors(3), space=0.1, cex.axis=0.8, las=1,
>   names.arg=c("Mon","Tue","Wed","Thu","Fri"), cex=0.8*)
>
> # Place the legend at (6,30) using heat colors
> legend(*6, 30,* names(*autos_data*), cex=*0.8*,  
> fill=*heat.colors(3)*);
>
> But I do not understand
> *par(xpd=T, mar=par()$mar+c(0,0,0,4))*
>
> Anyway it does not work for me when I change...
>
>
>> y1 <- runif(100, max=1, min=0)
>> y2 <- rnorm(100)
>> ylim <- c(min(y1, y2), max(y1,y2))
>> plot(x, y1, pch=1, ylim=ylim)
>> points(x, y2, pch=2)
>> legend("topleft", legend=c("Uniform", "Normal"), pch=c(1,2))
>
> To
>
>> par(xpd=T, mar=par()$mar+c(0,0,0,4))
>> plot(x, y1, pch=1, ylim=ylim)
>> points(x, y2, pch=2)
>> legend(6, 30, legend=c("Uniform", "Normal"), pch=c(1,2))
>
> I do not get to see the legend at all.
>

I think you want to set xpd to NA (rather than TRUE as in your  
example) according to the docs for par(). "A logical value or NA. If  
FALSE, all plotting is clipped to the plot region, if TRUE, all  
plotting is clipped to the figure region, and if NA, all plotting is  
clipped to the device region."  I have a hind-sight wish that it had  
been defined originally with "plot", "fig" and "dev" instead of FALSE,  
TRUE and NA because I am forgetful and I *always* have to look it up.

Using the mar argument is a way to manage the margin size around the  
plot region within the device region.  It is handy when you want to  
plan for extra annotations along the sides of the figure.  In your  
example the new value of par is set to its original except on the  
right hand side where it picks up 4 extra lines.

mar = par()$mar + c(0,0,0,4)


Cheers,
Ben


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

2010-08-29 Thread Shane O'Mahony
I'm trying to run an epsilon regression model, and am comparing the results
between e1071 and kernlab.  I believe that I'm calling the ksvm and svm
functions the same way but I'm getting different results:

library(e1071); library(kernlab)
ksvm(x=1:100, y=(1:100)/5, type="eps-svr", kpar=list(sigma=1))
svm(x=1:100, y=(1:100)/5, type="eps-regression", gamma=0.5)

I get a different number of support vectors and different fitted values.

Am I doing something wrong?

Thanks,
Sean

[[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] Putting legend *outside* plotting area

2010-08-29 Thread Worik R
Is there  a simple way to put a legend outside the plot area for a simple
plot?

I found... (at http://www.harding.edu/fmccown/R/)

# Expand right side of clipping rect to make room for the legend
*par(xpd=T, mar=par()$mar+c(0,0,0,4))*

# Graph autos (transposing the matrix) using heat colors,
# put 10% of the space between each bar, and make labels
# smaller with horizontal y-axis labels
barplot(*t*(autos_data), main="Autos", ylab="Total",
   col=*heat.colors(3), space=0.1, cex.axis=0.8, las=1,
   names.arg=c("Mon","Tue","Wed","Thu","Fri"), cex=0.8*)

# Place the legend at (6,30) using heat colors
legend(*6, 30,* names(*autos_data*), cex=*0.8*, fill=*heat.colors(3)*);

But I do not understand
*par(xpd=T, mar=par()$mar+c(0,0,0,4))*

Anyway it does not work for me when I change...


> y1 <- runif(100, max=1, min=0)
> y2 <- rnorm(100)
> ylim <- c(min(y1, y2), max(y1,y2))
> plot(x, y1, pch=1, ylim=ylim)
> points(x, y2, pch=2)
> legend("topleft", legend=c("Uniform", "Normal"), pch=c(1,2))

To

> par(xpd=T, mar=par()$mar+c(0,0,0,4))
> plot(x, y1, pch=1, ylim=ylim)
> points(x, y2, pch=2)
> legend(6, 30, legend=c("Uniform", "Normal"), pch=c(1,2))

I do not get to see the legend at all.

I am confused

cheers
Worik

[[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] CRAN (and crantastic) updates this week

2010-08-29 Thread Crantastic
CRAN (and crantastic) updates this week

New packages


* ProjectTemplate (0.1-2)
  Maintainer: John Myles White
  Author(s): John Myles White
  http://crantastic.org/packages/ProjectTemplate

  The ProjectTemplate package provides a function, create.project(),
  that automatically builds a directory for a new R project with a
  clean sub-directory structure and automatic data and library loading
  tools. The hope is that standardized data loading, automatic
  importing of best practice packages, integrated unit testing and
  useful nudges towards keeping a cleanly organized codebase will
  improve the quality of R coding.

* QuACN (1.0)
  Maintainer: Laurin Mueller
  Author(s): Laurin Mueller
  http://crantastic.org/packages/QuACN

  Quantitative Analysis of Complex Networks. This package offers a set
  of topological network measures to analyze complex Networks
  structurally.

* RandForestGUI (1.0)
  Maintainer: Rory Michelland
  Author(s): Rory Michelland , Genevieve Grundmann
 
  http://crantastic.org/packages/RandForestGUI

  A graphical user interface program to analyze microbial profiles
  (taxonomic sequences, fingerprints and microarrays) based on
  conditional inference random forest

* RcmdrPlugin.TextMining (0.1-0)
  Maintainer: Dzemil Lusija
  Author(s): Dzemil Lusija
  http://crantastic.org/packages/RcmdrPlugin-TextMining

  WARNING: This package is currently in beta status! This package
  provide GUI for demonstration of text mining concepts and "tm"
  package. It is implemented as a plugin to the R-Commander, which is
  based on tcl/tk. This set of dialogs can be accessed through the
  menu TextMining that is added to the R-Commander menus.

* SMCP (1.1.1)
  Maintainer: Jin (Gordon) Liu
  Author(s): Jin (Gordon) Liu
  http://crantastic.org/packages/SMCP

  A package containing functions that generate microarray data, fit the
  marginalized linear model with MCP and QA penalties and conduct
  cross-validation to select the tuning parameter.


Updated packages


anapuce (2.2), archetypes (2.0-2), assist (3.0), BLR (1.2), CADStat
(2.2-6), CHNOSZ (0.9-2), coin (1.0-16), demography (1.03), DEoptim
(2.0-6), FEST (0.08), FitAR (1.85), FunNet (1.00-10), futile.paradigm
(1.0.3), GGally (0.2.2), GGMselect (0.1-2), glmulti (0.6-3), JOP
(1.0.4), MIfuns (4.0.16), mondate (0.9.08.23), multitaper (0.1-2),
MuMIn (0.13.9), MuMIn (0.13.8), mutossGUI (0.1-4), nls2 (0.1-3), NMF
(0.5.02), nnc (1.12), party (0.9-9998), PBSddesolve (1.08.11),
penalizedSVM (1.1), PET (0.4.9), pomp (0.32-1), PowerTOST (0.7-2),
pROC (1.3.2), ProjectTemplate (0.1-2), REQS (0.8-7), Rlabkey
(2.1.114), ROracleUI (1.1-3), RPyGeo (0.9-2), RSAGA (0.91-1), RSiena
(1.0.11.119), sifds (0.9-1), SPACECAP (1.0.1), spatstat (1.20-3),
spBayes (0.2-0), stringr (0.4), TIMP (1.10), TRIANG (1.2), WGCNA
(0.93), YieldCurve (3.1)



This email provided as a service for the R community by
http://crantastic.org.

Like it?  Hate it?  Please let us know: crana...@gmail.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] Using termplot() with transformations of x

2010-08-29 Thread Peter Dunn
Hi

>the two models  are identical because of having the same independent
> variable and dependent variable.they produce different termplot()s because
> of they base on different variables,one is x,the other is logx.see the
> lateral axis.

Sure; this is all obvious from the code and the plots.

But my question is *why* two fundamentally identical models produce different 
termplot()s?

As the original post asks:  If this is intended, what is the logic? Or am I 
missing something?

Let me place explain further.

Suppose I try this

m1 <- lm(y~x)
termplot(m1)

and I see that there is a problem.  So I decide to use log(x) as a predictor 
instead of x; I could do this one of two ways:

logx <- log(x)

m2 <- lm(y~logx)
termplot(m2)

m3 <- lm(y~log(x))
termplot(x3)


In the first case, the new termplot() tells me the model looks good.

In the second case, I output is the same as for termplot(m1) produced, and I 
don't really learn anything new.  

So the original questions remain: If this is intended, what is the logic? Or am 
I missing something?

Perhaps I could add: How do I explain and justify this behaviour to someone?

Thanks.

P.



Peter Dunn: Biostatistician (Room T4.12)
School of Health and Sport Science
Faculty of Science, Health and Education  ML-34
University of the Sunshine Coast, Locked Bag 4
Maroochydore DC Qld 4558
 
Tel: +61 7 5456 5085
Fax: +61 7 5430 2896
Email: pdu...@usc.edu.au
www.usc.edu.au

CRICOS Provider Number: 01595D
This communication is intended for the recipient only and should not be 
forwarded, distributed or otherwise read by others without express permission. 
The views expressed in this email are not necessarily those of the University 
of the Sunshine Coast.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question regarding significance of a covariate in a coxme survival

2010-08-29 Thread Norm Matloff
Using a p-value to make any kind of decision is questionable to begin
with, and especially unreliable in choosing covariates in regression.
Old studies, e.g. by Walls and Weeks and by Bendel and Afifi, have shown
that if predictive ability is the criterion of interest and one wishes
to use p-values for deciding whether to include a covariate, one should
set the p-value bar very large, at 0.25 and even 0.40.

By contrast, methods such as AIC are aimed at avoiding overfitting, by
penalizing models with large numbers of covariates.  Same for Mallows'
Cp, cross validation etc.

So, the p-value and AIC are answering quite different questions, and
thus should not be expected to give the same or even similar results.
But, worse than that, many point out that p-values tend not to be
answering ANY question of practical interest.

It's a shame that the use of p-values is so entrenched.  I can expand on
this, with references, if there is interest.

Norm Matloff
Professor of Computer Science (formerly Statistics)
University of California, Davis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Finding functions of large dataset for numerical integration

2010-08-29 Thread David Winsemius


On Aug 29, 2010, at 3:42 PM, sam.e wrote:



Hello everyone,

I have been trying to figure out away to integrate under a spline  
produced
by the package tps(fields). As the package does not output functions  
I am
trying to do something similar to the trapezium rule. My data are 3D  
(x, y &

z). I have extracted from the surface output by Tps the values of z at
regular intervals so that I have a grid of figures, for example:

1  4  6  6  8
8  3  2  7  7
2  3  4  9  7
1  2  5  6  7
0  1  4  5  6

I was wondering what the best method for working out the functions  
of the
squares between the number corner points is? I have a number of  
these to do
and am struggling to think of a code or where to look that will  
process my

data in this way so that I can then integrate.

Any help or advice would be much appreciated!


Not sure this is the perfect solution since it does not take into  
account the trapezoidal approximations that might increase its  
accuracy but here is some code that Chuck Berry offered a couple of  
months back to improve some code I had offered as a 2D-ECDF function:


> ?table
> ecdf.tbl2 <-  # from Chuck Berry
+   function(mat) {
+   mat[is.na(mat)] <- 0
+   t( apply( apply( mat,2, cumsum ), 1, cumsum ))}
>
> indat<- read.table(textConnection("1  4  6  6  8
+ 8  3  2  7  7
+ 2  3  4  9  7
+ 1  2  5  6  7
+ 0  1  4  5  6 ")  )
> ecdf.tbl2(indat)
 V1 V2 V3 V4  V5
[1,]  1  5 11 17  25
[2,]  9 16 24 37  52
[3,] 11 21 33 55  77
[4,] 12 24 41 69  98
[5,] 12 25 46 79 114

Maybe it will give you some useful ideas since your system is only 2d.  
There is also a mecdf package, that might be examined for ideas. I  
seem to remember reading that the functions in the old package "adapt"  
had been incorporated elsewhere in the R panoply. Running:

??"multivariate integration"
... makes me think that package cubature might be what I am remembering.


--
David Winsemius, MD
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] Finding source files automatically within a script

2010-08-29 Thread Gabor Grothendieck
On Sun, Aug 29, 2010 at 1:13 PM, Abhisek  wrote:
> Hi there,
>
> Ive tried trawling the lists for a solution but I could not find any
> matches.  I am typing up all my code on a Linux machine and I call this
> other script file from my script file using source("foo.r").  Now sometimes
> i access my folder from my Windows machine at work (the files are on
> dropbox).  But of course my windows machine would not understand the linux
> path name.
>
> Is there any syntax for searching the file system for "foo.r" from within
> the script file that I am writing?  I know that I can always change the
> working directory to the one where the script file is stored but is there
> any other way?
>
> Thanks!
> Abhisek Banerjee
>

You could (1) use file.exists to successively check specific paths.
It will return FALSE if the path does not exist letting you skip over
the bad paths.  See ?file.exists

You could alternately (2) set an option in the your .Profile on both
machines (?options, ?getOption, ?Startup), (3) outside of R set up
environment variables on both machines reading them in with Sys.getenv
or (4) set up configuration files (e.g. a file with just one line
giving the path to the file) which you read in from your home
directory e.g., readLines("~/.myconfig")  Note that ~ works from
within R even on Windows and forward slashes work in Windows filenames
from within R as well as backslashes.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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 prb (Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : )

2010-08-29 Thread David Winsemius


On Aug 29, 2010, at 3:13 PM, moleps wrote:



glm(A~B+C+D+E+F,family = binomial(link =  
"logit"),data=tre,na.action=na.omit)

Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
 contrasts can be applied only to factors with 2 or more levels

however,

glm(A~B+C+D+E,family = binomial(link =  
"logit"),data=tre,na.action=na.omit)


runs fine

glm(A~B+C+D+F,family = binomial(link =  
"logit"),data=tre,na.action=na.omit)


runs fine



glm(A~E+F,family = binomial(link =  
"logit"),data=tre,na.action=na.omit)

Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
 contrasts can be applied only to factors with 2 or more levels

Why is this? Could it be due to collinearity between the two?


Perhaps, at least to the extent that the term "collinearity" is an  
appropriate term for factor interactions. The obvious question at this  
point is: What does:


with( tre, table(E,F) )   # show?

--

David Winsemius, MD
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] Saving plot to tiff, with high resolution for publication ?

2010-08-29 Thread David Winsemius


On Aug 29, 2010, at 12:46 PM, Tal Galili wrote:


Hello all.

A Journal we are sending an article to is asking for the following:

To ensure the best reproduction quality of your figures we would  
appreciate

high resolution files. All figures should preferably be in TIFF or EPS
format... and should have the following resolution: Graph: 800 -  
1200 DPI


Photo: 400 - 800 DPI

Color (only CMYK): 300 - 400 DPI (DPI = dots per inch)

Since I am sending a graph, I am trying to save it using tiff.

Here is the code I am using:

tiff(filename = "c:\\aaa.tiff",

res = 800, pointsize = 2)


?tiff

(Merely from reading the help pages... not claiming to be an expert in  
graphics devices.) At the moment I suspect you are running into  
problems because the default units for the height and width of the  
tiff device is in pixels (="px") and the default size for each is 480.  
The width in pixels is less than 800 so you need to get your 800 into  
480 by dividing by 2.  Perhaps changing the units to "cm" or "in" and  
then the using materially smaller sizes for height and width you can  
get more satisfactory combinations of size and resolution.


(Of course, this does not apply to EPS since it is not a raster image  
format. Either your publisher is confused on this point or you haven't  
faithfully transmitted their message.)


--
David.


plot(1:100)

dev.off()

But sadly, it produces a very "bulky" image (and if I where to not use
pointsize = 2, I would get the error massage:

Error in plot.new() : figure margins too large

)


I am clearly missing something basic here about the use of DPI, I  
would

appreciate any help in figuring this out.

Thanks!


Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il  
(Hebrew) |

www.r-statistics.com (English)
--

[[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
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] Saving plot to tiff, with high resolution for publication ?

2010-08-29 Thread Joshua Wiley
Hi Tal,

You have set the resolution, but you have not set the width/height.
The res argument generally controls how many pixels per inch (PPI
which is often used similarly to DPI).  So if you want 800 DPI and you
want it to be a 4 x 4 inch graph something like:

tiff(file = "temp.tiff", width = 3200, height = 3200, units = "px", res = 800)
plot(1:10, 1:10)
dev.off()

This will make a file that is 3200 x 3200 pixels, with an 800
resolution gives you 3200/800 = 4 inches.

I would also recommend choosing some sort of compression or you will
end up with a rather large file.

Cheers,

Josh

On Sun, Aug 29, 2010 at 9:46 AM, Tal Galili  wrote:
> Hello all.
>
> A Journal we are sending an article to is asking for the following:
>
>  To ensure the best reproduction quality of your figures we would appreciate
> high resolution files. All figures should preferably be in TIFF or EPS
> format... and should have the following resolution: Graph: 800 - 1200 DPI
>
> Photo: 400 - 800 DPI
>
> Color (only CMYK): 300 - 400 DPI (DPI = dots per inch)
>
> Since I am sending a graph, I am trying to save it using tiff.
>
> Here is the code I am using:
>
> tiff(filename = "c:\\aaa.tiff",
>
>     res = 800, pointsize = 2)
>
> plot(1:100)
>
> dev.off()
>
> But sadly, it produces a very "bulky" image (and if I where to not use
> pointsize = 2, I would get the error massage:
>
>  Error in plot.new() : figure margins too large
>
> )
>
>
> I am clearly missing something basic here about the use of DPI, I would
> appreciate any help in figuring this out.
>
> Thanks!
>
>
> Tal
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> --
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] glm prb (Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : )

2010-08-29 Thread moleps

glm(A~B+C+D+E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit)
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : 
  contrasts can be applied only to factors with 2 or more levels

however,

glm(A~B+C+D+E,family = binomial(link = "logit"),data=tre,na.action=na.omit)

runs fine

glm(A~B+C+D+F,family = binomial(link = "logit"),data=tre,na.action=na.omit)

runs fine



glm(A~E+F,family = binomial(link = "logit"),data=tre,na.action=na.omit)
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") : 
  contrasts can be applied only to factors with 2 or more levels

Why is this? Could it be due to collinearity between the two?


Regards,

//M

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Finding functions of large dataset for numerical integration

2010-08-29 Thread sam.e

Hello everyone,

I have been trying to figure out away to integrate under a spline produced
by the package tps(fields). As the package does not output functions I am
trying to do something similar to the trapezium rule. My data are 3D (x, y &
z). I have extracted from the surface output by Tps the values of z at
regular intervals so that I have a grid of figures, for example:

1  4  6  6  8
8  3  2  7  7
2  3  4  9  7
1  2  5  6  7
0  1  4  5  6 

I was wondering what the best method for working out the functions of the
squares between the number corner points is? I have a number of these to do
and am struggling to think of a code or where to look that will process my
data in this way so that I can then integrate.

Any help or advice would be much appreciated!

Sam
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Finding-functions-of-large-dataset-for-numerical-integration-tp2399305p2399305.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] Saving plot to tiff, with high resolution for publication ?

2010-08-29 Thread Barry Rowlingson
On Sun, Aug 29, 2010 at 5:46 PM, Tal Galili  wrote:
> Hello all.
>
> A Journal we are sending an article to is asking for the following:
>
>  To ensure the best reproduction quality of your figures we would appreciate
> high resolution files. All figures should preferably be in TIFF or EPS
> format... and should have the following resolution: Graph: 800 - 1200 DPI
>
> Photo: 400 - 800 DPI
>
> Color (only CMYK): 300 - 400 DPI (DPI = dots per inch)
>
> Since I am sending a graph, I am trying to save it using tiff.

 Firstly, EPS is a vector format so DPI doesn't make any sense (except
for embedding raster image data within it).

 Secondly, how do you know many dots (pixels) to make your image if
you don't know how big in inches your image is going to be?

 Thirdly, if its a graph, it's probably best saved as an EPS to
preserve the inherent vector nature of a plot.

 Fourthly, I should have answered this on stackoverflow.org in order
to increase my reputation points :) Or maybe decrease them :)

 Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Finding source files automatically within a script

2010-08-29 Thread Abhisek
Hi there,

Ive tried trawling the lists for a solution but I could not find any
matches.  I am typing up all my code on a Linux machine and I call this
other script file from my script file using source("foo.r").  Now sometimes
i access my folder from my Windows machine at work (the files are on
dropbox).  But of course my windows machine would not understand the linux
path name.

Is there any syntax for searching the file system for "foo.r" from within
the script file that I am writing?  I know that I can always change the
working directory to the one where the script file is stored but is there
any other way?

Thanks!
Abhisek Banerjee

[[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] Interpreting cv.glm

2010-08-29 Thread M_miller

Hey!

Just a quick question:

How do you interpret cross-validation error?

For my model the function cv.glm returns a cross validation error of 0.31 

does this mean to say that model has an accuracy of 0.69
(69 Percent of points are correctly classified)?

Thanks,  

Mark
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Interpreting-cv-glm-tp2399135p2399135.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] Saving plot to tiff, with high resolution for publication ?

2010-08-29 Thread Tal Galili
Hello all.

A Journal we are sending an article to is asking for the following:

 To ensure the best reproduction quality of your figures we would appreciate
high resolution files. All figures should preferably be in TIFF or EPS
format... and should have the following resolution: Graph: 800 - 1200 DPI

Photo: 400 - 800 DPI

Color (only CMYK): 300 - 400 DPI (DPI = dots per inch)

Since I am sending a graph, I am trying to save it using tiff.

Here is the code I am using:

tiff(filename = "c:\\aaa.tiff",

 res = 800, pointsize = 2)

plot(1:100)

dev.off()

But sadly, it produces a very "bulky" image (and if I where to not use
pointsize = 2, I would get the error massage:

 Error in plot.new() : figure margins too large

)


I am clearly missing something basic here about the use of DPI, I would
appreciate any help in figuring this out.

Thanks!


Tal

Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[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] Three-dimensional contingency table

2010-08-29 Thread David Winsemius


On Aug 28, 2010, at 10:58 PM, Randklev, Charles wrote:


Hi,

I am trying to assemble a three-way contingency table examining the  
presence/absence of mussels, water depth (Depth1 and Depth 2) and  
water velocity (Flow vs. No Flow). I have written the following code  
listed below; however, when run the glm I get the following message,  
"Error in model.frame.default(formula = Count ~ MP + wd + wv,  
drop.unused.levels = TRUE) : variable lengths differ (found for  
'MP')". This may be something simple, if so I apologize. Any help  
would be greatly appreciated.




Best,
C.R.

numbers <- c(1134,956,328,529,435,599,27,99)
dim(numbers) <- c(2,2,2)
numbers
dimnames(numbers)[[3]] <-list("Mussels", "No Mussels")
dimnames(numbers)[[2]] <- list("Flow", "No Flow")
dimnames(numbers)[[1]] <- list("Depth1", "Depth2")
ftable(numbers)
as.data.frame.table(numbers)
frame <- as.data.frame.table(numbers)
names(frame) <- c("wd", "wv", "MP", "Count")
frame
attach(frame)
model1 <- glm(Count~MP+wd+wv,poisson)


I don't get that error, so maybe you have more than one MP variable  
after attaching "frame". Have you used ls() recently. If there is an  
extra "MP" you should see it there but it shouldn't show up if it is  
only attached. The attach function is a common cause of perplexing  
errors.


--
David.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] take component names of a list

2010-08-29 Thread Dimitris Rizopoulos

check at the online help file of function ?names(), and then try this:

names(list.a)


I hope it helps.

Best,
Dimitris


On 8/29/2010 5:51 PM, Hyunchul Kim wrote:

Hi, all

I want to take a vector of component names of a list.

list.a<- list('x'=1, 'y'=2)

how to get a c('x','y') from list.a?

Thanks in advance,

Hyunchul

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



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] need help for a repackaging problem!

2010-08-29 Thread Samy Khezami
Hy,

I had a mistake on a function of a package i have created!
I have solved it and then i repackaged and installed the modified package.
I use to launch R from Excel!
And so when i launch R, and next call my function from the workspace, i
still find the problem on my function.
And when i read on my workspace, the source code of my function, i find the
old version of my function (the one from the precedent version of my
package)!
If one of you have ever met this kind of problem, could you help me.

Thanks


Samy Khezami

-- 
Samy Khezami

M.S. Quantitative Finance
EM Lyon Business School
0033625430829
samy-khezami@em-lyon.com

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] take component names of a list

2010-08-29 Thread Henrique Dallazuanna
Try this:

names(list.a)

On Sun, Aug 29, 2010 at 12:51 PM, Hyunchul Kim
wrote:

> Hi, all
>
> I want to take a vector of component names of a list.
>
> list.a <- list('x'=1, 'y'=2)
>
> how to get a c('x','y') from list.a?
>
> Thanks in advance,
>
> Hyunchul
>
>[[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

[[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] take component names of a list

2010-08-29 Thread Hyunchul Kim
Hi, all

I want to take a vector of component names of a list.

list.a <- list('x'=1, 'y'=2)

how to get a c('x','y') from list.a?

Thanks in advance,

Hyunchul

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to take a os.path.basename

2010-08-29 Thread Henrique Dallazuanna
Take a look on ?basename help page.

On Sun, Aug 29, 2010 at 12:07 PM, Hyunchul Kim
wrote:

> Hi, all
>
> I made a simple R script to take the basename of a file without directory
> names.
>
> path.splitted <- strsplit('/path/to/a_basename', '/')
> path.length <- length(path.splitted[[1]])
> basename <- path.splitted[[1]][path.length] # basename <- 'a_basename'
>
> Is there a simple function for this?
>
> something like os.path.basename(a_filename) of python?
>
> Thanks in advance,
>
> Hyunchul
>
>[[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

[[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] how to take a os.path.basename

2010-08-29 Thread Hyunchul Kim
Hi, all

I made a simple R script to take the basename of a file without directory
names.

path.splitted <- strsplit('/path/to/a_basename', '/')
path.length <- length(path.splitted[[1]])
basename <- path.splitted[[1]][path.length] # basename <- 'a_basename'

Is there a simple function for this?

something like os.path.basename(a_filename) of python?

Thanks in advance,

Hyunchul

[[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] Question regarding significance of a covariate in a coxme survival model

2010-08-29 Thread C. Peng

My suggestion for Teresa: 

If compare model 1 and model 2 with model 0 respectively, the (penalized)
likelihood ratio test is valid. 
IF you compare model 2 with model 3, the (penalized) likelihood ratio test
is invalid. You may want to use AIC/SBC to make a subjective decision. 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-significance-of-a-covariate-in-a-coxme-survival-model-tp2313880p2399116.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] Question regarding significance of a covariate in a coxme survival model

2010-08-29 Thread Cheng Peng

My suggestion:

If compare model 1 and model 2 with model 0 respectively, the (penalized)
likelihood ratio test is valid.
IF you compare model 2 with model 3, the (penalized) likelihood ratio test
is invalid. You may want to use AIC/SBC to make a subjective decision.


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-significance-of-a-covariate-in-a-coxme-survival-model-tp2313880p2399095.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] Three-dimensional contingency table

2010-08-29 Thread Cheng Peng

I didn't see any error when I ran your code in my computer:

> numbers <- c(1134,956,328,529,435,599,27,99) 
> dim(numbers) <- c(2,2,2) 
> numbers 
, , 1

 [,1] [,2]
[1,] 1134  328
[2,]  956  529

, , 2

 [,1] [,2]
[1,]  435   27
[2,]  599   99

> dimnames(numbers)[[3]] <-list("Mussels", "No Mussels") 
> dimnames(numbers)[[2]] <- list("Flow", "No Flow") 
> dimnames(numbers)[[1]] <- list("Depth1", "Depth2") 
> ftable(numbers) 
Mussels No Mussels
  
Depth1 Flow1134435
   No Flow  328 27
Depth2 Flow 956599
   No Flow  529 99
> as.data.frame.table(numbers) 
Var1Var2   Var3 Freq
1 Depth1FlowMussels 1134
2 Depth2FlowMussels  956
3 Depth1 No FlowMussels  328
4 Depth2 No FlowMussels  529
5 Depth1Flow No Mussels  435
6 Depth2Flow No Mussels  599
7 Depth1 No Flow No Mussels   27
8 Depth2 No Flow No Mussels   99
> frame <- as.data.frame.table(numbers) 
> names(frame) <- c("wd", "wv", "MP", "Count") 
> frame 
  wd  wv MP Count
1 Depth1FlowMussels  1134
2 Depth2FlowMussels   956
3 Depth1 No FlowMussels   328
4 Depth2 No FlowMussels   529
5 Depth1Flow No Mussels   435
6 Depth2Flow No Mussels   599
7 Depth1 No Flow No Mussels27
8 Depth2 No Flow No Mussels99
> attach(frame) 
> model1 <- glm(Count~MP+wd+wv,poisson) 
> summary(model1)

Call:
glm(formula = Count ~ MP + wd + wv, family = poisson)

Deviance Residuals: 
   1 2 3 4 5 6 7
8  
  2.5545   -7.0682   -0.13437.48891.05555.7533  -11.0107  
-4.2551  

Coefficients:
 Estimate Std. Error z value Pr(>|z|)
(Intercept)   6.956680.02631 264.414  < 2e-16 ***
MPNo Mussels -0.932370.03466 -26.900  < 2e-16 ***
wdDepth2  0.126290.03127   4.039 5.37e-05 ***
wvNo Flow-1.156260.03657 -31.618  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 2279.76  on 7  degrees of freedom
Residual deviance:  286.14  on 4  degrees of freedom
AIC: 355.18

Number of Fisher Scoring iterations: 4


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Three-dimensional-contingency-table-tp2398915p2399062.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] Question regarding significance of a covariate in a coxme survival model

2010-08-29 Thread Cheng Peng

The likelihood ratio test is more reliable when one model is nested in the
other. This true for your case.
AIC/SBC are usually used when two models are in a hiearchical structure.
Please also note that any decision made
made based on AIC/SBC scores are very subjective since no sampling
distribution can be used to make a "rigorous" decision. 
regarding the magnitutes between the loglikelihood and AIC/SBC, I would say
the author must used a modified version in coxme()
since several different modified AIC/SBC scores are running in practice.


My suggestion would be to use LR test for your case:

For the integrated likelihhod:

LL.small.model = - 467.3549(including lifedxm)
LL.large.model = - 471.(excluding lifedxm)
DF.diff = 3 - 1 = 2

LR: -2*(- 471. + 467.3549) = 7.9568
p-value: 1-pchisq(7.9568,2) = 0.01871556


For the penalized likelihhod:

LPL.small.model = -435.2096 (including lifedxm)
LPL.large.model = -436.0478 (excluding lifedxm)
DF.diff = 3 - 1 = 2

PLR: -2*(- 436.0478 + 435.2096 ) = 1.6764
p-value: 1-pchisq(1.6764,2) = 0.4324883

Two different likehood methods produce different results, which one you
should use depends 
on which likelihood makes more sense to you (or which likehood is better).

HTH

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-significance-of-a-covariate-in-a-coxme-survival-model-tp2313880p2399090.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] Question regarding significance of a covariate in a coxme survival model

2010-08-29 Thread C. Peng

The likelihood ratio test is more reliable when one model is nested in the
other. This true for your case. 
AIC/SBC are usually used when two models are in a hiearchical structure.
Please also note that any decision made made based on AIC/SBC scores are
very subjective since no sampling distribution can be used to make a
"rigorous" decision. Regarding the magnitutes between the loglikelihood and
AIC/SBC, I would say the author must used a modified version in coxme()
since several different modified AIC/SBC scores are running in practice. 


My suggestion would be to use LR test for your case: 

For the integrated likelihhod: 

LL.small.model = - 467.3549(including lifedxm) 
LL.large.model = - 471.(excluding lifedxm) 
DF.diff = 3 - 1 = 2 

LR: -2*(- 471. + 467.3549) = 7.9568 
p-value: 1-pchisq(7.9568,2) = 0.01871556 


For the penalized likelihhod: 

LPL.small.model = -435.2096 (including lifedxm) 
LPL.large.model = -436.0478 (excluding lifedxm) 
DF.diff = 3 - 1 = 2 

PLR: -2*(- 436.0478 + 435.2096 ) = 1.6764 
p-value: 1-pchisq(1.6764,2) = 0.4324883 

Two different likehood methods produce different results, which one you
should use depends 
on which likelihood makes more sense to you (or which likehood is better). 

HTH 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Question-regarding-significance-of-a-covariate-in-a-coxme-survival-model-tp2313880p2399114.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] extracting year from date

2010-08-29 Thread Henrique Dallazuanna
Try this:


format(data$start, "%Y")

On Sun, Aug 29, 2010 at 11:32 AM, André de Boer  wrote:

> Hi,
>
> Sorry for this simple question but I searched the internet and can't find
> the answer.
>
> >From a date I want the year extracted:
> > data$start[1
> [1] "2006-11-01"
>
> Thanks for the answer,
> Andre
>
>[[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

[[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] extracting year from date

2010-08-29 Thread André de Boer
Hi,

Sorry for this simple question but I searched the internet and can't find
the answer.

>From a date I want the year extracted:
> data$start[1
[1] "2006-11-01"

Thanks for the answer,
Andre

[[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] Three-dimensional contingency table

2010-08-29 Thread Ista Zahn
Hi,
Your example works fine for me. My guess is that you have one of wd,
wv, MP, or Count defined as a global variable. This is the main reason
the use of attach() is discouraged by many people on this list. The
safer thing to do is

model1 <- glm(Count~MP+wd+wv,poisson. data = frame)

-Ista
On Sat, Aug 28, 2010 at 10:58 PM, Randklev, Charles
 wrote:
> Hi,
>
> I am trying to assemble a three-way contingency table examining the 
> presence/absence of mussels, water depth (Depth1 and Depth 2) and water 
> velocity (Flow vs. No Flow). I have written the following code listed below; 
> however, when run the glm I get the following message, "Error in 
> model.frame.default(formula = Count ~ MP + wd + wv, drop.unused.levels = 
> TRUE) : variable lengths differ (found for 'MP')". This may be something 
> simple, if so I apologize. Any help would be greatly appreciated.
>
> Best,
> C.R.
>
> numbers <- c(1134,956,328,529,435,599,27,99)
> dim(numbers) <- c(2,2,2)
> numbers
> dimnames(numbers)[[3]] <-list("Mussels", "No Mussels")
> dimnames(numbers)[[2]] <- list("Flow", "No Flow")
> dimnames(numbers)[[1]] <- list("Depth1", "Depth2")
> ftable(numbers)
> as.data.frame.table(numbers)
> frame <- as.data.frame.table(numbers)
> names(frame) <- c("wd", "wv", "MP", "Count")
> frame
> attach(frame)
> model1 <- glm(Count~MP+wd+wv,poisson)
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] About plot graphs

2010-08-29 Thread Stephen Liu
Hi David,

Thanks for your advice.

B.R.
Stephen L



- Original Message 
From: David Winsemius 
To: Stephen Liu 
Cc: "r-help@r-project.org" 
Sent: Sun, August 29, 2010 1:52:50 AM
Subject: Re: [R] About plot graphs


On Aug 28, 2010, at 9:15 AM, Stephen Liu wrote:

> Hi Gavin,
> 
> Lot of thank for your detail explanation.
> 
> Just looked at;
> ?with
> ?within
> 
> Both "Evaluate an Expression in a Data Environment"
> 
> Usage: Both;
> with(data, expr, ...)
> within(data, expr, ...)
> 
> Details:
> .
> ‘within’ is similar, except that it examines the environment after
> the evaluation of ‘expr’ and makes the corresponding modifications
> to ‘data’ (this may fail in the data frame case if objects are
> created which cannot be stored in a data frame), and returns it.
> ‘within’ can be used as an alternative to ‘transform’.
> 
> What does it mean ". examines the environment after the evaluation of 
>'expr'

I take it to mean that the results of expr (applied to "data" and anything else 
used as arguments) are then used to update "data", but only if possible, i.e., 
if those results are congruent with the structure of "data". I read that phrase 
as covering the "if possible" assessment process.


> ."
> 
> Tks
> 
> B.R.
> Stephen
> 
> 
> B.R.
> Stephen L
> 
> 
> 
> - Original Message 
> From: Gavin Simpson 
> To: Stephen Liu 
> Cc: "r-help@r-project.org" 
> Sent: Sat, August 28, 2010 3:28:34 PM
> Subject: Re: [R] About plot graphs
> 
> On Fri, 2010-08-27 at 22:14 -0700, Stephen Liu wrote:
>> Hi Gavin,
>> 
>> 
>> Thanks for your advice and the examples explaining plotting settings.
>> 
>> The steps on your examples work on my test.
>> 
>> 
>>> 2) Don't attach() things, you are asking for trouble
>> 
>>> If a function has a formula method (which plot does) then use it like
>>> this: plot(Draft_No. ~ Day_of_year, data = Test01)
>> 
>>> If the function doesn't have a formula method, then wrap it in a
>>> with()
>>> call:
>> 
>>> with(Test01, plot(Day_of_year, Draft_No.))
>> 
>>> No need for attach.
>> 
>> 
>> Noted and thanks.  What will be the problem caused by "attach()"?
> 
> If you change the underlying data, this is not reflected in the attached
> copy, because it is just that, a "copy"[1] created at the point at which
> you attached the object. E.g.
> 
> ## Some data, which we attach
> dat <- data.frame(A = 1:10, B = letters[1:10])
> attach(dat)
> ## Look at A
> A
> ## Change or dat object by altering the A component
> dat <- within(dat, A <- LETTERS[1:10])
> ## Look at A
> A
> ## Look at what A really is
> with(dat, A)
> 
> Using with() and within() etc have two key advantages over attach: i)
> only one version of the data/object exists, ii) the intention of code
> using:
> 
> with(dat, "do something with A")
> 
> is much more clear than
> 
> "do something with A"
> 
> A could be anything, anywhere. More info is on the ?attach help page.
> 
> [1] ?attach contains the details of what I mean by "copy"
> 
>> 
>>> dev.new(height = 6, width = 12)
>>> layout(matrix(1:2, ncol = 2))
>>> op <- par(pty = "s") ## this is the important bit
>>> plot(runif(100), rnorm(100))
>>> plot(runif(100), rnorm(100), col = "red")
>>> par(op) ## now reset the pars
>>> layout(1)
>> 
>> What is the function of layout(1) ?  Tks
> 
> The opposite of
> 
> layout(matrix(1:4, ncol = 2))
> 
> for example. It ( layout(1) ) says create a layout with a single
> plotting region. So we use it to reset the current device back to
> normal. I find it is good working practice to tidy up after doing plots
> like this. In the code above, we change both the layout() and the
> plotting parameters (via par() ), and the last two lines of code in that
> example reset these changes.
> 
> G
> 
>> 
>> B.R.
>> satimis
>> 
>> 
>> 
>> 
>> - Original Message 
>> From: Gavin Simpson 
>> To: Stephen Liu 
>> Cc: "r-help@r-project.org" 
>> Sent: Fri, August 27, 2010 5:38:40 PM
>> Subject: Re: [R] About plot graphs
>> 
>> On Fri, 2010-08-27 at 02:05 -0700, Stephen Liu wrote:
>>> Hi Gavin,
>>> 
>>> Thanks for your advice which works for me.
>>> 
>>> 
>>> (rectangular window)
>>> dev.new(height = 6, width = 12)
>>> layout(matrix(1:2, nrow=1))
>>> plot(Test01$Day_of_year, Test01$Draft_No.)
>>> attach(Test01)
>>> plot(Day_of_year,Draft_No.)
>> 
>> 1) I can't reproduce this; where/what is Test01? But don;t bother
>> sending, see my example below
>> 2) Don't attach() things, you are asking for trouble
>> 
>> If a function has a formula method (which plot does) then use it like
>> this: plot(Draft_No. ~ Day_of_year, data = Test01)
>> 
>> If the function doesn't have a formula method, then wrap it in a with()
>> call:
>> 
>> with(Test01, plot(Day_of_year, Draft_No.))
>> 
>> No need for attach.
>> 
>>> 
>>> (rectangular window in vertical position)
>>> dev.new(height = 12, width = 4)
>>> layout(matrix(1:2, nrow=2))
>>> plot(Test01$Day_of_year, Test01$Draft_No.)
>>> plot(Day_of_year,Draft_No.)
>>> 
>>> (height = 1

Re: [R] About plot graphs

2010-08-29 Thread Stephen Liu
Hi Greg,

Thanks for your advice.

> data(women)
> women
   height weight
1  58115
2  59117
3  60120
4  61123
5  62126
6  63129
7  64132
8  65135
9  66139
10 67142
11 68146
12 69150
13 70154
14 71159
15 72164
> 

> attach(women)
> library(lattice)

> data(singer)
Warning message:
In data(singer) : data set 'singer' not found


Continued;

> attach(singer)

The following object(s) are masked from women :

 height 

> plot(weight,height)
Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ

No graph plotted.


> detach()
> attach(singer[1:15,])

The following object(s) are masked from women :

 height 

> plot(weight,height)

A graph weight(x) height(y) plotted.


B.R.
Stephen L






- Original Message 
From: Greg Snow 
To: Stephen Liu ; "gavin.simp...@ucl.ac.uk" 

Cc: "r-help@r-project.org" 
Sent: Sun, August 29, 2010 2:58:12 AM
Subject: RE: [R] About plot graphs

Gavin gave some problems with relying attaching data, here is another example, 
somewhat artificial, but not unrealistic (I had similar to this happen to me 
before I learned better):

attach(women)
# do some stuff
library(lattice)
attach(singer)
# do some more stuff

# now we want to go back and look at the women data
plot(weight,height)

#or even worse
detach()
attach(singer[1:15,])

plot(weight,height)

# what conclusions do we draw from the plot?

detach()
detach()




--
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 Stephen Liu
> Sent: Friday, August 27, 2010 11:14 PM
> To: gavin.simp...@ucl.ac.uk
> Cc: r-help@r-project.org
> Subject: Re: [R] About plot graphs
>
> Hi Gavin,
>
>
> Thanks for your advice and the examples explaining plotting settings.
>
> The steps on your examples work on my test.
>
>
> > 2) Don't attach() things, you are asking for trouble
>
> > If a function has a formula method (which plot does) then use it like
> > this: plot(Draft_No. ~ Day_of_year, data = Test01)
>
> > If the function doesn't have a formula method, then wrap it in a
> > with()
> > call:
>
> > with(Test01, plot(Day_of_year, Draft_No.))
>
> > No need for attach.
>
>
> Noted and thanks.  What will be the problem caused by "attach()"?
>
>
> > dev.new(height = 6, width = 12)
> > layout(matrix(1:2, ncol = 2))
> > op <- par(pty = "s") ## this is the important bit
> > plot(runif(100), rnorm(100))
> > plot(runif(100), rnorm(100), col = "red")
> > par(op) ## now reset the pars
> > layout(1)
>
> What is the function of layout(1) ?  Tks
>
>
> B.R.
> satimis
>
>
>
>
> - Original Message 
> From: Gavin Simpson 
> To: Stephen Liu 
> Cc: "r-help@r-project.org" 
> Sent: Fri, August 27, 2010 5:38:40 PM
> Subject: Re: [R] About plot graphs
>
> On Fri, 2010-08-27 at 02:05 -0700, Stephen Liu wrote:
> > Hi Gavin,
> >
> > Thanks for your advice which works for me.
> >
> >
> > (rectangular window)
> > dev.new(height = 6, width = 12)
> > layout(matrix(1:2, nrow=1))
> > plot(Test01$Day_of_year, Test01$Draft_No.)
> > attach(Test01)
> > plot(Day_of_year,Draft_No.)
>
> 1) I can't reproduce this; where/what is Test01? But don;t bother
> sending, see my example below
> 2) Don't attach() things, you are asking for trouble
>
> If a function has a formula method (which plot does) then use it like
> this: plot(Draft_No. ~ Day_of_year, data = Test01)
>
> If the function doesn't have a formula method, then wrap it in a with()
> call:
>
> with(Test01, plot(Day_of_year, Draft_No.))
>
> No need for attach.
>
> >
> > (rectangular window in vertical position)
> > dev.new(height = 12, width = 4)
> > layout(matrix(1:2, nrow=2))
> > plot(Test01$Day_of_year, Test01$Draft_No.)
> > plot(Day_of_year,Draft_No.)
> >
> > (height = 12, width = 6) can't work.  The graphs plotted are
> distorted off
> > square shape.  I must reduce "width = 4"
> >
> > Why?  TIA
>
> Because you don't appreciate that the dimensions of the device are not
> the same as the dimensions of the plotting region *on* the device. Most
> notably, the margins on the device are given by par("mar") for example
> and are not square:
>
> > par("mar")
> [1] 5.1 4.1 4.1 2.1
>
> So more space is set aside on the bottom then anywhere else, and the
> margin on the right is quite small.
>
> You have already been provided with an answer that you dismissed
> because
> you didn't appear to appreciate what you were being told.
>
> Compare this:
>
> dev.new(height = 6, width = 12)
> layout(matrix(1:2, ncol = 2))
> plot(runif(100), rnorm(100))
> plot(runif(100), rnorm(100), col = "red")
> layout(1)
>
> with this:
>
> dev.new(height = 6, width = 12)
> layout(matrix(1:2, ncol = 2))
> op <- par(pty = "s") ## this is the important bit
> plot(runif(100), rnorm(100))
> plot(runif(100), rnorm(100), col =

Re: [R] calculations with dates

2010-08-29 Thread jim holtman
Try this:

> x
  startdate   enddate
1 27SEP2005 01JAN2006
> x$start <- as.Date(x$startdate, format="%d%b%Y")
> x$end <- as.Date(x$enddate, format="%d%b%Y")
> x
  startdate   enddate  startend
1 27SEP2005 01JAN2006 2005-09-27 2006-01-01
> x$duration <- x$end - x$start
> x
  startdate   enddate  startend duration
1 27SEP2005 01JAN2006 2005-09-27 2006-01-01  96 days
>


On Sun, Aug 29, 2010 at 8:20 AM, André de Boer  wrote:
> Hi,
>
> I have a data.frame with factors in columns like
>
> startdate      enddate
> 27SEP2005 01JAN2006
>
> How can I calculate the duration between those two dates and move this in a
> extra column in the data.frame.
>
> Thanks,
> André
>
>        [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] calculations with dates

2010-08-29 Thread André de Boer
Hi,

I have a data.frame with factors in columns like

startdate  enddate
27SEP2005 01JAN2006

How can I calculate the duration between those two dates and move this in a
extra column in the data.frame.

Thanks,
André

[[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] approxfun-problems (yleft and yright ignored)

2010-08-29 Thread Nora Muda





  
[[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] Please sigh me out from the R-help. Thank you!

2010-08-29 Thread Johnson, Cedrick W.

https://stat.ethz.ch/mailman/listinfo/r-help

At the bottom of the webpage.

-c

On 08/29/2010 03:58 AM, Kaigang Li wrote:






[[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] Please sigh me out from the R-help. Thank you!

2010-08-29 Thread Kaigang Li




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