[R] Help with dudi.pca
Dear R-helpers, I have two data frames, op and em4: str(op) 'data.frame': 37 obs. of 5 variables: $ m: num 0.202 0.336 0.122 0.139 0.14 ... $ lln : num 0.798 0.643 0.863 0.835 0.823 ... $ rrn : num 0.789 0.702 0.894 0.895 0.923 ... $ asym2: num 0.177 0.304 0.108 0.187 0.274 ... $ asym3: num 0.0755 0.0975 0.0818 0.0651 0.13 ... str(rownames(op)) chr [1:37] abov-belw ampl-rstr angl-rndd ascn-dscn ... str(em3) 'data.frame': 37 obs. of 9 variables: $ B--: int 4 1 12 14 0 3 2 15 3 5 ... $ P--: int 4 1 2 3 5 15 1 0 3 1 ... $ U--: int 10 16 4 1 13 0 15 3 12 12 ... $ --B: int 5 13 10 15 6 1 5 16 5 8 ... $ --P: int 6 2 5 2 12 16 5 0 13 10 ... $ --U: int 7 3 3 1 0 1 8 2 0 0 ... $ -N-: int 0 2 11 0 17 0 1 0 14 3 ... $ -P-: int 15 0 2 16 0 2 2 16 0 0 ... $ -R-: int 3 16 5 2 1 16 15 2 4 15 ... str(rownames(em3)) chr [1:37] abov-belw ampl-rstr angl-rndd ascn-dscn asym- symm end-bgnn ... Thus the 37 rownames in both are the same. Now I do a pca of op: (op.dudi - dudi.pca(op, scale = F, scan = F)) Duality diagramm class: pca dudi $call: dudi.pca(df = op, scale = F, scannf = F) $nf: 2 axis-components saved $rank: 5 eigen values: 0.09233 0.03109 0.01322 0.002024 0.0001017 vector length modecontent 1 $cw5 numeric column weights 2 $lw37 numeric row weights 3 $eig 5 numeric eigen values data.frame nrow ncol content 1 $tab 37 5modified array 2 $li37 2row coordinates 3 $l137 2row normed scores 4 $co52column coordinates 5 $c152column normed scores other elements: cent norm and of em3 (em3.dudi - dudi.pca(em3, scale = F, scan = F)) Duality diagramm class: pca dudi $call: dudi.pca(df = em3, scale = F, scannf = F) $nf: 2 axis-components saved $rank: 6 eigen values: 105.5 80.73 55.08 24.06 8.83 ... vector length modecontent 1 $cw9 numeric column weights 2 $lw37 numeric row weights 3 $eig 6 numeric eigen values data.frame nrow ncol content 1 $tab 37 9modified array 2 $li37 2row coordinates 3 $l137 2row normed scores 4 $co92column coordinates 5 $c192column normed scores other elements: cent norm I would like to do a coinertia analysis between the two results. coinertia(op.dudi, em3.dudi) Error in paste(COCA, 1:n.axes, sep = ) : element 2 is empty; the part of the args list of ':' being evaluated was: (1, n.axes) coinertia(op.dudi, em3.dudi, n.axes = 2) Error in sqrt(Dp) : Non-numeric argument to mathematical function Can anyone tell me why the coinertia fails, and how to fix it? I would be happy to send the two data files, if you were willing to help. Thanks, MK _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011;Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with colormodel in pdf driver
Hi Luis, Following David's suggestion, it worked for me: pdf('exp.pdf',colormodel='grey') # Note the change here :) barplot(table(subset(iris,Petal.Width1)$Species)) dev.off() Here is my session info: sessionInfo() R version 2.8.1 Patched (2009-01-01 r47434) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base HTH, Jorge On Fri, Jan 23, 2009 at 11:17 PM, David Winsemius dwinsem...@comcast.netwrote: Try changing the color to grey. Despite the help pages saying this: colormodel a character string describing the color model: currently allowed values are rgb, gray and cmyk. Defaults to rgb. I got the expected behavior by making the gray - grey change on my Mac OS 10.5.6/R2.8.1 system. -- David Winsemius On Jan 23, 2009, at 7:21 PM, Luis Torgo wrote: I'm trying to create figures in PDF that use the 'gray' colormodel instead of the default 'RGB' model, by requirements of a publisher. My problem has to do with the fact that I'm not being able to get gray colors with this option on the pdf() driver. Here is a small example for problem replication: R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnustatus major 2 minor 8.1year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) pdf('exp.pdf',colormodel='gray') barplot(table(subset(iris,Petal.Width1)$Species)) dev.off() Contrary to what I was expecting the bars appear in black and not gray as they are supposed to. This is not particularly serious for this toy graph but for others it creates more problems. Interesting enough this problem does not occur with the same option on the postscript() driver as it can be observed by running: postscript('exp.eps',colormodel='gray') barplot(table(subset(iris,Petal.Width1)$Species)) dev.off() Any help is most appreciated. Luis Torgo -- Luis Torgo FEP/LIAAD - INESC Porto, LA Phone : (+351) 22 339 20 93 University of Porto Fax : (+351) 22 339 20 99 R. de Ceuta, 118, 6o email : lto...@liaad.up.pt 4050-190 PORTO - PORTUGAL WWW : http://www.liaad.up.pt/~ltorgo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to prevent duplications of data within a loop
Dear Juliet, Why don't you use *apply() instead a for() loop? Here is a starting point: apply(myData[,-1],2,function(x) coefficients(lm(response~x))) var1 var2 var3 (Intercept) 0.10438369 0.10415221 0.1176728 x -0.03354243 0.02429041 -0.2240759 Note that the second row of the code above is the same you get with you procedure. See ?apply for more information. HTH, Jorge On Sat, Jan 24, 2009 at 12:30 AM, Juliet Hannah juliet.han...@gmail.comwrote: Hi All, I had posted a question on a similar topic, but I think it was not focused. I am posting a modification that I think better accomplishes this. I hope this is ok, and I apologize if it is not. :) I am looping through variables and running several regressions. I have reason to believe that the data is being duplicated because I have been monitoring the memory use on unix. How can I avoid this? Here is an example of how I am going about this. For lm, I also tried model=FALSE, but this did not seem to do the job. Any ideas? Thanks for your time. Regards, Juliet # create data set.seed(1) response - rnorm(50) var1 - rnorm(50) var2 - rnorm(50) var3 - rnorm(50) myData - data.frame(response,var1,var2,var3) var.names - names(myData)[2:4] numVars - length(var.names) betas - rep(-1,numVars) names(betas) - var.names #run regression on var1 through var3. for (Var_num in 1:numVars) { col.name - var.names[Var_num] mylm - lm(response ~ get(col.name),data=myData,model=FALSE) betas[Var_num] - coef(mylm)[2] } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R startup and shutdown question
Hi, ?.First ?.Last Sammy Philip James Smith wrote: Hi R-Community: Here is what I want to do: Every time I start R I want R to: 1. remove(list=ls()), and 2. source another file automatically. Then, when I shutdown R, I want R to: 1. remove(list=ls()) How do I do this? I recall vaguely that S could do this, but I don't remember exactly how it worked. Thanks for your help! Phil Smith __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Blay S KATH Kumasi, Ghana. -- View this message in context: http://www.nabble.com/R-startup-and-shutdown-question-tp21622562p21637693.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with colormodel in pdf driver
'gray' is what is in the code: 'grey' uses rgb -- just look at the pdf produced. The issue is that the wrong ('stroke' not 'fill') colour is set in ht 'gray' colormodel. On Fri, 23 Jan 2009, David Winsemius wrote: Try changing the color to grey. Despite the help pages saying this: colormodel a character string describing the color model: currently allowed values are rgb, gray and cmyk. Defaults to rgb. I got the expected behavior by making the gray - grey change on my Mac OS 10.5.6/R2.8.1 system. -- David Winsemius On Jan 23, 2009, at 7:21 PM, Luis Torgo wrote: I'm trying to create figures in PDF that use the 'gray' colormodel instead of the default 'RGB' model, by requirements of a publisher. My problem has to do with the fact that I'm not being able to get gray colors with this option on the pdf() driver. Here is a small example for problem replication: R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnustatus major 2 minor 8.1 year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) pdf('exp.pdf',colormodel='gray') barplot(table(subset(iris,Petal.Width1)$Species)) dev.off() Contrary to what I was expecting the bars appear in black and not gray as they are supposed to. This is not particularly serious for this toy graph but for others it creates more problems. Interesting enough this problem does not occur with the same option on the postscript() driver as it can be observed by running: postscript('exp.eps',colormodel='gray') barplot(table(subset(iris,Petal.Width1)$Species)) dev.off() Any help is most appreciated. Luis Torgo -- Luis Torgo FEP/LIAAD - INESC Porto, LA Phone : (+351) 22 339 20 93 University of Porto Fax : (+351) 22 339 20 99 R. de Ceuta, 118, 6o email : lto...@liaad.up.pt 4050-190 PORTO - PORTUGAL WWW : http://www.liaad.up.pt/~ltorgo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with dudi.pca
Hi Michael, coinertia(op.dudi, em3.dudi) Error in paste(COCA, 1:n.axes, sep = ) : element 2 is empty; Something makes me think that this is not the full error message, or the correct error message, or that you have something else in your call to coinertia? Why? Because you also list this: coinertia(op.dudi, em3.dudi, n.axes = 2) Error in sqrt(Dp) : Non-numeric argument to mathematical function Fact is, coinertia does not accept n.axes as an argument, it uses nf = to specify the number of axes. The function paste(), which is generating the error message, is used in coinertia(). All I can say from what you have given is do it again with a clean environment, and make sure that you are using the correct arguments to coinertia. Are you able to debug? If not send me your data and I will fix/find the problem. Regards, Mark. Michael Kubovy wrote: Dear R-helpers, I have two data frames, op and em4: str(op) 'data.frame': 37 obs. of 5 variables: $ m: num 0.202 0.336 0.122 0.139 0.14 ... $ lln : num 0.798 0.643 0.863 0.835 0.823 ... $ rrn : num 0.789 0.702 0.894 0.895 0.923 ... $ asym2: num 0.177 0.304 0.108 0.187 0.274 ... $ asym3: num 0.0755 0.0975 0.0818 0.0651 0.13 ... str(rownames(op)) chr [1:37] abov-belw ampl-rstr angl-rndd ascn-dscn ... str(em3) 'data.frame': 37 obs. of 9 variables: $ B--: int 4 1 12 14 0 3 2 15 3 5 ... $ P--: int 4 1 2 3 5 15 1 0 3 1 ... $ U--: int 10 16 4 1 13 0 15 3 12 12 ... $ --B: int 5 13 10 15 6 1 5 16 5 8 ... $ --P: int 6 2 5 2 12 16 5 0 13 10 ... $ --U: int 7 3 3 1 0 1 8 2 0 0 ... $ -N-: int 0 2 11 0 17 0 1 0 14 3 ... $ -P-: int 15 0 2 16 0 2 2 16 0 0 ... $ -R-: int 3 16 5 2 1 16 15 2 4 15 ... str(rownames(em3)) chr [1:37] abov-belw ampl-rstr angl-rndd ascn-dscn asym- symm end-bgnn ... Thus the 37 rownames in both are the same. Now I do a pca of op: (op.dudi - dudi.pca(op, scale = F, scan = F)) Duality diagramm class: pca dudi $call: dudi.pca(df = op, scale = F, scannf = F) $nf: 2 axis-components saved $rank: 5 eigen values: 0.09233 0.03109 0.01322 0.002024 0.0001017 vector length modecontent 1 $cw5 numeric column weights 2 $lw37 numeric row weights 3 $eig 5 numeric eigen values data.frame nrow ncol content 1 $tab 37 5modified array 2 $li37 2row coordinates 3 $l137 2row normed scores 4 $co52column coordinates 5 $c152column normed scores other elements: cent norm and of em3 (em3.dudi - dudi.pca(em3, scale = F, scan = F)) Duality diagramm class: pca dudi $call: dudi.pca(df = em3, scale = F, scannf = F) $nf: 2 axis-components saved $rank: 6 eigen values: 105.5 80.73 55.08 24.06 8.83 ... vector length modecontent 1 $cw9 numeric column weights 2 $lw37 numeric row weights 3 $eig 6 numeric eigen values data.frame nrow ncol content 1 $tab 37 9modified array 2 $li37 2row coordinates 3 $l137 2row normed scores 4 $co92column coordinates 5 $c192column normed scores other elements: cent norm I would like to do a coinertia analysis between the two results. coinertia(op.dudi, em3.dudi) Error in paste(COCA, 1:n.axes, sep = ) : element 2 is empty; the part of the args list of ':' being evaluated was: (1, n.axes) coinertia(op.dudi, em3.dudi, n.axes = 2) Error in sqrt(Dp) : Non-numeric argument to mathematical function Can anyone tell me why the coinertia fails, and how to fix it? I would be happy to send the two data files, if you were willing to help. Thanks, MK _ Professor Michael Kubovy University of Virginia Department of Psychology Postal Address: P.O.Box 400400, Charlottesville, VA 22904-4400 Express Parcels Address: Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903 Office:B011; Phone: +1-434-982-4729 Lab:B019; Phone: +1-434-982-4751 WWW:http://www.people.virginia.edu/~mk9y/ Skype name: polyurinsane [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Help-with-dudi.pca-tp21637152p21638090.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Does anyone has this paper in pdf?
Rolf Turner wrote: ... It always gets fussy and fiddly whenever legal issues arise. It would be nice if there were no such thing as ``intellectual property'' (which has always seemed to me to be an oymoron) and no such thing as lawyers. Hey, some of my best friends are lawyers. And who wants to go back to trial by combat? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave encoding problem
The two documents were actually different, which I didn't notice yesterday. One had different encoding. Thanks for your help Duncan. Unfortunetly the other problem still exists. My R or Sweave seems not to be able to work with utf-8 encoding. Everything works fine with latin-1, though. I could check my assumption if there was a possibility to switch R from latin-1 to utf-8. Does anybody have an idea how that might work? Gerrit Voigt Duncan Murdoch schrieb: Gerrit Voigt wrote: Hi Roland, thanks for your answere. I actually tried out a different, smaller Latex-header and the sweave-process suddenly worked. So I copied parts of the old header into the new one, to check what part is causing the trouble. In the end I had two documents with identical content. The new document worked fine with Sweave the other still gave out the error-message. If anybody has experienced that problem before, and knows an answere, please let me know. This sounds like you have discovered homeopathic properties in Sweave! It will be serious if input files remember errors even after they have been removed. But I think it's more likely that the files just look the same in your editor, but are actually different in some way you don't see. Candidates: - the encoding: maybe your editor is recognizing the encoding, and automatically displaying similar content from different input. - non-printing characters: maybe your editor is skipping some. I'd suggest doing a binary compare on the two files to see what the differences are. I think you are on Windows (but I may be misreading the quotes below); I recommend Beyond Compare (a shareware compare utility). It has a hex viewer plug-in that could show you a detailed comparison. I imagine diff on Unix has something similar. Duncan Murdoch Unfortunaetly I also still have an encoding problem with the new documt, that ran through Sweave. If I use ISO-8859-15 fontencoding in my editor and latin1 for input encoding in my Latex-document everything works fine. If I keep both in utf8, as I would like it, german mutated vowels (Umlaute) aren't displayed correctly. Rau, Roland schrieb: Hi Gerrit, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gerrit Voigt Sent: Monday, January 19, 2009 4:48 PM To: r-help@r-project.org Subject: [R] Sweave encoding problem Hello, Sweave seems to have trouble processing german letters in R. For example, my noweb R-input looks like this. = Oberflächenfehler = c(4, 11, 6, 2, 7, 9) @ If I send it through Sweave, I get the following error message. error: chunk 1 Error in parse(text = chunk) : unexpected input in Oberflä extra: Warning message: In readLines(f[1]) : underfull last line in C:\ (my R is in german, so I needed to translate the error message myself.) I got the impression, that this is an encoding issue of Sweave, since the input typed into R directly works just fine. The encoding I use in my noweb document is utf8. I don't think it has something to do with German letters. I saved the following text in a file 'sweavy.Snw': \documentclass{article} \begin{document} Hello World! = 1+1 @ = Oberflächenfehler = c(4, 11, 6, 2, 7, 9) @ \end{document} This is what happened in R: library(utils) Sweave(sweavy.Snw) Writing to file sweavy.tex Processing code chunks ... 1 : echo term verbatim 2 : echo term verbatim You can now run LaTeX on 'sweavy.tex' sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base And also the dvi looked fine after processing latex sweavy.tex To make things sure, I did in my editor (GNU Emacs 22.1.50.1) C-x RET f utf-8 to change set-buffer-file-coding-system to utf-8. Still works fine. Maybe this helps you further to track down the reason for the problem?!? Best, Roland -- This mail has been sent through the MPI for Demographic Research. Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __
Re: [R] Is it possible for R to import a SigmaPlot file?
On Thu, 2009-01-22 at 14:58 -0800, Jason Rupert wrote: I recently received a Sigmaplot file (*.jnb)from a customer and would like to know if I can input it to a data frame and then manipulate the data in R. I did a search on Google and on RSeek (www.rseek.org), but did not get any good hits. Thank for any feedback and insight you can provide. P.S. Love the flexibility of R and would love to keep using it. Just wanting to know if this is possible. Thanks again. Hi Jason, I don't know sigmaplot, but I thing is possible export sigmaplot database for other type of files. If you export jnb file to csv file is possible read a database in R. I will talk with a person work with me and tonight I send other mail with more details. -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 example
Hi Felipe, As I recall that is a known bug in the current version of ggplot2. Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Felipe Carrillo Verzonden: donderdag 22 januari 2009 23:57 Aan: r-h...@stat.math.ethz.ch Onderwerp: [R] ggplot2 example I need to plot two graphics just like the example below but for some reason your example crashes. Using facet_wrap seems to be the cause: library(ggplot2) upper - with(economics, data.frame(date,value = psavert, position = upper)) upper lower - with(economics, data.frame(date,value = unemploy,position = lower)) lower #upper$date - as.Date(upper$date,%m/%d/%Y) #lower$date - as.Date(lower$date,%m/%d/%Y) ggplot(mapping = aes(x=date, y=value)) + geom_line(data = upper) + geom_area(data = lower) + facet_wrap(~ position, scale = free_y,ncol=1) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Vector Autocorrelation Function in R?
Andreas Klein schrieb: Hello. Does anyone know, if there is a function in R to compute the vector autocorrelations? ?ccf on bivariate time series. + have a look at the vars package though I am not sure what exactly you are trying. hth Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extra rows of 'NAs' in imported dataset
'The R Inferno' page 87 talks about getting extra columns from data derived from spreadsheets. It happens because the spreadsheet program thinks for some reason that the extra cells are used -- a cell was probably clicked on. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) M-J Milloy wrote: Hello all: I'm hoping you can help me determine the source of this problem. I've just used read.csv to bring a small (581 rows, 9 vars) dataset into R (2.7.0., Mac OS 10.5.5). The dataset was created in Excel 2008 from a datadump from an Oracle database. I've done this many times before and had no problems. The dataset (a) appears to have extra rows filled with NAs. For example, a[a$mmt.dose == 10, ] ID COHORTF st.y st.m st.d days md mmt.dose NA NA NA NA NA NA NA NA NA NA NA.1 NA NA NA NA NA NA NA NA NA NA.2 NA NA NA NA NA NA NA NA NA NA.3 NA NA NA NA NA NA NA NA NA NA.4 NA NA NA NA NA NA NA NA NA NA.5 NA NA NA NA NA NA NA NA NA 22288 V PC NA NA NA NA MOSE 10 NA.6 NA NA NA NA NA NA NA NA NA NA.7 NA NA NA NA NA NA NA NA NA NA.8 NA NA NA NA NA NA NA NA NA NA.9 NA NA NA NA NA NA NA NA NA NA.10 NA NA NA NA NA NA NA NA NA 474 756 VC 2004 101 1553 UNKN 10 I've examined the original CSV file and also exported the a dataset to a CSV and found no source for these entries. Any help would be much appreciated! M-J -- PhD student, School of Population and Public Health, University of British Columbia Musqueam Territory, British Columbia Research Assistant, Urban Health Research Institute, BC Centre for Excellence in HIV/AIDS St. Paul's Hospital, Vancouver, Canada [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Package installation failed
Odette Gaston wrote: Hi Uwe and all, Error message was: error in normalizePath(path) : path[1]: no such file to load Hmmm, what does traceback() tell you at that point? Have you had a cionnection to CRAN and has something been downloaded? If so, to which directory? Where is R installed? Do you have set some library path other than the R default? Uwe Ligges Many thanks, Odette On Fri, Jan 23, 2009 at 1:22 AM, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: Odette Gaston wrote: Hi folks, I am currently having the problem with using R 2.8.1 that I cannot install some of packages from CRAN or local drive and somebody may be able to help me. ex) faraway package and lme4 package. I have downloaded them in my hard drive as local, but still R was unable to find the package (message showed up as no such file). I could download most packages, but not all what I want. I showed my PC to R experts around and nobody had ideas. I've re-installed newest R and updated packages hundred times, but still same message came up. So, what is the error message when you try, e.g. install.packages(lme4) ? Uwe Ligges My working environment is: OS: XP Windows R2.8.1 Any suggestions would be appreciated. Thanks a lot, Odette [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get a primitive function object
If I understand properly, you want '-' to be a generic function, which it currently isn't. There may be a way to fake that (I can't think of any). But I'm wondering if you should rethink what you want. The only reason that I can think of that you would want to change '-' is because of some extra side effect that you want to happen. That is not in the spirit of R. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Yi Zhang wrote: i was sort-of joking, though it's a real option if you want it. but seriously, there's no reason for the %#* lamenting: x - 1 '-' = function(x,y) 0 x - 2 # 0 .Primitive('-')(x,2) x # 2 base::'-'(x, 3) x # 3 base::'-'('-', base::'-') x - 4 x # 4 vQ I'm still not sure if this can help solve my problem. If I want to overwrite the `-` operator for a particular type of objects, but preserve its effect for other regular objects (in other words, if I do x-5 with my new -, x will be 5 and nothing strange happens), then what should I put in the [ ] below? old - `-` old(`-`, function(x, value){ if (value is my type) do something [ ] # to bind the object value to symbol x: no matter what you do here, the binding/assignment is local within this function?! }) Hope I have made myself clear. Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dimnames in pkg ipred
I think I solved the problem =) My dataset is an .arff file. So I read my data into R via read.arff. I tried the following: Export the dataframe to an txt-file and import it once again in R via read.table. With the new dataset if works fine. Maybe the error comes from the variable-names. I attached a txt-file containing the str(traindat.bin) output from the data.frame, which I import via read.arff Cheers, TIM -Ursprüngliche Nachricht- Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Gesendet: Friday, January 23, 2009 11:03 AM An: Häring, Tim (LWF) Betreff: Re: AW: [R] dimnames in pkg ipred Häring, Tim (LWF) wrote: OK, the information I send to the list were rather sparse. Sorry for that! I just tried the command with the recent Version of R and ipred. The error message is the same. I want to create a classification model. My data consist of 5414 observations and 98 variables whereof 33 are numeric, the remainder are binary nominal (factor) variables. My output SOIL_UNIT is a factor variable with 82 levels. I hope this are enough information to understand the problem. What does str(traindat.bin) tell you? Is it a data.frame? Can you reduce the data.frame in a way (less variables and observations) so that you can send the rest by e-mail and we can see the error? Uwe Ligges Cheers, TIM -Ursprüngliche Nachricht- Von: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Gesendet: Thursday, January 22, 2009 6:49 PM An: Häring, Tim (LWF) Cc: r-help@r-project.org Betreff: Re: [R] dimnames in pkg ipred Häring, Tim (LWF) wrote: Hello List, I`m trying to make prediction using a bagged tree with the package ipred. I tried to follow the manual but I`m getting an error message. Also browsing through the list-archive I didn`t find any hint. Maybe someone can help me? selbag - bagging(SOIL_UNIT ~., data=traindat.bin, coob=TRUE) Error in dimnames(X) - list(dn[[1L]], unlist(collabs, use.names = FALSE)) : length of 'dimnames' [2] not equal to array extent I´m using R 2.7.2 on Win XP and the latest version of ipred. Please do read the posting guide. - We do not have traindat.bin, hence cannot reproduce your problem - Does it happen with recent versions of R and ipred? Best, Uwe Ligges Thanks a lot. TIM --- Dipl.-Geogr. Tim Häring Sachgebiet Standort und Bodenschutz (SG 2.1) Bayerische Landesanstalt für Wald und Forstwirtschaft Am Hochanger 11 D-85354 Freising Tel.: +49-(0)8161/71-4769 E-Mail: tim.haer...@lwf.bayern.de http://www.lwf.bayern.de [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. str(traindat.bin) 'data.frame': 5414 obs. of 98 variables: $ SOIL_UNIT : Factor w/ 82 levels 17b,19a,19b,..: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Allgaeuschichten: Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Anmooriger_Boden: Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Aptychenschichten : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Bachschuttkegel : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Baustein-Schichten : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Baustein-Schichten_Nagelfluh: Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Bergschlipf : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Bergsturz : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Bunte_Hornsteinschichten: Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Bunte_Mergel: Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Bunter_Liaskalk : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Cenoman : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Cenoman_Breccie : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Cenoman_Kalksandstein : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Cenoman_Mergel : Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Deutenhausener_Schichten: Factor w/ 2 levels f,t: 1 1 1 1 1 1 1 1 1 1 ... $ GEOL_UNIT=Gewaesser
Re: [R] Does anyone has this paper in pdf?
Rolf Turner-3 wrote: Is this really a violation of copyright? If I have a copy of a journal I believe it is within the compass of ``fair practice'' (or some such jargon) to make a photocopy of a particular article and give this copy to a colleague or student for research purposes. Likewise I believe it is ``fair practice'' for me to send a copy of a pdf file (that I have legitimately acquired) to a colleague or student for research purposes. Yes I believe it would constitute a breach of copyright. I looked up the copyright information at the local University (see http://www.shef.ac.uk/library/services/copyrigh.html ) and I'd imagine its similar elsewhere. The particular point regarding copying is probably http://www.shef.ac.uk/library/services/copyrules.html and this sentence is the most pertinent... A key feature of the 1988 Act is that anyone wishing to make a single copy of a short extract from any book, journal or newspaper for the purposes of research for a non-commercial purpose or private study, is likely to be able to do so under the fair dealing provisions. Its slightly ambiguous but I'd imagine that its an individual who has to make the copy for themselves. If copying material for others were permissible then as Wacek points out the whole thing would break down as it could then go on ad nauseum. Note there is a link to issues dealing with teaching material, and I'd imagine colleagues at your institution are likely to have the same access rights, so technically its just as easy to send them a link to download a paper themselves. Rolf Turner-3 wrote: It always gets fussy and fiddly whenever legal issues arise. It would be nice if there were no such thing as ``intellectual property'' (which has always seemed to me to be an oymoron) and no such thing as lawyers. I agree access to all research should be open, particularly if its been funded by public bodies. A series of videos from BioMed Central on the issue of Open Acccess is at http://uk.youtube.com/view_play_list?p=49C6909B5770663A Neil -- View this message in context: http://www.nabble.com/Does-anyone-has-this-paper-in-pdf--tp21594321p21622193.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R startup and shutdown question
Hi R-Community: Here is what I want to do: Every time I start R I want R to: 1. remove(list=ls()), and 2. source another file automatically. Then, when I shutdown R, I want R to: 1. remove(list=ls()) How do I do this? I recall vaguely that S could do this, but I don't remember exactly how it worked. Thanks for your help! Phil Smith __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Relative frequency of cases in data frame matching a specified criteria
I want to get the relative frequency of cases in a data frame that matches a specified criteria, omiting NA values. This seem so simple, but I can't come up with an effective way. nrow(data[data$variablevalue !is.na(data$variable),])/nrow(data) works but is very ineffective and CPU consuming when the data frame is large (more than 13000 rows and 400 columns). /S __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot seq
Dear Felipe, Provide a dummy sample if your dataset is big or confidential. The actual values are not that important to figure out what kind of plot you want. How did you code Week? Numeric? Try convert it into a factor with levels = c(27:52, 1:26). And then set the breaks to seq(1, 52, by = 2). WFBox - data.frame(Week = rep(1:52, 10), FL = rnorm(520)) WFBox$fWeek - factor(WFBox$Week, levels = c(27:52, 1:26)) library(ggplot2) ggplot(WFBox, aes(fWeek, FL)) + geom_boxplot(outlier.colour=pink,outlier.size=3,outlier.shape=21,fill= goldenrod,colour=blue) + scale_x_discrete(breaks=c(seq(1,51,2))) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Felipe Carrillo Verzonden: donderdag 22 januari 2009 23:54 Aan: r-h...@stat.math.ethz.ch Onderwerp: [R] ggplot seq Hi Hadley: Not sure if you received my email, so I am resending it again. I have dealt with this before and I can't remember how it got resolved. It is too much data to reproduce the example below(49.000 records) but all I am after is trying to get the x axis breaks. I want my x axis to go from 27 to 51 and 1 to 25 by 2. I am trying to concatenate the breaks but it sorts the seq() in ascending order. Is there a way to workaround it? see scale_x_continuous below: boxP - ggplot(WFBox, aes(Week, FL,group=Week)) boxP + geom_boxplot(outlier.colour=pink,outlier.size=3,outlier.shape=21,fill= goldenrod,colour=blue) + scale_x_discrete(breaks=c(seq(27,51,2),seq(1,25,2))) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2
Dear Vikas, First a few remarks: - as we don't have your dataset, your example is not reproducible. Please do add a (dummy) dataset next time. - adding spaces makes code much more readable. - why do you use scale_colour_gradient2 if you set the midpoint at the lower level? Use scale_colour_gradient instead. - You will have to tell us what the desired labels should look like. I tried to figure out what your data looks like an created an example that works. Let us know if that is what you want. n - 20 nPhase - 5 b3 - expand.grid(Year = seq_len(n), Phase = runif(nPhase, min = 1, max = 2)) b3$CDR - rnorm(nrow(b3)) qplot(Year, CDR, data=b3,colour=Phase, group = Phase, geom=c(point,line),legend.position=bottom) +scale_colour_gradient(limits=c(1,2), low=magenta, high=darkblue,breaks=c(1,2),labels=c(a,b)) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Vikas Rawal Verzonden: donderdag 22 januari 2009 17:59 Aan: r-help@r-project.org Onderwerp: [R] ggplot2 I have been struggling to get the legends in ggplot2 right or do away with them altogether (on which I have already sent a post). In the following code, the labels argument in the scale_colour_gradient2 does not give me the desired labels in the legend. Could someone explain? qplot(Year,CDR,data=b3,colour=Phase,geom=c(point,line),legend.positi on=bottom)-p p+scale_colour_gradient2(limits=c(1,2), midpoint=1,low=magenta, mid=magenta, high=darkblue,breaks=c(1,2),labels=c(a,b)-p p Vikas [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R startup and shutdown question
Philip Smith wrote: Hi R-Community: Here is what I want to do: Every time I start R I want R to: 1. remove(list=ls()), and You do not need to given you start with an emty workspace, i.e. start R with: R --no-restore 2. source another file automatically. Write it in your RProfile (for details, see ?Startup) Then, when I shutdown R, I want R to: 1. remove(list=ls()) Then do not save the workspace or start R with R --no-save (or with both args: R --no-save --no-restore) Uwe Ligges How do I do this? I recall vaguely that S could do this, but I don't remember exactly how it worked. Thanks for your help! Phil Smith __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Relative frequency of cases in data frame matching a specified criteria
in this case you just need: mean(data$variable value !is.na(data$variable)) I hope it helps. Best, Dimitris Stefan Björk wrote: I want to get the relative frequency of cases in a data frame that matches a specified criteria, omiting NA values. This seem so simple, but I can't come up with an effective way. nrow(data[data$variablevalue !is.na(data$variable),])/nrow(data) works but is very ineffective and CPU consuming when the data frame is large (more than 13000 rows and 400 columns). /S __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] convergence problem gamm / lme
Geert, Can you get a simpler model with, say, a quadratic dependence on lon, lat to converge, using glmmPQL? The answer might give a clue about whether the issue is related to using a smoother, or is something more basic. How confident are you that the Poisson assumption is reasonable? Can the model be fitted to a random subsample of the data, or does it always fail? PQL can fail to converge, but it's usually not as obstinate as it seems to be in this case, if the model structure is reasonable and identifiable. best, Simon On Thursday 22 January 2009 15:52, geert aarts wrote: Hope one of you could help with the following question/problem: We would like to explain the spatial distribution of juvenile fish. We have 2135 records, from 75 vessels (code_tripnr) and 7 to 39 observations for each vessel, hence the random effect for code_tripnr. The offset (�offsetter�) accounts for the haul duration and sub sampling factor. There are no extreme outliers in lat/lon. The model we try to fit is: gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1), family=poisson, niterPQL=200) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in MEestimate(lmeSt, grps) : NA/NaN/Inf in foreign function call (arg 1) We tried several things. We added some noise to lon and lat, modelled the density instead of using a count with model offset, and we normalized the explanatory variables. We also changed several settings (see models below). Interestingly, we do manage to fit a more complex model: gamm2-gamm(count~offset(offsetter)+ s(lat,lon,year,dayofyear), random=list(code_tripnr=~1),family=poisson, correlation = corGaus(0.1, form=~lat + lon)) The models are fitted using mgcv 1.4-1 and R 2.7.1 on a 64Bits Debian OS. So there seems to be a convergence problem, correct? And does someone have an idea what might cause this? Secondly are there some tricks/solutions. E.g. perhaps we could use the results from the more complex model (gamm2 above), but I do not know exactly how. All help/advice would be greatly appreciated. Kind regards, Geert gamm3-gamm(count~offset(offsetter)+s(lon,lat), random=list(code_tripnr=~1),family=poisson, correlation = corExp(1, form=~X + Y),nite rPQL=200) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in recalc.corSpatial(object[[i]], conLin) : NA/NaN/Inf in foreign function call (arg 1) gamm3-gamm(count~offset(offsetter)+s(lon,lat,k=c(1,1)),random=list(code_ tripnr=~1),family=poisson, niterPQL=200) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in lme.formula(fixed = fixed, random = random, data = data, correlation = correlation, : nlminb problem, convergence error code = 1 message = false convergence (8) In addition: Warning messages: 1: In if (k M + 1) { : the condition has length 1 and only the first element will be used .Options$mgcv.vc.logrange=0.001 # we also tried higher settings gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1), family=poisson, niterPQL=200, control=lmeControl(opt=optim)) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in optim(c(coef(lmeSt)), function(lmePars) -logLik(lmeSt, lmePars), initial value in 'vmmin' is not finite gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1), family=poisson, niterPQL=200,control=lmeControl(minAbsParApV ar=0.1)) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in recalc.corSpatial(object[[i]], conLin) : NA/NaN/Inf in foreign function call (arg 1) gamm3-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1), family=poisson, niterPQL=200) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in MEestimate(lmeSt, grps) : NA/NaN/Inf in foreign function call (arg 1) gamm3-gamm(count~offset(offsetter)+s(lon,lat,k=c(1,1)),random=list(code_tr ipnr=~1),family=poisson, niterPQL=200) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in lme.formula(fixed = fixed, random = random, data = data, correlation = correlation, : nlminb problem, convergence error code = 1 message = false convergence (8) In addition: Warning messages: 1: In if (k M + 1) { : the condition has length 1 and only the first element will be used 2: In smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) : basis dimension, k, increased to minimum possible gamm3-gamm(count~offset(offsetter)+s(lon,lat,k=c(8,8)),random=list(code_tr ipnr=~1),family=poisson, niterPQL=200) Maximum number of PQL iterations: 200 iteration 1 iteration 2 Error in lme.formula(fixed = fixed, random = random, data = data, correlation = correlation, : nlminb problem, convergence error code = 1 message = false convergence (8) In addition:
Re: [R] how to get a primitive function object
Wacek Kusnierczyk wrote: Duncan Murdoch wrote: You can use parent.frame() as the pos or envir argument to assign(), and then the assignment happens in the caller's frame. And assign() is also another way out if you overwrite - with something that doesn't work; just call it to reassign base::`-` to it. Or just rm(`-`) to unhide the original one. unless you have redefined rm as well, that is. Right, but then there's remove, or base::rm. Unless you redefined remove and `::`. So here's the question for a frustrating contest: is it possible to define enough functions in the global environment to render your R session completely unrecoverable? (I think it probably is.) And what's the minimal set, or the minimal script to brick your R? No manipulating the search list or writing anywhere but the global environment is allowed. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave encoding problem
Gerrit Voigt wrote: The two documents were actually different, which I didn't notice yesterday. One had different encoding. Thanks for your help Duncan. Unfortunetly the other problem still exists. My R or Sweave seems not to be able to work with utf-8 encoding. Everything works fine with latin-1, though. I could check my assumption if there was a possibility to switch R from latin-1 to utf-8. Does anybody have an idea how that might work? Connections and functions that read from them generally have an encoding argument; I think you need to have that set to UTF-8 or latin1 as appropriate. However, Sweave() doesn't offer an option to pass that arg down to the readLines() call that actually reads the file. I believe options(encoding=UTF-8) or options(encoding=latin1) will set the default if you run it before calling Sweave. You will probably find it frustrating to keep switching that option; I'd recommend storing files in the native encoding for your system, which R will default to using. (This doesn't work if you share the same file on multiple systems, of course.) Duncan Murdoch Gerrit Voigt Duncan Murdoch schrieb: Gerrit Voigt wrote: Hi Roland, thanks for your answere. I actually tried out a different, smaller Latex-header and the sweave-process suddenly worked. So I copied parts of the old header into the new one, to check what part is causing the trouble. In the end I had two documents with identical content. The new document worked fine with Sweave the other still gave out the error-message. If anybody has experienced that problem before, and knows an answere, please let me know. This sounds like you have discovered homeopathic properties in Sweave! It will be serious if input files remember errors even after they have been removed. But I think it's more likely that the files just look the same in your editor, but are actually different in some way you don't see. Candidates: - the encoding: maybe your editor is recognizing the encoding, and automatically displaying similar content from different input. - non-printing characters: maybe your editor is skipping some. I'd suggest doing a binary compare on the two files to see what the differences are. I think you are on Windows (but I may be misreading the quotes below); I recommend Beyond Compare (a shareware compare utility). It has a hex viewer plug-in that could show you a detailed comparison. I imagine diff on Unix has something similar. Duncan Murdoch Unfortunaetly I also still have an encoding problem with the new documt, that ran through Sweave. If I use ISO-8859-15 fontencoding in my editor and latin1 for input encoding in my Latex-document everything works fine. If I keep both in utf8, as I would like it, german mutated vowels (Umlaute) aren't displayed correctly. Rau, Roland schrieb: Hi Gerrit, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gerrit Voigt Sent: Monday, January 19, 2009 4:48 PM To: r-help@r-project.org Subject: [R] Sweave encoding problem Hello, Sweave seems to have trouble processing german letters in R. For example, my noweb R-input looks like this. = Oberflächenfehler = c(4, 11, 6, 2, 7, 9) @ If I send it through Sweave, I get the following error message. error: chunk 1 Error in parse(text = chunk) : unexpected input in Oberflä extra: Warning message: In readLines(f[1]) : underfull last line in C:\ (my R is in german, so I needed to translate the error message myself.) I got the impression, that this is an encoding issue of Sweave, since the input typed into R directly works just fine. The encoding I use in my noweb document is utf8. I don't think it has something to do with German letters. I saved the following text in a file 'sweavy.Snw': \documentclass{article} \begin{document} Hello World! = 1+1 @ = Oberflächenfehler = c(4, 11, 6, 2, 7, 9) @ \end{document} This is what happened in R: library(utils) Sweave(sweavy.Snw) Writing to file sweavy.tex Processing code chunks ... 1 : echo term verbatim 2 : echo term verbatim You can now run LaTeX on 'sweavy.tex' sessionInfo() R version 2.7.0 (2008-04-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base And also the dvi looked fine after processing latex sweavy.tex To make things sure, I did in my editor (GNU Emacs 22.1.50.1) C-x RET f utf-8 to change set-buffer-file-coding-system to utf-8. Still works fine. Maybe this helps you further to track down the reason for the problem?!? Best, Roland -- This mail has been sent through
[R] can't load rJava in R 2.8.1 on Windows XP
Dear community, unfortunately I did not manage load the rJava package receiving the following error-message: library(rJava) Error in inDL(x, as.logical(local), as.logical(now), ...) : kann shared library 'C:/Programme/R/2.8.1/library/rJava/libs/rJava.dll' nicht laden: LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. Error : .onLoad in 'loadNamespace' für 'rJava' fehlgeschlagen Fehler: Laden von Paket/Namensraum für 'rJava' fehlgeschlagen Translation: can't load library ... rJava.dll LoadLibrary failure: the module was not found Reinstalling the package did not help, installing the latest developement version didn't help as well. The shared library rJava.dll is in place (exactly where R is looking for it)! Are there any ideas, what's wrong. I'd appreciate any kind of help very much, as I need rJava urgently to use RWeka and iPlots. Best regards, Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Returning NA from lm
Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2 A 4 A 6.5 ...repeat 96 times with differing values of A B 1 B 2.3 B NA B 6.5 ...repeat 96 times with differing values of B etc I run these against a linear model using tapply(data$Value, data$Key,FUN=regr,100) where regr-function(x,w) { #run the model against the last w values of x lm((x[length(x)-w):length(x)]~myModel(w)) } In the results, I want to return NA for any Key group where one or more of the values is NA. If I run the above I get a regression structure ignoring the missing values and returning values for data that contains NA. Using na.action=na.fail or na.action=NULL causes the whole tapply function to fail and I get nothing. Is there a way I can get lm to return NA if any of the values in the data are NA but valid numbers for complete data? I realise that I could remove the groups with NAs but I'm running the regressions over multiple time periods and most of the data groups will have a full complement of data for at least some of these periods. It becomes a pain to manage NAs if I do that. Sorry if the above is a little unclear. Thanks Neil . This message is intended only for the use of the person(s) to whom it is addressed. It may contain information which is privileged and confidential. Accordingly any unauthorised use is strictly prohibited. If you are not the intended recipient, please contact the sender as soon as possible. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction, unless specifically agreed otherwise. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any opinions or advice contained in this Internet email are subject to the terms and conditions expressed in any applicable governing Marble Bar Asset Management LLP's terms and conditions of business or client agreement letter. Any comments or statements made herein do not necessarily reflect those of Marble Bar Asset Management LLP. Marble Bar Asset Management LLP is regulated and authorised by the FSA. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R for Computational Neuroscience?
Hi all, I've noticed that many computational neuroscience research groups use MATLAB. While it's possible that MATLAB may have some features unavailable in R, I suspect that this may instead simply be a case of costly tradition, where researchers were taught MATLAB as students and pay for it as researchers because it's all they know. I'd like to attempt to break the cycle by offering colleagues resources on using R for computational neuroscience, but I haven't been able to find anything (searched the task view, r-seek, google). Can anyone direct me to resources on using R for computational neuroscience? Input on my possibly naive assumption that R is a sufficient tool for this field would also be appreciated. Cheers, Mike -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University www.thatmike.com Looking to arrange a meeting? Check my public calendar: http://www.thatmike.com/mikes-public-calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with writing data to *.xls file
I read data from *.xls file and i did some caliculations on that data and now i have to create a column in the same .xls file i tried it with *write.xls() *but the thing is it deleted all the columns previously presented in that file and it created a column and inserted data can any one suggest what to do for this You cannot insert a column in the sheet but you can write a data matrix/frame which contains the newly calculated column. myfile - test.xls # read data #dat - read.xls( myfile ) dat - cbind( 1:4, rep(41,4), rep(43,4) ) # calculate and prepare full data to write calc - dat[,2] + 1 dat - cbind( dat[,1], dat[,2], calc, dat[,3] ) # write (sheet will be overwritten with new data) #write.xls( dat, myfile ) -- Regards, Hans-Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates)
Thank you Greg for your explanations. I think you explained the problem clearly now. Mvh. Marie On Thu, Jan 22, 2009 at 10:24 PM, Greg Snow greg.s...@imail.org wrote: Comments interspersed below From: Marie Sivertsen [mailto:mariesiv...@gmail.com] Sent: Thursday, January 22, 2009 1:17 PM To: Greg Snow Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Unexpected behaviour of the as.Date (was: Error as.Date on Invalid Dates) [snip] For your question, the help page for as.Date includes: format: A character string. The default is '%Y-%m-%d'. For details see 'strftime'. To be strict, neither 1/13/2001 nor 13/1/2001 match the format, so both should raise error, I think. Since the behaviour seem not to apply the default strictly, why ought one think 13/1/2001 will not be parsed the only reasonable way? The help page for as.Date refers to the help page for strptime which says that details are system specific. So there may be some systems where you would get an error from '/' not being '-', but apparently on your system they are treated the same. Personally I see a big difference between interpreting an obvious separator as such and changing the order of values. The fact that it sometimes gets the one correct does not imply to me that the other should happen automatically. Dealing with the separators can be done on an individual basis as each character string is processed. Guessing the order of the entries could require looking at the entire vector/file/dataset, which I expect would slow things down quite a bit. (and how long would it be before someone complained that it processed file A correctly, but file B should have been treated like A, but since it only included days less than 13, the program did not realize this). And Character strings are processed as far as necessary for the format specified: any trailing characters are ignored. I don't see anything in your examples that runs counter to the above. Yes they do. None of them match the format, but some parse correctly, some produce rubbish, and some raise error. Maybe you want to improve the help page fo the as.Date to say something like The default is a sequence of numerical representations of the year, then the month, then the day, separated by one of '-', '/', ..., which make it clearer. But is it correct? It may be system dependent (or all systems may do the exact same now). How about if the help page tells you to find out for your system (easy fix, it already does). Remember that computers do exactly what you tell them to do, not what you think that they should do. Computers do exactly what they were programmed to do, and what they will do depends on what the developer told them to do when they are given certain input. I expect them to do exactly what I tell them to do, and it is to parse 1/13/2001 the only reasonable way. It seems that someone told them to do something else... I was using the general 'you' above that includes the programmer as well as the user, since you (singular) did not specify the format, the computer used the default format that the programmer (part of the collective 'you') specified which says the order is year, month, day. Many problems come as a result of users forgetting that they are smarter than the computer. I see 3 ways to remedy the problem: 1. Make computers that are as smart or smarter than people. 2. Make the programmers anticipate every way that someone may use a particular function and make them implement all of the functionality even if they don't think it is worth the time/effort since there is an easy work around for many of the less likely used features. 3. Don't expect the computer to guess correctly and tell it exactly what you want it to do. I don't think that number 1 will ever happen, and there are plenty of science fiction stories that suggest problems with even trying. Option 2 stinks of hubris, and even if it were possible, I personally would not want to wait until they were finished before being able to use the functions/programs. Which leaves option 3, which I think is the best approach even without arguments against the others. I think the moral of this story is: program defensively, always specify a date format! Mvh. Marie -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can't load rJava in R 2.8.1 on Windows XP
Most likely Java is not in place, including in the DLL search path. On Fri, 23 Jan 2009, drflxms wrote: Dear community, unfortunately I did not manage load the rJava package receiving the following error-message: library(rJava) Error in inDL(x, as.logical(local), as.logical(now), ...) : kann shared library 'C:/Programme/R/2.8.1/library/rJava/libs/rJava.dll' nicht laden: LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. You should get a popup here with more information (from Windows). The problem is not rJava.dll, but one of its dependencies. Error : .onLoad in 'loadNamespace' für 'rJava' fehlgeschlagen Fehler: Laden von Paket/Namensraum für 'rJava' fehlgeschlagen Translation: can't load library ... rJava.dll LoadLibrary failure: the module was not found Reinstalling the package did not help, installing the latest developement version didn't help as well. The shared library rJava.dll is in place (exactly where R is looking for it)! Are there any ideas, what's wrong. I'd appreciate any kind of help very much, as I need rJava urgently to use RWeka and iPlots. Best regards, Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Returning NA from lm
See ?na.exclude On Fri, 23 Jan 2009, Neil Beddoe wrote: Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2 A 4 A 6.5 ...repeat 96 times with differing values of A B 1 B 2.3 B NA B 6.5 ...repeat 96 times with differing values of B etc I run these against a linear model using tapply(data$Value, data$Key,FUN=regr,100) where regr-function(x,w) { #run the model against the last w values of x lm((x[length(x)-w):length(x)]~myModel(w)) } In the results, I want to return NA for any Key group where one or more of the values is NA. If I run the above I get a regression structure ignoring the missing values and returning values for data that contains NA. Using na.action=na.fail or na.action=NULL causes the whole tapply function to fail and I get nothing. Is there a way I can get lm to return NA if any of the values in the data are NA but valid numbers for complete data? I realise that I could remove the groups with NAs but I'm running the regressions over multiple time periods and most of the data groups will have a full complement of data for at least some of these periods. It becomes a pain to manage NAs if I do that. Sorry if the above is a little unclear. Thanks Neil -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Write to multiple connections or multiple text files
Hi all, I want to modify a large number of text files (ca 4000) by replacing a value found on a particular line in them with a value from an R object. For a single file I would normally use: con-file (foo.txt, open=r+) content-readLines(con) content[n]-test writeLines(content,con) close(con) For repeating this for several files I can write a for loop around this. However, my problem with this is that it is rather slow. I am therefore wondering if there is any other way to write to multiple connections in a similar way as one can e.g. write to a large number of rows in a matrix simultaneously? (Note that seek() is not so practical for me since the number of bytes before the specific line varies between the files, therefore I use reanLines() and match the right line instead.) My Systems: OS: Windows Server 2003 Linux Red Hat (interchangeably) R version: 2.7.2 Thanks for any suggestions! ooo Jafet Andersson Eawag - The Swiss Federal Institute of Aquatic Science and Technology Ueberlandstrasse 133 P.O. Box 611 CH-8600 Duebendorf Switzerland Phone: +41 (0)44 823 5358 Fax: +41 (0)44 823 5028 http://www.eawag.ch/index_EN __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Does anyone has this paper in pdf?
Note there is a link to issues dealing with teaching material, and I'd imagine colleagues at your institution are likely to have the same access rights, so technically its just as easy to send them a link to download a paper themselves. Hello, On this point, I remember taking courses at university in which the professor was not allowed to make and distribute copies of certain articles for the students. However we were free to go and make the copies (legally) ourselves. There seems to be a point beyond which capitalism introduces more inefficiencies into the market than it solves. Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in appending data into*.csv file
You can probably use one of the 'apply' functions, but it is hard to tell you which one since you did not provide commented, minimal, self-contained, reproducible code, or an example of what you thought the output should look like. On Fri, Jan 23, 2009 at 2:28 AM, venkata kirankumar kiran4u2...@gmail.com wrote: Hi all, I got a problem with appending data into the *.csv file like abc-read.csv(bbb.csv) # reading data from one csv file abc1-mean(subset(abc,Group==A)) hear i have to creat a .csv file and in that i have to create column's with names *group, mean* and farther i have to caliculate for Groups:-A, B, C, D, F and i have to append data to consicutive rows of groups can any one suggest how can i farward in this issue thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Write to multiple connections or multiple text files
The solution you have seems to read in all the lines of data at once, operate on them and then write them out as a whole chunck. Having multiple connections open won't really help since I/O is serial. So is the code you included the actual code, or just an example? It would help to see what the real code is to see if there is some way of optimizing it. On Fri, Jan 23, 2009 at 8:06 AM, Andersson, Jafet jafet.anders...@eawag.ch wrote: Hi all, I want to modify a large number of text files (ca 4000) by replacing a value found on a particular line in them with a value from an R object. For a single file I would normally use: con-file (foo.txt, open=r+) content-readLines(con) content[n]-test writeLines(content,con) close(con) For repeating this for several files I can write a for loop around this. However, my problem with this is that it is rather slow. I am therefore wondering if there is any other way to write to multiple connections in a similar way as one can e.g. write to a large number of rows in a matrix simultaneously? (Note that seek() is not so practical for me since the number of bytes before the specific line varies between the files, therefore I use reanLines() and match the right line instead.) My Systems: OS: Windows Server 2003 Linux Red Hat (interchangeably) R version: 2.7.2 Thanks for any suggestions! ooo Jafet Andersson Eawag - The Swiss Federal Institute of Aquatic Science and Technology Ueberlandstrasse 133 P.O. Box 611 CH-8600 Duebendorf Switzerland Phone: +41 (0)44 823 5358 Fax: +41 (0)44 823 5028 http://www.eawag.ch/index_EN __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 3d scatter plot with both error bars and a flexibly fitted surface
Dear R-helpers: I, an entry level R user, wonder how make a 3d scatter plot with both error bars and a flexibly fitted surface. Can anyone eligthen me? Many Thanks in advance. -Sean [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Multifractal detrended fluctuation analysis
Apologies for re-posting. I mistakenly sent embedded text in my initial post. Sorry, I'm new at this. Best, - J. Dixon Dear R-users, Has anyone written a function for multifractal detrended fluctuation analysis? The fractal package does mono-fractal DFA, but not multifractal as far as I can tell. The MF-DFA approach is presented in: J. W. Kantelhardt, S. Zschiegner, E. Koscielny-Bunde, S. Havlin, A. Bunde, and H. E. Stanley, Multifractal Detrended Fluctuation Analysis of Nonstationary Time Series, Physica A 316, 87-114 (2002). Thanks for any help you can provide. Sincerely, J. Dixon -- James A. Dixon Department of Psychology 406 Babbidge Road, Unit 1020 University of Connecticut Storrs, CT 06269-1020 Phone: (860)486-6880 Fax: (860)486-2760 email: james.di...@uconn.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Does anyone has this paper in pdf?
On Wed, Jan 21, 2009 at 4:45 PM, aim...@iastate.edu wrote: de Jong, S. (1993) SIMPLS: an alternative approach to partial least squares regression. Chemometrics and Intelligent Laboratory Systems, 18, 251–263 Learn to use interlibrary loan: http://www.lib.iastate.edu/services1/ill_info.html Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can't load rJava in R 2.8.1 on Windows XP
On 1/23/2009 7:38 AM, drflxms wrote: Dear community, unfortunately I did not manage load the rJava package receiving the following error-message: library(rJava) Error in inDL(x, as.logical(local), as.logical(now), ...) : kann shared library 'C:/Programme/R/2.8.1/library/rJava/libs/rJava.dll' nicht laden: LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. Error : .onLoad in 'loadNamespace' für 'rJava' fehlgeschlagen Fehler: Laden von Paket/Namensraum für 'rJava' fehlgeschlagen Translation: can't load library ... rJava.dll LoadLibrary failure: the module was not found That message comes from Windows, not R, and it's misleading. It does not say that rJava.dll was not found, it says that a DLL needed by it is not found. It would be helpful if it told you which one. You should complain to Microsoft about it. If rJava.dll had been missing, the English message would have been shared library 'rJava' not found The pedump utility (in the Rtools set, see www.murdoch-sutherland.com/Rtools) can tell you what the dependencies are: pedump -i rJava.dll shows that it imports things from these dlls: R.dll KERNEL32.dll msvcrt.dll jvm.dll The first 3 are routine; without those R wouldn't work. (Without KERNEL32.dll, nothing in Windows would work.) So as Brian said, it's likely jvm.dll that it can't find, or possibly a DLL that it depends on. Did you install Java first, as rJava requires? Duncan Murdoch Reinstalling the package did not help, installing the latest developement version didn't help as well. The shared library rJava.dll is in place (exactly where R is looking for it)! Are there any ideas, what's wrong. I'd appreciate any kind of help very much, as I need rJava urgently to use RWeka and iPlots. Best regards, Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] forecasting error?
Hello everybody! I have an ARIMA model for a time series. This model was obtained through an auto.arima function. The resulting model is a ARIMA(2,1,4)(2,0,1)[12] with drift (my time series has monthly data). Then I perform a 12-step ahead forecast to the cited model... so far so good... but when I look the plot of my forecast I see that the result is really far from the behavior of my time series... in fact, there is a considerable gar between the last value of the series and the first forecast. My guess is that I'm doing something wrong. Here is what I do: mods-auto.arima(x[[1]],start.p=0,start.q=0,start.P=0,start.Q=0,stepwise=TRUE,stationary=FALSE) ARIMA(2,1,4)(2,0,1)[12] with drift # the output Call: auto.arima(x = x[[k]], start.p = 0, start.q = 0, start.P = 0, start.Q = 0, stationary = FALSE, stepwise = TRUE) Coefficients: ar1 ar2 ma1 ma2 ma3 ma4sar1 0.0639 -0.7820 -1.2103 1.2236 -0.9511 0.2357 1.0031 s.e. 0.0686 0.0582 0.1098 0.1558 0.1568 0.1007 0.0716 sar2 sma1 drift -0.0711 -0.8963 -780.9456 s.e. 0.0747 0.0608 403.2112 sigma^2 estimated as 10202381: log likelihood = -1100.61 AIC = 2206.69 AICc = 2209.23 BIC = 2236.98 for-forecast(mods,h=12,newxreg=(1+length(x[[1]])):(length(x[[1]]+12))) #forecast and as I said before, the results dont seem to be right. In fact, when I restrict the search of the model on the auto.arima function to stationary models only an I perform the forecast (without the newxreg-option) the results are very much acceptable. ANY HELP OR COMMENTARY I VERY WELCOMED!! thanks in advance! Diego. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 example
As I recall that is a known bug in the current version of ggplot2. That's right - because of an underlying bug in R which will be fixed in the next release of R and worked around in the next release of ggplot2. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Dates in Common
I have two collections of dates and I want to figure out what dates they have in common. This is not giving me what I want (I don't know what it is giving me). What is the best way to do this? Tom data1 [1] 1948-02-24 EST 1949-04-12 EST 1950-05-29 EDT 1951-05-21 EDT [5] 1951-12-20 EST 1953-01-22 EST 1955-02-28 EST 1956-03-08 EST [9] 1957-03-22 EST 1958-02-07 EST data2 [1] 1948-02-24 EST 1949-04-12 EST 1950-05-29 EDT 1951-05-21 EDT [5] 1951-12-20 EST 1953-01-22 EST 1955-02-28 EST 1956-03-08 EST [9] 1957-03-22 EST 1958-02-07 EST intersect(data1,data2) [1] -689626800 -653943600 -618350400 -587505600 -569098800 -534625200 [7] -468356400 -436042800 -403297200 -375476400 -- View this message in context: http://www.nabble.com/Dates-in-Common-tp21624909p21624909.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dates in Common
you want: ans - intersect(data1,data2) class(ans) - c(POSIXt,POSIXct) I personally think intersect should preserve the class of the object (if both args have the same class), but I think r-core has a different opinion. -Whit On Fri, Jan 23, 2009 at 9:02 AM, Tom La Bone boo...@gforcecable.com wrote: I have two collections of dates and I want to figure out what dates they have in common. This is not giving me what I want (I don't know what it is giving me). What is the best way to do this? Tom data1 [1] 1948-02-24 EST 1949-04-12 EST 1950-05-29 EDT 1951-05-21 EDT [5] 1951-12-20 EST 1953-01-22 EST 1955-02-28 EST 1956-03-08 EST [9] 1957-03-22 EST 1958-02-07 EST data2 [1] 1948-02-24 EST 1949-04-12 EST 1950-05-29 EDT 1951-05-21 EDT [5] 1951-12-20 EST 1953-01-22 EST 1955-02-28 EST 1956-03-08 EST [9] 1957-03-22 EST 1958-02-07 EST intersect(data1,data2) [1] -689626800 -653943600 -618350400 -587505600 -569098800 -534625200 [7] -468356400 -436042800 -403297200 -375476400 -- View this message in context: http://www.nabble.com/Dates-in-Common-tp21624909p21624909.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] forecasting error?
See last line on every message to r-help and note the reproducible part. One problem may be that your auto.arima call has no xreg yet your prediction has newxreg. On Fri, Jan 23, 2009 at 8:48 AM, diego Diego dhab...@gmail.com wrote: Hello everybody! I have an ARIMA model for a time series. This model was obtained through an auto.arima function. The resulting model is a ARIMA(2,1,4)(2,0,1)[12] with drift (my time series has monthly data). Then I perform a 12-step ahead forecast to the cited model... so far so good... but when I look the plot of my forecast I see that the result is really far from the behavior of my time series... in fact, there is a considerable gar between the last value of the series and the first forecast. My guess is that I'm doing something wrong. Here is what I do: mods-auto.arima(x[[1]],start.p=0,start.q=0,start.P=0,start.Q=0,stepwise=TRUE,stationary=FALSE) ARIMA(2,1,4)(2,0,1)[12] with drift # the output Call: auto.arima(x = x[[k]], start.p = 0, start.q = 0, start.P = 0, start.Q = 0, stationary = FALSE, stepwise = TRUE) Coefficients: ar1 ar2 ma1 ma2 ma3 ma4sar1 0.0639 -0.7820 -1.2103 1.2236 -0.9511 0.2357 1.0031 s.e. 0.0686 0.0582 0.1098 0.1558 0.1568 0.1007 0.0716 sar2 sma1 drift -0.0711 -0.8963 -780.9456 s.e. 0.0747 0.0608 403.2112 sigma^2 estimated as 10202381: log likelihood = -1100.61 AIC = 2206.69 AICc = 2209.23 BIC = 2236.98 for-forecast(mods,h=12,newxreg=(1+length(x[[1]])):(length(x[[1]]+12))) #forecast and as I said before, the results dont seem to be right. In fact, when I restrict the search of the model on the auto.arima function to stationary models only an I perform the forecast (without the newxreg-option) the results are very much acceptable. ANY HELP OR COMMENTARY I VERY WELCOMED!! thanks in advance! Diego. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to study the lead and lag relation of two time series?
Yes, it's called Ocular Econometrics. You plot both series on the same chart and use your onboard pattern detector. If you can't see it on the plot, it's unlikely that any correlations you find in other ways will have much predictive power, and that's the only kind of relationship that counts. I know you asked for a systematic way to do this, but at least with economic time series, experience tells me that correlations that can't be seen with the naked eye are rarely meaningful. I'm now ready to duck all the brickbats that are about to come my way. Jeff Michael comtech@gmail.com writes: Hi all, Is there a way to study the lead and lag relation of two time series? Let's say I have two time series, At and Bt. Is there a systematic way of concluding whether it's A leading B or B leading A and by how much? Thanks! -- Jeff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can't load rJava in R 2.8.1 on Windows XP
Dear Mr. Murdoch, Dear Mr. Ripley, Dear Mr. Wang, thank you very much for your quick and efficient help! It is exactly as Duncan explained it: Including jvm.dll in PATH solved the problem immediately. Everything works fine now. The only thing is, that I do not understand why I had to do this manualy, as I installed Java Runtime Environment a long time ago, updated frequently and never encountered any difficulties in using Java software. Anyway, I am happy now :-) Thanx again for your great support! Greetings from Munich, Germany, Felix Duncan Murdoch schrieb: On 1/23/2009 7:38 AM, drflxms wrote: Dear community, unfortunately I did not manage load the rJava package receiving the following error-message: library(rJava) Error in inDL(x, as.logical(local), as.logical(now), ...) : kann shared library 'C:/Programme/R/2.8.1/library/rJava/libs/rJava.dll' nicht laden: LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. Error : .onLoad in 'loadNamespace' für 'rJava' fehlgeschlagen Fehler: Laden von Paket/Namensraum für 'rJava' fehlgeschlagen Translation: can't load library ... rJava.dll LoadLibrary failure: the module was not found That message comes from Windows, not R, and it's misleading. It does not say that rJava.dll was not found, it says that a DLL needed by it is not found. It would be helpful if it told you which one. You should complain to Microsoft about it. If rJava.dll had been missing, the English message would have been shared library 'rJava' not found The pedump utility (in the Rtools set, see www.murdoch-sutherland.com/Rtools) can tell you what the dependencies are: pedump -i rJava.dll shows that it imports things from these dlls: R.dll KERNEL32.dll msvcrt.dll jvm.dll The first 3 are routine; without those R wouldn't work. (Without KERNEL32.dll, nothing in Windows would work.) So as Brian said, it's likely jvm.dll that it can't find, or possibly a DLL that it depends on. Did you install Java first, as rJava requires? Duncan Murdoch Reinstalling the package did not help, installing the latest developement version didn't help as well. The shared library rJava.dll is in place (exactly where R is looking for it)! Are there any ideas, what's wrong. I'd appreciate any kind of help very much, as I need rJava urgently to use RWeka and iPlots. Best regards, Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reading nc files
Dear all, I have to open and read several netCDF (.nc) files. I installed the ncdf package and everything works fine. The problem is that I also have several netCDF files that are also ziped. These files are in the form,: nc_file.gz I tried different ways (within R) to unzip and read them, but they did not work. I'll appreciate any suggestion on how to do that. Thanks, Magdalena Lucini __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get a primitive function object
Duncan Murdoch wrote: Wacek Kusnierczyk wrote: Duncan Murdoch wrote: You can use parent.frame() as the pos or envir argument to assign(), and then the assignment happens in the caller's frame. And assign() is also another way out if you overwrite - with something that doesn't work; just call it to reassign base::`-` to it. Or just rm(`-`) to unhide the original one. unless you have redefined rm as well, that is. Right, but then there's remove, or base::rm. Unless you redefined remove and `::`. So here's the question for a frustrating contest: is it possible to define enough functions in the global environment to render your R session completely unrecoverable? (I think it probably is.) And what's the minimal set, or the minimal script to brick your R? No manipulating the search list or writing anywhere but the global environment is allowed. Duncan Murdoch you might want to specify what 'completely unrecoverable' means, and what approaches are allowed. for the former, i guess that: - 'incompletely recoverable' means that there is at least one function name in the global environment such that its value has been redefined and it's not possible, within the session, to revert the binding to the original value; - 'completely unrecoverable' means that if there are any function names with redefined bindings in the global environment, it is not possible, within the session, to revert the binding for any of them. you might also mean the extreme situation where there is no function name that has not been redefined and it is not possible to recover the original binding for any function name, but i guess this is not what you mean. (if you do, then i think the answer is negative, what should be fairly easy to prove.) the two cases are effectively equivalent: - if we are in a completely unrecoverable situation, then there is at least one function name that cannot be reverted to the original value, hence the situation is also incompletely recoverable (for those logically inclined, there is one obvious completely unrecoverable situation, one in which no function name has been redefined; i'll ignore this void case); - conversely, if we are in an incompletely recoverable situation with n function names redefined of which m are recoverable, recovering those m leads to a completely unrecoverable situation. note, 'unrecoverable' does not necessarily mean useless. for the latter above (allowed approaches), i hope that using 'assign' is ok. you have already hinted a solution; i believe, naively, that it satisfies the requirement: for (f in strsplit('remove rm :: .Primitive .Internal', split=' ')[[1]]) assign(f, function() 'roobisch') as far as i can see, this renders a completely unrecoverable, but still pretty useful session. vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is there any function can be used to compare two probit models made from same data?
Hi - wouldn't it be possible to bootstrap the difference between the fit of the 2 models? For example, if one had a *linear* regression problem, the following script could be used (although I'm sure that it could be improved): library(MASS); library(boot) #create intercorrelated data Sigma - matrix(c(1,.5,.4, .5,1,.8, .4,.8,1),3,3) Sigma dframe-as.data.frame(mvrnorm(n-200, rep(0, 3), Sigma)) names(dframe)-c('disease','age','ht') #age and ht are predictors of 'disease' head(dframe); cor(dframe) #bootstrap the difference between models containing the 2 predictors model.fun - function(data, indices) { dsub-dframe[indices,] m1se-summary(lm(disease~age,data=dsub))$sigma; m2se-summary(lm(disease~ht,da=dsub))$sigma; diff-m1se-m2se; #diff is the difference in the SEs of the 2 models } eye - boot(dframe,model.fun, R=200); class(eye); names(eye); des(an(eye$t)) boot.ci(eye,conf=c(.95,.99),type=c('norm')) Ben Bolker wrote: jingjiang yan jingjiangyan at gmail.com writes: hi, people How can we compare two probit models brought out from the same data? Let me use the example used in An Introduction to R. Consider a small, artificial example, from Silvey (1970). On the Aegean island of Kalythos the male inhabitants suffer from a congenital eye disease, the effects of which become more marked with increasing age. Samples of islander males of various ages were tested for blindness and the results recorded. The data is shown below: Age: 20 35 45 55 70 No. tested: 50 50 50 50 50 No. blind: 6 17 26 37 44 now, we can use the age and the blind percentage to produce a probit model and get their coefficients by using glm function as was did in An Introduction to R My question is, let say there is another potential factor instead of age affected the blindness percentage. for example, the height of these males. Using their height, and their relevant blindness we can introduce another probit model. If I want to determine which is significantly better, which function can I use to compare both models? and, in addition, compared with the Null hypothesis(i.e. the same blindness for all age/height) to prove this model is effective? You can use a likelihood ratio test (i.e. anova(model1,model0) to compare either model to the null model (blindness is independent of both age and height). The age model and height model are non-nested, and of equal complexity. You can tell which one is *better* by comparing log-likelihoods/deviances, but cannot test a null hypothesis of significance. Most (but not all) statisticians would say you can compare non-nested models by using AIC, but you don't get a hypothesis-test/p-value in this way. Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Is-there-any-function-can-be-used-to-compare-two-probit-models-made-from-same-data--tp21614487p21625839.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vegan metaMDS
Hi, Hi Radu, I'm trying to use metaMDS with a dissimilarity matrix of angles, not Bray-Curtis, and I wanted to know if there is an in-built function to produce a plot of stress values against dimensions, that could be used to determine the 'true' dimension of the solution. I am unaware of any formal test for determining the proper number of dimensions in an NMDS ordination. It probably makes sense to think about your data and interpretation of your solution. For example it can be hard to present a 4D solution. Also, as I understand it the first dimension of a NMDS ordination with 2 dimensions will not be the same as the first dimension of an NMDS ordination with 3 dimensions. The axes are arbitrary in this method. One idea is to simply plot the stress by dimensions and look to see where the stress levels off or drops to an acceptable level. here is a rough example! plot(c('2','3','4','5'), c(23.26272,16.37268,12.9641,10.50830), xlab = 'dimensions', ylab = 'stress', type = 'b') hope this helps, Michael Denslow I.W. Carpenter Jr. Herbarium [BOON] Appalachian State University Boone, North Carolina U.S.A. -- AND -- Communications Manager Southeastern Regional Network of Expertise and Collections sernec.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can't load rJava in R 2.8.1 on Windows XP
On 1/23/2009 9:44 AM, drflxms wrote: Dear Mr. Murdoch, Dear Mr. Ripley, Dear Mr. Wang, thank you very much for your quick and efficient help! It is exactly as Duncan explained it: Including jvm.dll in PATH solved the problem immediately. Everything works fine now. The only thing is, that I do not understand why I had to do this manualy, as I installed Java Runtime Environment a long time ago, updated frequently and never encountered any difficulties in using Java software. If you look at rJava:::.onLoad now that you can load the package, you'll see that it goes through a number of tests to try to find the right path. Those work on my system (and presumably on Simon Urbanek's, the rJava maintainer), but not on yours. It might be helpful to him if you could find some small change to his search that would work on systems like yours, even without adding the jvm.dll path to the general PATH. (I don't have it in mine.) Duncan Murdoch Anyway, I am happy now :-) Thanx again for your great support! Greetings from Munich, Germany, Felix Duncan Murdoch schrieb: On 1/23/2009 7:38 AM, drflxms wrote: Dear community, unfortunately I did not manage load the rJava package receiving the following error-message: library(rJava) Error in inDL(x, as.logical(local), as.logical(now), ...) : kann shared library 'C:/Programme/R/2.8.1/library/rJava/libs/rJava.dll' nicht laden: LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. Error : .onLoad in 'loadNamespace' für 'rJava' fehlgeschlagen Fehler: Laden von Paket/Namensraum für 'rJava' fehlgeschlagen Translation: can't load library ... rJava.dll LoadLibrary failure: the module was not found That message comes from Windows, not R, and it's misleading. It does not say that rJava.dll was not found, it says that a DLL needed by it is not found. It would be helpful if it told you which one. You should complain to Microsoft about it. If rJava.dll had been missing, the English message would have been shared library 'rJava' not found The pedump utility (in the Rtools set, see www.murdoch-sutherland.com/Rtools) can tell you what the dependencies are: pedump -i rJava.dll shows that it imports things from these dlls: R.dll KERNEL32.dll msvcrt.dll jvm.dll The first 3 are routine; without those R wouldn't work. (Without KERNEL32.dll, nothing in Windows would work.) So as Brian said, it's likely jvm.dll that it can't find, or possibly a DLL that it depends on. Did you install Java first, as rJava requires? Duncan Murdoch Reinstalling the package did not help, installing the latest developement version didn't help as well. The shared library rJava.dll is in place (exactly where R is looking for it)! Are there any ideas, what's wrong. I'd appreciate any kind of help very much, as I need rJava urgently to use RWeka and iPlots. Best regards, Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The Quality Accuracy of R
Hi All, We have all had to face skeptical colleagues asking if software made by volunteers could match the quality and accuracy of commercially written software. Thanks to the prompting of a recent R-help thread, I read, R: Regulatory Compliance and Validation Issues, A Guidance Document for the Use of R in Regulated Clinical Trial Environments (http://www.r-project.org/doc/R-FDA.pdf). This is an important document, of interest to the general R community. The question of R's accuracy is such a frequent one, it would be beneficial to increase the visibility of the non-clinical information it contains. A document aimed at a general audience, entitled something like, R: Controlling Quality and Assuring Accuracy could be compiled from the these sections: 1. What is R? (section 4) 2. The R Foundation for Statistical Computing (section 3) 3. The Scope of this Guidance Document (section 2) 4. Software Development Life Cycle (section 6) Marc Schwartz, Frank Harrell, Anthony Rossini, Ian Francis and others did such a great job that very few words would need to change. The only addition I suggest is to mention how well R did in, Keeling Parvur's A comparative study of the reliability to nine statistical software packages, May 1, 2007 Computational Statistics Data Analysis, Vol.51, pp 3811-3831. Given the importance of this issue, I would like to see such a document added to the PDF manuals in R's Help. The document mentions (Sect. 6.3) that a set of validation tests, data and known results are available. It would be useful to have an option to run that test suite in every R installation, providing clear progress, Validating accuracy of t-tests...Validating accuracy of linear regression Whether or not people chose to run the tests, they would at least know that such tests are available. Back in my mainframe installation days, this step was part of many software installations and it certainly gave the impression that those were the companies that took accuracy seriously. Of course the other companies probably just ran their validation suite before shipping, but seeing it happen had a tremendous impact. I don't know how much this would add to download, but if it was too much, perhaps it could be implemented as a separate download. I hope these suggestions can help mitigate the concerns so many non-R users have. Cheers, Bob = Bob Muenchen (pronounced Min'-chen), Manager, Research Computing Support U of TN Office of Information Technology Stokely Management Center, Suite 200 916 Volunteer Blvd., Knoxville, TN 37996-0520 Voice: (865) 974-5230 FAX: (865) 974-4810 Email: muenc...@utk.edu Web: http://oit.utk.edu/research http://oit.utk.edu/scc Map to Office: http://www.utk.edu/maps Newsletter: http://listserv.utk.edu/archives/rcnews.html http://listserv.utk.edu/archives/statnews.html = [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Table Modification
I am trying to construct a two-way table where, instead of printing the two-way frequencies in the table, I would like to print the values of a third variable that correspond to the frequencies. For example, the following is easily constructed in R fact1 - factor(sample(LETTERS[1:3],10,replace=TRUE)) fact2 - factor(sample(LETTERS[25:26],10,replace=TRUE)) fact3 - letters[1:10] data.frame(fact1,fact2,fact3) fact1 fact2 fact3 1 C Z a 2 A Y b 3 A Y c 4 C Z d 5 A Z e 6 A Y f 7 B Y g 8 B Y h 9 C Z i 10 A Y j table(fact1,fact2) fact2 fact1 Y Z A 4 1 B 2 0 C 0 3 But I would like to create something like this (done physically by hand) ... fact2 fact1Y Z A b,c,f,je B g,h - C- a,d,i Any help would be appreciated. Thank you in advance. For what it is worth, Sys.info() sysname Windows release XP version build 2600, Service Pack 2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dates in Common
The problem is in the intersect function that does x = as.vector(x) and therefore transforms date vector into a numeric . Try to: d1 = as.character(data1) ; d2 = as.character(data2) d = intersect(d1, d2) data = as.Date(d) A. Tom La Bone wrote: I have two collections of dates and I want to figure out what dates they have in common. This is not giving me what I want (I don't know what it is giving me). What is the best way to do this? Tom data1 [1] 1948-02-24 EST 1949-04-12 EST 1950-05-29 EDT 1951-05-21 EDT [5] 1951-12-20 EST 1953-01-22 EST 1955-02-28 EST 1956-03-08 EST [9] 1957-03-22 EST 1958-02-07 EST data2 [1] 1948-02-24 EST 1949-04-12 EST 1950-05-29 EDT 1951-05-21 EDT [5] 1951-12-20 EST 1953-01-22 EST 1955-02-28 EST 1956-03-08 EST [9] 1957-03-22 EST 1958-02-07 EST intersect(data1,data2) [1] -689626800 -653943600 -618350400 -587505600 -569098800 -534625200 [7] -468356400 -436042800 -403297200 -375476400 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extract certain months toyears (zoo)
Dear useRs and developeRs, In my diploma thesis I work with a daily time series of glacier runoff data. I did already aggregate them to monthly means etc. Now i want to use just the summer values (I am indecisive by now what that means, but let's make it easy and use months like June). Is there a way to extract the data off this zoo into another zoo with frequency=1 ? Do you have alternative suggestions how to get to such data?? what i did... # ## want to create monthly aggr. and extract the summer data # library(zoo) a.z- read.zoo(glacierdischarge.txt, header=TRUE, sep=,, dec = ., na.string=NA, format = %d.%m.%Y) a.z.mean - aggregate(a.z, as.yearmon, mean) a.z.median - aggregate(a.z, as.yearmon, median) a.z.sd - aggregate(a.z, as.yearmon, sd) a.z.min - aggregate(a.z, as.yearmon, min) a.z.max - aggregate(a.z, as.yearmon, max) a.z.sum - aggregate(a.z, as yearmon, sum) a.zoo-cbind(mean = a.z.mean, median= a.z.median, sd = a.z.sd, min= a.z.min, max= a.z.max) head(a.zoo) I tried it with merge and... ##vector including all junes l-length(a.zoo$mean) Junes-seq(6, l, by = 12) but stuck. Hopefully Bastian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Histogram for grouped data in R
I have grouped data in this format Size -- Count 0-10 -- 15 10-20 -- 25 20-50 -- 10 50-100 -- 5 I've been trying to find a way to set this up with the proper histogram heights, but can't seem to figure it out. So any help would be much appreciated! -- View this message in context: http://www.nabble.com/Histogram-for-grouped-data-in-R-tp21624806p21624806.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Outputing residuals
Hello, I was wondering if someone could tell me how to output, to file, the residuals from a REML model-fit. The type of residuals I am interested in are the simple original raw values - model fit type. Thanks in advance, Josh B. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot seq
Thanks Thierry: The use of levels is what I needed, thanks for your help. From: ONKELINX, Thierry thierry.onkel...@inbo.be Subject: RE: [R] ggplot seq To: mazatlanmex...@yahoo.com, r-h...@stat.math.ethz.ch Date: Friday, January 23, 2009, 3:01 AM Dear Felipe, Provide a dummy sample if your dataset is big or confidential. The actual values are not that important to figure out what kind of plot you want. How did you code Week? Numeric? Try convert it into a factor with levels = c(27:52, 1:26). And then set the breaks to seq(1, 52, by= 2). WFBox - data.frame(Week = rep(1:52, 10), FL = rnorm(520)) WFBox$fWeek - factor(WFBox$Week, levels = c(27:52, 1:26)) library(ggplot2) ggplot(WFBox, aes(fWeek, FL)) + geom_boxplot(outlier.colour=pink,outlier.size=3,outlier.shape=21,fill= goldenrod,colour=blue) + scale_x_discrete(breaks=c(seq(1,51,2))) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be Onderwerp: [R] ggplot seq I have dealt with this before and I can't remember how it got resolved. It is too much data to reproduce the example below(49.000 records) but all I am after is trying to get the x axis breaks. I want my x axis to go from 27 to 51 and 1 to 25 by 2. I am trying to concatenate the breaks but it sorts the seq() in ascending order. Is there a way to workaround it? see scale_x_continuous below: boxP - ggplot(WFBox, aes(Week, FL,group=Week)) boxP + geom_boxplot(outlier.colour=pink,outlier.size=3,outlier.shape=21,fill= goldenrod,colour=blue) + scale_x_discrete(breaks=c(seq(27,51,2),seq(1,25,2))) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Table Modification
If I understood propelly tapply(fact3, list(fact1, fact2) , paste, collapse = ,) A. Derek Ogle wrote: I am trying to construct a two-way table where, instead of printing the two-way frequencies in the table, I would like to print the values of a third variable that correspond to the frequencies. For example, the following is easily constructed in R fact1 - factor(sample(LETTERS[1:3],10,replace=TRUE)) fact2 - factor(sample(LETTERS[25:26],10,replace=TRUE)) fact3 - letters[1:10] data.frame(fact1,fact2,fact3) fact1 fact2 fact3 1 C Z a 2 A Y b 3 A Y c 4 C Z d 5 A Z e 6 A Y f 7 B Y g 8 B Y h 9 C Z i 10 A Y j table(fact1,fact2) fact2 fact1 Y Z A 4 1 B 2 0 C 0 3 But I would like to create something like this (done physically by hand) ... fact2 fact1Y Z A b,c,f,je B g,h - C- a,d,i Any help would be appreciated. Thank you in advance. For what it is worth, Sys.info() sysname Windows release XP version build 2600, Service Pack 2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram for grouped data in R
Le ven. 23 janv. à 08:55, darthgervais a écrit : I have grouped data in this format Size -- Count 0-10 -- 15 10-20 -- 25 20-50 -- 10 50-100 -- 5 I've been trying to find a way to set this up with the proper histogram heights, but can't seem to figure it out. So any help would be much appreciated! Define your data as a grouped.data object using the function of the same name in package actuar. Then you can simply use hist() as usual to get what you want. See: @Article{Rnews:Goulet+Pigeon:2008, author = {Vincent Goulet and Mathieu Pigeon}, title = {Statistical Modeling of Loss Distributions Using actuar}, journal = {R News}, year = 2008, volume = 8, number = 1, pages = {34--40}, month = {May}, url = http, pdf = Rnews2008-1 } HTH --- Vincent Goulet Acting Chair, Associate Professor École d'actuariat Université Laval, Québec vincent.gou...@act.ulaval.ca http://vgoulet.act.ulaval.ca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram for grouped data in R
Hi, Try this: x-c(15,25,10,5) names(x)-c('0-10','10-20','20-50','50-100') barplot(x,space=0,xlab='Size',ylab='Count',col=1:4) See ?barplot for more information. HTH, Jorge On Fri, Jan 23, 2009 at 8:55 AM, darthgervais darthgerv...@yahoo.ca wrote: I have grouped data in this format Size -- Count 0-10 -- 15 10-20 -- 25 20-50 -- 10 50-100 -- 5 I've been trying to find a way to set this up with the proper histogram heights, but can't seem to figure it out. So any help would be much appreciated! -- View this message in context: http://www.nabble.com/Histogram-for-grouped-data-in-R-tp21624806p21624806.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Is it possible for R to import a SigmaPlot file?
Check the package 'foreign'. It can read data from SPSS,Minitab,SAS,Systat (sigmaplot is part of Systat) etc. I also use Sigmaplot and an easy workaround is to convert the sigmaplot file to csv or xls file and then read it into R. Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Fri, 1/23/09, Bernardo Rangel Tura t...@centroin.com.br wrote: From: Bernardo Rangel Tura t...@centroin.com.br Subject: Re: [R] Is it possible for R to import a SigmaPlot file? To: jasonkrup...@yahoo.com Cc: r-help@r-project.org Date: Friday, January 23, 2009, 1:39 AM On Thu, 2009-01-22 at 14:58 -0800, Jason Rupert wrote: I recently received a Sigmaplot file (*.jnb)from a customer and would like to know if I can input it to a data frame and then manipulate the data in R. I did a search on Google and on RSeek (www.rseek.org), but did not get any good hits. Thank for any feedback and insight you can provide. P.S. Love the flexibility of R and would love to keep using it. Just wanting to know if this is possible. Thanks again. Hi Jason, I don't know sigmaplot, but I thing is possible export sigmaplot database for other type of files. If you export jnb file to csv file is possible read a database in R. I will talk with a person work with me and tonight I send other mail with more details. -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Returning NA from lm
I tried that I'm afraid. I still get values for groups with missing data. I think na.exclude just ignores the NAs but I want it to return NA. Where one of the values is NA. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: 23 January 2009 13:04 To: Neil Beddoe Cc: r-help@r-project.org Subject: Re: [R] Returning NA from lm See ?na.exclude On Fri, 23 Jan 2009, Neil Beddoe wrote: Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2 A 4 A 6.5 ...repeat 96 times with differing values of A B 1 B 2.3 B NA B 6.5 ...repeat 96 times with differing values of B etc I run these against a linear model using tapply(data$Value, data$Key,FUN=regr,100) where regr-function(x,w) { #run the model against the last w values of x lm((x[length(x)-w):length(x)]~myModel(w)) } In the results, I want to return NA for any Key group where one or more of the values is NA. If I run the above I get a regression structure ignoring the missing values and returning values for data that contains NA. Using na.action=na.fail or na.action=NULL causes the whole tapply function to fail and I get nothing. Is there a way I can get lm to return NA if any of the values in the data are NA but valid numbers for complete data? I realise that I could remove the groups with NAs but I'm running the regressions over multiple time periods and most of the data groups will have a full complement of data for at least some of these periods. It becomes a pain to manage NAs if I do that. Sorry if the above is a little unclear. Thanks Neil -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 . This message is intended only for the use of the person(s) to whom it is addressed. It may contain information which is privileged and confidential. Accordingly any unauthorised use is strictly prohibited. If you are not the intended recipient, please contact the sender as soon as possible. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction, unless specifically agreed otherwise. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any opinions or advice contained in this Internet email are subject to the terms and conditions expressed in any applicable governing Marble Bar Asset Management LLP's terms and conditions of business or client agreement letter. Any comments or statements made herein do not necessarily reflect those of Marble Bar Asset Management LLP. Marble Bar Asset Management LLP is regulated and authorised by the FSA. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Table Modification
Yes, that was exactly what I was looking for. Very concise. Thank you. My real example has many more items in each cell. I will now have to figure out how to put a carriage return after, say, every fourth item. Nevertheless, thank you very much for the quick and accurate answer. -Original Message- From: r...@quantide.com [mailto:r...@quantide.com] Sent: Friday, January 23, 2009 9:25 AM To: Derek Ogle Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Table Modification If I understood propelly tapply(fact3, list(fact1, fact2) , paste, collapse = ,) A. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3d scatter plot with both error bars and a flexibly fitted surface
Sean Zhang seanecon at gmail.com writes: I, an entry level R user, wonder how make a 3d scatter plot with both error bars and a flexibly fitted surface. For regular grid data, I found interp.loess in package tpg easiest to use to compute the fine grid required for the plot. For irregular data, check package akima and the chapter on spatial statistics in MASS (Venables/Ripley). For plotting, nothing beats surface3d in package rgl, but you will have to do some additional work. Try library(rgl) demo(abundance) for something that comes close to your requirements. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract certain months toyears (zoo)
Please read the last line to every post on r-help particularly noting the reproducible part. Assuming you have a series such as z below and want June, July and August of each year: library(zoo) set.seed(1) z - zoo(rnorm(25), as.yearmon(2000-01) + 0:24/12) z[format(time(z), %m) %in% c(06, 07, 08)] Jun 2000 Jul 2000 Aug 2000 Jun 2001 Jul 2001 Aug 2001 -0.8204684 0.4874291 0.7383247 0.9438362 0.8212212 0.5939013 On Fri, Jan 23, 2009 at 6:52 AM, Bastian Pöschl rot...@gmx.li wrote: Dear useRs and developeRs, In my diploma thesis I work with a daily time series of glacier runoff data. I did already aggregate them to monthly means etc. Now i want to use just the summer values (I am indecisive by now what that means, but let's make it easy and use months like June). Is there a way to extract the data off this zoo into another zoo with frequency=1 ? Do you have alternative suggestions how to get to such data?? what i did... # ## want to create monthly aggr. and extract the summer data # library(zoo) a.z- read.zoo(glacierdischarge.txt, header=TRUE, sep=,, dec = ., na.string=NA, format = %d.%m.%Y) a.z.mean - aggregate(a.z, as.yearmon, mean) a.z.median - aggregate(a.z, as.yearmon, median) a.z.sd - aggregate(a.z, as.yearmon, sd) a.z.min - aggregate(a.z, as.yearmon, min) a.z.max - aggregate(a.z, as.yearmon, max) a.z.sum - aggregate(a.z, as yearmon, sum) a.zoo-cbind(mean = a.z.mean, median= a.z.median, sd = a.z.sd, min= a.z.min, max= a.z.max) head(a.zoo) I tried it with merge and... ##vector including all junes l-length(a.zoo$mean) Junes-seq(6, l, by = 12) but stuck. Hopefully Bastian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] forward slash vs double backslash R and Tinn-R
I installed the newest version of R and once again ran into problem with Tinn-R failing when trying to use the R explorer. I had this problem once before and solved it when I added the following .trPaths = c( 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/search.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/objects.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/file.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/selection.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/block.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/lines.r') The posted configuration file tries to accomplish this situation with .trPaths - paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''), c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r', 'lines.r'), sep='') BUT IT FAILS. Farrel Buchinsky __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] forward slash vs double backslash R and Tinn-R
The only apparent reason for the failure is that the elegant line using Sys.getenv denerates filenames with double backslashes instead of forward slashes. I am working in Windows XP and I thought that R could use double backslashes or a single forward slash. So what am I not understanding about the whole slash thing? Farrel Buchinsky On Fri, Jan 23, 2009 at 11:10, Farrel Buchinsky fjb...@gmail.com wrote: I installed the newest version of R and once again ran into problem with Tinn-R failing when trying to use the R explorer. I had this problem once before and solved it when I added the following .trPaths = c( 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/search.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/objects.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/file.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/selection.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/block.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/lines.r') The posted configuration file tries to accomplish this situation with .trPaths - paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''), c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r', 'lines.r'), sep='') BUT IT FAILS. Farrel Buchinsky __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] forward slash vs double backslash R and Tinn-R
On 1/23/2009 11:10 AM, Farrel Buchinsky wrote: I installed the newest version of R and once again ran into problem with Tinn-R failing when trying to use the R explorer. I had this problem once before and solved it when I added the following .trPaths = c( 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/search.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/objects.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/file.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/selection.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/block.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/lines.r') The posted configuration file tries to accomplish this situation with .trPaths - paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''), c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r', 'lines.r'), sep='') BUT IT FAILS. I think you want to be sending this to the Tinn-R maintainers, possibly with a patch to give something that works. Reporting it on R-help may be useful for someone else hit with the same problem who looks it up here, but it won't be likely to get it fixed. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] text vector clustering
Hans-Joerg Bibiko's function Levenshtein would help; cf. below for an example (very clumsy with two loops, but you can tweak that with apply stuff). HTH, STG levenshtein - function(string1, string2, case=TRUE, map=NULL) { # levenshtein algorithm in R # # Author : Hans-Joerg Bibiko # Date: 29/06/2006 # Contact : bib...@eva.mpg.de # string1, string2 := strings to compare # case = TRUE := case sensitivity; case = FALSE := case insensitivity # map := character vector of c(regexp1, replacement1, regexp2, replacement2, ...) # example: # map - c([aeiou],V,[^aeiou],C) := replaces all vowels with V and all others with C # levenshtein(Bank,Bond, map=map) = 0 if(!is.null(map)) { m - matrix(map, ncol=2, byrow=TRUE) s - c(ifelse(case, string1, tolower(string1)), ifelse(case, string2, tolower(string2))) for(i in 1:dim(m)[1]) s - gsub(m[i,1], m[i,2], s) string1 - s[1] string2 - s[2] } if(ifelse(case, string1, tolower(string1)) == ifelse(case, string2, tolower(string2))) return(0) s1 - strsplit(paste( , ifelse(case, string1, tolower(string1)), sep=), NULL)[[1]] s2 - strsplit(paste( , ifelse(case, string2, tolower(string2)), sep=), NULL)[[1]] l1 - length(s1) l2 - length(s2) d - matrix(nrow = l1, ncol = l2) for(i in 1:l1) d[i,1] - i-1 for(i in 1:l2) d[1,i] - i-1 for(i in 2:l1) for(j in 2:l2) d[i,j] - min((d[i-1,j]+1) , (d[i,j-1]+1) , (d[i-1,j-1]+ifelse(s1[i] == s2[j], 0, 1))) d[l1,l2] } # end of function Hans-Joerg Bibiko's levenshtein # generate names set.seed(1) all.names-character(10) for (i in 1:10) { all.names[i]-paste(sample(letters, sample(4:10, 1), replace=T), collapse=) } all.names # generate matrix sims-matrix(0, nrow=10, ncol=10) attr(sims, dimnames)-list(all.names, all.names) # fill matrix (clumsy) for (j in 1:9) { for (k in (j+1):10) { sims[j,k]-sims[k,j]-levenshtein(all.names[j], all.names[k]) } } plot(hclust(as.dist(sims))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] text vector clustering
On Fri, Jan 23, 2009 at 08:28, Stefan Th. Gries stgr...@gmail.com wrote: Hans-Joerg Bibiko's function Levenshtein would help; cf. below for an example (very clumsy with two loops, but you can tweak that with apply stuff). Like this maybe (sorry, should've thought about that earlier): [...] x-rep(all.names, length(all.names)) y-rep(all.names, each=length(all.names)) sims-matrix(mapply(levenshtein, x, y), ncol=10) [...] STG __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] glm binomial loglog (NOT cloglog) link
I would like to do an R glm() with family = binomial(link=loglog) Right now, the cloglog link exists, which is nice when the data have a heavy tail to the left. I have the opposite case and the loglog link is what I need. Can someone suggest how to add the loglog link onto glm()? It would be lovely to have it there by default, and it certainly makes sense to have the two opposite cases cloglog and loglog. Thanks for any help. Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] forward slash vs double backslash R and Tinn-R
I'm on Windows XP and it works fine for me, so the only apparent reason for the failure may not be the real reason. BUT IT FAILS isn't very explicit. If your .trPaths definition works for you, why not use it? As Duncan Murdoch said, you're really asking in the wrong place. There's a forum somewhere dedicated to Tinn-R. Try looking here http://www.sciviews.org/Tinn-R/ initially. HTH KJ Farrel Buchinsky fjb...@gmail.com wrote in message news:bd93cdad0901230813i11911802lb3fdcdb85c983...@mail.gmail.com... The only apparent reason for the failure is that the elegant line using Sys.getenv denerates filenames with double backslashes instead of forward slashes. I am working in Windows XP and I thought that R could use double backslashes or a single forward slash. So what am I not understanding about the whole slash thing? Farrel Buchinsky On Fri, Jan 23, 2009 at 11:10, Farrel Buchinsky fjb...@gmail.com wrote: I installed the newest version of R and once again ran into problem with Tinn-R failing when trying to use the R explorer. I had this problem once before and solved it when I added the following .trPaths = c( 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/search.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/objects.txt', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/file.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/selection.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/block.r', 'C:/Documents and Settings/fbuchins/Application Data/Tinn-R/tmp/lines.r') The posted configuration file tries to accomplish this situation with .trPaths - paste(paste(Sys.getenv('APPDATA'), '\\Tinn-R\\tmp\\', sep=''), c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r', 'lines.r'), sep='') BUT IT FAILS. Farrel Buchinsky __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot, lines and disordered x and y
Hello, I have 2d data where x coordinate is not given in usual ascending order (x1,...,x1+l; l0), and instead in another, regular, but not ascending or descending order (for illustration: x1,-x1,x1+dx1,-x1-dx1,).y is an array which corresponds to the way x is ordered. I have noticed that giving 'plot(x,y,type='l') produces a plot where the points are connected in a completely wrong way. It is as the plot/lines assumes an ascending order between the succesive y points ignoring the fact that they are not (it connects y(x1) with y(-x1), for x1+dx). I don't know whether this could be a bug, because maybe sorting the y coordinates appropriately and then interpolating lines plotting is too much to ask of the plot function. But, I've felt like sharing :-) Additionally, 'points' function will plot the data properly. Cheers, TK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Stat textbook recommendations?
Hello, I'm looking for a textbook that can explain some of the math behind the intro-to-intermediate stuff like ANOVA, multiple regression, non- parametric tests, etc. A little background: I took an intro stats course last year and would like to further my education. Being as that was the highest (and only) stats class the local community college offers, it looks like I'm on my own from here. I've been working through some of the online 'stats with R' tutorials as well as Dalgaard's ISWR. Where I'm running into problems is the transition from Bluman's 'A Brief Introduction to Elementary Statistics' (covers up through paired t- tests, chi-squared/goodness-of-fit, simple linear regression correlation, and just barely mentions ANOVA) with a TI-83+, to even books like ISWR... when they start getting into the things like one and two-way ANOVA, multiple regression, model selection, survival, etc. I start feeling like I have one hand tied behind my back - I just don't have enough theoretical exposure to really understand what techniques I would use when, relative to my own projects outside the book. Several of the 'intro to stats using R' books and pdf tutorials mention that they are not really meant as a standalone statistics text book, but in addition to a traditional stats textbook (Verzani mentions Kitchen's book specifically). So I guess what I'm looking for is any other recommendations on intro or intermediate textbooks that deal primarily with the math/theory behind the processes. If they were oriented towards R that's be great, but otherwise I guess I'd be most interested in something relatively platform-agnostic - I've seen some books that were slanted heavily towards a particular software package (Minitab) that I cannot afford or justify for personal use. TIA, Monte [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Table Modification
?strwrap On Fri, Jan 23, 2009 at 10:47 AM, Derek Ogle do...@northland.edu wrote: Yes, that was exactly what I was looking for. Very concise. Thank you. My real example has many more items in each cell. I will now have to figure out how to put a carriage return after, say, every fourth item. Nevertheless, thank you very much for the quick and accurate answer. -Original Message- From: r...@quantide.com [mailto:r...@quantide.com] Sent: Friday, January 23, 2009 9:25 AM To: Derek Ogle Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Table Modification If I understood propelly tapply(fact3, list(fact1, fact2) , paste, collapse = ,) A. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can't load rJava in R 2.8.1 on Windows XP
Duncan Murdoch murdoch at stats.uwo.ca writes: If you look at rJava:::.onLoad now that you can load the package, you'll see that it goes through a number of tests to try to find the right path. Slightly different for me, but failure: jvm.dll is on path (checked successfully with where jvm.dll) Rgui: Dialog Box (Translated from German) R Console: RGui.exe Component not found The application could not be started because jvm.dll could not be found. rJava package as of today R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale: LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252; LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices datasets utils methods base __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Categorical Variables and glm()
When including categorical variables in a regression, the default in R is to set the first level as the base. Is there an option to specify a different level as the base? Regards, Stephen Collins, MPP | Analyst Health Benefits | Aon Consulting [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] New international competition for the Digital Humanities
(Slightly off topic and outside my area - but this may be of interest to the R community) WASHINGTON (January 16, 2009) -- Today, a new international competition called the Digging into Data Challenge was announced by four leading research agencies: the Joint Information Systems Committee (JISC) from the United Kingdom, the National Endowment for the Humanities (NEH) and the National Science Foundation (NSF) from the United States, and the Social Sciences and Humanities Research Council (SSHRC) from Canada. The Digging into Data Challenge encourages humanities and social science research using large-scale data analysis, challenging scholars to develop international partnerships and explore vast digital resources, including electronic repositories of books, newspapers, and photographs to identify new opportunities for scholarship. Interested applicants must first submit a letter of intent by March 15, 2009. Further information about the competition and the application process can be found at http://www.diggingintodata.org . See the full press release at: http://www.sshrc-crsh.gc.ca/web/whatsnew/press_releases/2009/digging_into_data_e.asp La version française suit le texte anglais. This email may contain privileged and/or confidential information, and the Bank of Canada does not waive any related rights. Any distribution, use, or copying of this email or the information it contains by other than the intended recipient is unauthorized. If you received this email in error please delete it immediately from your system and notify the sender promptly by email that you have done so. Le présent courriel peut contenir de l'information privilégiée ou confidentielle. La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion, utilisation ou copie de ce courriel ou des renseignements qu'il contient par une personne autre que le ou les destinataires désignés est interdite. Si vous recevez ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans délai à l'expéditeur un message électronique pour l'aviser que vous avez éliminé de votre ordinateur toute copie du courriel reçu. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Returning NA from lm
If anyone's interested, I got round it by doing: tryCatch(lm(data~model,na.action=na.fail),error=function(err){NA}) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Neil Beddoe Sent: 23 January 2009 15:40 To: 'Prof Brian Ripley' Cc: r-help@r-project.org Subject: Re: [R] Returning NA from lm I tried that I'm afraid. I still get values for groups with missing data. I think na.exclude just ignores the NAs but I want it to return NA. Where one of the values is NA. -Original Message- From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Sent: 23 January 2009 13:04 To: Neil Beddoe Cc: r-help@r-project.org Subject: Re: [R] Returning NA from lm See ?na.exclude On Fri, 23 Jan 2009, Neil Beddoe wrote: Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2 A 4 A 6.5 ...repeat 96 times with differing values of A B 1 B 2.3 B NA B 6.5 ...repeat 96 times with differing values of B etc I run these against a linear model using tapply(data$Value, data$Key,FUN=regr,100) where regr-function(x,w) { #run the model against the last w values of x lm((x[length(x)-w):length(x)]~myModel(w)) } In the results, I want to return NA for any Key group where one or more of the values is NA. If I run the above I get a regression structure ignoring the missing values and returning values for data that contains NA. Using na.action=na.fail or na.action=NULL causes the whole tapply function to fail and I get nothing. Is there a way I can get lm to return NA if any of the values in the data are NA but valid numbers for complete data? I realise that I could remove the groups with NAs but I'm running the regressions over multiple time periods and most of the data groups will have a full complement of data for at least some of these periods. It becomes a pain to manage NAs if I do that. Sorry if the above is a little unclear. Thanks Neil -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 . This message is intended only for the use of the person(s) to whom it is addressed. It may contain information which is privileged and confidential. Accordingly any unauthorised use is strictly prohibited. If you are not the intended recipient, please contact the sender as soon as possible. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction, unless specifically agreed otherwise. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any opinions or advice contained in this Internet email are subject to the terms and conditions expressed in any applicable governing Marble Bar Asset Management LLP's terms and conditions of business or client agreement letter. Any comments or statements made herein do not necessarily reflect those of Marble Bar Asset Management LLP. Marble Bar Asset Management LLP is regulated and authorised by the FSA. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. . This message is intended only for the use of the person(s) to whom it is addressed. It may contain information which is privileged and confidential. Accordingly any unauthorised use is strictly prohibited. If you are not the intended recipient, please contact the sender as soon as possible. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction, unless specifically agreed otherwise. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any opinions or advice contained in this Internet email are subject to the terms and conditions expressed in any applicable governing Marble Bar Asset Management LLP's terms and conditions of business or client agreement letter. Any comments or statements made herein do not necessarily reflect those of Marble Bar Asset Management LLP. Marble Bar Asset Management LLP is regulated and authorised by the FSA. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and
[R] latex in Hmisc: cell formating
Hi Dieter, Thank you for pointing out the website. From the website it seems the bug has been fixed early 2008 (see http://biostat.mc.vanderbilt.edu/trac/Hmisc/changeset/582 ). So I upgraded my Hmisc package to 3.4-4, which was published on 11/3/2008 and hoped it would work. However, the problem persisted. ...Tao Tao Shi hotmail.com writes: ## I'm using R 2.8.0 on WinXP, Hmisc_3.4-3 table1 - matrix(10, 180,7) cell.format - matrix(, ncol=7, nrow=180) cell.format[c(seq(3,180,6),seq(4,180,6)),] - color{red} cell.format[c(seq(5,180,6),seq(6,180,6)),] - color{green} latex(table1, where='htbp', long=TRUE, lines.page=1000, size=scriptsize, + cgroup=c(group1,group2), n.cgroup=c(6,1), + rgroup=c(n=1,n=5,n=10,n=20,n=50), n.rgroup=rep(36,5), + cellTexCmds=cell.format, numeric.dollar = FALSE) Error in cat(rcellTexCmds[i, colNum], , cx[i, colNum], file = file, : subscript out of bounds ## if I remove the column name grouping, it works fine! ## latex(table1, where='htbp', long=TRUE, lines.page=1000, size=scriptsize, + #cgroup=c(group1,group2), n.cgroup=c(6,1), + rgroup=c(n=1,n=5,n=10,n=20,n=50), n.rgroup=rep(36,5), + cellTexCmds=cell.format, numeric.dollar = FALSE) The example you posted is good, but it is more helpful to post the code, not the pasted result, so that trying you example does not require manual editing. I had reported a similar case a year ago; see below. Maybe you should post it at: http://biostat.mc.vanderbilt.edu/trac/Hmisc/ # library(Hmisc) sessionInfo() x - matrix(1:12, nrow=2, dimnames=list(c('a','p'), letters[1:6])) cellTex = matrix(rep(, NROW(x) * NCOL(x)), nrow=NROW(x)) cellTex[1,1] - cellcolor[gray]{0.9} # works ok p = latex(x,file=a.tex, cellTexCmds = cellTex) # ok # Works ok p = latex(x,file=a.tex, cgroup = c(a,b,c),n.cgroup=c(2,2,2) ) # Fails with a error message subscript out of bounds p = latex(x, file=a.tex, cellTexCmds = cellTex, cgroup = c(a,b,c),n.cgroup=c(2,2,2) ) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Anova and unbalanced designs
Dear R-list! My question is related to an Anova including within and between subject factors and unequal group sizes. Here is a minimal example of what I did: library(car) within1 - c(1,2,3,4,5,6,4,5,3,2); within2 - c(3,4,3,4,3,4,3,4,5,4) values - data.frame(w1 = within1, w2 = within2) values - as.matrix(values) between - factor(c(rep(1,4), rep(2,6))) betweenanova - lm(values ~ between) with - expand.grid(within = factor(1:2)) withinanova - Anova(betweenanova, idata=with, idesign= ~as.factor(within), type = III ) I do not know if this is the appropriate method to deal with unbalanced designs. I observed, that SPSS calculates everything identically except the main effect of the within factor, here, the SSQ and F-value are very different If selecting the option show means, the means for the levels of the within factor in SPSS are the same as: mean(c(mean(values$w1[1:4]),mean(values$w1[5:10]))) and mean(c(mean(values$w2[1:4]),mean(values$w2[5:10]))). In other words, they are calculated as if both groups would have the same size. I wonder if this is a good solution and if so, how could I do the same thing in R? However, I think if this is treated in SPSS as if the group sizes are identical, then why not the interaction, which yields to the same result as using Anova()? Many thanks in advance for your time and help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Categorical Variables and glm()
on 01/23/2009 11:10 AM Stephen Collins wrote: When including categorical variables in a regression, the default in R is to set the first level as the base. Is there an option to specify a different level as the base? See ?relevel and the See Also's listed therein. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Categorical Variables and glm()
Hi, contrasts(yourvariablename)=contr.treatment(levels(yourvariablename),base=3) 3 is the number of the category that you want to be your baseline. Replace accordingly. Cheers, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Stephen Collins Gesendet: Friday, January 23, 2009 12:10 PM An: r-h...@stat.math.ethz.ch Betreff: [R] Categorical Variables and glm() When including categorical variables in a regression, the default in R is to set the first level as the base. Is there an option to specify a different level as the base? Regards, Stephen Collins, MPP | Analyst Health Benefits | Aon Consulting [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R stepping through multiplie interactions
I have a lm in R in the form model - lm( Z ~ A*B*C*D,data=mydata) I want to run the model and include all interactions expect the 4 way (A:B:C:D) is there an easy way of doing this? I then want to step down the model eliminating the non-significant terms I understand step() does this but how would I do it by hand? -- View this message in context: http://www.nabble.com/R-stepping-through-multiplie-interactions-tp21629339p21629339.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot seq
Actually 'levels' works OK by ordering the x axis labels but since I have 52 weeks it gets too crowded. Here's part of my dataset with a reproducible example. sampDat - Week FryPassage 27 665 28 2232 29 9241 30 28464 31 41049 32 82216 33 230411 34 358541 35 747839 36 459682 37 609567 38 979475 39 837189 40 429016 41 523436 42 304785 43 125005 44 28047 45 5141 46 7503 47 2273 48 1065 49 0 50 0 51 0 52 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 WFBar - read.table(textConnection(sampDat), header = TRUE) WFBar # Bar graph (option # 1) options(scipen=3) bargraph - qplot(factor(Week,levels=c(27:52,1:26)),FryPassage, data=WFBar,geom=bar,fill=I(grey65),colour=I(goldenrod), ylab=Numb of Fish,xlab=Week) bargraph # levels give me the desired X axis order but it is too crowded # Bar graph (option # 2) If I skip levels then I don't get to see the bars for the skipped levels options(scipen=3) WFBar$Week - factor(WFBar$Week,levels=c('27','29','31','33','35','37','39','41','43','45','47','49','51','1','5','10','15','20','25')) bargraph - qplot(WFBar$Week,FryPassage,data=WFBar,geom=bar,fill=I(grey65),colour=I(goldenrod), ylab=Numb of Fish,xlab=Week) bargraph # It seems that thickmarks is what I need here. I was trying to concatenate c(seq(27,51,2),seq(1,25,2)) like someone else #suggested but this doesn't seem to work with scale_x_continuous(breaks= c(seq(27,51,2),seq(1,25,2))). # So, my question here is: How can I use the seq() function to create my custom thick marks along the x axis (same order # as the WFBar object skipping one week in between? --- On Fri, 1/23/09, ONKELINX, Thierry thierry.onkel...@inbo.be wrote: From: ONKELINX, Thierry thierry.onkel...@inbo.be Subject: RE: [R] ggplot seq To: mazatlanmex...@yahoo.com, r-h...@stat.math.ethz.ch Date: Friday, January 23, 2009, 3:01 AM Dear Felipe, Provide a dummy sample if your dataset is big or confidential. The actual values are not that important to figure out what kind of plot you want. How did you code Week? Numeric? Try convert it into a factor with levels = c(27:52, 1:26). And then set the breaks to seq(1, 52, by = 2). WFBox - data.frame(Week = rep(1:52, 10), FL = rnorm(520)) WFBox$fWeek - factor(WFBox$Week, levels = c(27:52, 1:26)) library(ggplot2) ggplot(WFBox, aes(fWeek, FL)) + geom_boxplot(outlier.colour=pink,outlier.size=3,outlier.shape=21,fill= goldenrod,colour=blue) + scale_x_discrete(breaks=c(seq(1,51,2))) HTH, Thierry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stat textbook recommendations?
I like: Applied Linear Statistical Models by Neter, Kutner, Nachtsheim, and Wasserman (McGraw Hill) It is not specific to any stats package, but it gives a good mix of theory behind the routines and how to apply them and covers a good breadth of material. A must have for statistics and R is: Modern Applied Statistics with S by Venables and Ripley (Springer). This gives specific examples and commands to use in S-plus/R along with more background information and theory than the R tutorials. Once you have the theory down, a couple more books that help with the practical aspects of using R to do the analysis are: A Handbook of Statistical Analyses Using R by Everitt and Hothorn (Chapman Hall/CRC) An R and S-PLUS Companion to Applied Regression by Fox (Sage) There may be other good ones out there that I am not familiar enough with to recommend. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Monte Milanuk Sent: Friday, January 23, 2009 9:57 AM To: r-help@r-project.org Subject: [R] Stat textbook recommendations? Hello, I'm looking for a textbook that can explain some of the math behind the intro-to-intermediate stuff like ANOVA, multiple regression, non- parametric tests, etc. A little background: I took an intro stats course last year and would like to further my education. Being as that was the highest (and only) stats class the local community college offers, it looks like I'm on my own from here. I've been working through some of the online 'stats with R' tutorials as well as Dalgaard's ISWR. Where I'm running into problems is the transition from Bluman's 'A Brief Introduction to Elementary Statistics' (covers up through paired t- tests, chi-squared/goodness-of-fit, simple linear regression correlation, and just barely mentions ANOVA) with a TI-83+, to even books like ISWR... when they start getting into the things like one and two-way ANOVA, multiple regression, model selection, survival, etc. I start feeling like I have one hand tied behind my back - I just don't have enough theoretical exposure to really understand what techniques I would use when, relative to my own projects outside the book. Several of the 'intro to stats using R' books and pdf tutorials mention that they are not really meant as a standalone statistics text book, but in addition to a traditional stats textbook (Verzani mentions Kitchen's book specifically). So I guess what I'm looking for is any other recommendations on intro or intermediate textbooks that deal primarily with the math/theory behind the processes. If they were oriented towards R that's be great, but otherwise I guess I'd be most interested in something relatively platform-agnostic - I've seen some books that were slanted heavily towards a particular software package (Minitab) that I cannot afford or justify for personal use. TIA, Monte [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] glm binomial loglog (NOT cloglog) link
William Simpson william.a.simpson at gmail.com writes: I would like to do an R glm() with family = binomial(link=loglog) Right now, the cloglog link exists, which is nice when the data have a heavy tail to the left. I have the opposite case and the loglog link is what I need. Can someone suggest how to add the loglog link onto glm()? It would be lovely to have it there by default, and it certainly makes sense to have the two opposite cases cloglog and loglog. Thanks for any help. Bill Look at the example under ?family for how to write a user-specified link and the source of the make.link function can be useful to. Ken -- Ken Knoblauch Inserm U846 Institut Cellule Souche et Cerveau Département Neurosciences Intégratives 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R stepping through multiplie interactions
On 1/23/2009 12:44 PM, ppeetteerr wrote: I have a lm in R in the form model - lm( Z ~ A*B*C*D,data=mydata) I want to run the model and include all interactions expect the 4 way (A:B:C:D) is there an easy way of doing this? I then want to step down the model eliminating the non-significant terms I understand step() does this but how would I do it by hand? For the first part, try this: lm(Z ~ (A + B + C + D)^3, data = mydata) -- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plotting curve in xYplot -- using panel.curve
Hello, I am trying to plot a curve over points plotted with se's in xYplot (see example below). I can get Figure 1 below to plot the data with error. However, I keep getting a the error message Error using packet 1 object y not found Can anyone see what I am doing wrong? Thanks! John --- a=0.002; b=31.7; c=0.51 sds=rep(c(0,3,5,10,20,50,200), each=3) y1=c(0,0,0.16, 0, 0.33,0.5, 0.16, 0.83, 1.16, 0.67, 0.5, 1.16, 0.83, 2.33, 3.6, 5.5, 4.33, 1.16, 22, 13, 12) lo=y1-0.1*y1 hi=y1+0.1*y1 # Figure 1 xYplot(Cbind(y1, lo, hi)~jitter(sds, amount=1), method=bars,ylim=c(0,max(hi)+1), ylab=Y, xlab=X) # Figure 2 xYplot(Cbind(y1, lo, hi)~jitter(sds, amount=1), method=bars,ylim=c(0,max(hi)+1), ylab=Y, xlab=X, panel=function(...){ panel.xYplot(x,y,...) panel.number=panel.number() panel.curve(curve(a*(x+c)/1+a*b*(x+c), from=0, type=l, lwd=2)) } ) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R stepping through multiplie interactions
Z ~ (A+B+C+D)^3 means give all main effects and interactions up to the 3 way interactions, but not above (change ^3 to ^2 to limit to 2 way interactions). You can do a semi manual stepwise procedure using the add1 and drop1 commands or the addterm and dropterm commands in the MASS package. But be aware that using a final model gained from stepwise procedures tends to give estimates of the slopes biased away from 0. Better options have been discussed quite a bit on this list (search the archives) and Frank Harrell's book Regression Modeling Strategies gives more information. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of ppeetteerr Sent: Friday, January 23, 2009 10:45 AM To: r-help@r-project.org Subject: [R] R stepping through multiplie interactions I have a lm in R in the form model - lm( Z ~ A*B*C*D,data=mydata) I want to run the model and include all interactions expect the 4 way (A:B:C:D) is there an easy way of doing this? I then want to step down the model eliminating the non-significant terms I understand step() does this but how would I do it by hand? -- View this message in context: http://www.nabble.com/R-stepping-through- multiplie-interactions-tp21629339p21629339.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stat textbook recommendations?
You might want to check out the following: http://www.stochas.org/ http://www1.appstate.edu/~arnholta/PASWR/index.htm http://turtle.gis.umn.edu/pmwiki/pmwiki.php/StatisticsandDatawithR/HomePage http://www.janehorgan.com/ I own all of these books and like them. The book by Dr. Jan Horgan: Probability with R: An Introduction with Computer Science Applications is nice in that it's quick and right to the point. Don't let the title fool you, there's plenty of information applicable to all fields. The book by Dr. Kenneth Baclawski: Introduction to Probability with R is has more theory than the previous book and also has lots of worked problems. The other two books are general prob/stat books, I find they're both extremely well written with the Arnholt book with a little more theory. All of these books start from first principles (no required stat background, just some math) but I suspect that all of these may be a good next step to bridge the gaps that you mention. In addition, I think that owners of PASWR and SADWR may be able to get a solution manual from the author (if you're working on your own and not taking a class). Cheers, Dan Viar Chesapeake, VA On Fri, Jan 23, 2009 at 11:57 AM, Monte Milanuk memila...@gmail.com wrote: Hello, I'm looking for a textbook that can explain some of the math behind the intro-to-intermediate stuff like ANOVA, multiple regression, non- parametric tests, etc. A little background: I took an intro stats course last year and would like to further my education. Being as that was the highest (and only) stats class the local community college offers, it looks like I'm on my own from here. I've been working through some of the online 'stats with R' tutorials as well as Dalgaard's ISWR. Where I'm running into problems is the transition from Bluman's 'A Brief Introduction to Elementary Statistics' (covers up through paired t- tests, chi-squared/goodness-of-fit, simple linear regression correlation, and just barely mentions ANOVA) with a TI-83+, to even books like ISWR... when they start getting into the things like one and two-way ANOVA, multiple regression, model selection, survival, etc. I start feeling like I have one hand tied behind my back - I just don't have enough theoretical exposure to really understand what techniques I would use when, relative to my own projects outside the book. Several of the 'intro to stats using R' books and pdf tutorials mention that they are not really meant as a standalone statistics text book, but in addition to a traditional stats textbook (Verzani mentions Kitchen's book specifically). So I guess what I'm looking for is any other recommendations on intro or intermediate textbooks that deal primarily with the math/theory behind the processes. If they were oriented towards R that's be great, but otherwise I guess I'd be most interested in something relatively platform-agnostic - I've seen some books that were slanted heavily towards a particular software package (Minitab) that I cannot afford or justify for personal use. TIA, Monte [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stat textbook recommendations?
If you don't want to be on your own, and you are looking for more statistics courses than you have available locally, Texas AM University statistics department offers some single courses, a 4-course certificate, and an entire masters degree, all online, no campus visits required. I am in their masters program now. Colorado State University offers similar things, also no campus visits needed. --Chris Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton 40 Arch Street, Johnson City, NY 13790 cryanatbinghamtondotedu PGP public keys available at http://home.stny.rr.com/ryancw/ If you want to build a ship, don't drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea. [Antoine de St. Exupery] Monte Milanuk wrote: Hello, I'm looking for a textbook that can explain some of the math behind the intro-to-intermediate stuff like ANOVA, multiple regression, non- parametric tests, etc. A little background: I took an intro stats course last year and would like to further my education. Being as that was the highest (and only) stats class the local community college offers, it looks like I'm on my own from here. . . . __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Appending objects created using filehash package
Hi, I am working with a very large dataset, and am using the 'filehash' package to manage such a large file. While I have no problem accessing objects that I load into a database, I was hoping there is a better way to append to objects already in the database. The only way I know now to append to an object, basically requires rewriting the entire object. Sample code: = # Setting up the database library(filehash) A - data.frame(a=c(abcde, fghij, klmno), stringsAsFactors=FALSE) dumpDF( A, dbName=myTestDB) envTest - db2env(db=myTestDB) ls(envTest) with(envTest, a) # Appending to object a, but basically rewriting it... envTest$a - c(envTest$a, HELLO, GOODBYE) with(envTest, a) If anyone has a suggestion on how to append to an object without completely rewriting it, I would really appreciate it. Because in my actual implementation, a is a vector of class character with ~3.5 million elements... writing it (and rewriting it) takes quite a bit of time. For reference, I am using a Windows Vista machine with: R.version.string [1] R version 2.8.0 (2008-10-20) Thanks, Brigid [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot, lines and disordered x and y
Ok, here is a bit more information: R is version 2.7.1 (2008-06-23) A constructed example: x-c(1,-1,2,-2,3,-3,4,-4,5,-5) y-c(1,0,2,0,3,0,4,0,5,0) plot(x,y,type='l') #bad plot(x,y) # this is how it should look like So what we should see here is a flat y=0 for x0 and identity for x0. Instead, we have a saw-like shape where e.g y(x=-1) is connected to y(x=1) . This is of course minor (actually asymptotically, no annoyance at all). I am just mentioning it for 'completness' sake and because a divinely ideal plotting function should cope with data given in any order. Cheers! TK Cheers, TK 2009/1/23 jim holtman jholt...@gmail.com: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. A sample of data causing the problem would help. It is most likely the way you have it specified. On Fri, Jan 23, 2009 at 11:37 AM, Todor Kondic doliche...@gmail.com wrote: Hello, I have 2d data where x coordinate is not given in usual ascending order (x1,...,x1+l; l0), and instead in another, regular, but not ascending or descending order (for illustration: x1,-x1,x1+dx1,-x1-dx1,).y is an array which corresponds to the way x is ordered. I have noticed that giving 'plot(x,y,type='l') produces a plot where the points are connected in a completely wrong way. It is as the plot/lines assumes an ascending order between the succesive y points ignoring the fact that they are not (it connects y(x1) with y(-x1), for x1+dx). I don't know whether this could be a bug, because maybe sorting the y coordinates appropriately and then interpolating lines plotting is too much to ask of the plot function. But, I've felt like sharing :-) Additionally, 'points' function will plot the data properly. Cheers, TK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get a primitive function object
On Fri, Jan 23, 2009 at 5:15 AM, Patrick Burns pbu...@pburns.seanet.com wrote: If I understand properly, you want '-' to be a generic function, which it currently isn't. There may be a way to fake that (I can't think of any). But I'm wondering if you should rethink what you want. The only reason that I can think of that you would want to change '-' is because of some extra side effect that you want to happen. That is not in the spirit of R. Yes, I wanted some side effect of '-', to have my own reference counting for some large resource. I guess this is already the most non-intrusive way I can think of--initially I modified R's source code, an even worse option. Patrick Burns -- Yi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Write to multiple connections or multiple text files
On Fri, 23 Jan 2009, Andersson, Jafet wrote: Hi all, I want to modify a large number of text files (ca 4000) by replacing a value found on a particular line in them with a value from an R object. For a single file I would normally use: con-file (foo.txt, open=r+) content-readLines(con) content[n]-test writeLines(content,con) close(con) If you know 'n' before opening the connection or can easily figure it out using the system's grep command (on your linux side), you would probably be best off using two calls to the system() function along with your system's head, cat, and tail functions to copy the parts you do not alter to a temp file. Using pipe() with the system's head and tail commands you pick off the line you modify and cat() to append it in between the system() call that copies what preceeds it and and the call that copies what succeeds it. Once the temp file is complete, you replace the orignal with it. HTH, Chuck For repeating this for several files I can write a for loop around this. However, my problem with this is that it is rather slow. I am therefore wondering if there is any other way to write to multiple connections in a similar way as one can e.g. write to a large number of rows in a matrix simultaneously? (Note that seek() is not so practical for me since the number of bytes before the specific line varies between the files, therefore I use reanLines() and match the right line instead.) My Systems: OS: Windows Server 2003 Linux Red Hat (interchangeably) R version: 2.7.2 Thanks for any suggestions! ooo Jafet Andersson Eawag - The Swiss Federal Institute of Aquatic Science and Technology Ueberlandstrasse 133 P.O. Box 611 CH-8600 Duebendorf Switzerland Phone: +41 (0)44 823 5358 Fax: +41 (0)44 823 5028 http://www.eawag.ch/index_EN __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] compound outcome variables (not specifically R-related)
I would like to try to do a journal club session for my family practice residents on the uses, and especailly the pitfalls, of compound outcome variables, like stroke or myocardial infarction or coronary bypass surgery. They appear frequently in clinical trial literature. Can anyone recommend any good articles discussing the issues? Thanks. --Chris Ryan -- Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton 40 Arch Street, Johnson City, NY 13790 cryanatbinghamtondotedu PGP public keys available at http://home.stny.rr.com/ryancw/ If you want to build a ship, don't drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea. [Antoine de St. Exupery] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot, lines and disordered x and y
Dear Todor, How about this? x-c(1,-1,2,-2,3,-3,4,-4,5,-5) y-c(1,0,2,0,3,0,4,0,5,0) DF-data.frame(x,y) plot(with(DF,DF[order(x),]),type='o') HTH, Jorge On Fri, Jan 23, 2009 at 1:41 PM, Todor Kondic doliche...@gmail.com wrote: Ok, here is a bit more information: R is version 2.7.1 (2008-06-23) A constructed example: x-c(1,-1,2,-2,3,-3,4,-4,5,-5) y-c(1,0,2,0,3,0,4,0,5,0) plot(x,y,type='l') #bad plot(x,y) # this is how it should look like So what we should see here is a flat y=0 for x0 and identity for x0. Instead, we have a saw-like shape where e.g y(x=-1) is connected to y(x=1) . This is of course minor (actually asymptotically, no annoyance at all). I am just mentioning it for 'completness' sake and because a divinely ideal plotting function should cope with data given in any order. Cheers! TK Cheers, TK 2009/1/23 jim holtman jholt...@gmail.com: PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. A sample of data causing the problem would help. It is most likely the way you have it specified. On Fri, Jan 23, 2009 at 11:37 AM, Todor Kondic doliche...@gmail.com wrote: Hello, I have 2d data where x coordinate is not given in usual ascending order (x1,...,x1+l; l0), and instead in another, regular, but not ascending or descending order (for illustration: x1,-x1,x1+dx1,-x1-dx1,).y is an array which corresponds to the way x is ordered. I have noticed that giving 'plot(x,y,type='l') produces a plot where the points are connected in a completely wrong way. It is as the plot/lines assumes an ascending order between the succesive y points ignoring the fact that they are not (it connects y(x1) with y(-x1), for x1+dx). I don't know whether this could be a bug, because maybe sorting the y coordinates appropriately and then interpolating lines plotting is too much to ask of the plot function. But, I've felt like sharing :-) Additionally, 'points' function will plot the data properly. Cheers, TK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.