Re: [R] How to append to a data.frame?
On Tue, 9 Dec 2003, David Kreil wrote: > > Hi, > > I have a data.frame that I need to construct iteratively. > > At the moment, I'm doing: > > d<-data.frame(x=c(),y=c(),z=()); > > # {and, within some loop} > > d<-rbind(d,data.frame(x=newx,y=newy,z=newz); > > > While this works, it is horribly verbose and probably not efficient, either. > My real data.frame has, of course, many more columns, which can be of > different modes. > > I vaguely recall that in much earlier R versions the following worked > > d[dim(d)[1]+1,]<-c(newx,newy,newz); > > but not anymore (both 1.7 and 1.8 give "subscript out of bounds"). > > Can anyone suggest a more elegant and/or efficient way of achieving this, > please? Cc to this address highly appreciated. Just allocate a large enough data frame to start with, then use indexing to insert the rows. If you cannot get a good bound on the eventual size, over-allocate and double in size as needed. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] R^2 analogue in polr() and prerequisites for polr()
many thanks! I was just asking for a r-square analogue, since the students I will present the results to, might like to know, how the measure of fit in an ordinal regression (e.g. the residual deviance) compare to measures they know (from introductory courses to linear regression) (such as the r-square), means: how much of the variance of the dependent variable can be explained by the variance of the independent variables. thanks and best regards christoph On Tue, 2003-12-09 at 07:26, Prof Brian Ripley wrote: > On 8 Dec 2003, Christoph Lehmann wrote: > > > (1)In polr(), is there any way to calculate a pseudo analogue to the > > R^2. Just for use as a purely descriptive statistic of the goodness of > > fit? > > First define the statistic you are interested in! There is an absolute > measure of fit, the residual deviance. > > > (2) And: what are the assumptions which must be fulfilled, so that the > > results of polr() (t-values, etc.) are valid? How can I test these > > prerequisites most easily: I have a three-level (ordered factor) > > response and four metric variables. > > This is discussed with worked examples in the book that MASS supports, so > please consult your copy. -- Christoph Lehmann <[EMAIL PROTECTED]> __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] R^2 analogue in polr() and prerequisites for polr()
On 8 Dec 2003, Christoph Lehmann wrote: > (1)In polr(), is there any way to calculate a pseudo analogue to the > R^2. Just for use as a purely descriptive statistic of the goodness of > fit? First define the statistic you are interested in! There is an absolute measure of fit, the residual deviance. > (2) And: what are the assumptions which must be fulfilled, so that the > results of polr() (t-values, etc.) are valid? How can I test these > prerequisites most easily: I have a three-level (ordered factor) > response and four metric variables. This is discussed with worked examples in the book that MASS supports, so please consult your copy. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] axes that meet
R v. 1.7.1, Windows 2000. A particular journal wants me to provide scatter plots with no box, but with axes that meet in the lower left corner. It seems as though there must be an easy way of doing this, but my reading the help on plot.default, axis, and box have not provided any clues. I would be most appreciative of any feedback. Thank you, Hank Stevens Dr. Martin Henry H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/botany/bot/henry.html http://www.muohio.edu/ecology __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How to append to a data.frame?
Hi, I have a data.frame that I need to construct iteratively. At the moment, I'm doing: d<-data.frame(x=c(),y=c(),z=()); # {and, within some loop} d<-rbind(d,data.frame(x=newx,y=newy,z=newz); While this works, it is horribly verbose and probably not efficient, either. My real data.frame has, of course, many more columns, which can be of different modes. I vaguely recall that in much earlier R versions the following worked d[dim(d)[1]+1,]<-c(newx,newy,newz); but not anymore (both 1.7 and 1.8 give "subscript out of bounds"). Can anyone suggest a more elegant and/or efficient way of achieving this, please? Cc to this address highly appreciated. With many thanks, David. Dr David Philip Kreil ("`-''-/").___..--''"`-._ Research Fellow`6_ 6 ) `-. ( ).`-.__.`) University of Cambridge(_Y_.)' ._ ) `._ `. ``-..-' ++44 1223 764107, fax 333992 _..`--'_..-_/ /--'_.' ,' www.inference.phy.cam.ac.uk/dpk20 (il),-'' (li),' ((!.-' __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Font
Use 'pointsize' argument, see ?postscript. This will proportionately scale all plot elements: title, axes labels and annotations, and plotting symbols (pch). If you want to control them separately, you may have to use the cex* parameters directly: cex, cex.axis, cex.lab, etc, see ?par. Best Aleksey On Tue, 9 Dec 2003, Savano wrote: > UseR's, > > I run R on Red Hat linux 8. I did some graphics using: > > ps.options(paper="a4",horizontal=T,family="Times"); > > postscript(file="boxplotdistancia.eps"); > boxplot(distancia); > dev.off() > > How I change the font size? > > Thanks for helping. > > Savano > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] p-value from chisq.test working strangely on 1.8.1
Hello everybody, I'm seeing some strange behavior on R 1.8.1 on Intel/Linux compiled with gcc 3.2.2. The p-value calculated from the chisq.test function is incorrect for some input values: > chisq.test(matrix(c(0, 1, 1, 12555), 2, 2), simulate.p.value=TRUE) Pearson's Chi-squared test with simulated p-value (based on 2000 replicates) data: matrix(c(0, 1, 1, 12555), 2, 2) X-squared = 1e-04, df = NA, p-value = 1 > chisq.test(matrix(c(0, 1, 1, 12556), 2, 2), simulate.p.value=TRUE) [...] data: matrix(c(0, 1, 1, 12556), 2, 2) X-squared = 1e-04, df = NA, p-value = < 2.2e-16 > chisq.test(matrix(c(0, 1, 1, 12557), 2, 2), simulate.p.value=TRUE) [...] data: matrix(c(0, 1, 1, 12557), 2, 2) X-squared = 1e-04, df = NA, p-value = 1 In these three calls to chisq.test, I'm varying the input matrix by only 1 observation, but the p-value changes by 16 orders of magnitude. This is reproducible on my system. Please let me know if any other information would be useful. chisq.test works properly for these inputs on Mac OS X 10.3.1 with R 1.8.0. I don't know if the problem is with Linux or 1.8.1. This bug looks very similar to bug 4718, which was reported in R 1.8.0 and fixed in R 1.8.1. They may be related. http://r-bugs.biostat.ku.dk/cgi-bin/R/Analyses-fixed?id=4718; user=guest;selectid=4718 Jeff __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Font
UseR's, I run R on Red Hat linux 8. I did some graphics using: ps.options(paper="a4",horizontal=T,family="Times"); postscript(file="boxplotdistancia.eps"); boxplot(distancia); dev.off() How I change the font size? Thanks for helping. Savano __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Interfacing R and Python in MS Windows
Hi all, I need the power of R from within some of my Python programs... I use debian linux (woody) at home and windows XP at work (the latter is where I need to get things done!) This are my packages: R 1.8.0 Python 2.3 RSPython 0.5-3 This is what I've done: (1) Since the Windows Binary of RSPython is compiled against Python 2.2 I downloaded the tarball (2) Followed the instructions in INSTALL.win (with pexports and everything) (3) In the RGUI "Install package(s) from local zip files..." (4) NO errors reported during this process (5) When I try to "Load package" in R it show this error: > local({pkg <- select.list(sort(.packages(all.available = TRUE))) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) Error in testRversion(descfields) : This package has not been installed properly See the Note in ?library (6) In Python >>> import RS Traceback (most recent call last): File "", line 1, in ? ImportError: No module named RS Please help me to get this excelent tools going on in Windows. Thanks in advance, Hector __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Frequent crash printing graphics windows and wavethresh
I often have R (1.8.1) crash after I generate several graphics windows using windows() or X11(), print a graphics window and then rerun the same script. A windows message comes up saying "Program error Rterm.exe .." (I can get the same problem using Rgui.) Xemacs tells me "Process R trace trap" at time and date The entry in the Dr Watson logs starts with Application exception occurred: App: (pid=134697032) When: 26/11/2002 @ 21:12:10.057 Exception number: c005 (access violation) The situation in which I can consistently produce this is when I am using the wavethresh3 dll and associated functions. I have tried to generate the same problem without using wavelet functions (just producing several graphics windows with plots of random numbers) but cannot reproduce this problem consistently from a new session. I was wondering if anyone else is experiencing this problem Regards Ross Darnell -- University of Queensland, Brisbane QLD 4067 AUSTRALIA Email: <[EMAIL PROTECTED]> __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] R^2 analogue in polr() and prerequisites for polr()
Hi (1)In polr(), is there any way to calculate a pseudo analogue to the R^2. Just for use as a purely descriptive statistic of the goodness of fit? (2) And: what are the assumptions which must be fulfilled, so that the results of polr() (t-values, etc.) are valid? How can I test these prerequisites most easily: I have a three-level (ordered factor) response and four metric variables. many thanks Christoph -- Christoph Lehmann <[EMAIL PROTECTED]> __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Matrix to dates
See ?DateTimeClasses, ?strptime, and ?as.character This example from strptime should get you going: ## read in date/time info in format 'm/d/y h:m:s' dates <- c("02/27/92", "02/27/92", "01/14/92", "02/28/92", "02/01/92") times <- c("23:03:20", "22:29:56", "01:03:30", "18:21:03", "16:56:26") x <- paste(dates, times) z <- strptime(x, "%m/%d/%y %H:%M:%S") z Good luck, Andy __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Matrix to dates
Let's try again! I have a matrix in which the first column is a four digit year, and the second column is a 2 digit month. How do I convert the matrix to a date function, please? Thanks, Erin Version 1.8.0 mailto: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Matrix to Dates
Hello again R People: If I have a matrix with 2 columns > z1 1960 1 1960 9 1961 6 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Design functions after Multiple Imputation
I am a new user of R for Windows, enthusiast about the many functions of the Design and Hmisc libraries. I combined the results of a Cox regression model after multiple imputation (of missing values in some covariates). Now I got my vector of coefficients (and of standard errors). My question is: How could I use directly that vector to run programs such as 'nomogram', 'calibrate', 'validate.cph' which, in contrast, call for the saved results form 'cph' ? I did not use 'aregImpute' for multiple imputation. However, even if I did it, 'fit.mult.impute' seems not to allow specifying the option 'surv=TRUE' (essential to get a nomogram) or 'x=TRUE, y=TRUE' (which are essential for 'calibrate' and 'validate.cph'. Therefore, I dont't see how I could get a nomogram or run other Design functions after 'aregImpute'. thank you so much in advance Umberto _ MSN Extra Storage! Hotmail all'ennesima potenza. Provalo! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Recoding problem
> I have the following variables, all of which are logicals > > fmar15 fcoc15 fher15fcrk15fidu15 > > what I would like is a variable drug15 which equals > idu if fidu15 is T; crk if fidu15 is F but fcrk is T, her if fher15 is > T but fcrk15 and fidu15 are F and so on > > What's the best way to do this? > I don't know about the best way, but if I understand your question, the following achieves what you want: > tab <- cbind(fidu15, fcrk15, fher15, fcoc15, fmar15) > substring(colnames(tab), 2, 4)[apply(tab, 1, match, x = T)] HTH Ray Brownrigg __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Durbin Watson thanks!
Hi all The Durbin Watson is also in the lmtest library as dwtest. Thanks to all of you who answered so promptly!! R Help rocks! Sincerely, Erin __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] aggregate and names of factors
On 08 Dec 2003 14:13:59 +0100 Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Christophe Pallier <[EMAIL PROTECTED]> writes: > > > Hello, > > > > I use the function 'aggregate' a lot. > > > > One small annoyance is that it is necessary to name the factors in the > > 'by' list to get the names in the resulting data.frame (else, they > > appear as Group.1, Group.2...etc). For example, I am forced to > > write: > > > > aggregate(y,list(f1=f1,f2=f2),mean) > > > > instead of aggregate(y,list(f1,f2),mean) > > > > (for two factors with short names, it is not such a big deal, but I > > ususally have about 8 factors with long names...) > > > > I wrote a modified 'aggregate.data.frame' function (see the code > > below) so that it parses the names of the factors and uses them in the > > output > > data.frame. I can now typer aggregate(y,list(f1,f2),mean) ans the > > resulting data.frame > > has variables with names 'f1' and 'f2'. > > > > However, I have a few questions: > > > > 1. Is is a good idea at all? When expressions rather than variables > > are > >used as factors, this will probably result in a mess. Can one test > >if an argument within a list, is just a variable name or a more > >complex expression?). Is there a better way? > > This issue is not just relevant for aggregate. There are a couple of > other places where you want a named list to get names on output - > lapply(list(foo,bar,baz) function(x) lm(x~age)), say. One option that > I've been toying around with is to clone the code from data.frame and > have a function namedList() or nlist() which automagically supplies > names by deparsing the call. Now where did I put that code sketch... llist in the Hmisc packages does that Frank > > -- >O__ Peter Dalgaard Blegdamsvej 3 > c/ /'_ --- Dept. of Biostatistics 2200 Cph. N > (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 > ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help --- Frank E Harrell JrProfessor and ChairSchool of Medicine Department of BiostatisticsVanderbilt University --- Frank E Harrell JrProfessor and ChairSchool of Medicine Department of BiostatisticsVanderbilt University __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Durbin Watson test
help.search("durbin") on my box gives: durbin.watson(car) Durbin-Watson Test for Autocorrelated Errors dwtest(lmtest) Durbin-Watson Test so you'll need either the `car' or `lmtest' package. HTH, Andy > From: Of Erin Hodgess > > Hi R People: > > Where is the Durbin Watson test located, please? > > I tried looking in the ctest library, but to no avail. > > Version 1.8.0 for Windows. > > Thanks for the help! > > > Sincerely, > Erin Hodgess > mailto: [EMAIL PROTECTED] > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] stripchart problem
I would like to plot datapoints according to the sex of the person, e.g. circle for a girl and square for a boy, like this: Have you tried using stripplot (a lattice plot) instead? You can then use the group argument to display different groups differently. eg. stripplot(age ~ family, data=famdata, group=sex) Hadley __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Durbin Watson
the Durbin Watson function is in the car library. thanks, Erin __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Durbin Watson test
Hi R People: Where is the Durbin Watson test located, please? I tried looking in the ctest library, but to no avail. Version 1.8.0 for Windows. Thanks for the help! Sincerely, Erin Hodgess mailto: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Re: Compiling R in 64-bit mode on AIX
On Tuesday 14 October 2003 21:05, you wrote: > Hi. I saw your post from earlier this year in which you were soliciting > help on compiling R as a 64-bit application under AIX. We have been having > trouble with the same problem. > > Have you gotten anywhere? > > Thanks for any help. > > Best regards, > > Matthew Wiener > RY84-202 > Applied Computer Science & Mathematics Dept. > Merck Research Labs > 126 E. Lincoln Ave. > Rahway, NJ 07065 > 732-594-5303 Matthew, Liu first sorry for the delay in answering, but I was buried in an important project. I can offer you a solution that was actually found by one of our customers, Tobias Reber from DKFZ (German Cancer Research Center). I am appending a patch (generated by cvs diff -c ...) that I applied to R v1.6.2. Then I typed the following two commands. OBJECT_MODE=64 \ MAKE=gmake \ CC="cc -DSTDC" \ CXX="xlC" \ MAIN_LDFLAGS="-Wl,-brtl" \ SHLIB_LDFLAGS="-Wl,-G" \ F77="xlf" \ ./configure \ --without-x \ --without-blas OBJECT_MODE=64 gmake After this I tested with "gmake check" and found no errors. I have just retried the above on the following setup. h/w p690+ 1.7GHz [EMAIL PROTECTED] R]$ oslevel -r 5200-02 [EMAIL PROTECTED] R]$ lslpp -l | grep vac.C vac.C 6.0.0.5 APPLIEDC for AIX Compiler vac.C.readme.ibm 6.0.0.1 COMMITTED C for AIX iFOR/LS Information vac.C 6.0.0.5 APPLIEDC for AIX Compiler [EMAIL PROTECTED] R]$ lslpp -L | grep xlfcmp xlfcmp 8.1.1.3A FXL Fortran Compiler xlfcmp.html.en_US 8.1.1.0C FXL Fortran Compiler xlfcmp.idebug.html.en_US 8.1.1.0C FDistributed Debugger xlfcmp.msg.en_US 8.1.1.1A FXL Fortran Compiler Messages - xlfcmp.pdf.en_US 8.1.1.0C FXL Fortran Compiler xlfcmp.ps.en_US8.1.1.0C FXL Fortran Compiler I copied the r-help mailing list, but I am not sure whether I can post there. Could you please post this if you don't see it posted ? Thanks. -- Mit freundlichen Gruessen/Best Regards Dr. Christoph Pospiech High Performance & Parallel Computing Advanced Computing Technology Center Phone +49-621-469450, Fax: ...-469200, eMail: [EMAIL PROTECTED] Mobile +49-171 765 5871 Please Note new Tel+FAX Number __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] test for arima coef's significancy
>Can you explain how you managed to derive a t distribution for this >statistic, yet none of the references mentioned in the various help pages >contain such a result? OK, let's say it was a naive and not well thought attempt. I tried it because I used to work with SAS and with the proc ARIMA, I think I was able to get a pvalue for significancy test for each coefficient. I have seen in one of your previous mail on the help mailing list that I could use the wald test or a likelyhood ratio test for the global significancy of the coef but nothing about each coef significancy >Could you also explain why a one-sided p-value is appropriate, and how the >bounded space containing the coefficients is not relevant, nor are >missing values in the series? Do you mean it is sufficient to check if zero belongs to the confidence interval centered on the coef value? >It's hard for the R-developers to write a function to compute something we >do not know how to find theoretically, so please share your exceptional >insights with us. I'll do my best for the next contribution. * Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. SG Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. Decouvrez l'offre et les services de SG Asset Management sur le site www.sgam.fr This message and any attachments (the "message") are confide...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] stripchart problem
stripchart always plots all the points in a given group with the same symbol, so you can't do what you want with it. Here are some alternatives: 1. Its not very nice but coplot can get you a chart somewhat in the vein you are looking for: with(famdata, coplot(age~family|family, pch=ifelse(sex=="m",22,1))) 2. With a bit more work, you can try creating it yourself using plot: with(famdata, plot(age, as.numeric(family), pch=ifelse(sex=="m",22,1),axes=F)) axis(1) lv <- levels(famdata$family) axis(2,seq(lv),lv) I have not examined the above closely so you might want to double check them. --- Hello, I am trying to plot age distribution data for a certain condition that runs in families. Below is a simplified view of the dataset, i.e. in this case there are four families, each line corresponding to one individual with age at diagnosis and sex. > famdata family age sex 1 fam1 2.1 f 2 fam1 2.3 f 3 fam1 1.0 m 4 fam2 7.3 f 5 fam2 4.1 f 6 fam2 1.2 f 7 fam2 0.6 m 8 fam3 3.5 m 9 fam3 2.5 m 10 fam3 2.9 m 11 fam3 5.6 m 12 fam3 4.4 f 13 fam10 1.1 f 14 fam10 1.2 f 15 fam10 2.9 f 16 fam10 2.2 f 17 fam10 4.7 m I can nicely plot the age distribution by families with > stripchart(famdata$age~famdata$family) I would like to plot datapoints according to the sex of the person, e.g. circle for a girl and square for a boy, like this: > stripchart(famdata$age~famdata$family, pch=ifelse(famdata$sex=="m", 22, 1)) But this command doesn't work as I expected. Datapoints from fam2 are shown as squares, all the rest as circles. Still , this seems OK: > ifelse(famdata$sex=="m", 22, 1) [1] 1 1 22 1 1 1 22 22 22 22 22 1 1 1 1 1 22 Any clues ? Thanks a lot for your help, alex __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] test for arima coef's significancy
On Mon, 8 Dec 2003, STOLIAROFF VINCENT wrote: > Dear sirs, > > I would like to know if there is a function to compute the pvalue for the > significancy of arima coef in an arima object created by > the arima function. > > I have written this one: > > pvalueArima<-function(x,arima) > { > t<-(arima$coef)/(diag(arima$var.coef)^0.5) > df<-length(x)-length(arima$coef) > 1-pt(t,df) > } > > Has somebody already implemented something equivalent ? Can you explain how you managed to derive a t distribution for this statistic, yet none of the references mentioned in the various help pages contain such a result? Could you also explain why a one-sided p-value is appropriate, and how the bounded space containing the coefficients is not relevant, nor are missing values in the series? It's hard for the R-developers to write a function to compute something we do not know how to find theoretically, so please share your exceptional insights with us. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Recoding problem
Hello I have the following variables, all of which are logicals fmar15 fcoc15 fher15fcrk15fidu15 what I would like is a variable drug15 which equals idu if fidu15 is T; crk if fidu15 is F but fcrk is T, her if fher15 is T but fcrk15 and fidu15 are F and so on What's the best way to do this? Thanks in advance Peter L. Flom, PhD Assistant Director, Statistics and Data Analysis Core Center for Drug Use and HIV Research National Development and Research Institutes 71 W. 23rd St www.peterflom.com New York, NY 10010 (212) 845-4485 (voice) (917) 438-0894 (fax) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] trouble with predict.l1ce
Dear R-help, I am having trouble with the predict function in lasso2. For example: > data(Iowa) > l1c.I <- l1ce(Yield ~ ., Iowa, bound = 10, absolute.t=TRUE) > predict (l1c.I) # this works is fine > predict (l1c.I,Iowa) Error in eval(exper,envir, enclos) : couldn't find function "Yield" And I have similar trouble whenever I use the newdata argument in prediction. thanks in advance, Clayton [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] test for arima coef's significancy
Dear sirs, I would like to know if there is a function to compute the pvalue for the significancy of arima coef in an arima object created by the arima function. I have written this one: pvalueArima<-function(x,arima) { t<-(arima$coef)/(diag(arima$var.coef)^0.5) df<-length(x)-length(arima$coef) 1-pt(t,df) } Has somebody already implemented something equivalent ? thank you for your help and comments Vincent S. * Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. SG Asset Management et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. Découvrez l'offre et les services de SG Asset Management sur le site www.sgam.fr This message and any attachments (the "message") are confide...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Windows Memory Issues
On Sat, 6 Dec 2003, Prof Brian Ripley wrote: > I think you misunderstand how R uses memory. gc() does not free up all > the memory used for the objects it frees, and repeated calls will free > more. Don't speculate about how memory management works: do your > homework! Are you saying that consecutive calls to gc() will free more memory than a single call, or am I misunderstanding? Reading ?gc and ?Memory I don't see anything about this mentioned. Where should I be looking to find more comprehensive info on R's memory management?? I'm not writing any packages, just would like to have a better handle on efficiently using memory as it is usually the limiting factor with R. FYI, I'm running R1.8.1 and RedHat9 on a P4 with 2GB of RAM in case there is any platform specific info that may be applicable. Thanks, Doug Grove Statistical Research Associate Fred Hutchinson Cancer Research Center > In any case, you are using an outdated version of R, and your first > course of action should be to compile up R-devel and try that, as there > has been improvements to memory management under Windows. You could also > try compiling using the native malloc (and that *is* described in the > INSTALL file) as that has different compromises. > > > On Sat, 6 Dec 2003, Richard Pugh wrote: > > > Hi all, > > > > I am currently building an application based on R 1.7.1 (+ compiled > > C/C++ code + MySql + VB). I am building this application to work on 2 > > different platforms (Windows XP Professional (500mb memory) and Windows > > NT 4.0 with service pack 6 (1gb memory)). This is a very memory > > intensive application performing sophisticated operations on "large" > > matrices (typically 5000x1500 matrices). > > > > I have run into some issues regarding the way R handles its memory, > > especially on NT. In particular, R does not seem able to recollect some > > of the memory used following the creation and manipulation of large data > > objects. For example, I have a function which receives a (large) > > numeric matrix, matches against more data (maybe imported from MySql) > > and returns a large list structure for further analysis. A typical call > > may look like this . > > > > > myInputData <- matrix(sample(1:100, 750, T), nrow=5000) > > > myPortfolio <- createPortfolio(myInputData) > > > > It seems I can only repeat this code process 2/3 times before I have to > > restart R (to get the memory back). I use the same object names > > (myInputData and myPortfolio) each time, so I am not create more large > > objects .. > > > > I think the problems I have are illustrated with the following example > > from a small R session . > > > > > # Memory usage for Rui process = 19,800 > > > testData <- matrix(rnorm(1000), 1000) # Create big matrix > > > # Memory usage for Rgui process = 254,550k > > > rm(testData) > > > # Memory usage for Rgui process = 254,550k > > > gc() > > used (Mb) gc trigger (Mb) > > Ncells 369277 9.9 667722 17.9 > > Vcells 87650 0.7 24286664 185.3 > > > # Memory usage for Rgui process = 20,200k > > > > In the above code, R cannot recollect all memory used, so the memory > > usage increases from 19.8k to 20.2. However, the following example is > > more typical of the environments I use . > > > > > # Memory 128,100k > > > myTestData <- matrix(rnorm(1000), 1000) > > > # Memory 357,272k > > > rm(myTestData) > > > # Memory 357,272k > > > gc() > > used (Mb) gc trigger (Mb) > > Ncells 478197 12.8 818163 21.9 > > Vcells 9309525 71.1 31670210 241.7 > > > # Memory 279,152k > > > > Here, the memory usage increases from 128.1k to 279.1k > > > > Could anyone point out what I could do to rectify this (if anything), or > > generally what strategy I could take to improve this? > > > > Many thanks, > > Rich. > > > > Mango Solutions > > Tel : (01628) 418134 > > Mob : (07967) 808091 > > > > > > [[alternative HTML version deleted]] > > > > __ > > [EMAIL PROTECTED] mailing list > > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > > > > -- > Brian D. Ripley, [EMAIL PROTECTED] > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] stripchart problem
> Hello, > > I am trying to plot age distribution data for a certain condition that > runs in families. Below is a simplified view of the dataset, i.e. in > this case there are four families, each line corresponding to one > individual with age at diagnosis and sex. > > > famdata >family age sex > 1fam1 2.1 f > 2fam1 2.3 f > 3fam1 1.0 m > 4fam2 7.3 f > 5fam2 4.1 f > 6fam2 1.2 f > 7fam2 0.6 m > 8fam3 3.5 m > 9fam3 2.5 m > 10 fam3 2.9 m > 11 fam3 5.6 m > 12 fam3 4.4 f > 13 fam10 1.1 f > 14 fam10 1.2 f > 15 fam10 2.9 f > 16 fam10 2.2 f > 17 fam10 4.7 m > > I can nicely plot the age distribution by families with > > > stripchart(famdata$age~famdata$family) > > I would like to plot datapoints according to the sex of the person, e.g. > circle for a girl and square for a boy, like this: > > > stripchart(famdata$age~famdata$family, pch=ifelse(famdata$sex=="m", > 22, 1)) Try this: stripchart(famdata$age ~ famdata$family, pch = c(1, 22)[unclass(famdata$sex)]) (maybe you need to have "c(22, 1)") HTH Emmanuel Paradis > > But this command doesn't work as I expected. Datapoints from fam2 are > shown as squares, all the rest as circles. Still , this seems OK: > > > ifelse(famdata$sex=="m", 22, 1) > [1] 1 1 22 1 1 1 22 22 22 22 22 1 1 1 1 1 22 > > Any clues ? > > Thanks a lot for your help, > > alex > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] WinMenus - is there a way of knowing if a WinMenu or WinMenuItem already exists?
On Mon, 8 Dec 2003, Finn Sando wrote: > I am developing a menusystem using the functions WinMenuAdd and > WinMenuAddItem etc. > > I want to be able to shift between different interfaces (ie. different sets of > menu-trees). > Therefore I would like to be able to ask whether a specific menu already exists in > order > to remove or add it Without errors. That is I am looking for something like: > > WinMenuExist(menuname) and WinMenuExistItem(menuname,itemname) > > Are there any way asking such question of R? No. But you could contribute such functionality. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] WinMenus - is there a way of knowing if a WinMenu or WinMenuItem already exists?
I am developing a menusystem using the functions WinMenuAdd and WinMenuAddItem etc. I want to be able to shift between different interfaces (ie. different sets of menu-trees). Therefore I would like to be able to ask whether a specific menu already exists in order to remove or add it Without errors. That is I am looking for something like: WinMenuExist(menuname) and WinMenuExistItem(menuname,itemname) Are there any way asking such question of R? -- Finn __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] stripchart problem
Hello, I am trying to plot age distribution data for a certain condition that runs in families. Below is a simplified view of the dataset, i.e. in this case there are four families, each line corresponding to one individual with age at diagnosis and sex. > famdata family age sex 1fam1 2.1 f 2fam1 2.3 f 3fam1 1.0 m 4fam2 7.3 f 5fam2 4.1 f 6fam2 1.2 f 7fam2 0.6 m 8fam3 3.5 m 9fam3 2.5 m 10 fam3 2.9 m 11 fam3 5.6 m 12 fam3 4.4 f 13 fam10 1.1 f 14 fam10 1.2 f 15 fam10 2.9 f 16 fam10 2.2 f 17 fam10 4.7 m I can nicely plot the age distribution by families with > stripchart(famdata$age~famdata$family) I would like to plot datapoints according to the sex of the person, e.g. circle for a girl and square for a boy, like this: > stripchart(famdata$age~famdata$family, pch=ifelse(famdata$sex=="m", 22, 1)) But this command doesn't work as I expected. Datapoints from fam2 are shown as squares, all the rest as circles. Still , this seems OK: > ifelse(famdata$sex=="m", 22, 1) [1] 1 1 22 1 1 1 22 22 22 22 22 1 1 1 1 1 22 Any clues ? Thanks a lot for your help, alex __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] TukeyHSD changes if I create interaction term
Dear R community, I'm trying to understand this behavior of TukeyHSD. My goal is to obtain defensible, labelled multiple comparisons of an interaction term. Firstly, if I plot the TukeyHSD from the model that calculates its own interactions, then the y-axis labels appear to be reflected on their median when compared to the text output of the TukeyHSD statement. The labels are integers. Secondly, if I provide an interaction term for the model, to try to coerce TukeyHSD to label the comparisons, then the multiple comparison outcome is quite different, as is the output from coefficients(). It must be using a different parameterization, because the anova statements that summarize the model are identical. However, if two different parameterizations give rise to two different sets of multiple comparisons, how ought we choose between them? The following snippet illustrates. === data(warpbreaks) warpbreaks$WT <- interaction(warpbreaks$wool, warpbreaks$tension) summary(fm1 <- aov(breaks ~ wool * tension, data = warpbreaks)) summary(fm2 <- aov(breaks ~ wool + tension + WT, data = warpbreaks)) summary(fm1) # Identical summary(fm2) # Identical coefficients(fm1) # Different coefficients(fm2) # Different TukeyHSD(fm1, "wool:tension") # (1) My first concern is that the y-axis labels seem to be reflected # in their median. plot(TukeyHSD(fm1, "wool:tension")) # Labels are upside down? # (2) My second concern is that the estimates and intervals are # different from fm2 TukeyHSD(fm2, "WT") === I would appreciate any advice. Andrew -- Andrew Robinson Ph: 208 885 7115 Department of Forest Resources Fa: 208 885 6226 University of Idaho E : [EMAIL PROTECTED] PO Box 441133W : http://www.uidaho.edu/~andrewr Moscow ID 83843 Or: http://www.biometrics.uidaho.edu No statement above necessarily represents my employer's opinion. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Add row to data frame
On Mon, 8 Dec 2003, Pascal A. Niklaus wrote: > Martin Maechler wrote: > > >>"Pascal" == Pascal A Niklaus <[EMAIL PROTECTED]> > >>on Mon, 08 Dec 2003 11:47:02 +0100 writes: > >> > >> > > > >Pascal> Hi all, is there an easy way to build up a data > >Pascal> frame by sequentially adding individual rows? > > > >yes, pretty easy, but usually not recommended because quite > >inefficient. > > > >rbind() does work with data frames in the cases we know. > >Have a look at help(rbind.data.frame) > > > > > >Pascal> The data frame consists of numeric and character > >Pascal> columns. I thought of rbind, but I ended up with > >Pascal> numeric values for the character columns. > > > >We'd need to see [i.e give a reproducible example!] > >how you "ended up with numeric values for the character > >columns" -- which I guess were *factor* instead of character ? > > > > > Yes, there was a factor... There's one problem left, though... The row > names are 1, 11, 111 etc, instead of 1,2,3... > > > df <- NULL; > > > > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > > df > A B C > 1 1 abc 1.3540030 > 11 1 abc -0.7229597 > 111 1 abc -0.4922653 > > Of course, I can do a attr(df,"row.names") <- 1:3 at the end, but is > there an easier way? Ideally, I would like to name the row already when > adding it to the data frame. Easy! Create the data frame with the row names you want -- see ?data.frame. > Is there another way than setting the > row.names attribute "manually" with the attr command? What do you think row.names<- does? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Add row to data frame
Martin Maechler wrote: "Pascal" == Pascal A Niklaus <[EMAIL PROTECTED]> on Mon, 08 Dec 2003 11:47:02 +0100 writes: Pascal> Hi all, is there an easy way to build up a data Pascal> frame by sequentially adding individual rows? yes, pretty easy, but usually not recommended because quite inefficient. rbind() does work with data frames in the cases we know. Have a look at help(rbind.data.frame) Pascal> The data frame consists of numeric and character Pascal> columns. I thought of rbind, but I ended up with Pascal> numeric values for the character columns. We'd need to see [i.e give a reproducible example!] how you "ended up with numeric values for the character columns" -- which I guess were *factor* instead of character ? Yes, there was a factor... There's one problem left, though... The row names are 1, 11, 111 etc, instead of 1,2,3... > df <- NULL; > > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > df <- rbind(df,data.frame(A=1,B="abc",C=rnorm(1))) > df A B C 1 1 abc 1.3540030 11 1 abc -0.7229597 111 1 abc -0.4922653 Of course, I can do a attr(df,"row.names") <- 1:3 at the end, but is there an easier way? Ideally, I would like to name the row already when adding it to the data frame. Is there another way than setting the row.names attribute "manually" with the attr command? Pascal __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] thanks!! get mean of several rows
Dear all! Thanks to all who replied to my question on getting the means of several rows, and the one with the standard error + mean-plot! Many of them worked fine just as they were, others had to be adapted a bit. However, I can finally do my calculations, and find myself happy as a man could be, plotting fancy graphs whole day long. Moreover, I think I have learned quite a bit on R, seeing so many ways to do the same thing. Thanks a lot, again, I was really at the edge of going home and get drunk! Cheers, Jan -- __ Jan Wantia Dept. of Information Technology, University of Zürich Andreasstr. 15 CH 8050 Zürich Switzerland Tel.: +41 (0) 1 635 4315 Fax: +41 (0) 1 635 45 07 email: [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] aggregate and names of factors
Christophe Pallier <[EMAIL PROTECTED]> writes: > Hello, > > I use the function 'aggregate' a lot. > > One small annoyance is that it is necessary to name the factors in the > 'by' list to get the names in the resulting data.frame (else, they > appear as Group.1, Group.2...etc). For example, I am forced to > write: > > aggregate(y,list(f1=f1,f2=f2),mean) > > instead of aggregate(y,list(f1,f2),mean) > > (for two factors with short names, it is not such a big deal, but I > ususally have about 8 factors with long names...) > > I wrote a modified 'aggregate.data.frame' function (see the code > below) so that it parses the names of the factors and uses them in the > output > data.frame. I can now typer aggregate(y,list(f1,f2),mean) ans the > resulting data.frame > has variables with names 'f1' and 'f2'. > > However, I have a few questions: > > 1. Is is a good idea at all? When expressions rather than variables are >used as factors, this will probably result in a mess. Can one test >if an argument within a list, is just a variable name or a more >complex expression?). Is there a better way? This issue is not just relevant for aggregate. There are a couple of other places where you want a named list to get names on output - lapply(list(foo,bar,baz) function(x) lm(x~age)), say. One option that I've been toying around with is to clone the code from data.frame and have a function namedList() or nlist() which automagically supplies names by deparsing the call. Now where did I put that code sketch... -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] extracting p value from GEE
Hi, Many thanks for your kind help. best regards, Yu-Kang From: Emmanuel Paradis <[EMAIL PROTECTED]> To: "Tu Yu-Kang" <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: [R] extracting p value from GEE Date: Fri, 05 Dec 2003 15:48:41 +0100 At 11:53 04/12/2003 +, vous avez 嶰rit: Dear R users, If anyone can tell me how to extract the p values from the output of gee? They are easily computed from the output of summary(gee(...)) which prints either a "z" or a "t" depending in the "family" option. z follows, under the null hypothesis, a normal distribution N(0, 1), you have the corresponding P-value with (for a two-tailed test): 2 * (1 - pnorm(abs(z))) t follows a 'Student' distribution with df degrees of freedom given by N- k - 1, where N is the number of observations, and k is the number of estimated paramaters. I think, but am not definitely sure, that N is counted among all clusters, and k is the number of parameters in the GLM eventually included the estimated scale (correlation parameters are not counted). As above, you have the P-value with: 2 * (1 - pnorm(abs(t), df)) HTH Emmanuel Paradis Many thanks in advance. Yu-Kang _ 免費試聽 MSN 英語學習:和真人老師線上學英文 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help _ 來逛逛 MSN eShop:便利的購物環境、優質的網路商家,隨時有驚喜的優惠促銷等著您 ! http://msn.com.tw/eshop __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] aggregate and names of factors
Hello, I use the function 'aggregate' a lot. One small annoyance is that it is necessary to name the factors in the 'by' list to get the names in the resulting data.frame (else, they appear as Group.1, Group.2...etc). For example, I am forced to write: aggregate(y,list(f1=f1,f2=f2),mean) instead of aggregate(y,list(f1,f2),mean) (for two factors with short names, it is not such a big deal, but I ususally have about 8 factors with long names...) I wrote a modified 'aggregate.data.frame' function (see the code below) so that it parses the names of the factors and uses them in the output data.frame. I can now typer aggregate(y,list(f1,f2),mean) ans the resulting data.frame has variables with names 'f1' and 'f2'. However, I have a few questions: 1. Is is a good idea at all? When expressions rather than variables are used as factors, this will probably result in a mess. Can one test if an argument within a list, is just a variable name or a more complex expression?). Is there a better way? 2. I would also like to keep the name of the data when it is a vector, and not a data.frame. The current version transforms it into 'x'. I have not managed to modify this behavior, so I am forced to use aggregate(data.frame(y),list(f1,f2),mean) 3. I would love to have yet another a version that handles formula so that I could type: aggregate(y~f1*f2) I have a provisory version (see below), but it does not work very well. I would be grateful for any suggestions. In particular, I would love to have a 'subset' parameter, as in the lm function) Here is the small piece of code fot the embryo of aggregate.formula: my.aggregate.formula = function(formula,FUN=mean) { { d=model.frame(formula) factor.names=lapply(names(d)[sapply(d,is.factor)],as.name) factor.list=lapply(factor.names,eval) names(factor.list)=factor.names aggregate(d[1],factor.list,FUN) } Christophe Pallier http://www.pallier.org --- HEre is the code for aggregate.data.frame that recovers the name sof the factors: my.aggregate.data.frame <- function (x, by, FUN, ...) { if (!is.data.frame(x)) { x <- as.data.frame(x) } if (!is.list(by)) stop("`by' must be a list") if (is.null(names(by))) { # names(by) <- paste("Group", seq(along = by), sep = ".") names(by)=lapply(substitute(by)[-1],deparse) } else { nam <- names(by) ind <- which(nchar(nam) == 0) if (any(ind)) { names(by)[ind] <- lapply(substitute(by)[c(-1,-(ind))],deparse) } } y <- lapply(x, tapply, by, FUN, ..., simplify = FALSE) if (any(sapply(unlist(y, recursive = FALSE), length) > 1)) stop("`FUN' must always return a scalar") z <- y[[1]] d <- dim(z) w <- NULL for (i in seq(along = d)) { j <- rep(rep(seq(1:d[i]), prod(d[seq(length = i - 1)]) * rep(1, d[i])), prod(d[seq(from = i + 1, length = length(d) - i)])) w <- cbind(w, dimnames(z)[[i]][j]) } w <- w[which(!unlist(lapply(z, is.null))), ] y <- data.frame(w, lapply(y, unlist, use.names = FALSE)) names(y) <- c(names(by), names(x)) y } __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Help
Stephen Opiyo wrote: Hi, I have a data set (data frame) approx. 50 rows * 600 columns. The columns are separated by commas. I would like to know how to remove those commas between the columns. What should I do to remove those commas? I guess during the import of the data? Please read the R Data Import/Export manual and the help page ?read.table. It tells you how to use the argument "sep". Secondly, if I want only to use part of the (data frame), say (50 rows * 300 columns) instead of (50 rows * 600 columns), what should I do? Index the data frame appropriately. See the manual "An Introduction to R". Also, the help page ?data.frame points you to subsetting methods in its "See Also" Section. Uwe Ligges Thanks, Stephen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Reading formated databases
Kenneth Cabrera wrote: Hi R-users: How can I read an ascii database that is controled by the column number? For example: 7349593Luis Miguel Ariza Gutierrez 32342123 9394583X XX 34234930 39483 CCC CC39203230 3484932YY YYZZ ZZZ39402343 39203 WWW V 342343 There are 4 variables, ID, Name, Last Name, Numeric Variable. 1 Variable column 1-8 2 Variable column 9-25 3 Variable column 26-51 4 Variable column 51-59 Thank you for your help Kenneth See ?read.fwf Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] graphical parametres...
Anne Piotet wrote: Hi...it is probably trivial, but I do not know how to do the following: I want the output of a xy plot to be plotted in different colors according to a given condition ... I want to plot temperature dependency of flow stress ; for some (rare) occurencies I've got a special condition (chemical composition change) , and I want these points to appear on the same graph...I do know how to change the appearance of all the plots with the par() command or the points()... Thanks Anne [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help I guess you are looking for something like: y <- sample(1:10) plot(1:10, y, col = ifelse(y > 5, "red", "black")) Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Reading formated databases
Kenneth Cabrera wrote: How can I read an ascii database that is controled by the column number? ?read.fwf -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Reading formated databases
Hi R-users: How can I read an ascii database that is controled by the column number? For example: 7349593Luis Miguel Ariza Gutierrez 32342123 9394583X XX 34234930 39483 CCC CC39203230 3484932YY YYZZ ZZZ39402343 39203 WWW V 342343 There are 4 variables, ID, Name, Last Name, Numeric Variable. 1 Variable column 1-8 2 Variable column 9-25 3 Variable column 26-51 4 Variable column 51-59 Thank you for your help Kenneth -- Kenneth Roy Cabrera Torres Celular +57 (315) 405 9339 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] tkrplot with grid lattice plots
Hello, i tried to use a lattice graphics with tkrplot it seems that it doen't work, here is the exemple used: > library(tkrplot) > tt <- tktoplevel() > tktitle(tt)<-"Exemple" > > randdata<-data.frame(x=rnorm(100), y=rnorm(100), idobs=rep(1:10, each=10)) > > plot.graph<-function() { + plot(randdata$x, randdata$y) + } > > plot.graph2<-function() { + print(xyplot(x ~ y | idobs, data = randdata, as.table=F, type="p", panel=panel.xyplot, main="", lty=1)) + } > > img <-tkrplot(tt, fun=plot.graph) > tkgrid(img) > img2 <-tkrplot(tt, fun=plot.graph2) Error in check.length(gparname) : gpar element fontsize must not be length 0 I had a look at the tkrplot function but can't understand what is wrong. Thanks for any help! Eric Esposito __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] help
Hi, there, I have a question about multinom rountine. The response is a matrix, and the predicator is a data frame called dat. I would like multinom to get response and data from within this function test instead of from R Console session. - test <- function() { library(nnet) response <- diag(1,3) dat <- as.data.frame(matrix(round(rnorm(6)),3,2)) fit <- summary(multinom(response ~ ., data=dat)) coefficients <- fit$coefficients return(coefficients) } -- The response and dat are two different data sets, and one does not include another. But it seems multinom automatically get data and response from R Console environment, not the function test itself. So when I run the above function (assume that in R console we don't have objects response and dat), it gives error: cannot find response and dat. How can I let multinom get the data for the formula from within the function test without assigning response and dat into the R console environment. Thanks very much. Jun Han [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Help
Hi, I have a data set (data frame) approx. 50 rows * 600 columns. The columns are separated by commas. I would like to know how to remove those commas between the columns. What should I do to remove those commas? Secondly, if I want only to use part of the (data frame), say (50 rows * 300 columns) instead of (50 rows * 600 columns), what should I do? Thanks, Stephen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Add row to data frame
> "Pascal" == Pascal A Niklaus <[EMAIL PROTECTED]> > on Mon, 08 Dec 2003 11:47:02 +0100 writes: Pascal> Hi all, is there an easy way to build up a data Pascal> frame by sequentially adding individual rows? yes, pretty easy, but usually not recommended because quite inefficient. rbind() does work with data frames in the cases we know. Have a look at help(rbind.data.frame) Pascal> The data frame consists of numeric and character Pascal> columns. I thought of rbind, but I ended up with Pascal> numeric values for the character columns. We'd need to see [i.e give a reproducible example!] how you "ended up with numeric values for the character columns" -- which I guess were *factor* instead of character ? Regards to Basel, Martin Maechler <[EMAIL PROTECTED]> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] graphical parametres...
Hi...it is probably trivial, but I do not know how to do the following: I want the output of a xy plot to be plotted in different colors according to a given condition ... I want to plot temperature dependency of flow stress ; for some (rare) occurencies I've got a special condition (chemical composition change) , and I want these points to appear on the same graph...I do know how to change the appearance of all the plots with the par() command or the points()... Thanks Anne [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Add row to data frame
Hi all, is there an easy way to build up a data frame by sequentially adding individual rows? The data frame consists of numeric and character columns. I thought of rbind, but I ended up with numeric values for the character columns. Pascal __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Confidence intervals in ANOVA
Hallo! I have the a model with 3 time points, 2 treatments and N subjects. I can calculate an ANOVA but I can not calculate the CI of the interaction term (time and treatment), which I need for a closer look at the effect of the treatment to the 3 time points. I do NOT want to use lme because I can not manage it to reproduce text book examples (see my posting [R] lme: reproducing example Karl Knoblick (Tue 02 Dec 2003 - 21:34:54 EST)). Here some sample data: # Data # 35 subjects ID<-factor(rep(1:35,each=3)) TREAT<-factor(c(rep("A", 60), rep("B", 45))) TIME<-factor(rep(1:3, 35)) Y<-numeric(length=105) set.seed(1234) Y<-rnorm(105) # want to see an effect: Y[TREAT=="A" & TIME==2]<-Y[TREAT=="A" & TIME==2] - 1 DF<-data.frame(Y, ID, TREAT, TIME) # 2 possible designs: # Design 1 with random term DF.aov1<-aov(Y ~ TIME*TREAT + Error(TREAT:ID), data=DF) summary(DF.aov1) # Design 2 without random term DF.aov2<-aov(Y ~ TIME*TREAT, data=DF) summary(DF.aov2) I am also not sure about the design - I think design 1 is more appropriate. What I have tried is to calculate the CI of the coefficients: confint(DF.aov1[[2]]) confint(DF.aov1[[3]]) (or: confint(DF.aov2) ) But how can I get the CI for a concrete difference for example between the treatments at time point 2? I really hope, sombody can help! Karl __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help