[R] What did I do wrong? Bootstrap with glm

2009-10-01 Thread Chunhao Tu
Hi R users, I just play with a small data set (from SAS) by using the boot with glm. But I don't know what I did wrong. Would someone please give me a hint? > require(boot) > carc<-read.table(file="C:\\Documents and > Settings\\admin\\Desktop\\drug.txt",header=T) > carc n cc car age 1 500

[R] Something wrong with my function Please Help

2009-09-29 Thread Chunhao Tu
Hi R users, I try to build a function to compute odds ratio and relative risk however something wrong. I stuck for many hours but I really don't know how to solve it. Would someone please give me a hint? > OR.RR<-function(x){ + x <- as.matrix(any(dim(x)==2)) + OR<-(x[1,1]*x[2,2])/(x[1

[R] The code behind the function

2009-09-09 Thread Chunhao Tu
Hi R users, I have a question. How can I see the code behind the function. For example, > boxplot function (x, ...) UseMethod("boxplot") I really would like to see how people code this. Could someone please show me how to see the code behind the function? Many Thanks Tu -- View this message

[R] strange results in summary and IQR functions

2009-09-08 Thread Chunhao Tu
Dear R users, Something is strange in summary and IQR. Suppose, I have a data set and I would like to find the Q1, Q2, Q3 and IQR. x<-c(2,4,11,12,13,15,31,31,37,47) > summary(x) Min. 1st Qu. MedianMean 3rd Qu.Max. 2.00 11.25 14.00 20.30 31.00 47.00 > IQR(x) [1] 19.75

[R] Help LSD multiple comparison test

2009-06-23 Thread Chunhao Tu
Hi R users, I know this is a old question but I did not see any clear answer. Is there any way or package to perform LSD test in R such as H0: A=B. H0, A=C and H0 B=C. Thank you in advance Tu -- View this message in context: http://www.nabble.com/Help-LSD-multiple-comparison-test-tp24178161p24

[R] Please Help pairwise.t.test!!

2009-06-11 Thread Chunhao Tu
Hi R users, My question is, If I have 3 groups, A, B, C and I know mean of A =20, B=21, and C=20.5 and I also know the standard error of A =1.1, B=2.2, C=3.2. Plus, I know A has 30 observations, B has 78, C has 45. But I do not have the raw data. Can I use pairwise.t.test to conduct a Bonferron

Re: [R] Error setting rowname if rowname currently NULL

2009-03-02 Thread Chunhao Tu
Hi, At the 1st step, you only assign a name for the 1st row. However, fred has 4 rows which mean you need to assign 4 rownames for these 4 rows. At the 2nd step, you only "CHANGE" the 1st rowname from 1 to APPLE If I am wrong please correct me. Thanks -Original Message- From: r-help-

[R] Help How to use a loop to do pair comparison

2009-02-23 Thread Chunhao Tu
Hi R users, I have a question. How can I use for loop to do pair comparisons. For example, > x<-c(1,2,3) > result<-matrix(data=NA, nrow=choose(3,2), ncol=1) > for(i in 1: length(x)) +{ result[i,]<-ifelse(x[i] > x[i+1], yes="Big", no="Small") + result} > result [,1] [1,] "Sm

Re: [R] 3 curves / 1 plot

2008-10-02 Thread Chunhao Tu
Michel PETITJEAN-2 wrote: > > I am a new user of R. > Please does somebody knows how to plot 3 datasets > (x1,a1),...,(xn,an), (x1,b1),...,(xn,bn), and (x1,c1),...,(xn,cn) > on a single x,y plot, each of the three datasets being plotted with > its own character pch() ? > (three calls to plot()

Re: [R] Bug or feature with finding a list element?

2008-10-01 Thread Chunhao Tu
Hi, I have tried this with R-2.7.2 then I got > alist[['goodbye']] NULL > alist[['hi']] NULL > alist[['hello']] [1] 10 The results make sense to me thus you might want to update your R version. chunhao B Fox wrote: > > This seems odd. When I try to look up a list element which has a space

Re: [R] lapply where each list object has multiple parts

2008-10-01 Thread Chunhao Tu
Hi Eric, > data<-list(x1 <- c(0,1,2,3),x2 <- c(7,8),x3 <- c(2,6,6,8), x4 <- c(4,8)) > lapply(X=data, mean) [[1]] [1] 1.5 [[2]] [1] 7.5 [[3]] [1] 5.5 [[4]] [1] 6 Hope it helps Chunhao eric lee-8 wrote: > > Hi. I have a list where each object in the list has multiple parts. I'd > like to