Re: [R] how to put the results of loop into a dataframe
Dear Zhi Jie, Zhang, This problem seems so straightforward that I wonder whether I misunderstand what you want: x - runif(100) y - x + 1 z - x + y Data - data.frame(x, y, z) I hope this helps, John On Tue, 20 Jun 2006 09:09:16 +0800 zhijie zhang [EMAIL PROTECTED] wrote: Dear friends, suppose i want to do the following caulation for 100 times, how to put the results of x , y and z into the same dataframe/dataset? x-runif(1) y-x+1 z-x+y thanks in advance! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R galleries
Hello! I just noticed new link on R wiki on R galleries and wanted to share this info with YOU! - R graphical manuals (this is awesome page as there are all help pages of all packages on CRAN and probably even more and all graphics examples are displayed! - more than 8000 images!) http://bg9.imslab.co.jp/Rhelp/ This is a very nice addition to already existing R graph and movies galleries - R Graph Gallery http://addictedtor.free.fr/graphiques/ - R Movies Gallery http://addictedtor.free.fr/movies/ -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc at bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- One must learn by doing the thing; for though you think you know it, you have no certainty until you try. Sophocles ~ 450 B.C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] survest function and counting process style input
Hi, I have fitted a cox model with time-varying covariates (counting process style) using the cph function of the Design package. Now I want to know the survival probability of a single individual at every time of his history. I know the survest function, but I am not sure how to interpretet its output when using time-varying covariates. When the input consists of multiple values, does survest just compute the probabilities as if it are independent individuals or can/does it take in consideration that it is the history of a single individual? Is the latter even possible with a counting process cox model? An example: Individual x has a history of 3 months and the cox model is fitted with two time-varying covariates: a b testcase - data.frame(a =c(4,5,2), b = c(1,0,1)) survest(coxmodel, testcase, time = c(1,2,3)) Is this the right way to compute the probabilities of a single individual? Thank you in advance! Regards, Laurens Alberts [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] how to put the results of loop into a dataframe
On Tue, Jun 20, 2006 at 09:09:16AM +0800, zhijie zhang wrote: suppose i want to do the following caulation for 100 times, how to put the results of x , y and z into the same dataframe/dataset? x-runif(1) y-x+1 z-x+y Several possibilities: 1) Use rbind Before loop: d = NULL And in the loop: d = rbind(d, data.frame(x, y, z)) 2) Build empty data frame of desired size beforehand and fill by row E.g. for 10 rows: d = data.frame( x=rep(0, 10), y=rep(0,10), z=rep(0,10)) And in the loop (index i): d[i, ] = c(x, y, z) 3) Build vectors first, dataframe after the loop x = NULL y = NULL z = NULL in the loop: x = append(x, runif(1)) ... After loop: d = data.frame(x, y, z) Solutions 13 are slower but you don't need to know the final number of rows in advance. Solution 2 is cleaner, in my opinion, but requires that you know the final size. Of course, for the particular example calculation you don't need a loop at all: x = runif(100) y = x+1 z = x+y d = data.frame(x,y,z) cu Philipp -- Dr. Philipp PagelTel. +49-8161-71 2131 Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186 Technical University of Munich Science Center Weihenstephan 85350 Freising, Germany and Institute for Bioinformatics / MIPS Tel. +49-89-3187 3675 GSF - National Research Center Fax. +49-89-3187 3585 for Environment and Health Ingolstädter Landstrasse 1 85764 Neuherberg, Germany http://mips.gsf.de/staff/pagel __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Create variables with common values for each group
Dear all, sorry, this is for sure really basic, but I searched a lot in the internet, and just couldn't find a solution. The problem is to create new variables from a data frame which contains both individual and group variables, such as mean age for an household. My data frame: df hhid h.age 1 1001002023 2 1001002023 3 1001012642 4 1001012660 5 1001014220 6 1001014249 7 1001014252 8 1001015018 9 1001015051 10 1001015028 where hhid is the same number for each household, h.age the age for each household member. I tried tapply, by(), and aggregate. The best I could get was: by(df, df$hhid, function(subset) rep(mean(subset$h.age,na.rm=T),nrow(subset))) df$hhid: 10010020 [1] 23 23 df$hhid: 10010126 [1] 51 51 df$hhid: 10010142 [1] 40.3 40.3 40.3 df$hhid: 10010150 [1] 32.3 32.3 32.3 Now I principally only would have to stack up the mean values, and this is where I'm stucked. The function aggregate works nice, and I could loop then, but I was wondering whether there is a better way to do that. My end result should look like this (assigning mean.age to the data frame): hhid h.age mean.age 1 1001002023 23.00 2 1001002023 23.00 3 1001012642 51.00 4 1001012660 51.00 5 1001014220 40.33 6 1001014249 40.33 7 1001014252 40.33 8 1001015018 32.33 9 1001015051 32.33 10 1001015028 32.33 Cheers, and thanks a lot, Stephan Lindner -- --- Stephan Lindner, Dipl.Vw. 1512 Gilbert Ct., V-17 Ann Arbor, Michigan 48105 U.S.A. Tel.: 001-734-272-2437 E-Mail: [EMAIL PROTECTED] The prevailing ideas of a time were always only the ideas of the ruling class -- Karl Marx __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] hello Excel... (native/Package/BETA)
Dear list members I am pleased to annonce that I have just finished a native Excel reader/writer. It's wrapped up in two packages: either xlsReadWrite (open source) or the slightly beefed-up xlsReadWritePro (shareware). Working with Excel data is now as easy as writing read.xls and write.xls. Some more details: - Infos and download: http://treetron.googlepages.com - for detailed documentation pls. download and see: help files, DESCRIPTION and README. - I set up a newsgroup for technical questions and feedback: http://groups.google.ch/group/supportR - while it could be ported to other platforms, currently it is WINDOWS only (see technical below) - native means, that the file will be read/written in binary form (without needing Excel). The format is Excel version 97 - 2003 - xlsReadWrite and xlsReadWritePro both are powerful: - handle data.frames and matrices/vectors of type double, integer, logical, character - allow to select sheets - support colNames and a title - lets you skip rows at the beginning of the file - the Pro version additionally: - lets you select subdata (columns, rows or pick cells) in Excel - can have colClasses (currently mainly for rownames, more, e.g. string-dates to come) - has xls.sheet: insert, select, delete sheets - has xls.open and xls.close: work with an xls-object in memory - has xls.info: gives information about file - Technical/License: - it's written in Delphi (Pascal) and therefore Windows only - the open source compiler FreePascal potentially allows to compile for other platforms (http://www.freepascal.org/wiki/index.php/Platform_list). [while I am interested in this for reasons of completeness, it's unlikely that I will look into it soon without somebody funding. The Linux people probably won't care anyway and just for macs, hmm, there are still much other things I'd like to look into] - it's written by using the third party library www.tmssoftware.com/flexcel.htm. - the open source version is GPLv2 and has an exception to allow linking flexcel. Due to this exception the package as a whole is non-free and non-standard. - the shareware package has a trial period which allows to check out for anybody for free. After the trial it has to be licenced for a small fee (or you can reinstall it..., but I hope not many people will do that!). It is also possible to license the source code. Suggestions, bug reports and other comments are very welcome. If possible I try to incorporate them in the gold version. Best regards, Hans-Peter [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lattice xyplot - aligning date labels so that they align with the grid lines in panel.grid
Hi Deepayan, You will need to do it manually, e.g.: xyplot(value ~ date, data = x, panel = function(x, y, subscripts, ...) { panel.grid(h = -1, v = 0, col = grey, lwd = 1, lty = 1) panel.abline(v = as.Date(c(2005/01/01, 2006/01/01)), col = grey, lwd = 1, lty = 1) panel.xyplot(x, y, ...) }) For more, you can put in more locations in panel.abline, and the same locations as tick mark positions in scales$y$at. Thanks for the suggestion. That seems to be what I was looking for. This solution now allows me to specify the number of labels. The only cost is that this has be done manually outside the xyplot command but I don't mind this. x - data.frame( date = seq(as.Date(2005/01/01), as.Date(2006/06/01), length.out = 20), value = runif(20)) numLbl - 6 # choose number of labels xx - seq(from = min(x$date), to = max(x$date), length.out = numLbl) xyplot(value ~ date, data = x, panel = function(x, y, subscripts, ...) { panel.grid(h = -1, v = 0, col = grey, lwd = 1, lty = 1) panel.abline(v = xx, col = grey, lwd = 1, lty = 1) panel.xyplot(x, y, ...) }, scale = list(x = list(at = as.numeric(xx), labels = format(xx, %b%y), cex = 0.75, rot = 45)) ) Regards, John. -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: 19 June 2006 19:58 To: Gavin, John Cc: r-help@stat.math.ethz.ch Subject: Re: lattice xyplot - aligning date labels so that they align with the grid lines in panel.grid On 6/19/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have a basic question about aligning date labels for the x-axis in an xyplot so that they align with the grid lines from the panel.grid argument. For example, with x - data.frame( date = seq(as.Date(2005/01/01), as.Date(2006/06/01), length.out = 20), value = runif(20)) xyplot(value ~ date, data = x, panel = function(x, y, subscripts, ...) { panel.grid(h = -1, v = -1, col = grey, lwd = 1, lty = 1) panel.xyplot(x, y, ...) }) How can I get the labels on the x-axis to align with the vertical grid lines? i.e. I have 6 vertical grid lines by default (v = -1) in this example so I would like 6 labels along the x-axis at the same points, whereas I see only 2 (2005 and 2006). You will need to do it manually, e.g.: xyplot(value ~ date, data = x, panel = function(x, y, subscripts, ...) { panel.grid(h = -1, v = 0, col = grey, lwd = 1, lty = 1) panel.abline(v = as.Date(c(2005/01/01, 2006/01/01)), col = grey, lwd = 1, lty = 1) panel.xyplot(x, y, ...) }) For more, you can put in more locations in panel.abline, and the same locations as tick mark positions in scales$y$at. As an alternative I would be happy to just specify the number of labels as long as panel.grid's vertical lines aligned with the labels. Not possible currently, unlikely to be possible ever. R.version.string [1] Version 2.3.1 (2006-06-01) on Windows NT4. Regards, John. John Gavin [EMAIL PROTECTED], Commodities, FIRC, UBS Investment Bank, 2nd floor, 100 Liverpool St., London EC2M 2RH, UK. Phone +44 (0) 207 567 4289 This communication is issued by UBS AG or an affiliate (UBS...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- http://www.stat.wisc.edu/~deepayan/ This communication is issued by UBS AG or an affiliate (UBS...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Create variables with common values for each group
you can use something like: dat - data.frame(hhid = rep(c(10010020, 10010126, 10010142, 10010150), c(2, 2, 3, 3)), h.age = sample(18:50, 10, TRUE)) ### dat$mean.age - rep(tapply(dat$h.age, dat$hhid, mean), tapply(dat$h.age, dat$hhid, length)) dat I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Stephan Lindner [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, June 20, 2006 10:42 AM Subject: [R] Create variables with common values for each group Dear all, sorry, this is for sure really basic, but I searched a lot in the internet, and just couldn't find a solution. The problem is to create new variables from a data frame which contains both individual and group variables, such as mean age for an household. My data frame: df hhid h.age 1 1001002023 2 1001002023 3 1001012642 4 1001012660 5 1001014220 6 1001014249 7 1001014252 8 1001015018 9 1001015051 10 1001015028 where hhid is the same number for each household, h.age the age for each household member. I tried tapply, by(), and aggregate. The best I could get was: by(df, df$hhid, function(subset) rep(mean(subset$h.age,na.rm=T),nrow(subset))) df$hhid: 10010020 [1] 23 23 df$hhid: 10010126 [1] 51 51 df$hhid: 10010142 [1] 40.3 40.3 40.3 df$hhid: 10010150 [1] 32.3 32.3 32.3 Now I principally only would have to stack up the mean values, and this is where I'm stucked. The function aggregate works nice, and I could loop then, but I was wondering whether there is a better way to do that. My end result should look like this (assigning mean.age to the data frame): hhid h.age mean.age 1 1001002023 23.00 2 1001002023 23.00 3 1001012642 51.00 4 1001012660 51.00 5 1001014220 40.33 6 1001014249 40.33 7 1001014252 40.33 8 1001015018 32.33 9 1001015051 32.33 10 1001015028 32.33 Cheers, and thanks a lot, Stephan Lindner -- --- Stephan Lindner, Dipl.Vw. 1512 Gilbert Ct., V-17 Ann Arbor, Michigan 48105 U.S.A. Tel.: 001-734-272-2437 E-Mail: [EMAIL PROTECTED] The prevailing ideas of a time were always only the ideas of the ruling class -- Karl Marx __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Create variables with common values for each group
Stephan Lindner wrote: Dear all, sorry, this is for sure really basic, but I searched a lot in the internet, and just couldn't find a solution. The problem is to create new variables from a data frame which contains both individual and group variables, such as mean age for an household. My data frame: df hhid h.age 1 1001002023 2 1001002023 3 1001012642 4 1001012660 5 1001014220 6 1001014249 7 1001014252 8 1001015018 9 1001015051 10 1001015028 where hhid is the same number for each household, h.age the age for each household member. I tried tapply, by(), and aggregate. The best I could get was: by(df, df$hhid, function(subset) rep(mean(subset$h.age,na.rm=T),nrow(subset))) df$hhid: 10010020 [1] 23 23 df$hhid: 10010126 [1] 51 51 df$hhid: 10010142 [1] 40.3 40.3 40.3 df$hhid: 10010150 [1] 32.3 32.3 32.3 Now I principally only would have to stack up the mean values, and this is where I'm stucked. The function aggregate works nice, and I could loop then, but I was wondering whether there is a better way to do that. You could use aggregate() and then merge() the result with df. Something like this: df.agg - aggregate(df$h.age, list(hhid = df$hhid), mean) names(df.agg)[2] - mean.age merge(df, df.agg) hhid h.age mean.age 1 1001002023 23.0 2 1001002023 23.0 3 1001012642 51.0 4 1001012660 51.0 5 1001014220 40.3 6 1001014249 40.3 7 1001014252 40.3 8 1001015018 32.3 9 1001015051 32.3 10 1001015028 32.3 My end result should look like this (assigning mean.age to the data frame): hhid h.age mean.age 1 1001002023 23.00 2 1001002023 23.00 3 1001012642 51.00 4 1001012660 51.00 5 1001014220 40.33 6 1001014249 40.33 7 1001014252 40.33 8 1001015018 32.33 9 1001015051 32.33 10 1001015028 32.33 Cheers, and thanks a lot, Stephan Lindner -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Create variables with common values for each group
Stephan Lindner lindners at umich.edu writes: The problem is to create new variables from a data frame which contains both individual and group variables, such as mean age for an household. My data frame: df hhid h.age 1 1001002023 2 1001002023 ... where hhid is the same number for each household, h.age the age for each household member. I tried tapply, by(), and aggregate. The best I could get was: by(df, df$hhid, function(subset) rep(mean(subset$h.age,na.rm=T),nrow(subset))) df$hhid: 10010020 [1] 23 23 df$hhid: 10010126 [1] 51 51 try something like do.call(rbind,byresult) As you did not provide a running example, the suggestion is only approximately correct. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] inplace assignment: solution
I worked this out over the weekend. I appreciate that using temporary variables would be simpler but I think this makes for quite readable code: # in RProfile.site inplace - function (f, arg=1) eval.parent(call(-,substitute(f)[[arg+1]], f),2) # examples in code inplace(foo[bar,baz] *2) # or inplace(paste(foo[bar,baz], 1:10)) # or inplace(sub(blah, bleh, foo[bar,baz]), 3) cheers Dave On 16/06/06, David Hugh-Jones [EMAIL PROTECTED] wrote: It's more a general point about having to write things out twice when you do assignments. I could also have written: data.frame[some.condition another.condition, big.list.of.columns] - data.frame[some.condition another.condition, big.list.of.columns] * 2 + 55 or anything else. Equally, there could be any method of subsetting, or any expression that can be an assignment target, on the left hand side: data.frame[[some.complex.expression.for.columnames]] -data.frame[[some.complex.expression.for.columnames]] * 333 + foo * 56 rownames(matrix)[45:53] - paste(rownames(matrix)[45:53], blah) David On 16/06/06, Adaikalavan Ramasamy [EMAIL PROTECTED] wrote: I do not fully understand your question but how about : inplace - function( df, cond1, cond2, cols, suffix ){ w - which( cond1 cond2 ) df - df[ w, cols ] paste(df, suffix) return(df) } BTW, did you mean colnames(df) - paste(colnames(df), suffix) instead of paste(df, suffix) ? Regards, Adai On Fri, 2006-06-16 at 10:23 +0100, David Hugh-Jones wrote: I get tired of writing, e.g. data.frame[some.condition another.condition, big.list.of.columns] - paste(data.frame[some.condition another.condition, big.list.of.columns], foobar) I would a function like: inplace(paste(data.frame[some.condition another.condition, big.list.of.columns], foobar)) which would take the first argument of the inner function and assign the function's result to it. Has anyone done something like this? Are there simple alternative solutions that I'm missing? Cheers David __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Installing bioconductor
Hi, I been trying to install bioconducter into R using the script on the bioconductor home page. However, I get this error message: source(http://www.bioconductor.org/biocLite.R;) Error in file(file, r, encoding = encoding) : unable to open connection In addition: Warning message: unable to connect to 'www.bioconductor.org' on port 80. It is maybe due to security systems at my computer that I cannot go through this port? Does anyone know how I can change the port in R, so I can install the pakages from the bioconductor home page through another port? Thanks, Kristine [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] NLME: using the layout option with the plot command
Hi This is the 2nd time I am posting this question as I never got a reply the 1st time round - apologies to anybody who might take offense at this but I dont know what else to do. I am struggling to split up the plots of the grouped objects in nlme in a usable way. The standard plot command generates plots for each group on a single page. When there are many groups however this does not look so good. I have discovered the layout option which allows one to split up these plots over a certain number of pages but the problem is it very quickly scrolls through all the pages only leaving the final page in the viewer. My question is how does one get to view all these pages? Or even better is there an option where the pages change only when prompted by the user? Thanks Greg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Create variables with common values for each group
?ave x hhid h.age 1 1001002023 2 1001002023 3 1001012642 4 1001012660 5 1001014220 6 1001014249 7 1001014252 8 1001015018 9 1001015051 10 1001015028 cbind(x, ave(x$h.age, x$hhid)) hhid h.age ave(x$h.age, x$hhid) 1 1001002023 23.0 2 1001002023 23.0 3 1001012642 51.0 4 1001012660 51.0 5 1001014220 40.3 6 1001014249 40.3 7 1001014252 40.3 8 1001015018 32.3 9 1001015051 32.3 10 1001015028 32.3 On 6/20/06, Dieter Menne [EMAIL PROTECTED] wrote: Stephan Lindner lindners at umich.edu writes: The problem is to create new variables from a data frame which contains both individual and group variables, such as mean age for an household. My data frame: df hhid h.age 1 1001002023 2 1001002023 ... where hhid is the same number for each household, h.age the age for each household member. I tried tapply, by(), and aggregate. The best I could get was: by(df, df$hhid, function(subset) rep(mean(subset$h.age,na.rm=T ),nrow(subset))) df$hhid: 10010020 [1] 23 23 df$hhid: 10010126 [1] 51 51 try something like do.call(rbind,byresult) As you did not provide a running example, the suggestion is only approximately correct. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Create variables with common values for each group
jim holtman [EMAIL PROTECTED] writes: ?ave Finally, someone remembered it! cbind(x, ave(x$h.age, x$hhid)) hhid h.age ave(x$h.age, x$hhid) 1 1001002023 23.0 2 1001002023 23.0 Or, get rid of ugly colname using cbind(x, hhavg=ave(x$h.age, x$hhid)) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] NLME: using the layout option with the plot command
hi greg If you are using windows, set up a plot window and click the Record option in the menu. Then run the command. Now you can scroll back through previous pages by hitting Page Up. Beware that if you save your workspace without clearing the history, you may have a lot of bloat from the graphs. David On 20/06/06, Greg Distiller [EMAIL PROTECTED] wrote: Hi This is the 2nd time I am posting this question as I never got a reply the 1st time round - apologies to anybody who might take offense at this but I dont know what else to do. I am struggling to split up the plots of the grouped objects in nlme in a usable way. The standard plot command generates plots for each group on a single page. When there are many groups however this does not look so good. I have discovered the layout option which allows one to split up these plots over a certain number of pages but the problem is it very quickly scrolls through all the pages only leaving the final page in the viewer. My question is how does one get to view all these pages? Or even better is there an option where the pages change only when prompted by the user? Thanks Greg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] timediff
Hello, I've got 2 dates like these : 2006-02-08 17:12:55 2006-02-08 17:15:26 I wish to get the middle of these two date : 2006-02-08 17 :14 :10 Is there is a function in R to do that ? Thks all guillaume [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] timediff
COMTE Guillaume [EMAIL PROTECTED] writes: I've got 2 dates like these : 2006-02-08 17:12:55 2006-02-08 17:15:26 I wish to get the middle of these two date : 2006-02-08 17 :14 :10 Is there is a function in R to do that ? Well, x1 - as.POSIXct(2006-02-08 17:12:55) x2 - as.POSIXct(2006-02-08 17:15:26) x2-x1 Time difference of 2.516667 mins (x2-x1)/2 Time difference of 1.258333 mins x1+60*as.numeric((x2-x1)/2) [1] 2006-02-08 17:14:10 CET However, this goes wrong (although not without warning): x1+(x2-x1)/2 [1] 2006-02-08 17:12:56 CET Warning message: Incompatible methods (+.POSIXt, Ops.difftime) for + ---for reasons that are related to this: as.numeric(x2)-as.numeric(x1) # seconds! [1] 151 as.numeric(x2-x1) # minutes [1] 2.516667 (This suggests to me that the methodology for difftime objects is still not quite complete. Volunteers?) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] expanded dataset and random number
Dear all R-users, (My apologies if this subject is wrong) I have dataset: mydat - as.data.frame( matrix(c(14,0,1,0,1,1, 25,1,1,0,1,1, 5,0,0,1,1,0, 31,1,1,1,1,1, 10,0,0,0,0,1), nrow=5,ncol=6,byrow=TRUE)) dimnames(mydat)[[2]] -c(size,A,B,C,D,E) mydat size A B C D E 1 14 0 1 0 1 1 2 25 1 1 0 1 1 35 0 0 1 1 0 4 31 1 1 1 1 1 5 10 0 0 0 0 1 sum(mydat$size) [1] 85 where size is number of each row that have this combination of variables. In this dataset I have 85 tuples in expanded dataset. I want to generate random number between 1 and 85. Say, if the first random number is 15, so the number 15 is 1 1 0 1 1 then, if the next random number is 7, then 0 1 0 1 1 then if random number is 79 0 0 0 0 1 random number is 46 1 1 1 1 1 random number is 3 0 1 0 1 1 random number is 28 1 1 0 1 1 So, the result random tuples (order from 6 random number): 0 1 0 1 1 0 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 1 I would be very happy if anyone could help me. Thank you very much in advance. Kindly regards, Muhammad Subianto __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] timediff
On Tue, 20 Jun 2006 12:38:11 +0200 COMTE Guillaume wrote: Hello, I've got 2 dates like these : 2006-02-08 17:12:55 2006-02-08 17:15:26 I wish to get the middle of these two date : There is a mean method for POSIXct objects: x - as.POSIXct(c(2006-02-08 17:12:55, 2006-02-08 17:15:26)) mean(x) Best, Z 2006-02-08 17 :14 :10 Is there is a function in R to do that ? Thks all guillaume [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Function hints
Jonathan Baron wrote: On 06/19/06 13:13, Duncan Murdoch wrote: `help.search' does not allow full text search in the manpages (I can imagine why (1000 hits...), but without such a thing google, for instance, would probably not be half as useful as it is, right?) and there is no sorting by relevance in the `help.search' output, I think. how this sorting could be achieved is a different question, of course. You probably want RSiteSearch(keyword, restrict=functions) (or even without the restrict part). Yes. The restrict part will speed things up quite a bit, if you want to restrict to functions. Or, alternatively, you could use Namazu (which I use to generate what RSiteSearch provides) to generate an index specific to your own installed functions and packages. The trick is to cd to the directory /usr/lib/R/library, or the equivalent, and then say mknmz -q */html which will pick up the html version of all the man pages (assuming you have generated them, and I have no idea whether this can be done on Windows). To update, say mknmz --update=. -q */html Then make a bookmark for the Namazu search page in your browser, as a local file. (I haven't given all the details. You have to install Namazu and follow the instructions.) Or, if you have a web server, you could let Google do it for you. But, I warn you, Google will fill up your web logs pretty fast if you don't exclude it with robots.txt. I don't let it search my R stuff. I think that Macs and various Linux versions also have other alternative built-in search capabilities, but I haven't tried them. Beagle is the new Linux search tool, but I don't know what it does. Jon thanks for theses tips. I was not aware of the `RSiteSearch' function (I did know of the existence of the web sites, though) and this helps, but of course this is depdendent on web access (off-line labtop usage...) and does not know of 'local' (non-CRAN) packages (and knows of maybe too many contributed packages, which I might not want to consider for one reason or the other) thanks also for the hint on `Namazu'. maybe I do as adviced to get a index which is aware of my local configuration and private packages. (under MacOS there is a very good and fast full text search engine, but it cannot be told to only search the R documentation, for instance, so one gets lots of other hits as well.) what I really would love to see would be an improved help.search(): on r-devel I found a reference to the /concept tag in .Rd files and the fact that it is rarely used (again: I was not aware of this :-( ...), which might serve as keyword container suitable for improving help.search() results. what about changing the syntax here to something like \concept { keyword = score, keyword = score ... } where score would be restricted to a small range of values (say, 1-3 or 1-5). if package maintainer then would choose a handful of sensible keywords (and scores) for a package and its functions one could expect improved search results. this might be a naive idea, but could a sort-by-relevance in the help.search() output profit from this? to make it short: I'm not happy with the output, for instance, of help.search(fitting) #1 vs. help.search(linear fitting)#2 vs. help.search(non-linear fitting)#3 I somehow feel that `lm' and `nls' should both be found in the first search and that they should be near the top of the lists when they are found. but `lm' is found only in #1 (near the bottom of the list) and `nls' not at all (which is really bad). this is partly a problem, of course, of inconsistent nomenclature in the manpages but also due to the fact that help.search() only accepts single phrases as pattern (and maybe the absense of concept keywords including a score?) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Accessing date subfields
Hello, I can't figure out a proper way to extract the month number from a Date class variable. I can do it like this: today - as.Date(Sys.time()) as.integer (format.Date (today, %m)) but it must be inefficient, since I convert a date to text and back to a number. I tried: months(today) but the months() function returns the name of the month, not the month number. I need to process some time series of station data using season-dependent criteria, so I need the months numerically. Thanks in advance for any help, Maciej. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] nested for loop restriction?
Hello, is there a restriction for the number of loops in a nested for-loop in R? I wrote a small function to replace water gage hights by discharge values, where the outer loop walks through the levels of a gage time series and the inner loop looks up the corresponding dicharge value in a vector. It seems to work well, with the (however very annoying) restriction that the inner loop stops after 60 steps. I attached the function at the end of the mail, where tpframe is a 2-column time series dataframe (date,gage hights) and pqframe is a 2-column dataframe (gage hights, discharge). Any kind of help appreciated, as I am no native programmer and also quite new to R also replies like nice try, but there is a more convenient way in R: ..., thanks in advance, René p.zu.q - function (tpframe, pqframe) { tp - factor(tpframe[[2]]) tq - tp p - pqframe[[1]] q - pqframe[[2]] for (i in 1:length(levels(tp))) { pegel-levels(tp)[i] for (j in 1:length(brugga.p)) { if (p[j] == pegel) {levels(tq)[i] - q[j] break } else next } next } tpq - cbind(tpframe[[1]],as.data.frame(tp),as.data.frame(tq)) names(tpq) - c(date,P mm,Q m3/s) tpq } _ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] rescale the data into unit square?
Dear Rusers, Recently, i saw the sentence rescale the data into unit square for several times. Could anybody tell me what it means,and give an example? Thanks very much! -- Kind Regards, Zhi Jie,Zhang , [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How large a genetic analysis will you be able to do in R...
From: john hickey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: R genetic parameters Date: Tue, 20 Jun 2006 11:20:45 + X-OriginalArrivalTime: 20 Jun 2006 11:20:48.0892 (UTC) FILETIME=[94F903C0:01C6945B] X-Virus-Scanned: by amavisd-new at fcav.unesp.br Luiz, How large a genetic analysis will you be able to do in R, for example could you have 40,000 animals with records across 7,000 contemporary groups, a pedigree of 100,000 and do a three trait multivariate analysis on a 32 bit machine? I suspect that r can not handle so many fixed effects levels? Regards, John Hickey. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] GARCH
Dear all R-users, I have a GARCH related query. Suppose I fit a GARCH(1,1) model on a dataframe dat garch1 = garch(dat) summary(garch1) Call: garch(x = dat) Model: GARCH(1,1) Residuals: Min 1Q Median 3Q Max -4.7278 -0.3240 0. 0.3107 12.3981 Coefficient(s): Estimate Std. Error t value Pr(|t|) a0 1.212e-04 2.053e-0659.05 2e-16 *** a1 1.001e+00 4.165e-0224.04 2e-16 *** b1 2.435e-15 1.086e-02 2.24e-131 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Diagnostic Tests: Jarque Bera Test data: Residuals X-squared = 54480.76, df = 2, p-value 2.2e-16 Now I want to store the value of Pr(|t|) for coefficient a0, a1, and b1, and also values of these coefficients, so that I can use them in future separately. I know that I can do it for coefficients by using the command: coef(garch1)[a0] etc, but not for Pr(|t|). Can anyone please tell me how to do this? Thanks and regards, [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accessing date subfields
Maciej Radziejewski [EMAIL PROTECTED] writes: Hello, I can't figure out a proper way to extract the month number from a Date class variable. I can do it like this: today - as.Date(Sys.time()) as.integer (format.Date (today, %m)) but it must be inefficient, since I convert a date to text and back to a number. I tried: months(today) but the months() function returns the name of the month, not the month number. I need to process some time series of station data using season-dependent criteria, so I need the months numerically. Thanks in advance for any help, Wrong class, Date (and POSIXct) objects are basically numeric (time in days, resp. seconds, since Jan. 1, 1970): structure(1,class=Date) [1] 1970-01-02 structure(1,class=POSIXct) [1] 1970-01-01 01:00:01 CET Instead, try: as.POSIXlt(Sys.time())$mon [1] 5 (NB: zero-based...) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] nested for loop restriction?
Hi If you do not insist on loops you can either use merge merge(tpframe, pqframe) or df.new-data.frame(date=tpframe$date, discharge=pqframe$discharge[match(tpframe$gage heights, pqframe$gage heights)]) I hope I did not do typo :-) HTH Petr On 20 Jun 2006 at 14:20, René Capell wrote: Date sent: Tue, 20 Jun 2006 14:20:50 +0200 From: René Capell [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Organization: http://freemail.web.de/ Subject:[R] nested for loop restriction? Hello, is there a restriction for the number of loops in a nested for-loop in R? I wrote a small function to replace water gage hights by discharge values, where the outer loop walks through the levels of a gage time series and the inner loop looks up the corresponding dicharge value in a vector. It seems to work well, with the (however very annoying) restriction that the inner loop stops after 60 steps. I attached the function at the end of the mail, where tpframe is a 2-column time series dataframe (date,gage hights) and pqframe is a 2-column dataframe (gage hights, discharge). Any kind of help appreciated, as I am no native programmer and also quite new to R also replies like nice try, but there is a more convenient way in R: ..., thanks in advance, René p.zu.q - function (tpframe, pqframe) { tp - factor(tpframe[[2]]) tq - tp p - pqframe[[1]] q - pqframe[[2]] for (i in 1:length(levels(tp))) { pegel-levels(tp)[i] for (j in 1:length(brugga.p)) { if (p[j] == pegel) {levels(tq)[i] - q[j] break } else next } next } tpq - cbind(tpframe[[1]],as.data.frame(tp),as.data.frame(tq)) names(tpq) - c(date,P mm,Q m3/s) tpq } _ Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] rcor.test keeping column names
I have been using the function rcor.test in the ltm package and have been trying to use it for p-values of pairwise correlations using the pearson correlation . However when I call the p-values from the output it gives me back a number index instead of the row names (I transposed the columns and rows to compare genes and not columns) which shows up as column.number column.number p-value Is there anyway to get out an output that looks like column.name1 correlation p-value column.name2 for each pairwise comparison or at least to get column.name1 column.name2 p.value Damion Nero Plant Molecular Biology Lab Department of Biology New York University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Accessing date subfields
Hi you can also do as.POSIXlt(today)$mon but I do not know if it is more efficient HTH Petr On 20 Jun 2006 at 5:20, Maciej Radziejewski wrote: Date sent: Tue, 20 Jun 2006 05:20:38 -0700 (PDT) From: Maciej Radziejewski [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Accessing date subfields Send reply to: Maciej Radziejewski [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Hello, I can't figure out a proper way to extract the month number from a Date class variable. I can do it like this: today - as.Date(Sys.time()) as.integer (format.Date (today, %m)) but it must be inefficient, since I convert a date to text and back to a number. I tried: months(today) but the months() function returns the name of the month, not the month number. I need to process some time series of station data using season-dependent criteria, so I need the months numerically. Thanks in advance for any help, Maciej. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Slight fault in error messages
Thank you, Yan, Yan == Yan Wong [EMAIL PROTECTED] on Tue, 13 Jun 2006 12:27:48 +0100 writes: Yan Just a quick point which may be easy to correct. Whilst Yan typing the wrong thing into R 2.2.1, I noticed the Yan following error messages, which seem to have some stray Yan quotation marks and commas in the list of available Yan families. Perhaps they have been corrected in the Yan latest version (sorry, I don't want to upgrade yet, but Yan it should be easy to check)? glm(1 ~ 2, family=quasibinomial(link=foo)) Yan Error in quasibinomial(link = foo) : ?foo? link not Yan available for quasibinomial family, available links are Yan logit, , probit and cloglog glm(1 ~ 2, family=binomial(link=foo)) Yan Error in binomial(link = foo) : link foo not Yan available for binomial family, available links are Yan logit, probit, cloglog, cauchit and log Yan I hope this is helpful, yes, indeed, thank you. It will be fixed in the next versions of R. Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] rcor.test keeping column names
you can try something like the following: mat - matrix(rnorm(1000), 100, 10, dimnames = list(NULL, LETTERS[1:10])) rcts - rcor.test(mat) rcts pvals - as.data.frame(rcts$p.values) pvals$corr - rcts$cor.mat[lower.tri(rcts$cor.mat)] pvals[1:2] - sapply(pvals[1:2], factor, levels = 1:ncol(mat), labels = colnames(mat), simplify = FALSE) pvals[c(1,2,4,3)] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Damion Colin Nero [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, June 20, 2006 2:49 PM Subject: [R] rcor.test keeping column names I have been using the function rcor.test in the ltm package and have been trying to use it for p-values of pairwise correlations using the pearson correlation . However when I call the p-values from the output it gives me back a number index instead of the row names (I transposed the columns and rows to compare genes and not columns) which shows up as column.number column.number p-value Is there anyway to get out an output that looks like column.name1 correlation p-value column.name2 for each pairwise comparison or at least to get column.name1 column.name2 p.value Damion Nero Plant Molecular Biology Lab Department of Biology New York University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] list of interdependent functions
Hello, I discussed the following problem on the great useR conference with several people and wonder if someone of you knows a more elegant (or more common ?) solution than the one below. The problem: I have several sets of interrelated functions which should be compared. The functions themselves have different structure, application-specific names (for readability) and they should be exchangeable. I want to avoid to construct a generic for every new function, but the functions should be aggregated together in a common data structure (e.g. list eq or an S4 instance) *and* it should be able for them to see and call each other with too many $ or @. These functions are used in another function (called solver here) which may be used to prepare something before the call to f2. The example and a possible solution (which uses an environment manipulating function putInEnv()) is given below. Thanks a lot Thomas ##== ## An example ##== ## a small list of functions eq - list( f1 = function(x, K) K - x, f2 = function(x, r, K) r * x * f1(x, K) ) ## a solver fnction which calls them solverB - function(eq) { eq - putInEnv(eq, environment()) # that's the trick f1(3,4) + f2(1,2,3) } ## and the final call (e.g. from the command line) solverB(eq) ##== ## One possible solution. Is there a better one??? ##== putInEnv - function(eq, e) { ## clone, very important to avoid interferences!!! eq - as.list(unlist(eq)) lapply(eq, environment-, e) nn - names(eq) for (i in 1:length(eq)) { assign(nn[i], eq[[i]], envir = e) } eq } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] rescale the data into unit square?
If you can quote an actual instance of where it's mentioned, perhaps that will make it more clear. I'd interpret that as simply rescaling all variables to have min=0 and max=1, one variable at a time. Andy From: zhijie zhang Dear Rusers, Recently, i saw the sentence rescale the data into unit square for several times. Could anybody tell me what it means,and give an example? Thanks very much! -- Kind Regards, Zhi Jie,Zhang , [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] npmc package error
Hello all I haven't got the npmc package to work yet, despite several attempts. I'm new to R, so this might be a stupid question, but it's taking me hours already, so I'm asking for help. To be exact, this is what I typed, and what R told me: ++ colsmall-read.table(DBtest2) library(npmc) npmc(colsmall) Error in as.vector(x, mode) : invalid 'mode' of argument small.data-data.frame(class=colsmall$V1,var=colsmall$V2) small.data class var 1 alpha 111.5 2 alpha 114.4 3 alpha 124.8 4 alpha 110.0 5 alpha 102.0 6 alpha 121.0 [etc] npmc(small.data) Error in uniroot(f = function(arg) p - z.dist(arg, corr = corr, df = df, : f() values at end points not of opposite sign ++ The data file can be sent upon request. What did I do wrong? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Bayesian logistic regression?
Hi all. Are there any R functions around that do quick logistic regression with a Gaussian prior distribution on the coefficients? I just want posterior mode, not MCMC. (I'm using it as a step within an iterative imputation algorithm.) This isn't hard to do: each step of a glm iteration simply linearizes the derivative of the log-likelihood, and, at this point, essentially no effort is required to augment the data to include the prior information. I think this can be done by going inside the glm.fit() function--but if somebody's already done it, that would be a relief! Thanks. Andrew -- Andrew Gelman Professor, Department of Statistics Professor, Department of Political Science [EMAIL PROTECTED] www.stat.columbia.edu/~gelman Statistics department office: Social Work Bldg (Amsterdam Ave at 122 St), Room 1016 212-851-2142 Political Science department office: International Affairs Bldg (Amsterdam Ave at 118 St), Room 731 212-854-7075 Mailing address: 1255 Amsterdam Ave, Room 1016 Columbia University New York, NY 10027-5904 212-851-2142 (fax) 212-851-2164 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] write.table decimal digits
Hi all, I have a table with values that I rounded with: mytable = round(mytable, digits=2) and when I use write.table: write.table(mytable, file = /home/user/mytable.txt, sep = , row.names=TRUE, col.names=TRUE, quote=FALSE) the values are printed like 1 instead of 1.00 (which would make the table well-arranged vertically). How can I force write.table to write the values with two-digited decimals for all the fields? Thanks in advance, Albert. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R Training in the USA
Hello - need advice on a company or individual who will offer custom training in R in Atlanta Georgia. Specifically need training on data manipulations (equivalent to SAS data steps in R) and R Graphics. Does anyone know folks who train on R or any Firms? Google searches are coming up empty. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R Training in the USA
These guys advertize R workshops on the list fairly regularly: http://www.xlsolutions-corp.com/ Best, Jim zubin wrote: Hello - need advice on a company or individual who will offer custom training in R in Atlanta Georgia. Specifically need training on data manipulations (equivalent to SAS data steps in R) and R Graphics. Does anyone know folks who train on R or any Firms? Google searches are coming up empty. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] list of interdependent functions
Martin Morgan wrote: Here's another way: makeSolver - function() { f1 - function(x, K) K - x f2 - function(x, r, K) r * x * f1(x, K) function() f1(3,4) + f2(1,2,3) } solverB - makeSolver() solverB() makeSolver (implicitly) creates an environment, installs f1 and f2 into it, and then returns a function that gets assigned to solverB. Calling solverB invokes the function in makeSolver, so f1 and f2 are visible to it. The principle is similar to the 'bank account' example in section 10.7 of 'An introduction to R', available in the manuals section of cran. Thank you, and of course, I know this section, but's in fact a little bit different and uses a list of functions inside a function. Your solution is obvious at a first look but more tricky in the details. I wonder if it is possible to access the functions directly, e.g. to change the body of f1 from K-x to, say 1 (switch it off) or to introduce new functions afterwards (in a straigtforward way avoiding things like as.list(body) ... A down side is that the signature of solverB is not obvious; I'm not sure how the documentation facilities (R CMD check) cope with this. I don't know either and it may seem a little bit ghostly (to some users ;-) that one copies R function makeSolver to solverB but in reality gets a completely different function solverB that in fact uses *delegation* to access functions f1 and f2 stored in another object. Nice poster at useR! Thanks! Martin Thank you again. Thomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] $
If object is user defined is: object$df.residual the same thing as df.residual(object) This is my first time to encounter the $ sign in R, I'm new. I'm reviewing summary.glm and in most cases it looks as though the $ is used to extract some characteristic/property of the object, but I'm not positive. Thanks ~~ Jacob Davis Actuarial Analyst [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Installing bioconductor
Hi Kristine, Kristine Kleivi [EMAIL PROTECTED] writes: I been trying to install bioconducter into R using the script on the bioconductor home page. However, I get this error message: source(http://www.bioconductor.org/biocLite.R;) Error in file(file, r, encoding = encoding) : unable to open connection In addition: Warning message: unable to connect to 'www.bioconductor.org' on port 80. Bioconductor has its own mailing lists and issues with BioC installation, etc are best directed there. (http://www.bioconductor.org/docs/mailList.html) It is maybe due to security systems at my computer that I cannot go through this port? Does anyone know how I can change the port in R, so I can install the pakages from the bioconductor home page through another port? Most likely, your access to the internet is via a web proxy. Try reading the help page for download.packages, there are details there on how to configure R to connect to the internet via a web proxy. + seth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multivariate splits
Glenn De'ath published a paper in 'Ecology' several years ago and included S-Plus functions in the archives. I haven't looked at the files, so I'm not sure what modifications would be necessary for R. De'ath, G. 2002. Multivariate regression trees: a new technique for modeling species--environment relationships. Ecology 83:1105-1117. Archives: http://www.esapubs.org/archive/ecol/E083/017/ Scott Date: Mon, 19 Jun 2006 16:17:40 +0200 From: B?lint Cz?cz [EMAIL PROTECTED] Subject: [R] multivariate splits To: r-help r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed Dear R users! Does someone know about any algorithms / packages in R, that perform classification / regression / decision trees using multivariate splits? I have done some research, but I found nothing. Packages tree and rpart seem only to be able to do CART with univariate splits. Thank you for your help! B?lint -- Cz?cz B?lint PhD hallgat? BCE KTK Talajtan ?s V?zgazd?lkod?s Tansz?k 1118 Budapest, Vill?nyi ?t 29-43. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Function hints
what I really would love to see would be an improved help.search(): on r-devel I found a reference to the /concept tag in .Rd files and the fact that it is rarely used (again: I was not aware of this :-( ...), which might serve as keyword container suitable for improving help.search() results. what about changing the syntax here to something like \concept { keyword = score, keyword = score ... } where score would be restricted to a small range of values (say, 1-3 or 1-5). if package maintainer then would choose a handful of sensible keywords (and scores) for a package and its functions one could expect improved search results. this might be a naive idea, but could a sort-by-relevance in the help.search() output profit from this? This is not something I think you can solve automatically. Good keywording requries a lot of effort, and needs to be consistent to be useful. The only way to achieve consistency is to have only person keywording (difficult/expensive), or exhaustively document the process of keywording and then require all package authors to read and use (impossible). Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Function hints
hadley wickham wrote: what I really would love to see would be an improved help.search(): on r-devel I found a reference to the /concept tag in .Rd files and the fact that it is rarely used (again: I was not aware of this :-( ...), which might serve as keyword container suitable for improving help.search() results. what about changing the syntax here to something like \concept { keyword = score, keyword = score ... } where score would be restricted to a small range of values (say, 1-3 or 1-5). if package maintainer then would choose a handful of sensible keywords (and scores) for a package and its functions one could expect improved search results. this might be a naive idea, but could a sort-by-relevance in the help.search() output profit from this? This is not something I think you can solve automatically. Good keywording requries a lot of effort, and needs to be consistent to be useful. The only way to achieve consistency is to have only person I was thinking of manual keywording (by the package authors, nobody else!) as a means to give the search engine (help.search()) reasonable information including a (subjective) relevance score for each keyword. of course, the problem is the same as with every (especially permuted) index: to find the best compromise betweeen indexing next to nothing and indexing everything (the best probably meaning to index comprehensively but not excessively with reasonable index terms) in the documents at hand. sure, consistency could not be enforced but it's not consistent right now, simply because the real \keyword tag is far to restrictive for indexing purposes(only a handful of predefined allowed keywords) and otherwise only the name/alias and title in the Rd files seem to be searched (and here the author must be really aware that these fields are at the moment the ones which should be forced to contain the relevant 'keywords' if the function is to be found by help.search -- this imposes sometimes rather artificial constraints on the wording, especially if you try to include some general keyword in the title of a very specialized function). looking at the example I gave (help.search(fitting) etc.) it's quite clear that `nls' simply is not found because 'fitting' does not occur in the title, but I trust, if asked to provide, say, three keywords, one of them would contain fit or fitting. I mean, every scientific journal asks you to do just this: provide some free-text keywords, which you think to be relevant for the paper. there are no restrictions/directives, usually, but the purpose (to categorize the paper a bit) is served quite well. and maybe the \concept tag really is meant for something different, I'm not sure. what I have in mind really is similar to providing index terms (plus scores to guide `help.search' in sorting). to stay with the `nls' example: \concept { non-linear fitting = 4 non-linear least-squares = 5 non-linear models = 3 parameter estimimation = 2 gauss-newton = 1 } would probably achieve that `nls' usually is correctly found (if this syntax were allowed). apart from the scores (which would be nice, I think) my main point is that extensive use of \concept (or a new tag `\index', for instance, if \concept's purpose is actually different -- I'm not sure) should be pushed to get better hits from help.search(). I personally have decided to start using the \concept tag in its present form for our local .Rd files extensively to inject a sufficient number of free-text relevant keywords into help.search() joerg keywording (difficult/expensive), or exhaustively document the process of keywording and then require all package authors to read and use (impossible). Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] glm beta hypothesis testing
In summary.glm I'm trying to get a better feel for the z output. The following lines can be found in the function 1 if (p 0) { 2p1 - 1:p 3Qr - object$qr 4coef.p - object$coefficients[Qr$pivot[p1]] 5covmat.unscaled - chol2inv(Qr$qr[p1, p1, drop = FALSE]) 6dimnames(covmat.unscaled) - list(names(coef.p), names(coef.p)) 7covmat - dispersion * covmat.unscaled 8var.cf - diag(covmat) 9s.err - sqrt(var.cf) 10 tvalue - coef.p/s.err 11 dn - c(Estimate, Std. Error) In line 10 where the tvalue is calculated I understand where s.err is coming from and why it is used, but coef.p is throwing me for a loop. First off what is: coef.p - object$coefficients[Qr$pivot[p1]] giving us? This should be the distance the sample is from the null hypothesis so that when we divide by the standard error we get the t value. Then we would check distance to decide to reject or not. ~~ Jacob Davis Actuarial Analyst [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] $
Davis, Jacob B. wrote: If object is user defined is: object$df.residual the same thing as df.residual(object) This is my first time to encounter the $ sign in R, I'm new. I'm reviewing summary.glm and in most cases it looks as though the $ is used to extract some characteristic/property of the object, but I'm not positive. Thanks ~~ Jacob Davis Actuarial Analyst [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html `$' is for list component extraction. this is really very basic and, for once (I usually don't like this answer...), looking at the very first pages of the very first manual, would be not so bad an idea: http://cran.r-project.org/ -- Manuals -- An Introduction to R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] changes to terms.formula in 2.3.x
Hi, all, I just recently noticed a change in terms.formula from 2.2.1 to 2.3.1 (possibly 2.3.0, but I didn't check). Here's the problem: ## 2.2.1 update(~ x | y, z ~ .) z ~ x | y ## 2.3.1 update(~ x | y, z ~ .) z ~ (x | y) and in the NEWS for 2.3.1 o terms.formula needed to add parentheses to formulae with terms containing '|'. (PR#8462) So, there must be a reason for this change. However, in the lattice framework I have this causes many problems because now the `|' is interpreted as a logical OR. Could someone suggest a workaround for me so that I still get the 2.2.1 behavior my code relies on. Here's a very simple test function (works in 2.2.1, fails in 2.3.1): library(lattice) foo - function(x, data) { x - update(x, y ~ .) xyplot(x, data) } z - expand.grid(x = 1:10, g = letters[1:3]) z$y - rnorm(nrow(z)) foo(~ x | g, z) Thanks, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] FW: multivariate splits
-Original Message- From: Vayssières, Marc Sent: Tuesday, June 20, 2006 9:35 AM To: '[EMAIL PROTECTED]' Subject: RE: [R] multivariate splits Glen De'ath's package for R is on cran! It is called mvpart, see: http://cran.cnr.berkeley.edu/doc/packages/mvpart.pdf Cheers, Marc Vayssières -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Rollins Sent: Tuesday, June 20, 2006 8:13 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] multivariate splits Glenn De'ath published a paper in 'Ecology' several years ago and included S-Plus functions in the archives. I haven't looked at the files, so I'm not sure what modifications would be necessary for R. De'ath, G. 2002. Multivariate regression trees: a new technique for modeling species--environment relationships. Ecology 83:1105-1117. Archives: http://www.esapubs.org/archive/ecol/E083/017/ Scott Date: Mon, 19 Jun 2006 16:17:40 +0200 From: B?lint Cz?cz [EMAIL PROTECTED] Subject: [R] multivariate splits To: r-help r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed Dear R users! Does someone know about any algorithms / packages in R, that perform classification / regression / decision trees using multivariate splits? I have done some research, but I found nothing. Packages tree and rpart seem only to be able to do CART with univariate splits. Thank you for your help! B?lint -- Cz?cz B?lint PhD hallgat? BCE KTK Talajtan ?s V?zgazd?lkod?s Tansz?k 1118 Budapest, Vill?nyi ?t 29-43. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] changes to terms.formula in 2.3.x
Try this: fo - ~ x | y fo[[3]] - fo[[2]] fo[[2]] - as.name(z) fo z ~ x | y On 6/20/06, Sundar Dorai-Raj [EMAIL PROTECTED] wrote: Hi, all, I just recently noticed a change in terms.formula from 2.2.1 to 2.3.1 (possibly 2.3.0, but I didn't check). Here's the problem: ## 2.2.1 update(~ x | y, z ~ .) z ~ x | y ## 2.3.1 update(~ x | y, z ~ .) z ~ (x | y) and in the NEWS for 2.3.1 o terms.formula needed to add parentheses to formulae with terms containing '|'. (PR#8462) So, there must be a reason for this change. However, in the lattice framework I have this causes many problems because now the `|' is interpreted as a logical OR. Could someone suggest a workaround for me so that I still get the 2.2.1 behavior my code relies on. Here's a very simple test function (works in 2.2.1, fails in 2.3.1): library(lattice) foo - function(x, data) { x - update(x, y ~ .) xyplot(x, data) } z - expand.grid(x = 1:10, g = letters[1:3]) z$y - rnorm(nrow(z)) foo(~ x | g, z) Thanks, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] $
Thanks for humbling yourself to my level and not answering my question. If object is user defined is: object$df.residual the same thing as df.residual(object) You know I have self taught myself: Visual Basic, PL/SQL, C++, Matlab and I'm not a programmer. In these programs I help beginners all the time with the dumb easy to find questions because the first few months of working with a new language can be overwhelming even when the answer is staring you in the face. I have been in R less than a month and I only have time to spend maybe 20 minutes a day with it. I have about five manuals sitting on my desk that I thumb through while surfing the internet trying to figure things out. Asking about the $ sign is a basic question, but until I have spent at least 400 or so hours with the program I'm not going to know how to help myself. I go through this every time I learn a new piece of software and every time comments like yours come up. For the most part I'm sure most of the questions that come up in the list-serve can be answered independently if enough independent digging is done. The purpose of the list-serve is to aid and speed up the learning process. You know in about six months or a year I'm sure I will be up to speed and making contributions and then I will be helping to answer the $ sign questions so that they can be up to speed also and contribute. In the beginning it's helpful just to know where the resources are so one can begin to get a feel for how to help their self. Patrick Burns showed me where S Poetry was, being a newbie I had no idea what are where that was, now I do. -Original Message- From: Joerg van den Hoff [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 20, 2006 11:21 AM To: Davis, Jacob B. Cc: r-help@stat.math.ethz.ch Subject: Re: [R] $ Davis, Jacob B. wrote: If object is user defined is: object$df.residual the same thing as df.residual(object) This is my first time to encounter the $ sign in R, I'm new. I'm reviewing summary.glm and in most cases it looks as though the $ is used to extract some characteristic/property of the object, but I'm not positive. Thanks ~~ Jacob Davis Actuarial Analyst [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html `$' is for list component extraction. this is really very basic and, for once (I usually don't like this answer...), looking at the very first pages of the very first manual, would be not so bad an idea: http://cran.r-project.org/ -- Manuals -- An Introduction to R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Help with dimnames()
Hi R people: I'm trying to set the dimnames of a data frame called ests and am having trouble! First, I check to see if ests is a data.frame... is.data.frame( ests ) [1] TRUE ... and it is a data frame! Next, I try to assign dimnames to that data frame dimnames( ests )[[ 1 ]] - as.character( ests$stfips ) Error in row.names-.data.frame(`*tmp*`, value = c(1001, 1003, 1005, : missing 'row.names' are not allowed ... and I have trouble!! Finally, I check to see if ests$stfips has the same length as the number of rows in ests... nrow( ests ) == length( as.character( ests$stfips ) ) [1] TRUE ... and it does!! Does anybody have a suggestion to solve this problem? Thanks! Phil Smith [EMAIL PROTECTED] National Immunization Program Centers for Disease Control and Prevention Atlanta, GA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Help with dimnames()
On Tue, 20 Jun 2006, Smith, Phil (CDC/NIP/DMD) wrote: Hi R people: I'm trying to set the dimnames of a data frame called ests and am having trouble! First, I check to see if ests is a data.frame... is.data.frame( ests ) [1] TRUE ... and it is a data frame! Next, I try to assign dimnames to that data frame dimnames( ests )[[ 1 ]] - as.character( ests$stfips ) Error in row.names-.data.frame(`*tmp*`, value = c(1001, 1003, 1005, : missing 'row.names' are not allowed ests - data.frame(x=runif(50), y=runif(50)) stfips - c(letters[1:25], LETTERS[1:25]) is.na(stfips) - 50 dimnames( ests )[[ 1 ]] - as.character(stfips) reproduces the error message, and: which(is.na(stfips)) says which stfips is missing. If more than one is missing, the error message is different. ... and I have trouble!! Finally, I check to see if ests$stfips has the same length as the number of rows in ests... nrow( ests ) == length( as.character( ests$stfips ) ) [1] TRUE ... and it does!! Does anybody have a suggestion to solve this problem? Thanks! Phil Smith [EMAIL PROTECTED] National Immunization Program Centers for Disease Control and Prevention Atlanta, GA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] $
Davis, Jacob B. JBDavis at txfb-ins.com writes: Thanks for humbling yourself to my level and not answering my question. If object is user defined is: object$df.residual the same thing as df.residual(object) df.residual() is an extractor function. stats:::df.residual.default gives: function (object, ...) object$df.residual environment: namespace:stats so yes, in general they are the same thing. It's better to use the extractor function rather than $ if possible; while it doesn't appear that anyone has written a class of objects that have a different method for extracting the residual degrees of freedom, they could -- or someone could change the internal representation of lm and glm objects (unlikely though that is) to mean that object$df.residual was missing, or even wrong. Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] $
On Tue, 2006-06-20 at 12:03 -0500, Davis, Jacob B. wrote: Thanks for humbling yourself to my level and not answering my question. If object is user defined is: object$df.residual the same thing as df.residual(object) Hi, In this case, yes they are the same, but don't think that if you had object$foo that you could do foo(object) and get anything useful. Most of the time you can't and R will throw an error. df.residual() is an extractor function and these are generally preferred over extracting the component of the list directly using the $ notation. Other extractors include coef(), residuals(), fitted() etc. $ _is_ used to extract components from lists, and can be used on data frames as these are just a special type of list. Look at this example: y - runif(100) x - rnorm(100) mod - lm(y ~ x) mod mod$df.residual df.residual(mod) If we look at the structure of the lm object, we see many components: str(mod) There is a model component, which you could extract using mod$model but if you try model(mod) you'll get an error about not being able to find function model. Hopefully that explains things a little. Gav __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] changes to terms.formula in 2.3.x
Thanks, Gabor. Works like a charm. --sundar Gabor Grothendieck wrote: Try this: fo - ~ x | y fo[[3]] - fo[[2]] fo[[2]] - as.name(z) fo z ~ x | y On 6/20/06, Sundar Dorai-Raj [EMAIL PROTECTED] wrote: Hi, all, I just recently noticed a change in terms.formula from 2.2.1 to 2.3.1 (possibly 2.3.0, but I didn't check). Here's the problem: ## 2.2.1 update(~ x | y, z ~ .) z ~ x | y ## 2.3.1 update(~ x | y, z ~ .) z ~ (x | y) and in the NEWS for 2.3.1 o terms.formula needed to add parentheses to formulae with terms containing '|'. (PR#8462) So, there must be a reason for this change. However, in the lattice framework I have this causes many problems because now the `|' is interpreted as a logical OR. Could someone suggest a workaround for me so that I still get the 2.2.1 behavior my code relies on. Here's a very simple test function (works in 2.2.1, fails in 2.3.1): library(lattice) foo - function(x, data) { x - update(x, y ~ .) xyplot(x, data) } z - expand.grid(x = 1:10, g = letters[1:3]) z$y - rnorm(nrow(z)) foo(~ x | g, z) Thanks, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] $
R has many samples included with the distribution just look in the library sub folder of your distribution. In windows examine the base library c:\Program Files\R\R-2.3.1\library\base\R-ex you might find they are archived (rex.zip) extract them and use Tinn-R (or any other editor) to play around with the various samples. You might want to add a load statement to some samples as their library may not be auto loaded 'library(RODBC)' to examine the features/capabilities. That has been a nice bit of help for me thus far and a good idea to have included samples with an R distribution :) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Davis, Jacob B. Sent: Tuesday, June 20, 2006 1:04 PM To: Joerg van den Hoff Cc: r-help@stat.math.ethz.ch Subject: Re: [R] $ Thanks for humbling yourself to my level and not answering my question. If object is user defined is: object$df.residual the same thing as df.residual(object) You know I have self taught myself: Visual Basic, PL/SQL, C++, Matlab and I'm not a programmer. In these programs I help beginners all the time with the dumb easy to find questions because the first few months of working with a new language can be overwhelming even when the answer is staring you in the face. I have been in R less than a month and I only have time to spend maybe 20 minutes a day with it. I have about five manuals sitting on my desk that I thumb through while surfing the internet trying to figure things out. Asking about the $ sign is a basic question, but until I have spent at least 400 or so hours with the program I'm not going to know how to help myself. I go through this every time I learn a new piece of software and every time comments like yours come up. For the most part I'm sure most of the questions that come up in the list-serve can be answered independently if enough independent digging is done. The purpose of the list-serve is to aid and speed up the learning process. You know in about six months or a year I'm sure I will be up to speed and making contributions and then I will be helping to answer the $ sign questions so that they can be up to speed also and contribute. In the beginning it's helpful just to know where the resources are so one can begin to get a feel for how to help their self. Patrick Burns showed me where S Poetry was, being a newbie I had no idea what are where that was, now I do. -Original Message- From: Joerg van den Hoff [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 20, 2006 11:21 AM To: Davis, Jacob B. Cc: r-help@stat.math.ethz.ch Subject: Re: [R] $ Davis, Jacob B. wrote: If object is user defined is: object$df.residual the same thing as df.residual(object) This is my first time to encounter the $ sign in R, I'm new. I'm reviewing summary.glm and in most cases it looks as though the $ is used to extract some characteristic/property of the object, but I'm not positive. Thanks ~~ Jacob Davis Actuarial Analyst [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html `$' is for list component extraction. this is really very basic and, for once (I usually don't like this answer...), looking at the very first pages of the very first manual, would be not so bad an idea: http://cran.r-project.org/ -- Manuals -- An Introduction to R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] arima fails when called from command line
I'm sure there is no consistent way to reproduce this, but I'm hoping someone has some information. I have a time series we'll call y. The data gets updated every day, so I run a cron job that fits and predicts from an arima(0,0,1) X (1,1,1)_7 model. When I open R and run the script, it processes completely. If I call the script via a crontab entry R --no-save --slave myscript.R then the fitting of the arima model fails. I have checked to make sure the shell is calling the correct version of R, so it should be no different than when I am using it interactively ...right? Thanks for your time on this, B __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] hello Excel... (native/Package/BETA)
- the open source compiler FreePascal potentially allows to compile for other platforms (http://www.freepascal.org/wiki/index.php/Platform_list). [while I am interested in this for reasons of completeness, it's unlikely that I will look into it soon without somebody funding. The Linux people probably won't care anyway and just for macs, hmm, there are still much other things I'd like to look into] I got an email which kind of said that my use of Linux people is disrespectful and could imply that people who use Linux couldn't afford to supply fundings. It is *absolutely* not meant like this, I personally have Linux machines (Debian, now Ubuntu) but currently use Windows more. My server is Suse. I just wanted to express, that on linux afaik the people don't have the data in xls-format and prefer the text format. It's from hearsay/newsgroup/and my impression from a R-course. On Macs I personally know people who do a PhD and have their data in Excel. So I though, they could be interested. English is not my native language. Sorry for writing in a sloppy way. Hans-Peter [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Packaging platform-specific functions
I have a few functions, such as screenWidth() and screenHeight(), which I have been able to implement for a Unix/Linux environment, but not for Windows. (Does anyone know how to find the screen dimensions in Windows?) The Writing R Extensions manual tells me how to include platform-specific sections in documentation, and even how to have platform-specific help files. But it doesn't say anything about when or how to handle platform-specific code. In particular, how do package writers handle functions that make sense for one platform but not for another? I'd like to keep a single set of source code files and generate the Windows and Linux packages from it. Any suggestions? Jeff Hallman __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] glm beta hypothesis testing
Davis, Jacob B. JBDavis at txfb-ins.com writes: In summary.glm I'm trying to get a better feel for the z output. The following lines can be found in the function [snip] digging through the function is good: debugging your way through the function is sometimes even better. examples(glm,local=TRUE) ## run glm examples and get ## results left in local workspace) ls() debug(summary.glm) summary(glm.D93) shows ... p is object rank (~ number of parameters) Qr$pivot gives the order in which the parameters have been rearranged to solve the model, so Qr$pivot[p1] gives the rearranged order of the coefficients. We need this rearranged order because we're going to extract the unscaled covariance matrix by solving the inverse QR matrix, which is in the pivoted (rearranged) order. The null hypothesis for any particular contrast in glm is that the parameter is 0, so the estimates of the coefficients (object$coefficients) *are* the distance from the null hypothesis. Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Create variables with common values for each group
Peter Dalgaard p.dalgaard at biostat.ku.dk writes: ?ave Finally, someone remembered it! I feel ashamed. May I suggest to add a link under by and/or tapply ? Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lmer and mixed effects logistic regression
On 6/19/06, Rick Bilonick [EMAIL PROTECTED] wrote: On Sun, 2006-06-18 at 13:58 +0200, Douglas Bates wrote: If I understand correctly Rick it trying to fit a model with random effects on a binary response when there are either 1 or 2 observations per group. If you look at Rick's examples, it's worse than that; each group contains identical observations (by design?). May I suggest: glm(y ~ x, family = binomial, data = unique(example.df)) I think lmer gives a very sensible answer to this problem. Göran __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multivariate splits
From: Gavin Simpson On Tue, 2006-06-20 at 08:12 -0700, Scott Rollins wrote: Glenn De'ath published a paper in 'Ecology' several years ago and included S-Plus functions in the archives. I haven't looked at the files, so I'm not sure what modifications would be necessary for R. De'ath, G. 2002. Multivariate regression trees: a new technique for modeling species--environment relationships. Ecology 83:1105-1117. Archives: http://www.esapubs.org/archive/ecol/E083/017/ Scott Glenn's code is in package mvpart on CRAN. Not sure if the OP wanted this or not, but the multivariate nature of mvpart is in allowing multivariate responses, common in ecological data analysis. The fitting is still done using rpart (actually a modified version of rpart to allow for the multivariate response). Gavin The OP's reply to my follow-up to Torsten's message seems to indicate that he has univariate response. He wants something that can split on linear combinations of predictors, as described in the CART book, I believe. What I thought he wanted was something that finds some optimal subset of predictors to split each node. I am not aware of any open source implementations of tree algorithms that does linear combination splits, perhaps others know better. I suppose Torsten's double bagging (in the ipred package) sort of does that, but in an ensemble rather than a single tree. Andy Date: Mon, 19 Jun 2006 16:17:40 +0200 From: B?lint Cz?cz [EMAIL PROTECTED] Subject: [R] multivariate splits To: r-help r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed Dear R users! Does someone know about any algorithms / packages in R, that perform classification / regression / decision trees using multivariate splits? I have done some research, but I found nothing. Packages tree and rpart seem only to be able to do CART with univariate splits. Thank you for your help! B?lint -- Cz?cz B?lint PhD hallgat? BCE KTK Talajtan ?s V?zgazd?lkod?s Tansz?k 1118 Budapest, Vill?nyi ?t 29-43. - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Packaging platform-specific functions
Never mind. I RFTM'ed more carefully and found that the 'R' directory can also have a 'unix' or 'windows' subdirectory. [EMAIL PROTECTED] wrote: jh I have a few functions, such as screenWidth() and screenHeight(), which jh I have been able to implement for a Unix/Linux environment, but not for jh Windows. (Does anyone know how to find the screen dimensions in jh Windows?) jh The Writing R Extensions manual tells me how to include jh platform-specific sections in documentation, and even how to have jh platform-specific help files. But it doesn't say anything about when or jh how to handle platform-specific code. In particular, how do package jh writers handle functions that make sense for one platform but not for jh another? I'd like to keep a single set of source code files and jh generate the Windows and Linux packages from it. jh Any suggestions? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Comparing partial response curves from GAM
Hello all, I was wondering if anyone is aware of formal approaches and tools for comparing partial response curves produced in GAM? My interest is in determining if two partial response curves are statistically different. I recognize that point-wise standard error estimates can be produced using the GAM package but Im not certain how to translate this into a statistical test for the entire curve. Any feedback is much appreciated. Thanks. Solomon Solomon Dobrowski Tahoe Environmental Research Center (TERC) John Muir Institute of the Environment University of California, Davis 530 754 9354 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] arima fails when called from command line
From: Brian Dolan [EMAIL PROTECTED] Date: Tue Jun 20 12:54:14 CDT 2006 To: r-help@stat.math.ethz.ch Subject: [R] arima fails when called from command line hi : i had a similar problem a few weeks agowhen i was tryin g to use R CMD BATCH ( but when i sourced the copde at the r prompt everything worked fine ). eventually, i fiigured out that it had to do with a read.tale statement having a col.names argument that was too long for the script to handle. if it doesn't read in the data correctly, this might be causing the arima failed message. that's just a guess though. someone else may have a better idea. I'm sure there is no consistent way to reproduce this, but I'm hoping someone has some information. I have a time series we'll call y. The data gets updated every day, so I run a cron job that fits and predicts from an arima(0,0,1) X (1,1,1)_7 model. When I open R and run the script, it processes completely. If I call the script via a crontab entry R --no-save --slave myscript.R then the fitting of the arima model fails. I have checked to make sure the shell is calling the correct version of R, so it should be no different than when I am using it interactively ...right? Thanks for your time on this, B __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Successfully building 2.3.1 with Sun One Studio 8 on Solaris 9 (SPARC)
I had a hard time building 1.9.1 with the Sun One Studio on Solaris (SPARC) almost 2 years ago. I filed a bug report, but I can't seem to find it right now. For 2.3.1, I discovered that the same problems remain. Here are the tricks that resolved them for me if anyone is interested. #1. /usr/lib/cpp will give you nothing, but headaches. Fortunately, the Solaris Software Companion CD (SSCC) has an alternative version and alot of other goodies that will make your life easier. I'm assuming that you have installed all of these tools in the default location: /opt/sfw #2. the Sun Performance library is also on the SSCC which has optimized BLAS and LAPACK routines. This is an optional choice, so make sure you pick it. #3. for some reason, the Foreign package will not build initially. So delete src/library/Recommended/foreign.tgz and create src/library/Recommended/foreign.ts #4. setup your environment to be as free software-friendly as possible with /opt/sfw/bin in your PATH: CONFIG_SHELL=/usr/xpg4/bin/sh CC=cc GCC= CFLAGS=-xlibmil -dalign CXX=CC CXXFLAGS=-xlibmil -dalign F77=f95 F95=f95 FFLAGS=-xlibmil -dalign CPP=/opt/sfw/bin/cpp CPPFLAGS=-I/opt/sfw/include LDFLAGS=-L/opt/sfw/lib BLAS_LIBS=-xlic_lib=sunperf #5. configure, make and install configure --with-blas --with-lapack gmake gmake install cd src/library/Recommended R CMD INSTALL foreign_0.8-15.tar.gz #6. I also asked on R-help about how to install a bunch of packages at once. There were some interesting tips. But, the easiest way that I found was the command line: for i in *.tar.gz do R CMD INSTALL $i done That did the trick for me. Hopefully, I didn't leave anything out. Rodney __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sort of data.frame yields a thing which is not a data.frame...
I've observed something I don't understand, and I was hoping someone could point me to the right section of docs. There's a portion in one of my analyses in which I am wont to sort a data.frame so: seriesS - seriesS[order(as.Date(row.names(seriesS),format=%m/%d/%Y)),] So, I've got row.names which are textual representations of dates, I'd like to retain them as such, but order them datewise. As long as seriesS has more than one column, this works nicely, seriesS afterwards is a data.frame with columns similar to those it had going in. But if I encounter a case with only one column, the result is _not_ a data frame, but instead an ? array? list? I can solve this with a kluge: seriesS$stupid - 0; seriesS - seriesS[order(as.Date(row.names(seriesS),format=%m/%d/%Y)),] seriesS - seriesS[,-c(which(names(seriesS)==stupid)) ] but this mostly tells me I've failed to understand something about how the process should work. Any good references to the Chapter and Verse of the Canon of R I should hit? - Allen S. Rout __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sort of data.frame yields a thing which is not a data.frame...
Compare d-data.frame(a=c(1,2),b=c(2,3)) class(d[,1]) [1] numeric class(d[,1,drop=FALSE]) [1] data.frame Regards On 20 Jun 2006 15:52:36 -0400, Allen S. Rout [EMAIL PROTECTED] wrote: I've observed something I don't understand, and I was hoping someone could point me to the right section of docs. There's a portion in one of my analyses in which I am wont to sort a data.frame so: seriesS - seriesS[order(as.Date(row.names(seriesS),format=%m/%d/%Y)),] So, I've got row.names which are textual representations of dates, I'd like to retain them as such, but order them datewise. As long as seriesS has more than one column, this works nicely, seriesS afterwards is a data.frame with columns similar to those it had going in. But if I encounter a case with only one column, the result is _not_ a data frame, but instead an ? array? list? I can solve this with a kluge: seriesS$stupid - 0; seriesS - seriesS[order(as.Date(row.names(seriesS),format=%m/%d/%Y)),] seriesS - seriesS[,-c(which(names(seriesS)==stupid)) ] but this mostly tells me I've failed to understand something about how the process should work. Any good references to the Chapter and Verse of the Canon of R I should hit? - Allen S. Rout __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] strange use of sapply
I've tried and give up. I have a matrix of say 200 columns and 400 rows. For each odd ( or even i suppose if i wanted to )column, I want to know the number of rows in which the value is greater than zero. So, I did sapply(tempMatrix,2,function(x) sum( x 0 )) this almost works but i don't know how to tell it to only do the odd columns. my guess is , like everything else in R, this is possible. Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] expanded dataset and random number
A couple of suggestions: #First solution mydatexpanded-mydat[rep(1:5,mydat[,1]),] sampledat-mydatexpanded[sample(1:85,7),-1] #Second solution sampledat-mydat[sample(1:5,size=7,prob=mydat[,1]/85,replace=TRUE),-1] Regards Per Jensen On 6/20/06, Muhammad Subianto [EMAIL PROTECTED] wrote: Dear all R-users, (My apologies if this subject is wrong) I have dataset: mydat - as.data.frame( matrix(c(14,0,1,0,1,1, 25,1,1,0,1,1, 5,0,0,1,1,0, 31,1,1,1,1,1, 10,0,0,0,0,1), nrow=5,ncol=6,byrow=TRUE)) dimnames(mydat)[[2]] -c(size,A,B,C,D,E) mydat size A B C D E 1 14 0 1 0 1 1 2 25 1 1 0 1 1 35 0 0 1 1 0 4 31 1 1 1 1 1 5 10 0 0 0 0 1 sum(mydat$size) [1] 85 where size is number of each row that have this combination of variables. In this dataset I have 85 tuples in expanded dataset. I want to generate random number between 1 and 85. Say, if the first random number is 15, so the number 15 is 1 1 0 1 1 then, if the next random number is 7, then 0 1 0 1 1 then if random number is 79 0 0 0 0 1 random number is 46 1 1 1 1 1 random number is 3 0 1 0 1 1 random number is 28 1 1 0 1 1 So, the result random tuples (order from 6 random number): 0 1 0 1 1 0 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 1 I would be very happy if anyone could help me. Thank you very much in advance. Kindly regards, Muhammad Subianto __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strange use of sapply
sapply() is not the right tool. It operates on a list, and a matrix is not a list (at least not treated as you'd expected it to be). It would have sort of worked if tempMatrix were a data frame instead of a matrix. Try something like: colSums(tempMatrix[, seq(1, ncol(tempMatrix), by=2)] 0) Andy From: [EMAIL PROTECTED] I've tried and give up. I have a matrix of say 200 columns and 400 rows. For each odd ( or even i suppose if i wanted to )column, I want to know the number of rows in which the value is greater than zero. So, I did sapply(tempMatrix,2,function(x) sum( x 0 )) this almost works but i don't know how to tell it to only do the odd columns. my guess is , like everything else in R, this is possible. Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strange use of sapply
Hi Could you use something along the lines of the following: transposedat-t(dat) transposedat$oddrow-(1:ncol(dat))%%2 oddcolumns-t(transposedat[transposedat$oddrow==1,]) Now you should have the odd columns in a single dataframe. gzero-matrix(oddcolumns0,nrow=nrow(oddcolumns),ncol=ncol(oddcolumns)) colSums(gzero) Best regards Per Jensen On 6/20/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I've tried and give up. I have a matrix of say 200 columns and 400 rows. For each odd ( or even i suppose if i wanted to )column, I want to know the number of rows in which the value is greater than zero. So, I did sapply(tempMatrix,2,function(x) sum( x 0 )) this almost works but i don't know how to tell it to only do the odd columns. my guess is , like everything else in R, this is possible. Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Plotting Upper triangle of Matrix with diagonal as the Base
Try these functions (modify to suit your needs: tri1 - function(x){ n - dim(x)[2] for(i in n:1){ for( j in 1:(n-i+1) ){ cat(sprintf(' %5.2f',x[j,j+i-1])) } cat(\n) } } tri2 - function(x){ n - dim(x)[2] for(i in n:1){ cat( rep(' ', 3*(i-1)), sep='',collapse='' ) for( j in 1:(n-i+1) ){ cat(sprintf(' %5.2f',x[j,j+i-1])) } cat(\n) } } tmp - matrix(1:25,5) # not symmetric, but you get the idea tri1(tmp) tri2(tmp) Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cal Stats Sent: Monday, June 19, 2006 11:11 AM To: r help Subject: [R] Plotting Upper triangle of Matrix with diagonal as the Base Hi.. I a have a symmetric matrix to plot . I would like to plot only the Upper triangle but with the diagonal as the Base of the rectangle. Is there an easy way to do it. Thanks. Harsh - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Determine the data type of a function to an argument
Hello All: How can I determing the types of args passed to an R function? For example, given the following: calculate - function(...) { args - list(...) argName = names(args) if (arg1 == character) cat(arg1 is a character) else cat(arg1 is numeric) if (arg2 == character) cat(arg2 is a character) else cat(arg2 is a numeric) } value = calculate(arg1='222' arg2=333) Programatically, how can I determine if arg1 is a character and arg2 is numeric? Many Thanks: Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Query about getting a table of binned values
Hi I am working with a dataset of age and class of proteins #Age 0 0.0 0.677 #Class Type A Type B . . . Type K I wish to get a table that reads as follows 0-0.02 0.02-0.04 0.04-0.06 . 0.78-0.8 Type A15 20 5 8 Type B 86 . . . Type K 10 7 I would appreciate your input regarding the appropriate functions to use for this purpose regards Lalitha __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] timediff
This is probably one case where you want to use the 'difftime' function directly: x1 - as.POSIXct(2006-02-08 17:12:55) x2 - as.POSIXct(2006-02-08 17:15:26) x2-x1 Time difference of 2.516667 mins x3 - x2-x1 str(x3) Class 'difftime' atomic [1:1] 2.52 ..- attr(*, tzone)= chr ..- attr(*, units)= chr mins x4 - difftime(x2,x1,units='sec') str(x4) Class 'difftime' atomic [1:1] 151 ..- attr(*, tzone)= chr ..- attr(*, units)= chr secs On 20 Jun 2006 12:56:07 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote: COMTE Guillaume [EMAIL PROTECTED] writes: I've got 2 dates like these : 2006-02-08 17:12:55 2006-02-08 17:15:26 I wish to get the middle of these two date : 2006-02-08 17 :14 :10 Is there is a function in R to do that ? Well, x1 - as.POSIXct(2006-02-08 17:12:55) x2 - as.POSIXct(2006-02-08 17:15:26) x2-x1 Time difference of 2.516667 mins (x2-x1)/2 Time difference of 1.258333 mins x1+60*as.numeric((x2-x1)/2) [1] 2006-02-08 17:14:10 CET However, this goes wrong (although not without warning): x1+(x2-x1)/2 [1] 2006-02-08 17:12:56 CET Warning message: Incompatible methods (+.POSIXt, Ops.difftime) for + ---for reasons that are related to this: as.numeric(x2)-as.numeric(x1) # seconds! [1] 151 as.numeric(x2-x1) # minutes [1] 2.516667 (This suggests to me that the methodology for difftime objects is still not quite complete. Volunteers?) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Query about getting a table of binned values
Dear Lalitha Take a look at ?cut and ?table. Cut will create categories of your continuous Age variable and table will create a contingency table of the categorized values against Type i.e. #Creates practice data frame dat=data.frame(Type=sample(c(TypeA,TypeB,TypeC),100,replace=T),Age=runif(100)) #Creates table tab=table(dat$Type, cut(dat$Age,seq(0,1,.02))) You can use the labels argument within cut to get a more pretty output I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: lalitha viswanath [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Query about getting a table of binned values Date: Tue, 20 Jun 2006 13:57:07 -0700 (PDT) Hi I am working with a dataset of age and class of proteins #Age 0 0.0 0.677 #Class Type A Type B . . . Type K I wish to get a table that reads as follows 0-0.02 0.02-0.04 0.04-0.06 . 0.78-0.8 Type A15 20 5 8 Type B 86 . . . Type K 10 7 I would appreciate your input regarding the appropriate functions to use for this purpose regards Lalitha __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Determine the data type of a function to an argument
Look at ?class and perhaps is?. i.e. x=c(1,2,3) class(x) [1] character x=c(1,2,3) class(x) [1] numeric I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Alex Restrepo [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Determine the data type of a function to an argument Date: Tue, 20 Jun 2006 15:48:03 -0500 Hello All: How can I determing the types of args passed to an R function? For example, given the following: calculate - function(...) { args - list(...) argName = names(args) if (arg1 == character) cat(arg1 is a character) else cat(arg1 is numeric) if (arg2 == character) cat(arg2 is a character) else cat(arg2 is a numeric) } value = calculate(arg1='222' arg2=333) Programatically, how can I determine if arg1 is a character and arg2 is numeric? Many Thanks: Alex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] weird application of apply again
uugh : i promise that this will be my last question of the day. i hate to constantly bother this group but it takes me time to get familar with all of these functions, tricks and and manipulations. i appreciate everyone's patience. i used too splus a lot but i've gotten rusty. i have a matrix of say 200 rows and 600 columns. i have a function getprofit that takes two series and returns a number. getprofit-function(series1, series2) { do some stufff return(somenumber) is there a way to do something clever so that i call the function, getprofit, on the first two columns of the matrix ( where the first column is series1 and the second column is series2 ), then the next two columns of the matrix, then the next two columns of the matrix and so on and so forth return a 300 by 1 ( oir 1 by 300, it doesn't matter ) vector of somenumbers. i ( maybe stupidly ) put the data in a matrix but now i am thinking that wasn't a good thing to do ? i can change it to some thing else if i have to. thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] multi-dimension array of raw
I would like to store and manipulate large sets of marker genotypes compactly using raw data arrays. This works fine for vectors or matrices, but I run into the error shown in the example below as soon as I try to use 3 dimensional arrays (eg. animal x marker x allele). a - array(as.raw(1:6),c(2,3)) a [,1] [,2] [,3] [1,] 01 03 05 [2,] 02 04 06 a[1,] - raw(3) a [,1] [,2] [,3] [1,] 00 00 00 [2,] 02 04 06 b - array(as.raw(1:6),c(1,2,3)) b[1,,] [,1] [,2] [,3] [1,] 01 03 05 [2,] 02 04 06 b[1,1,] - raw(3) Error: incompatible types (from raw to raw) in array subset assignment I can work around this with computed indices, but I wonder if this is expected behaviour. Gerald Jansen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] weird application of apply again
Here is an example of adding up 2 consecutive rows, iterating through all the row: x - matrix(1:100,10) x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]1 11 21 31 41 51 61 71 8191 [2,]2 12 22 32 42 52 62 72 8292 [3,]3 13 23 33 43 53 63 73 8393 [4,]4 14 24 34 44 54 64 74 8494 [5,]5 15 25 35 45 55 65 75 8595 [6,]6 16 26 36 46 56 66 76 8696 [7,]7 17 27 37 47 57 67 77 8797 [8,]8 18 28 38 48 58 68 78 8898 [9,]9 19 29 39 49 59 69 79 8999 [10,] 10 20 30 40 50 60 70 80 90 100 sapply(seq(nrow(x)/2), function(z) sum(x[2*z-1,], x[2*z,])) [1] 930 970 1010 1050 1090 On 6/20/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: uugh : i promise that this will be my last question of the day. i hate to constantly bother this group but it takes me time to get familar with all of these functions, tricks and and manipulations. i appreciate everyone's patience. i used too splus a lot but i've gotten rusty. i have a matrix of say 200 rows and 600 columns. i have a function getprofit that takes two series and returns a number. getprofit-function(series1, series2) { do some stufff return(somenumber) is there a way to do something clever so that i call the function, getprofit, on the first two columns of the matrix ( where the first column is series1 and the second column is series2 ), then the next two columns of the matrix, then the next two columns of the matrix and so on and so forth return a 300 by 1 ( oir 1 by 300, it doesn't matter ) vector of somenumbers. i ( maybe stupidly ) put the data in a matrix but now i am thinking that wasn't a good thing to do ? i can change it to some thing else if i have to. thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multi-dimension array of raw
On 6/20/2006 6:24 PM, Gerald Jansen wrote: I would like to store and manipulate large sets of marker genotypes compactly using raw data arrays. This works fine for vectors or matrices, but I run into the error shown in the example below as soon as I try to use 3 dimensional arrays (eg. animal x marker x allele). a - array(as.raw(1:6),c(2,3)) a [,1] [,2] [,3] [1,] 01 03 05 [2,] 02 04 06 a[1,] - raw(3) a [,1] [,2] [,3] [1,] 00 00 00 [2,] 02 04 06 b - array(as.raw(1:6),c(1,2,3)) b[1,,] [,1] [,2] [,3] [1,] 01 03 05 [2,] 02 04 06 b[1,1,] - raw(3) Error: incompatible types (from raw to raw) in array subset assignment I can work around this with computed indices, but I wonder if this is expected behaviour. I don't think so. It is just an unimplemented case. Using raw in this way is a fairly unusual thing to do, and you've come across a case nobody thought of implementing. Indexing is a primitive function, so it's hard for you to fix this. It needs to be done in the internals of R (function ArrayAssign, in src/main/subassign.c, if you're interested). I'll try to take a look and see if it looks reasonable to add. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Extract information from the summary of 'lm'
Hi Everyone, I just don't know how to extract the information I want from the summary of a linear regression model fitting. For example, I fit the following simple linear regression model: results = lm(y_var ~ x_var) summary(results) gives me: Call: lm(formula = y_var ~ x_var) Residuals: Min 1Q Median 3Q Max -5.9859 -1.5849 0.4574 2.0163 4.6015 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -1.7782 0.5948 -2.990 0.004879 ** x_var 2.1237 0.5073 4.187 0.000162 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 I can get the esitmates (i.e. -1.7782 and 2.1237) of coefficients by calling results$coefficients But I don't know how to get the corresponding t values and P values for those coefficients. I am running a lot of regression models and I can not run 'summary' every time to get the t and P values for each model. Can anybody give me some hints? Thank you very much! Best, Jun Jun Ding, Ph.D. student Department of Biostatistics University of Michigan Ann Arbor, MI, 48105 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Extract information from the summary of 'lm'
ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2,10,20, labels=c(Ctl,Trt)) weight - c(ctl, trt) lm.D9 - lm(weight ~ group) summary(lm.D9)$coef Estimate Std. Error t value Pr(|t|) (Intercept)5.032 0.2202177 22.850117 9.547128e-15 groupTrt -0.371 0.3114349 -1.191260 2.490232e-01 class(summary(lm.D9)$coef) [1] matrix colnames(summary(lm.D9)$coef) [1] Estimate Std. Error t valuePr(|t|) So you can get t and p-value by summary(lm.D9)$coef[,t value] summary(lm.D9)$coef[,Pr(|t|)] If you want to get the result as matrix,just use the drop=F argument. summary(lm.D9)$coef[,Pr(|t|),drop=F] Pr(|t|) (Intercept) 9.547128e-15 groupTrt2.490232e-01 2006/6/21, Jun Ding [EMAIL PROTECTED]: Hi Everyone, I just don't know how to extract the information I want from the summary of a linear regression model fitting. For example, I fit the following simple linear regression model: results = lm(y_var ~ x_var) summary(results) gives me: Call: lm(formula = y_var ~ x_var) Residuals: Min 1Q Median 3Q Max -5.9859 -1.5849 0.4574 2.0163 4.6015 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) -1.7782 0.5948 -2.990 0.004879 ** x_var 2.1237 0.5073 4.187 0.000162 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 I can get the esitmates (i.e. -1.7782 and 2.1237) of coefficients by calling results$coefficients I think using coef(result) is a better habit. But I don't know how to get the corresponding t values and P values for those coefficients. I am running a lot of regression models and I can not run 'summary' every time to get the t and P values for each model. Can anybody give me some hints? Thank you very much! Best, Jun Jun Ding, Ph.D. student Department of Biostatistics University of Michigan Ann Arbor, MI, 48105 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Department of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] how to finish my task?
Dearfriends, A question related with resale(). I have a dataset *a* with three variables *x,y,id* I want to do two different things: 1. rescale the combination of x and y into the new range (0,1),that is, keep the shape of original plot; 2.rescale x and y into the new range (0,1) respectively,change the shape of original plot ; e.g. id-c(1,2,3,4,5,6,7,8,9,10) x-rnorm(10) y-rnorm(10) a-data.frame(id=id,x=x,y=y) Thanks very much! -- Kind Regards, Zhi Jie,Zhang ,PHD Department of Epidemiology School of Public Health Fudan University Tel:86-21-54237149 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] xyplot, type=b
Is there any way to have xyplot produce the points connected by lines analogous to the effect of type=b under standard graphics? I seem to recall doing this in xyplot at one point. Thanks, Ben __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] xyplot, type=b
apropos(^panel) will show you what panel function exist.It seems that panel.points plus panel.lines are what you want. dat-data.frame(x=1:10,y=1:10,z=sample(letters[1:3],10,T)) xyplot(y~x | z, data = dat,pan=function(x,y,...) {panel.points(x,y,...);panel.lines(x,y,...)}) 2006/6/21, Benjamin Tyner [EMAIL PROTECTED]: Is there any way to have xyplot produce the points connected by lines analogous to the effect of type=b under standard graphics? I seem to recall doing this in xyplot at one point. Thanks, Ben __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Department of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] xyplot, type=b
Thanks, but this proposal has the same effect as type=b in panel.xyplot, which as noted in the documentation is the same as type=o. To clarify, I don't want type=o at all; I want there to be gaps between the lines and points. Have a look at plot(y~x,data=dat,type=b) to see what I mean. Ben ronggui wrote: apropos(^panel) will show you what panel function exist.It seems that panel.points plus panel.lines are what you want. dat-data.frame(x=1:10,y=1:10,z=sample(letters[1:3],10,T)) xyplot(y~x | z, data = dat,pan=function(x,y,...) {panel.points(x,y,...);panel.lines(x,y,...)}) 2006/6/21, Benjamin Tyner [EMAIL PROTECTED]: Is there any way to have xyplot produce the points connected by lines analogous to the effect of type=b under standard graphics? I seem to recall doing this in xyplot at one point. Thanks, Ben __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] multi-dimension array of raw
On 6/20/2006 6:24 PM, Gerald Jansen wrote: I would like to store and manipulate large sets of marker genotypes compactly using raw data arrays. This works fine for vectors or matrices, but I run into the error shown in the example below as soon as I try to use 3 dimensional arrays (eg. animal x marker x allele). a - array(as.raw(1:6),c(2,3)) a [,1] [,2] [,3] [1,] 01 03 05 [2,] 02 04 06 a[1,] - raw(3) a [,1] [,2] [,3] [1,] 00 00 00 [2,] 02 04 06 b - array(as.raw(1:6),c(1,2,3)) b[1,,] [,1] [,2] [,3] [1,] 01 03 05 [2,] 02 04 06 b[1,1,] - raw(3) Error: incompatible types (from raw to raw) in array subset assignment I can work around this with computed indices, but I wonder if this is expected behaviour. This is now fixed in r-devel and r-patched. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] xyplot, type=b
Hi Benjamin Tyner wrote: Thanks, but this proposal has the same effect as type=b in panel.xyplot, which as noted in the documentation is the same as type=o. To clarify, I don't want type=o at all; I want there to be gaps between the lines and points. Have a look at plot(y~x,data=dat,type=b) Is this what you mean ... ? dat-data.frame(x=1:10,y=1:10,z=sample(letters[1:3],10,T)) xyplot(y~x | z, data = dat, panel = function(x, y, ...) { panel.lines(x, y, ...) panel.points(x, y, col=trellis.par.get(background)$col, cex=1.5, pch=16, ...) panel.points(x, y, ...) }) Paul ronggui wrote: apropos(^panel) will show you what panel function exist.It seems that panel.points plus panel.lines are what you want. dat-data.frame(x=1:10,y=1:10,z=sample(letters[1:3],10,T)) xyplot(y~x | z, data = dat,pan=function(x,y,...) {panel.points(x,y,...);panel.lines(x,y,...)}) 2006/6/21, Benjamin Tyner [EMAIL PROTECTED]: Is there any way to have xyplot produce the points connected by lines analogous to the effect of type=b under standard graphics? I seem to recall doing this in xyplot at one point. Thanks, Ben __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] xyplot, type=b
I can imagine the intended effect of this, but for some reason it does not work as expected--the 'gaps' do not show up (I'm using 2.3.0). Also, I think it would have to be tweaked to prevent overlapping for points very close together. Incidentally, the benefit I seek is most pronounced with pch=., as then one gets the best of both worlds. Ben Paul Murrell wrote: Is this what you mean ... ? dat-data.frame(x=1:10,y=1:10,z=sample(letters[1:3],10,T)) xyplot(y~x | z, data = dat, panel = function(x, y, ...) { panel.lines(x, y, ...) panel.points(x, y, col=trellis.par.get(background)$col, cex=1.5, pch=16, ...) panel.points(x, y, ...) }) Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] xyplot, type=b
I think Paul's suggestion works if you use: panel.points(x, y, col = white, cex = 1.5, pch = 16, ...) instead of the default background color. For me trellis.par.get(background)$col returns transparent. HTH, --sundar Benjamin Tyner wrote: I can imagine the intended effect of this, but for some reason it does not work as expected--the 'gaps' do not show up (I'm using 2.3.0). Also, I think it would have to be tweaked to prevent overlapping for points very close together. Incidentally, the benefit I seek is most pronounced with pch=., as then one gets the best of both worlds. Ben Paul Murrell wrote: Is this what you mean ... ? dat-data.frame(x=1:10,y=1:10,z=sample(letters[1:3],10,T)) xyplot(y~x | z, data = dat, panel = function(x, y, ...) { panel.lines(x, y, ...) panel.points(x, y, col=trellis.par.get(background)$col, cex=1.5, pch=16, ...) panel.points(x, y, ...) }) Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] GARCH
Arun Kumar Saha wrote: Dear all R-users, I have a GARCH related query. Suppose I fit a GARCH(1,1) model on a dataframe dat garch1 = garch(dat) summary(garch1) Call: garch(x = dat) Model: GARCH(1,1) Residuals: Min 1Q Median 3Q Max -4.7278 -0.3240 0. 0.3107 12.3981 Coefficient(s): Estimate Std. Error t value Pr(|t|) a0 1.212e-04 2.053e-0659.05 2e-16 *** a1 1.001e+00 4.165e-0224.04 2e-16 *** b1 2.435e-15 1.086e-02 2.24e-131 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Diagnostic Tests: Jarque Bera Test data: Residuals X-squared = 54480.76, df = 2, p-value 2.2e-16 Now I want to store the value of Pr(|t|) for coefficient a0, a1, and b1, and also values of these coefficients, so that I can use them in future separately. I know that I can do it for coefficients by using the command: coef(garch1)[a0] etc, but not for Pr(|t|). Can anyone please tell me how to do this? This is less a question about GARCH and more a question about how R works (which I know is true because I didn't know what GARCH was when I read the question and I still don't but I can provide you a usable answer). You can use the str() function to see the structure of an object in R: garch1.summary - summary(garch1) str(garch1.summary) List of 6 $ residuals: Time-Series [1:999] from 2 to 1000: 0.206 0.709 0.476 -0.291 -1.676 ... ..- attr(*, na.removed)= int 1 $ coef : num [1:3, 1:4] 0.0799 0.6287 0.2118 0.0110 0.0755 ... ..- attr(*, dimnames)=List of 2 .. ..$ : chr [1:3] a0 a1 b1 .. ..$ : chr [1:4] Estimate Std. Error t value Pr(|t|) $ call : language garch(x = x, order = c(1, 1)) $ order: Named num [1:2] 1 1 ..- attr(*, names)= chr [1:2] p q $ j.b.test :List of 5 ..$ statistic: Named num 0.468 .. ..- attr(*, names)= chr X-squared ..$ parameter: Named num 2 .. ..- attr(*, names)= chr df ..$ p.value : Named num 0.791 .. ..- attr(*, names)= chr X-squared ..$ method : chr Jarque Bera Test ..$ data.name: chr Residuals ..- attr(*, class)= chr htest $ l.b.test :List of 5 ..$ statistic: Named num 1.01 .. ..- attr(*, names)= chr X-squared ..$ parameter: Named num 1 .. ..- attr(*, names)= chr df ..$ p.value : num 0.316 ..$ method : chr Box-Ljung test ..$ data.name: chr Squared.Residuals ..- attr(*, class)= chr htest - attr(*, class)= chr summary.garch From this you can see that there is a coef list member that contains the information you are after: garch1.summary$coef Estimate Std. Error t value Pr(|t|) a0 0.07989234 0.01104719 7.231912 4.762857e-13 a1 0.62870916 0.07551333 8.325804 0.00e+00 b1 0.21184013 0.05384033 3.934599 8.333558e-05 this is apparently a matrix, so try matrix notation: garch1.summary$coef[,4] a0 a1 b1 4.762857e-13 0.00e+00 8.333558e-05 or garch1.summary$coef[1,4] [1] 4.762857e-13 Having said all that, this solution depends on implementation details of the innards of the relevant objects, and in general if accessor functions are available they should be used instead... but in this case such accessors don't seem to be available. help.search(garch-methods, package=tseries) -- --- Jeff NewmillerThe . . Go Live... DCN:[EMAIL PROTECTED]Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html