[R] How to have columns lined up?

2012-02-07 Thread hithit168
 Hi there,

Everytime when I paste My R output in WORD, the columns couldn't line up
nicely like they appear in  R console. Is there a way to fix this problem?
Thanks for any help!


time n.risk n.event survival std.err lower 95% CI upper 95% CI
6 21   30.857  0.07640.7071.000
7 17   10.807  0.08690.6360.977
   10 15   10.753  0.09630.5640.942
   13 12   10.690  0.10680.4810.900
   16 11   10.627  0.11410.4040.851
   22  7   10.538  0.12820.2860.789
   23  6   10.448  0.13460.1840.712

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-have-columns-lined-up-tp4367928p4367928.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] How to have columns lined up?

2012-02-08 Thread hithit168
Thanks a lot, David. 
Uh...this is not really an R question, but I couldn't find answer nowhere...

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-have-columns-lined-up-tp4367928p4369262.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] Error in apply(x2, 1, diff) : dim(X) must have a positive length

2012-02-12 Thread hithit168
Anyone knows hat might be the cause of this error? Thanks for any help!

>library(MASS)
> dif.mns = function(x2,tr1=.2,tr2=.3){ 
+ #generates four different 'means' using 
+ #difference scores from x2, an n x 2 matrix
+ #for use w/ bootstrap comparisons 
+ diffs = apply(x2,1,diff)  
+ mn1=mean(diffs) 
+ mn2=mean(diffs,tr=.2) 
+ mn3=mean(diffs,tr=.3) 
+ mn4=median(diffs) 
+ mns=c(mn1,mn2,mn3,mn4)  
+ list(mnds=round(mns,3)) } 

> dif.mns(shoes)
Error in apply(x2, 1, diff) : dim(X) must have a positive length

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-in-apply-x2-1-diff-dim-X-must-have-a-positive-length-tp4382435p4382435.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] Error in apply(x2, 1, diff) : dim(X) must have a positive length

2012-02-13 Thread hithit168
Thank you for your help, David. I was trying to run bootrapping on the
dataset "shoes" from MASS package. But I still have some problem here.

> as.matrix(data.frame(shoes),nrows=10,ncols=2,byrow=T)
A B
[1,] 13.2 14.0
[2,] 8.2 8.8
[3,] 10.9 11.2
[4,] 14.3 14.2
[5,] 10.7 11.8
[6,] 6.6 6.4
[7,] 9.5 9.8
[8,] 10.8 11.3
[9,] 8.8 9.3
[10,] 13.3 13.6
> y=as.matrix(data.frame(shoes),nrows=10,ncols=2,byrow=T)
> class(y)
[1] "matrix"
> apply(y,1,diff)
[1] 0.8 0.6 0.3 -0.1 1.1 -0.2 0.3 0.5 0.5 0.3
> dif.mns <- function(x2,tr1=.1,tr2=.2){
+ diffs=apply(x2,1,diff) 
+ mn1=mean(diffs)
+ mn2=mean(diffs,tr=.1)
+ mn3=mean(diffs,tr=.2)
+ mn4=median(diffs)
+ mns=c(mn1,mn2,mn3,mn4) 
+ list(mnds=round(mns,3))}
> dif.mns(y,tr1=.1,tr2=.2)
$mnds
[1] 0.410 0.400 0.417 0.400

> bootstrap(y,nboot=1000,theta=dif.mns)
Error in apply(x2, 1, diff) : dim(X) must have a positive length

I am not sure what I am doing wrong. When I run apply(y,1,diff) I am able to
get output, and when I run dif.mns with just the original dataset, I am also
able to get output.



--
View this message in context: 
http://r.789695.n4.nabble.com/Error-in-apply-x2-1-diff-dim-X-must-have-a-positive-length-tp4382435p4384129.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] Error in apply(x2, 1, diff) : dim(X) must have a positive length

2012-02-13 Thread hithit168
Thanks.

I use the bootstrap() function from the bootstrap package. Let me try it
again to see if I get any luck :)

--
View this message in context: 
http://r.789695.n4.nabble.com/Error-in-apply-x2-1-diff-dim-X-must-have-a-positive-length-tp4382435p4384608.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.