[R] testing column data against criteria, point by point
I am fairly new to R and I would like to do the following, but do not know where to start. Any help or direction would be appreciated. I have a time series of snow depth measurements. I would like to determine the depth of snowfall for each snowfall event. There is noise in the data so I only want to add data values if the subsequent depth is greater than the previous by a certain margin. I am only interested in calculating snow accumulation events. Example data: Time depth 184.3 284.5 386 486.1 585.8 686.7 787.9 889.1 990 10 89 11 88 12 88 13 89.1 14 90 15 91.2 16 89.9 ... ... I would like to create a second data frame from the data that looks something like this: EventInitialDepthFinalDepth AccumulationInitialTime FinalTime 184.390 5.7 1 9 288 91.23.2 11 15 ... I would like to write a program that progresses through the depth column, point by point, to test if (i+1) - i x. (where I will set x to exlude the noise in the data). As long as i+1 is greater than or equal to i, then the initial depth stays at the first data point and the final value changes to that in i+n. Once the test is false, this indicates the end of the event, the accumulation is calculated, all values are saved as event X and a new event is started. I tried using ifelse(), but I do not know how to move through the data and then save the initial and final values and time stamps in another table. Thank you very much for your time. Kara __ 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 on netbooks et al?
Dear useRs, With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? Many thanks, Bernd __ 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] modifying a built in function from the stats package (fixing arima)
If you ***look at the code*** for arima you will see that ``%+%'' is defined in terms of a call to ``.Call()'' which calls ``R_TSconv''. So apparently R_TSconv is a C or Fortran function or subroutine in a ``shared object library'' or dll upon which arima depends. Hence to do anything with it you'll need to get that shared object library and dynamically load it. (E.g. get the code, SHLIB it, and dynamically load the resulting shared object library.) The code is all available from the R source tarball. If this is a challenge for you then the best advice would be not to mess with it. Hi Rolf, It took me some time to come to the same conclusion (I didn't even know what .Call() was) but I've found an easier way to modify the R file without having to understand how to link dlls. I just downloaded the full R package, Rtools and followed the instructions in http://cran.r-project.org/doc/manuals/R-admin.html#Building-the-core-files to build it. Then I can modify C:\R\src\library\stats\R\arima.R and run it. It is quite exagerated that I have to build R in order to modify an R file without messing with dlls, and I think it would be interesting to make this process easier, but for now I'm happy to be productive again. Thank you all for your help, Best, MarC __ 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] Bug in by() with dates as levels?
hadley wickham h.wickham at gmail.com writes: You might also want to take a look at the plyr package: install.packages(plyr) library(plyr) ddply(x, .(A, D), function(df) sum(df$Z)) dlply(x, .(A, D), function(df) sum(df$Z)) I recently for the first time used the plyr package in an introductory course as a general replacement of for by, (x)apply, followed by do.call gymnastics. It was an amazing step forward to have a nicely orthogonal set of function that returns what people expected instead of converting everything to a list. I know, real MEN program assembler and love (x)apply... 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] modifying a built in function from the stats package (fixing arima)
On Thu, Mar 5, 2009 at 10:00 AM, Marc Vinyes mvin...@aleasoft.com wrote: If you ***look at the code*** for arima you will see that ``%+%'' is defined in terms of a call to ``.Call()'' which calls ``R_TSconv''. So apparently R_TSconv is a C or Fortran function or subroutine in a ``shared object library'' or dll upon which arima depends. Hence to do anything with it you'll need to get that shared object library and dynamically load it. (E.g. get the code, SHLIB it, and dynamically load the resulting shared object library.) The code is all available from the R source tarball. If this is a challenge for you then the best advice would be not to mess with it. Hi Rolf, It took me some time to come to the same conclusion (I didn't even know what .Call() was) but I've found an easier way to modify the R file without having to understand how to link dlls. I just downloaded the full R package, Rtools and followed the instructions in http://cran.r-project.org/doc/manuals/R-admin.html#Building-the-core-files to build it. Then I can modify C:\R\src\library\stats\R\arima.R and run it. It is quite exagerated that I have to build R in order to modify an R file without messing with dlls, and I think it would be interesting to make this process easier, but for now I'm happy to be productive again. Thank you all for your help, Best, MarC Just a quick note on your original question: if you use edit(arima), you have to remember that it returns the modified function, which then must be stored. I.e, use arima-edit(arima) instead of just edit(arima) ,and changes should be stored. Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ 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 on netbooks et al?
On Thu, Mar 05, 2009 at 08:47:25AM +, herrdittm...@yahoo.co.uk wrote: With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? I have R on my ASUS eeePC 1000H under Debian Linux and it works just fine. In my opinion the most limiting thing is the small keyboard. Everything else (RAM, Screen, CPU power) is what you would expect given the specs: Not the platform of choice for large-scale number crunching or writing elaborate programs but certainly good enough to do a little work on the train/plane/hotel/... cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel __ 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] is there any option like cex.axis in ggplot2?
Dear list, I made boxplots using ggplot and want to control for x- and yaxis. Using plot I can do it by setting cex.axis equally to any size but can't figure out how to do it with ggplot. ggplot(dat, aes(x = factor(time), y = volume)) + opts(axis.title.x=theme_text(size=8),axis.title.y=theme_text(size=8)) + geom_boxplot() + geom_jitter(aes(colour = id))+labs(x = time, y = volume) Thanks for your help, Tom __ Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling. Sök och jämför priser hos Kelkoo. http://www.kelkoo.se/c-100015813-bredband.html?partnerId=96914325 [[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] modifying a built in function from the stats package (fixing arima)
Just a quick note on your original question: if you use edit(arima), you have to remember that it returns the modified function, which then must be stored. I.e, use arima-edit(arima) instead of just edit(arima) ,and changes should be stored. THIS IS IT. IMHO, this should be written in BOLD LETTERS in the Introduction to R manual (edit is only mentioned to edit DATA). Best, MarC __ 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 r package for svdpack?
hi all, I was finding a r-package for the svd decomposition of sparse matrix. After no package was found, I get a good fortran/c package named svdpack/svdpackc http://www.netlib.org/svdpack/. I was wondering if there are any r-package for sparse matrix svd, or any packages implement the interface of svdpack/svdpackc? Thanks in advance! wentrue [[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] text at the upper left corner outside of the plot region
batho...@googlemail.com wrote: Hi, is there a way to place text at the upper left corner (or another corner) of the plot? I want to place it really at the upper left corner of the whole plot (the file I get), not at the upper left corner of the plot-region. I tried text() and mtext(), and corner.label() of the plotrix package but it didn't work out. Hi batholdy, I suppose we could rewrite corner.label like this: corner.label-function(label=NULL,x=-1,y=1,xoffset=NA,yoffset=NA, space=c(plot,figure),...) { if(is.na(xoffset)) xoffset-strwidth(m)/2 if(is.na(yoffset)) yoffset-strheight(m)/2 par.usr-par(usr) xpos-par.usr[(3+x)/2] ypos-par.usr[(3+y)/2+2] if(match(space[1],figure,0)) { par.pin-par(pin) xplotrange-par.usr[2]-par.usr[1] yplotrange-par.usr[4]-par.usr[3] par.mai-par(mai) xmar-xplotrange*par.mai[3+x]/par.pin[1] ymar-yplotrange*par.mai[2+y]/par.pin[2] cat(xmar,ymar,\n) xpos-xpos+x*xmar ypos-ypos+y*ymar } if(!is.null(label)) { if(match(space[1],figure,0)) par(xpd=TRUE) text(xpos-x*xoffset,ypos-y*yoffset,label,adj=c((1+x)/2,(1+y)/2)) if(match(space[1],figure,0)) par(xpd=FALSE) } return(list(x=xpos,y=ypos)) } The default behavior is to put the label just inside one corner of the plot. If you set space to figure, the label will appear just inside one corner of the figure region. Owzat? 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] R on netbooks et al?
herrdittm...@yahoo.co.uk wrote: With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? I've got R on my little EeePC as well. Great for most jobs and I highly recommend a DC/DC convertor for plugging into your car's cigarette lighter to get around the crap battery problem. 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.
[R] Problem using RMySQL and fCalendar
Hello: I am trying to use fCalendar for date arithmetic and the RMySQL package for accessing a MySQL database. The fCalendar math operations seem to work fine UNTIL I load the RMySQL package. Here is a demonstration: e...@fibonacci:~/Desktop/amCharts/rsa-metrics$ R R version 2.7.1 (2008-06-23) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] library(fCalendar, pos=2) # For date math Loading required package: MASS Loading required package: fUtilities Rmetrics Package fUtilities (290.76) loaded. Loading required package: fEcofin Rmetrics Package fCalendar (270.78.2) loaded. The new version of 'fCalendar' has been renamed to 'timeDate' dt-1947-06-13 myFC-America/NewYork DT-timeDate(dt, zone=myFC, FinCenter=myFC) DT + 3600 America/NewYork [1] [1947-06-13 01:00:00] library(RMySQL, pos=4) # For db access DT + 3600 Error in `+.timeDate`(DT, 3600) : no slot of name Data for this object of class timeDate In addition: Warning message: In `+.timeDate`(DT, 3600) : trying to get slot Data from an object (class timeDate) that is not an S4 object As you can see, I can do date arithmetic (DT + 3600) before I load the RMySQL package but not after. The pos arguments to the library() calls are an unsuccessful attempt to get R to use the Rmetrics fCalendar package that works instead of whatever gets loaded by RMySQL. I have Googled until my fingers turned blue and I can't find any useful information to fix this. Any help would be most appreciated. Thanks, eanichols __ 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 option like cex.axis in ggplot2?
Dear Tom, You can control the size of the axis title in ggplot2. It is described in the ggplot2 book. Have a look at Chapter 8: Polishing your plots for publication. You can find the book on the ggplot2 website. I tend to create my own theme for some specific type of plots. Below you can find a theme for plots with rotated labels on the X-axis. Using such a theme is similar to adding an extra geom. ggplot(dat, aes(x = factor(time), y = volume)) + geom_boxplot() + geom_jitter(aes(colour = id)) + labs(x = time, y = volume) + BaseThemeX90() BaseThemeX90 - function(base_size = 10) { structure(list( axis.line = theme_blank(), axis.text.x = theme_text(size = base_size * 0.8 , lineheight = 0.9, colour = grey50, hjust = 1, angle = 90), axis.text.y = theme_text(size = base_size * 0.8, lineheight = 0.9, colour = grey50, hjust = 1), axis.ticks = theme_segment(colour = grey50), axis.title.x = theme_text(size = base_size), axis.title.y = theme_text(size = base_size, angle = 90), axis.ticks.length = unit(0.15, cm), axis.ticks.margin = unit(0.1, cm), legend.background = theme_rect(colour=NA), legend.key =theme_rect(fill = grey95, colour = white), legend.key.size = unit(1.2, lines), legend.text = theme_text(size = base_size * 0.7), legend.title = theme_text(size = base_size * 0.8, face = bold, hjust = 0), legend.position = right, panel.background = theme_rect(fill = grey90, colour = NA), panel.border = theme_blank(), panel.grid.major = theme_line(colour = white), panel.grid.minor = theme_line(colour = grey95, size = 0.25), panel.margin = unit(0.25, lines), strip.background = theme_rect(fill = grey80, colour = NA), strip.label = function(variable, value) value, strip.text.x = theme_text(size = base_size * 0.8), strip.text.y = theme_text(size = base_size * 0.8, angle = -90), plot.background = theme_rect(colour = NA), plot.title =theme_text(size = base_size * 1.2), plot.margin = unit(c(1, 1, 0.5, 0.5), lines) ), class = options) } 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 Tom Cohen Verzonden: donderdag 5 maart 2009 10:13 Aan: r-help@r-project.org Onderwerp: [R] is there any option like cex.axis in ggplot2? Dear list, I made boxplots using ggplot and want to control for x- and yaxis. Using plot I can do it by setting cex.axis equally to any size but can't figure out how to do it with ggplot. ggplot(dat, aes(x = factor(time), y = volume)) + opts(axis.title.x=theme_text(size=8),axis.title.y=theme_text(size=8)) + geom_boxplot() + geom_jitter(aes(colour = id))+labs(x = time, y = volume) Thanks for your help, Tom __ Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling. Sök och jämför priser hos Kelkoo.
[R] including tabular information with a plot in R Graphics
Hi all, I have a presentation problem that I cannot find a solution to in the documetnation. I have a nice barplot. Below this I would also like a table with some information relating to the plot. My idea was to have the plot and table on the same graphics window so I can output them as an image file for a report. Does anybody know how to include tabular information from a dataset or table into the graphics device? Is there a better/more correct way to output tables and graphics to a single file? Thanks very much, Richie [[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 using RMySQL and fCalendar
EN == Elizabeth Nichols betsy.nich...@plexlogic.com on Thu, 05 Mar 2009 05:45:40 -0500 EN Hello: EN I am trying to use fCalendar for date arithmetic and the EN RMySQL package EN for accessing a MySQL database. The fCalendar math operations EN seem to EN work fine UNTIL I load the RMySQL package. Here is a EN demonstration: EN EN e...@fibonacci:~/Desktop/amCharts/rsa-metrics$ R EN EN R version 2.7.1 (2008-06-23) EN Copyright (C) 2008 The R Foundation for Statistical Computing EN ISBN 3-900051-07-0 EN EN R is free software and comes with ABSOLUTELY NO WARRANTY. EN You are welcome to redistribute it under certain conditions. EN Type 'license()' or 'licence()' for distribution details. EN EN Natural language support but running in an English locale EN EN R is a collaborative project with many contributors. EN Type 'contributors()' for more information and EN 'citation()' on how to cite R or R packages in publications. EN EN Type 'demo()' for some demos, 'help()' for on-line help, or EN 'help.start()' for an HTML browser interface to help. EN Type 'q()' to quit R. EN EN [Previously saved workspace restored] EN EN library(fCalendar, pos=2) # For date math EN Loading required package: MASS EN Loading required package: fUtilities EN Rmetrics Package fUtilities (290.76) loaded. EN Loading required package: fEcofin EN Rmetrics Package fCalendar (270.78.2) loaded. EN The new version of 'fCalendar' has been renamed to 'timeDate' EN dt-1947-06-13 EN myFC-America/NewYork EN DT-timeDate(dt, zone=myFC, FinCenter=myFC) EN DT + 3600 EN America/NewYork EN [1] [1947-06-13 01:00:00] EN library(RMySQL, pos=4) # For db access EN DT + 3600 EN Error in (DT, 3600) : EN no slot of name Data for this object of class timeDate EN In addition: Warning message: EN In (DT, 3600) : EN trying to get slot Data from an object (class timeDate) that EN is not EN an S4 object EN EN EN As you can see, I can do date arithmetic (DT + 3600) before EN I load the EN RMySQL package but not after. The pos arguments to the EN library() EN calls are an unsuccessful attempt to get R to use the Rmetrics EN fCalendar EN package that works instead of whatever gets loaded by RMySQL. EN EN I have Googled until my fingers turned blue and I can't find EN any useful EN information to fix this. Any help would be most appreciated. EN Thanks, EN eanichols Hi Elizabeth, Please note that the new version of 'fCalendar' has been renamed to 'timeDate' I tried your example with the new timeDate package and it worked fine for me. HTH Yohan -- PhD student Swiss Federal Institute of Technology Zurich www.ethz.ch __ 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 at the upper left corner outside of the plot region
is this something that helps? plot(1,2) mtext(test low right,side=1,outer=T,adj=1,line=-1) mtext(test low left,side=1,outer=T,adj=0,line=-1) mtext(test upper right,side=3,outer=T,adj=1,line=-1) mtext(test upper left,side=3,outer=T,adj=0,line=-1) hth batho...@googlemail.com schrieb: Hi, is there a way to place text at the upper left corner (or another corner) of the plot? I want to place it really at the upper left corner of the whole plot (the file I get), not at the upper left corner of the plot-region. I tried text() and mtext(), and corner.label() of the plotrix package but it didn't work out. 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. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in var(x, na.rm = na.rm) : no complete element pairs
Hello, I still have the same error which I have written in the Subject field, I leave here the code and I hope you can help me with this: filter.clones-function(zz.info,crom.info) { clones.info-zz.info cat(Removing clones which has a flag minor than 0\n) ord - order(clones.info$Flags) clones.info- clones.info[ ord, ] #for(j in 1:nrow(clones.info)) #{ del-0 #print(j) del-which(as.numeric(clones.info$Flags)0) if (length(del)!=0) { #print(j) clones.info-clones.info[-del,] #eliminados.info-clones.info[del,] #if(j==1) #{ #j-0 #} } #} ##Eliminar levaduras, moscas etc #for(j in 1:nrow(clones.info)) #{ del1-0 del1-grep(mix,clones.info$Name) if (length(del1)!=0) { #print(j) clones.info-clones.info[-del1,] } #} #for(j in 1:nrow(clones.info)) #{ del2-0 del2-grep(fly,clones.info$Name) if (length(del2)!=0) { #print(j) clones.info-clones.info[-del2,] } #} #for(j in 1:nrow(clones.info)) #{ del3-0 del3-grep(pombe,clones.info$Name) if (length(del3)!=0) { #print(j) clones.info-clones.info[-del3,] } #} #for(j in 1:nrow(clones.info)) #{ del4-0 del4-grep(DMSO,clones.info$Name) if (length(del4)!=0) { #print(j) clones.info-clones.info[-del4,] } #} #Eliminar los clones que estan unidos por un + o un menos #for(j in 1:nrow(clones.info)) #{ del5-0 del5-grep([+],clones.info$Name) if (length(del5)!=0) { #print(j) clones.info-clones.info[-del5,] } #} #for(j in 1:nrow(clones.info)) #{ del6-0 del6-grep([-],clones.info$Name) if(length(del6)!=0) { #print(j) clones.info-clones.info[-del6,] } #} #for(j in 1:nrow(clones.info)) #{ del7-0 del7-grep(rep,clones.info$Name) if(length(del7)!=0) { #print(j) clones.info-clones.info[-del7,] } #} del8-0 del8-grep(REP,clones.info$Name) if(length(del8)!=0) { #print(j) clones.info-clones.info[-del8,] } #cat(Numero de clones:,NROW(clones.info$Name),\n) #chroms.info-croms.info(PruebaDefinitiva.obj) #cat(Reordering the chromosomes\n) #ord - order(chroms.info$picked_off_as_SI_name) #chroms.info- chroms.info[ ord, ] #ord - order(PruebaDefinitiva.obj$crom.info$picked_off_as_SI_name) ##crom.info - crom.info[ ord, ] nrow(clones.info) #a-PruebaDefinitiva.obj$zz.info #PruebaDefinitiva.obj$zz.info-0 #PruebaDefinitiva.obj$zz.info-clones.info #PruebaDefinitiva.obj$zz.info clones.info cat(Reordering the chromosomes\n) ord - order(crom.info$picked_off_as_SI_name) crom.info- crom.info[ ord, ] #arch.info-cbind(arch.info,000) #names(arch.info)[NCOL(arch.info)]-Cromosomas clones2.info-clones.info clones2.info-cbind(clones2.info,000) names(clones2.info)[NCOL(clones2.info)]-Cromosomas clones2.info ##Añadir columna con los cromosomas #ncol(arch.info) #arch.info-arch.info #arch.info-cbind(arch.info,000) #names(arch.info)[NCOL(arch.info)]-Cromosomas ord - order(clones2.info$Name) clones2.info- clones2.info[ ord, ] for(i in 1:nrow(clones2.info)) { cat(Processing clon ,i,\n) find-match(clones2.info$Name[i],crom.info$picked_off_as_SI_name,nomatch=0) print(find) if((length(find)!=0) (find!=0)) { clones2.info$Cromosomas[i]-paste(crom.info$current_chromosome[find]) } find-0 } del1-0 del1-grep(X,clones2.info$Cromosomas) if (length(del1)!=0) { #print(j) clones2.info-clones2.info[-del1,] } del1-0 del1-grep(Y,clones2.info$Cromosomas) if (length(del1)!=0) { #print(j) clones2.info-clones2.info[-del1,] } del1-0 del1-grep(Un_,clones2.info$Cromosomas) if (length(del1)!=0) { #print(j) clones2.info-clones2.info[-del1,] } del1-0 del1-grep(DR,clones2.info$Cromosomas) if (length(del1)!=0) { #print(j) clones2.info-clones2.info[-del1,] } ord - order(clones2.info$Cromosomas)
Re: [R] including tabular information with a plot in R Graphics
Hi Richie, have a look at textplot() from the gplots-package. hope, it helps! R User R User schrieb: Hi all, I have a presentation problem that I cannot find a solution to in the documetnation. I have a nice barplot. Below this I would also like a table with some information relating to the plot. My idea was to have the plot and table on the same graphics window so I can output them as an image file for a report. Does anybody know how to include tabular information from a dataset or table into the graphics device? Is there a better/more correct way to output tables and graphics to a single file? Thanks very much, Richie [[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. -- Eik Vettorazzi Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790 __ 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] a few scatter plots for a specific correlation value
Hello, Is there a simple way to draw a few random sample scatter plots from a given specific correlation coefficient(say, 0.18)? __ 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] Fast Fourier Transform w.r.t. CreditRisk+
Dear R Helpers, Is there any literaure available (including R code) on Fast Fourier Transform being used in CreditRisk+? I need to learn how to apply the Fast Fourier Transform. I agree I am too vaue in my question and sincerely apologize for the same, but I am not able to understand as to where do I start for this particular assignment. I tried to search google for CRAN and Fast Fourier Transform, but I got something for FFT image. Basically I need to understand what is Fast Fourier Transform is and its use in CreditRisk+? With regards and tahnking in advance Maithili __ 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 on netbooks et al?
Dear Bernd, I fully subscribe to Jim and Philipp's posts, plus a note on operating systems, case you're a Windows user. I've got an eeePC 900, standard Xandros Linux version, happily running R. With LaTeX-Beamer installed, weighing less than 1 Kg and with WiFi this makes for an excellent companion on conferences and meetings. You can also get models with built-in UMTS from telecoms. As this was my first Linux box in my Windows-useR experience, the feel of R was quite different at the beginning; then I started using Emacs+ESS and i liked it so much that I took it over to Windows as well, so now the feel is the same for me irrespective of the OS I'm on (plus much, much more! but maybe you know that already). As for the general user experience, be careful that SDD performance is very erratic across models, which affects almost everything. See this http://www.youtube.com/watch?v=Uy8ZRoGbCxE if you like. My machine boots in 25'' and is reasonably responsive anyway (file manager takes some 5-10'' to open up, but it's one of the slowest things; R loads immediately; Emacs takes 5-10'' as well). HTH Giovanni ## original message: Message: 147 Date: Thu, 5 Mar 2009 10:31:39 +0100 From: Philipp Pagel p.pa...@wzw.tum.de Subject: Re: [R] R on netbooks et al? To: r-help@r-project.org Message-ID: 20090305093139.ga6...@localhost Content-Type: text/plain; charset=utf-8 On Thu, Mar 05, 2009 at 08:47:25AM +, herrdittm...@yahoo.co.uk wrote: With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? I have R on my ASUS eeePC 1000H under Debian Linux and it works just fine. In my opinion the most limiting thing is the small keyboard. Everything else (RAM, Screen, CPU power) is what you would expect given the specs: Not the platform of choice for large-scale number crunching or writing elaborate programs but certainly good enough to do a little work on the train/plane/hotel/... cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel ## Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:13}} __ 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] problems with exporting a chart
Elena Wilson wrote: Dear Uwe, Thank you very much for your email. I think I have worked out that the problem was related to the coordinates of the legend that are manually specified in the leg_loc command. However, I'm not exactly sure what was wrong with exporting the picture of the plot... To avoid the problem I have to run plot.new() before running the histogram command to refresh the default parameters of the Device window (that might have changed after plotting previous charts or changing the size of the device window or some other reasons I don't know of...) I'm sorry that I wasn't clear enough in my question. I'll try to be this time and give you an idea of what happened. If there is one legend, keywords like topleft, rightleft etc are very good, but they don't work with several legends to be placed on each individual sub-plot. Maybe you can suggest a better way of placing multiple legends on the charts that would automatically detect the coordinates for each legend??? R version 2.8.0 Lattice version 0.17-15 With regards to format and device, I've tried many ways: - Use the (Windows) device directly, then once the chart is ready I either copy it as a metafile There is also a win.metafile(), by the way. and then paste to a document, or try to save it as pdf/png/jpeg etc OR - Use pdf / png / jpeg functions to directly save the output to an external file This is the code (which works now): *To generate a similar data frame to the one I use: data=data.frame(Size=rep(c(60,70,150,250, 450),each=500), Delta_R2=rnorm(2500,mean=0,sd=1)) attach(data) library(lattice) plot.new() # I run it here to restore the default par options histogram(~Delta_R2|as.factor(Size), type=percent, col=red, xlab=Delta OLS - SV R squared, main=R Squared Deviations) leg_loc=matrix(c(-0.05, 0.3, 0.65, -0.05, 0.3, 0.4, 0.4, 0.4, 0.98, 0.98),ncol=2, nrow=5, byrow=FALSE) # specifying the coordinates of the legends for (i in 1:5) { nR=(i-1)*500+1 nR2=nR+499 z=data[nR:nR2,2] m-mean(z) std-sqrt(var(z)) iqr=IQR(z) median=median(z) legend(leg_loc[i,1],leg_loc[i,2], cex=0.7, legend= paste( Mean=,round(m,3),'\n', SD=,round(std,3),'\n', Median =,round(median,3),'\n', IQR=, round(iqr,3)),bty=n) } You probably do not want the legend function that is intended to works with base graphics. Instead, use the key argument for your lattice function histogram() as described in the help page ?xyplot. Example: histogram( ~ Delta_R2 | as.factor(Size), type=percent, col=red, xlab=Delta OLS - SV R squared, main=R Squared Deviations, panel = function(x, ...){ panel.histogram(x, ...) draw.key(list(cex=0.7, text=list(lab=c(paste(c('Mean', 'SD', 'Median', 'IQR'), round(c(mean(x), sd(x), median(x), IQR(x)), 3), sep==, draw = TRUE, vp = viewport(x = unit(0.25, npc), y = unit(0.9, npc))) }) Next, you probably do not want to copy but just re-print into an appropriate device. Uwe Ligges Then I copy it or save as pdf / png / jpeg etc... Thanks a lot for getting back to me regarding this! Best regards, Elena Wilson DBM Consultants Pty Ltd 5-7 Guest Street, Hawthorn, Victoria 3122, Australia T: (61 3) 9819 1555 www.dbmconsultants.com Please consider the environment before printing this email. NOTICE - The information contained in this email may be confidential and/or privileged. You should only read, disclose, re-transmit, copy, distribute, act in reliance on or commercialise the information if you are authorised to do so. If you receive this email communication in error, please notify us immediately by email to d...@dbmcons.com.au, or reply by email direct to the sender and then destroy any electronic or paper copy of this message. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, 4 March 2009 9:42 PM To: Elena Wilson Cc: r-help@r-project.org Subject:Re: [R] problems with exporting a chart Please read the posting guide which asks you to answer basic questions such as: Which R / lattice versions are we talking about? Which is the any format? Are you using the Devices directly or are you using some other way to copy contents of one device into another device? What is the exact, minimal code (including data!) that reproduces your problem? It would be nice if we could copy and paste in it work on our machines. Why do you call plot.new()? Uwe Ligges Elena Wilson wrote: Dear R helpers, I have a problem with exporting a chart (to any format). The graphic device becomes inactive and I get the 'Error: invalid graphics state' error message. I searched the help, web and FAQ but couldn't find the solution. This is my code: I chart a histogram for differences in R2 by sample size (an extract from the data is below). Altogether I have n=2500 observations (n=500 per sample size) Size; Delta_R2 60; 0.0073842 60; 0.0007156 ... 70; 0.0049717 70;
Re: [R] How to dump plots as bas64 strings?
On Wed, Mar 4, 2009 at 9:17 AM, Patrick Meyer pater...@gmail.com wrote: Hello My question might sound awkward, but I am looking for a way to somehow convert a plot in R into a base64 string. Here's an idea, but it is not at all satisfying. 1. write the plot to the harddisk: --- png(toto.png) plot(c(1,2,3)) dev.off() --- 2. somehow reload that file from the disk and transform it into a base64 string: --- bin-readBin(file(toto.png,rb), raw(), n=1000,endian = little) This isn't much of an improvement and does not even address the main concern but as no one has answered note that we can pass the filename as a character string and it will get rb automatically and we can just use raw if we like. Also n can be any size larger than the file size (see ?readBin) so if the file size is 1 or less: readBin(toto.png, raw, n = 1, endian = little) __ 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] Dropping rows conditionally
Have you looked at subset? For example, subset(mdat, !(mdat$C.1== 11)) You will have to add your other cases and there may be a better way to programmatically get it done, but maybe this will help you get started. --- On Thu, 3/5/09, Lazarus Mramba lmra...@kilifi.kemri-wellcome.org wrote: From: Lazarus Mramba lmra...@kilifi.kemri-wellcome.org Subject: [R] Dropping rows conditionally To: r-help@r-project.org Date: Thursday, March 5, 2009, 12:18 AM Dear R-help team, I am getting addicted to using R but keep on getting many challenges on the way especially on data management (data cleaning). I have been wanting to drop all the rows if there values are `NA' or have specific values like 1 or 2 or 3. mdat - matrix(1:21, nrow = 7, ncol=3, byrow=TRUE, dimnames = list(c(row1, row2,row3,row4,row5,row6,row7), c(C.1, C.2, C.3))) mdat-data.frame(mdat) mdat C.1 C.2 C.3 row1 1 2 3 row2 4 5 6 row3 7 8 9 row4 10 11 12 row5 13 14 15 row6 16 17 18 row7 19 20 21 I want to say drop row if value=1 or value =11 or value =20 How do I do that? Kind regards, Lazarus Mramba Junior Statistician P.O Box 986, 80108, Kilifi, Kenya Mobile No. +254721292370 Tel: +254 41 522063 Tel: +254 41 522390 (office extension : 419) This e-mail (including any attachment to it) contains information which is confidential. It is intended only for the use of the named recipient. If you have received this e-mail in error, please let us know by replying to the sender, and immediately delete it from your system. Please note, that in these circumstances, the use, disclosure, distribution or copying of this information is strictly prohibited. We apologize for any inconvenience that may have been caused to you. KEMRI-Wellcome Trust Programmecannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. KEMRI-Wellcome Trust Programme reserves the right to monitor all incoming and outgoing email traffic. Although the Programme has taken reasonable precautions to ensure no viruses are present in emails, it cannot accept responsibility for any loss or damage arising from the use of the email or attachments. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of KEMRI- Wellcome Trust Programme. __ 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] a few scatter plots for a specific correlation value
On 3/5/2009 6:46 AM, June Kim wrote: Hello, Is there a simple way to draw a few random sample scatter plots from a given specific correlation coefficient(say, 0.18)? scatter - function(n=100, r=.18){ require(MASS) mymat - mvrnorm(n, mu=c(0,0), Sigma=matrix(c(1,r,r,1), ncol=2), empirical=TRUE) plot(mymat[,1], mymat[,2]) } par(mfrow=c(2,2)) replicate(4, scatter()) __ 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. -- 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.
Re: [R] Problem using RMySQL and fCalendar
Yohan: First, thanks so much for the virtually instantaneous reponse. I really appreciate it. It seems I now have a different problem. I did an update.packages() and that resulted in getting timeDate package installed. Here is what happens now. Note that as soon as I load RMySQL, I can't print the dateTime object DT. But, I can do math on it and then print the result by turning it into characters. It does seem odd that dt (June 13) converts to DT (June 12th). I assume this has to do with timezones. Perhaps if you tell me exactly where you obtained your RMySQL and timeDate libraries, that would help. I am running Ubuntu (Intrepid). At any rate, this is definitely progress. Again, I appreciate your help. Elizabeth e...@fibonacci:/etc/apt$ R R version 2.7.1 (2008-06-23) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(timeDate) dt-1947-06-13 myFC-America/NewYork DT-timeDate(dt, format=%Y-%m-%d, FinCenter=myFC) DT America/NewYork [1] [1947-06-12 20:00:00] DT + 3600*24 America/NewYork [1] [1947-06-13 20:00:00] library(RMySQL) # For db access DT Error in function (object, ...) : Invalid generic function in 'usemethod' foo-DT + 3600*24 foo Error in function (object, ...) : Invalid generic function in 'usemethod' as.character(foo) [1] 1947-06-13 20:00:00 Yohan Chalabi wrote: EN == Elizabeth Nichols betsy.nich...@plexlogic.com on Thu, 05 Mar 2009 05:45:40 -0500 EN Hello: EN I am trying to use fCalendar for date arithmetic and the EN RMySQL package EN for accessing a MySQL database. The fCalendar math operations EN seem to EN work fine UNTIL I load the RMySQL package. Here is a EN demonstration: EN EN e...@fibonacci:~/Desktop/amCharts/rsa-metrics$ R EN EN R version 2.7.1 (2008-06-23) EN Copyright (C) 2008 The R Foundation for Statistical Computing EN ISBN 3-900051-07-0 EN EN R is free software and comes with ABSOLUTELY NO WARRANTY. EN You are welcome to redistribute it under certain conditions. EN Type 'license()' or 'licence()' for distribution details. EN EN Natural language support but running in an English locale EN EN R is a collaborative project with many contributors. EN Type 'contributors()' for more information and EN 'citation()' on how to cite R or R packages in publications. EN EN Type 'demo()' for some demos, 'help()' for on-line help, or EN 'help.start()' for an HTML browser interface to help. EN Type 'q()' to quit R. EN EN [Previously saved workspace restored] EN EN library(fCalendar, pos=2) # For date math EN Loading required package: MASS EN Loading required package: fUtilities EN Rmetrics Package fUtilities (290.76) loaded. EN Loading required package: fEcofin EN Rmetrics Package fCalendar (270.78.2) loaded. EN The new version of 'fCalendar' has been renamed to 'timeDate' EN dt-1947-06-13 EN myFC-America/NewYork EN DT-timeDate(dt, zone=myFC, FinCenter=myFC) EN DT + 3600 EN America/NewYork EN [1] [1947-06-13 01:00:00] EN library(RMySQL, pos=4) # For db access EN DT + 3600 EN Error in (DT, 3600) : EN no slot of name Data for this object of class timeDate EN In addition: Warning message: EN In (DT, 3600) : EN trying to get slot Data from an object (class timeDate) that EN is not EN an S4 object EN EN EN As you can see, I can do date arithmetic (DT + 3600) before EN I load the EN RMySQL package but not after. The pos arguments to the EN library() EN calls are an unsuccessful attempt to get R to use the Rmetrics EN fCalendar EN package that works instead of whatever gets loaded by RMySQL. EN EN I have Googled until my fingers turned blue and I can't find EN any useful EN information to fix this. Any help would be most appreciated. EN Thanks, EN eanichols Hi Elizabeth, Please note that the new version of 'fCalendar' has been renamed to 'timeDate' I tried your example with the new timeDate package and it worked fine for me. HTH Yohan __ 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 dump plots as bas64 strings?
Here's the solution I'm using now, but it is not very clean: png(out.png) plot(c(1,2,3)) dev.off() system(base64 -w0 out.png out.base64) b64txt - readLines(file(out.base64,rt)) It would be nice to have an internal solution, even if this exactly does what I want. Patrick Gabor Grothendieck wrote: On Wed, Mar 4, 2009 at 9:17 AM, Patrick Meyer pater...@gmail.com wrote: Hello My question might sound awkward, but I am looking for a way to somehow convert a plot in R into a base64 string. Here's an idea, but it is not at all satisfying. 1. write the plot to the harddisk: --- png(toto.png) plot(c(1,2,3)) dev.off() --- 2. somehow reload that file from the disk and transform it into a base64 string: --- bin-readBin(file(toto.png,rb), raw(), n=1000,endian = little) This isn't much of an improvement and does not even address the main concern but as no one has answered note that we can pass the filename as a character string and it will get rb automatically and we can just use raw if we like. Also n can be any size larger than the file size (see ?readBin) so if the file size is 1 or less: readBin(toto.png, raw, n = 1, endian = little) __ 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 editor that will work with Rcmdr
R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ 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] Dropping rows conditionally
There are functions for this purpose: ?na.omit # dispays help page for na.fail, na.omit, na.exclude, na.pass -- David Winsemius On Mar 5, 2009, at 1:18 AM, Lazarus Mramba wrote: Dear R-help team, I am getting addicted to using R but keep on getting many challenges on the way especially on data management (data cleaning). I have been wanting to drop all the rows if there values are `NA' or have specific values like 1 or 2 or 3. mdat - matrix(1:21, nrow = 7, ncol=3, byrow=TRUE, dimnames = list(c(row1, row2,row3,row4,row5,row6,row7), c(C.1, C.2, C.3))) mdat-data.frame(mdat) mdat C.1 C.2 C.3 row1 1 2 3 row2 4 5 6 row3 7 8 9 row4 10 11 12 row5 13 14 15 row6 16 17 18 row7 19 20 21 I want to say drop row if value=1 or value =11 or value =20 How do I do that? Kind regards, Lazarus Mramba Junior Statistician P.O Box 986, 80108, Kilifi, Kenya Mobile No. +254721292370 Tel: +254 41 522063 Tel: +254 41 522390 (office extension : 419) This e-mail (including any attachment to it) contains information which is confidential. It is intended only for the use of the named recipient. If you have received this e-mail in error, please let us know by replying to the sender, and immediately delete it from your system. Please note, that in these circumstances, the use, disclosure, distribution or copying of this information is strictly prohibited. We apologize for any inconvenience that may have been caused to you. KEMRI-Wellcome Trust Programmecannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. KEMRI-Wellcome Trust Programme reserves the right to monitor all incoming and outgoing email traffic. Although the Programme has taken reasonable precautions to ensure no viruses are present in emails, it cannot accept responsibility for any loss or damage arising from the use of the email or attachments. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of KEMRI- Wellcome Trust Programme. __ 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] Doubt Linear Regression
Hello. I have a file with 480 lines but each 6 lines corresponding just one sample. How can can work out the linear regression to each 6 lines? I use the model: model=lm(y~x) Sueli Rodrigues Agronomy Eng. - UNESP Master Degree - USP/ESALQ PPG-Soils and Plants Nutrition Phones(19)93442981 (19)33719762 __ 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] File checking
Hello, How can I check if file is empty in R, if it is, then jump out and read next file; if it isn't, then read through? Thanks a lot for any help. Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] Odp: testing column data against criteria, point by point
Hi r-help-boun...@r-project.org napsal dne 05.03.2009 09:46:17: I am fairly new to R and I would like to do the following, but do not know where to start. Any help or direction would be appreciated. I have a time series of snow depth measurements. I would like to determine the depth of snowfall for each snowfall event. There is noise in the data so I only want to add data values if the subsequent depth is greater than the previous by a certain margin. I am only interested in calculating snow accumulation events. Example data: Timedepth 184.3 284.5 386 486.1 585.8 686.7 787.9 889.1 990 1089 1188 1288 1389.1 1490 1591.2 1689.9 ...... I would like to create a second data frame from the data that looks something like this: EventInitialDepthFinalDepthAccumulationInitialTime FinalTime 184.3905.719 28891.23.21115 ... I would like to write a program that progresses through the depth column, point by point, to test if (i+1) - i x. (where I will set x to exlude the noise in the data). As long as i+1 is greater than or equal to i, then the initial depth stays at the first data point and the final value changes to that in i+n. Once the test is false, this indicates the end of the event, the accumulation is calculated, all values are saved as event X and a new event isstarted. I tried using ifelse(), but I do not know how to move through the data and then save the initial and final values and time stamps in another table. It is probably possible but I would use rle and cumsum # which of the data are increasing ind-rle(c(T,diff(test$depth)0)) # what is first depth of increasing interval first-test$depth[c(1,cumsum(ind$lengths)[!ind$values])] # what is last depth of increasing interval last-test$depth[cumsum(ind$lengths)[ind$values]] # what is accumulation last-first [1] 1.8 4.2 3.2 -3.8 the similar applies to evaluation which are first and last times of events and/or its duration. Regards Petr Thank you very much for your time. Kara __ 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] File checking
Try this: file.info(empty.txt)$size == 0 On Thu, Mar 5, 2009 at 7:43 AM, ling ling metal_lical...@live.com wrote: Hello, How can I check if file is empty in R, if it is, then jump out and read next file; if it isn't, then read through? Thanks a lot for any help. Tammy _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ [[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] subset
Hi, I have a vector x with certain ID numbers in it and want to create a subset from my dataset Y with this vector i.e extract only the data with the given IDs from vector x. example: x [1] 10066924 10207314 10257322 10334594 10348247 and now I want to create subset of dataset assignee with assignee $pdpass == x 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] File checking
?file.info On Thu, Mar 5, 2009 at 7:43 AM, ling ling metal_lical...@live.com wrote: Hello, How can I check if file is empty in R, if it is, then jump out and read next file; if it isn't, then read through? Thanks a lot for any help. Tammy _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ [[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] Doubt Linear Regression
On 3/5/2009 7:53 AM, Sueli Rodrigues wrote: Hello. I have a file with 480 lines but each 6 lines corresponding just one sample. How can can work out the linear regression to each 6 lines? I use the model: model=lm(y~x) mydf - data.frame(X = rnorm(480), Y = rnorm(480)) mydf$SAMPLE - rep(1:80, each=6) by(mydf, mydf$SAMPLE, function(x){summary(lm(Y ~ X, data = x))}) OR lapply(split(mydf, mydf$SAMPLE), function(x){summary(lm(Y ~ X, data = x))}) OR library(nlme) fm1 - lmList(Y ~ X | SAMPLE, mydf) summary(fm1) Sueli Rodrigues Agronomy Eng. - UNESP Master Degree - USP/ESALQ PPG-Soils and Plants Nutrition Phones(19)93442981 (19)33719762 __ 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. -- 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.
Re: [R] R editor that will work with Rcmdr
Dear John, I'm not entirely sure what you have in mind. Any editor or IDE that communicates with the R process and is compatible with the tcltk package will work in parallel with the Rcmdr. That is, when you submit R code from the editor, it will go directly to R and not to the Rcmdr script window. Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin Sent: March-05-09 7:18 AM To: r-help@r-project.org Subject: [R] R editor that will work with Rcmdr R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:10}} __ 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] testing column data against criteria, point by point
Look at these functions. They should give you the building blocks you need: ?diff # returns a vector of length n-1 #it would be a logical vector if wrapped in the appropriate functions #needs to be padded to line up with dataframes ?rle# returns a list with the lengths and values of the repeats # will work on logical vectors If your data is in a dataframe, snowdepth, with column names time and depth, then this might create a difference column in that dataframe: snowdepth$incr - c(0, diff(snowdepth$depth)) And this might give you the be a noise marker: snowdepth$noise - c(FALSE, diff(snowdepth$depth) x) You should also look at the function dput so you can offer reproducible code and data with further questions. -- David Winsemius On Mar 5, 2009, at 3:46 AM, Kara Przeczek wrote: I am fairly new to R and I would like to do the following, but do not know where to start. Any help or direction would be appreciated. I have a time series of snow depth measurements. I would like to determine the depth of snowfall for each snowfall event. There is noise in the data so I only want to add data values if the subsequent depth is greater than the previous by a certain margin. I am only interested in calculating snow accumulation events. Example data: Time depth 184.3 284.5 386 486.1 585.8 686.7 787.9 889.1 990 10 89 11 88 12 88 13 89.1 14 90 15 91.2 16 89.9 ... ... I would like to create a second data frame from the data that looks something like this: EventInitialDepthFinalDepth AccumulationInitialTime FinalTime 184.390 5.7 1 9 288 91.23.2 11 15 ... I would like to write a program that progresses through the depth column, point by point, to test if (i+1) - i x. (where I will set x to exlude the noise in the data). As long as i+1 is greater than or equal to i, then the initial depth stays at the first data point and the final value changes to that in i+n. Once the test is false, this indicates the end of the event, the accumulation is calculated, all values are saved as event X and a new event is started. I tried using ifelse(), but I do not know how to move through the data and then save the initial and final values and time stamps in another table. Thank you very much for your time. Kara __ 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] R editor that will work with Rcmdr
John Fox wrote: Dear John, I'm not entirely sure what you have in mind. Any editor or IDE that communicates with the R process and is compatible with the tcltk package will work in parallel with the Rcmdr. That is, when you submit R code from the editor, it will go directly to R and not to the Rcmdr script window. One fun prospect would be to integrate the Ctext widget as the built-in script editor. Some assembly required though. -p Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin Sent: March-05-09 7:18 AM To: r-help@r-project.org Subject: [R] R editor that will work with Rcmdr R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:10}} __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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] predict.fda - NAs are not allowed in subscripted assignments
Dear R users, I'm trying to perform flexible discriminant analysis (fda) with method bruto. I applied the fda function on my training data: bruto.fda - fda (fda.formula,data=train.data) where fda.formula is: PRES ~ VA_D123 + VA_D124 + VA_D127 + VA_DARU + VA_DCAN + VA_DFON + VA_DLAP + VA_DRID + VA_DRIR + VA_VVEG + VA_WDIN + VA_DIF3 + VA_DIF4 + VA_DIF5 + VA_CAAC + VA_CABC + VA_CABO + VA_CACA + VA_CACC + VA_CAMP + VA_CAPA + VA_CAUB + VA_CMCA + VA_CMIN + VA_CMLA + VA_CMMU + VA_CMRO + VA_D109 + VA_D110 + VA_D111 + VA_D112 + VA_D113 + VA_D114 + VA_D115 + VA_D116 + VA_D118 + VA_D119 + VA_D120 + VA_D121 and obtained this result: Call: fda(formula = fda.formula, data = train.data) Dimension: 1 Percent Between-Group Variance Explained: v1 100 Degrees of Freedom (per dimension): 4 Training Misclassification Error: 0 ( N = 4 ) My training data are: 'data.frame': 4 obs. of 41 variables: $ VA_D123: num 120 240 610 340 $ VA_D124: num 2870 3000 1900 1170 $ VA_D127: num 430 1770 690 1470 $ VA_DARU: num 69 62 129 57 $ VA_DCAN: num 664 356 667 131 $ VA_DFON: num 235 650 361 489 $ VA_DLAP: num 30 2 242 219 $ VA_DRID: num 1 0 4 7 $ VA_DRIR: num 325 117 46 132 $ VA_VVEG: num 1.5 4.5 4.1 1.5 $ VA_WDIN: num 210 20 165 85 $ VA_DIF3: num 138 306 154 240 $ VA_DIF4: num 47 0 4 7 $ VA_DIF5: num 1 737 218 527 $ VA_CAAC: num0.0 258.7 0.0 88.3 $ VA_CABC: num 117.9 137.6 79.8 38.1 $ VA_CABO: num 147.4 215.9 99.8 95.2 $ VA_CACA: num 117.9 163.0 79.8 19.0 $ VA_CACC: num 132.7 176.2 89.8 38.1 $ VA_CAMP: num 147.4 194.6 99.8 85.7 $ VA_CAPA: num0.0 175.5 0.0 66.7 $ VA_CAUB: num 117.9 178.9 79.8 57.1 $ VA_CMCA: num 132.65 4.76 89.80 0.00 $ VA_CMIN: num 132.7 23.8 89.8 0.0 $ VA_CMLA: num 147.4 45.6 99.8 0.0 $ VA_CMMU: num 132.65 4.76 89.80 0.00 $ VA_CMRO: num 0 0 0 0 $ VA_D109: num 3610 2740 4200 3420 $ VA_D110: num 310 3780 2960 4850 $ VA_D111: num 12930 7980 14630 9350 $ VA_D112: num 1580 6640 2460 4550 $ VA_D113: num 1030 10 200 370 $ VA_D114: num 450 1590 1480 670 $ VA_D115: num 10 20 0 0 $ VA_D116: num 780 1120 570 410 $ VA_D118: num 1690 3260 1560 3930 $ VA_D119: num 13730 8660 15380 10070 $ VA_D120: num 1270 70 570 360 $ VA_D121: num 350 410 140 270 $ CAT: num 254935 294186 296143 306054 $ PRES : num 1 1 0 0 Now I want to predict fitted values for my new.data 'data.frame': 418507 obs. of 41 variables: $ VA_D123: num 2560 2520 2480 2440 2400 2360 2320 2280 2230 2190 ... $ VA_D124: num 3410 3420 3430 3440 3460 3470 3480 3490 3500 3510 ... $ VA_D127: num 1710 1700 1690 1680 1670 1650 1640 1630 1610 1580 ... $ VA_DARU: num 29 24 19 14 9 4 1 6 11 16 ... $ VA_DCAN: num 882 881 879 878 877 876 875 873 872 871 ... $ VA_DFON: num 1742 1741 1740 1739 1738 ... $ VA_DLAP: num 346 341 336 331 326 321 316 311 306 301 ... $ VA_DRID: num 16 18 19 21 22 21 19 18 16 15 ... $ VA_DRIR: num 1419 1420 1421 1422 1423 ... $ VA_VVEG: num 1 2 2 2 1 1 4 4 4 4 ... $ VA_WDIN: num 327 340 353 367 380 393 406 420 434 447 ... $ VA_DIF3: num 36 32 29 26 23 21 19 18 16 15 ... $ VA_DIF4: num 119 114 109 104 99 94 89 84 79 74 ... $ VA_DIF5: num 2136 2133 2130 2127 2124 ... $ VA_CAAC: num 12.6 25.2 22.1 25.2 129.3 ... $ VA_CABC: num 0.0 0.0 0.0 23.8 54.0 ... $ VA_CABO: num 17.5 17.5 17.5 46.5 88.0 ... $ VA_CACA: num 17.5 17.5 17.5 39.7 98.4 ... $ VA_CACC: num 20.0 20.0 20.0 38.5 73.2 ... $ VA_CAMP: num 17.5 17.5 17.5 43.1 102.7 ... $ VA_CAPA: num 20.0 20.0 20.0 45.4 105.7 ... $ VA_CAUB: num 15.0 15.0 15.0 20.4 45.4 ... $ VA_CMCA: num 0 0 0 0 0 0 0 0 0 0 ... $ VA_CMIN: num 0 0 0 0 0 0 0 0 0 0 ... $ VA_CMLA: num 0.0 0.0 0.0 13.6 36.3 ... $ VA_CMMU: num 0 0 0 0 0 0 0 0 0 0 ... $ VA_CMRO: num 0 0 0 0 0 ... $ VA_D109: num 5050 5010 4960 4920 4880 4840 4800 4760 4720 4680 ... $ VA_D110: num 5000 4970 4940 4910 4880 4850 4820 4790 4760 4730 ... $ VA_D111: num 2600 2550 2500 2450 2400 2350 2300 2250 2200 2150 ... $ VA_D112: num 19400 19350 19300 19250 19200 ... $ VA_D113: num 770 740 710 680 650 620 590 570 540 520 ... $ VA_D114: num 480 450 420 400 360 310 260 210 160 110 ... $ VA_D115: num 0 0 0 0 0 0 50 100 100 120 ... $ VA_D116: num 1050 1010 970 940 910 880 850 820 790 760 ... $ VA_D118: num 620 630 640 650 670 690 720 750 780 810 ... $ VA_D119: num 16320 16270 16220 16170 16120 ... $ VA_D120: num 1980 1940 1900 1860 1820 1780 1730 1690 1660 1630 ... $ VA_D121: num 230 240 250 240 230 210 210 220 230 250 ... $ CAT: num 1 2 3 4 5 6 7 8 9 10 ... $ PRES : num NA NA NA NA NA NA NA NA NA NA ... I'm using: bruto.fitted - predict(bruto.fda, new.data) but obtained the following message: Error in mindist[l] - ndist[l] : NAs are not allowed in subscripted assignments What does it means? I can I solve the problem? P.S The same
Re: [R] subset
Hi Yannick, yannick misteli wrote: I have a vector x with certain ID numbers in it and want to create a subset from my dataset Y with this vector i.e extract only the data with the given IDs from vector x. example: x [1] 10066924 10207314 10257322 10334594 10348247 and now I want to create subset of dataset assignee with assignee$pdpass == x Try this: assignee.1-subset(assignee, pdpass %in% x) Kind regards, Kimmo __ 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] Odp: subset
Hi r-help-boun...@r-project.org napsal dne 05.03.2009 14:00:25: Hi, I have a vector x with certain ID numbers in it and want to create a subset from my dataset Y with this vector i.e extract only the data with the given IDs from vector x. example: x [1] 10066924 10207314 10257322 10334594 10348247 and now I want to create subset of dataset assignee with assignee $pdpass == x Use %in% operator. Regards Petr 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. __ 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] portable R editor
Hi Werner, Could you to post here details about the Tinn-R truly portable with JauntePE? I think it will be also useful for all Tinn-R users, like me. ;-) Many thanks, JCFaria Werner W. wrote: Many, many thanks for all the answers! Notepad++ looks very promising although it does not have a project file management facility. But it has a very clean appearance. I'll have to look into SciTE which also sounds quite good. There seem to be some good alternatives. Meanwhile, I found a freeware application which helps to make Tinn-R truly portable: JauntePE (http://www.portablefreeware.com/?id=1452) virtualizes access to the registry and file system and can easily be used to make also the ini settings portable. Thus, everything will be on the USB stick. Thanks again, Werner -- View this message in context: http://www.nabble.com/portable-R-editor-tp22291017p22351901.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] including tabular information with a plot in R Graphics
R User R User wrote: Hi all, I have a presentation problem that I cannot find a solution to in the documetnation. I have a nice barplot. Below this I would also like a table with some information relating to the plot. My idea was to have the plot and table on the same graphics window so I can output them as an image file for a report. Does anybody know how to include tabular information from a dataset or table into the graphics device? Is there a better/more correct way to output tables and graphics to a single file? Thanks very much, Richie The most general approach I've found is to use LaTeX, pre-processing the graphic to insert a table, creating a new ps or pdf file at a desired marker symbol you have put into the graphic. Details especially for Linux users are at http://biostat.mc.vanderbilt.edu/PsFrag. If using Windows and you are comfortable installing and using Perl, the instructions are also helpful. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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 on netbooks et al?
I've installed Ubuntu, Emacs, and R on my Samsung NC10 with 2 GB RAM. I think the keyboard is very usable on the NC10, and it has about 5-7 hours of battery life, which is also nice. R runs just fine on it. I'd consider paying extra for the Samsung just for the keyboard. herrdittm...@yahoo.co.uk wrote: Dear useRs, With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? Many thanks, Bernd __ 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] identify() and postscript output
In the following, I'm fitting a logistic regression model, and using car:::influencePlot. When I run the latter with output to the screen, it calls identify() that lets me label observations with large CookD. However, if I use postscript() to get .eps output, identify() seems not to be called at all. If instead, I use dev.copy2eps() after getting output to the screen, the point labels do not appear in the resulting .eps graph. Why? Is there a workaround? library(vcd) data(Arthritis) # define Better Arthritis$Better - Arthritis$Improved 'None' arth.mod1 - glm(Better ~ Age + Sex + Treatment , data=Arthritis, family='binomial') library(car) # influence plot #postscript(file=arthritis-diag2.eps, paper=special, height=6, width=6, onefile=TRUE, horizontal=FALSE) influencePlot(arth.mod1, main=Arthritis data: influencePlot) #dev.off() -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ 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] portable R editor
JauntePE is really easy to use. It does not take any particular skill. Just launch the main application, click on the Lauch JPE Quickie Button and it will guide you through the process. I left everything with the default settings. In brief, one starts the Tinn-R installer once from within JPE probably to check which folders, files, and registry entries are generated. Then, again from within JPE, one starts the now on the portable media installed Tinn-R application and finally the entire application can be packaged up which probably generates the starter and virtualization files within the Tinn-R folder. I realized that startup of Tinn-R is now slower and I haven't worked with that installation seriously yet but everything seems all right so far. Regards, Werner jcfaria wrote: Could you to post here details about the Tinn-R truly portable with JauntePE? I think it will be also useful for all Tinn-R users, like me. ;-) Many thanks, JCFaria -- View this message in context: http://www.nabble.com/portable-R-editor-tp22291017p22352524.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] Odp: nice way to find or not a value (problem with numeric(0))
Hello Petr, In fact spec is data.frame with a column called code (containing numerical values) and some other columns called data1, data2, ... containing data for each equipment (that is for each code). But I don't have the data for all my devices. It means that some 'code' are not in spec$Code. In that case I want to assign a default value to the data. for example : spec$Code spec$data1 4 12.5 820.2 Then, with code=4 spec$data1[spec$Code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) gives 12.5 But with code=654, I get numeric(0) instead of 1 because this value is not in spec$Code and returns numeric(0). I hope it is clearer (is it ?) and that you could find a nice way to write my test (the if-test works but is not very elegant). Thanks in adance for you help, Ptit Bleu. Petr Pikal wrote: Hi r-help-boun...@r-project.org napsal dne 04.03.2009 09:11:06: Hello, I have a data.frame called spec containing data about samples. But I don't have these data for all my samples. So if I have data (that is code of the sample is in spec$Code), I would like to assign data1 to the variable m. If I don't have this data, I would like to assign 1 to m. I tried this : m-spec$data1[spec$Code==code]*(code %in%specmodules$Code) + 1*(!code %in% specmodules$Code) It works when I have the data but if it is not the case I get numeric(0) instead of 1. I finally use the following command. It works but I'm sure there is a more elegant way. if (code %in%spec$Code) m-spec$data1[spec$Code==code] else m-1 It is a bit cryptic what do you want. Above version shall not work as it takes only one logical value but you probably have vector of values. (We do not know code, spec$Code or any other data you have). when I try your first construction with some values I have I get sensible results so without trying to find out how your data really look like I suggest you to inspect it more closely and/or provide some working example demonstrating what you did, what is the result and how the result shall look like. zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 50 10 1 120 80 50 20 zdrz$otac[5]-NA zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 50 1 1 120 80 50 20 zdrz$sklon[4]-Inf zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 Inf 1 1 120 80 50 20 zdrz$sklon[4]-NA zdrz$sklon*zdrz$otac %in% c(.6,1.2,2)+1*!(zdrz$otac %in% c(.6,1.2,2)) [1] 110 80 50 NA 1 1 120 80 50 20 Regards Petr Is there a way to avoid an if-test ? Thanks for your help, Have a good day, Ptit Bleu. -- View this message in context: http://www.nabble.com/nice-way-to-find-or-not-a- value-%28problem-with-numeric%280%29%29-tp22325406p22325406.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. -- View this message in context: http://www.nabble.com/nice-way-to-find-or-not-a-value-%28problem-with-numeric%280%29%29-tp22325406p22352529.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] RES: R on netbooks et al?
I use it on an ASUS EEE 701 PC! It works with some limitation, because this model have only 512mb of RAM. But it is working fine. The OS is Windows XP. I think that the better netbooks is one from HP, this netbook have an normal keyboard. Atenciosamente, Leandro Lins Marino Centro de Avaliação Fundação CESGRANRIO Rua Santa Alexandrina, 1011 - 2º andar Rio de Janeiro, RJ - CEP: 20261-903 R (21) 2103-9600 R.:236 ( (21) 8777-7907 ( lean...@cesgranrio.org.br Aquele que suporta o peso da sociedade é precisamente aquele que obtém as menores vantagens. (SMITH, Adam) Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE -Mensagem original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Em nome de Erik Iverson Enviada em: quinta-feira, 5 de março de 2009 11:03 Para: herrdittm...@yahoo.co.uk Cc: r-help@r-project.org Assunto: Re: [R] R on netbooks et al? I've installed Ubuntu, Emacs, and R on my Samsung NC10 with 2 GB RAM. I think the keyboard is very usable on the NC10, and it has about 5-7 hours of battery life, which is also nice. R runs just fine on it. I'd consider paying extra for the Samsung just for the keyboard. herrdittm...@yahoo.co.uk wrote: Dear useRs, With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? Many thanks, Bernd __ 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-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] dividing ts objects of different frequencies
Stephen J. Barr stephenjb...@gmail.com writes: I have two time series (ts) objects, 1 is yearly (population) and the other is quarterly (bankruptcy statistics). I would like to produce a quarterly time series object that consists of bankruptcy/population. Is there a pre-built function to intelligently divide these time series: What you need to do is create a quarterly population series, then divide it into your bankruptcy series. The only nice way I know to do this is to use the convert() function from my tis package. Here is it's help document: convert package:tis R Documentation Time scale conversions for time series Description: Convert 'tis' series from one frequency to another using a variety of algorithms. Usage: convert(x, tif, method = constant, observed. = observed(x), basis. = basis(x), ignore = F) Arguments: x: a univariate or multivariate 'tis' series. Missing values (NAs) are ignored. tif: a number or a string indicating the desired ti frequency of the return series. See 'help(ti))' for details. method: method by which the conversion is done: one of discrete, constant, linear, or cubic. Note that this argument is effectively ignored if 'observed.' is high or low, as the discrete method is the only one supported for that setting. observed.: observed attribute of the input series: one of beginning, end, high, low, summed, annualized, or averaged. If this argument is not supplied and observed('x') != NULL it will be used. The output series will also have this observed attribute. basis.: daily or business. If this argument is not supplied and basis('x') != NULL it will be used. The output series will also have this basis attribute. ignore: governs how missing (partial period) values at the beginning and/or end of the series are handled. For method == discrete or constant and ignore == T, input values that cover only part the first and/or last output time intervals will still result in output values for those intervals. This can be problematic, especially for observed == summed, as it can lead to atypical values for the first and/or last periods of the output series. Details: This function is a close imitation of the way FAME handles time scale conversions. See the chapter on Time Scale Conversion in the Users Guide to Fame if the explanation given here is not detailed enough. Start with some definitions. Combining values of a higher frequency input series to create a lower frequency output series is known as 'aggregation'. Doing the opposite is known as 'disaggregation'. If observed == high or low, the discrete method is always used. Disaggration for discrete series: (i) for observed == beginning (end), the first (last) output period that begins (ends) in a particular input period is assigned the value of that input period. All other output periods that begin (end) in that input period are NA. (ii) for observed == high, low, summed or averaged, all output periods that end in a particular input period are assigned the same value. For summed, that value is the input period value divided by the number of output periods that end in the input period, while for high, low and averaged series, the output period values are the same as the corresponding input period values. Aggregation for discrete series: (i) for observed == beginning (end), the output period is assigned the value of the first (last) input period that begins (ends) in the output period. (ii) for observed == high (low), the output period is assigned the value of the maximum (minimum) of all the input values for periods that end in the output period. (iii) for observed == summed (averaged), the output value is the sum (average) of all the input values for periods that end in the output period. Methods constant, linear, and cubic all work by constructing a continuous function F(t) and then reading off the appropriate point-in-time values if observed == beginning or end, or by integrating F(t) over the output intervals when observed == summed, or by integrating F(t) over the output intervals and dividing by the lengths of those intervals when observed == averaged. The unit of time itself is given by the 'basis' argument. The form of F(t) is determined by the conversion method. For constant conversions, F(t) is a step function with jumps at the boundaries of the input periods. If the first and/or last input periods only partly cover an output period, F is linearly extended to cover the first and last output periods as
[R] dummy variable encoding
Hi, can anyone tell me why an encoding of 1/2 for a dummy variable for two groups (e.g. gender) seems to be preferred over 0/1? It's been bugging me for a while, 0/1 seems more natural, but I have been told (without explanation) that 1/2 is better. Why? -- aleblanc __ 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] identify() and postscript output
From the help page: Details identify is a generic function, and only the default method is described here. identify is only supported on screen devices such as X11, windows and quartz. On other devices the call will do nothing. Why not collect the specifics of the identified points and then replot to your chosen output device perhaps with a different color or a text label? identify should return a value that can be used for that purpose. The help page provides an example that should be modifiable for that purpose. -- David Winsemius On Mar 5, 2009, at 9:18 AM, Michael Friendly wrote: In the following, I'm fitting a logistic regression model, and using car:::influencePlot. When I run the latter with output to the screen, it calls identify() that lets me label observations with large CookD. However, if I use postscript() to get .eps output, identify() seems not to be called at all. If instead, I use dev.copy2eps() after getting output to the screen, the point labels do not appear in the resulting .eps graph. Why? Is there a workaround? library(vcd) data(Arthritis) # define Better Arthritis$Better - Arthritis$Improved 'None' arth.mod1 - glm(Better ~ Age + Sex + Treatment , data=Arthritis, family='binomial') library(car) # influence plot #postscript(file=arthritis-diag2.eps, paper=special, height=6, width=6, onefile=TRUE, horizontal=FALSE) influencePlot(arth.mod1, main=Arthritis data: influencePlot) #dev.off() -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ 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] programing for partial maximum likelihood for cox models with two covariate
dears, I like two write a program with R to estimate the coefficients of covariate,I like two know the original program for this programing for partial maximum likelihood for cox models with two co variate. I did it with coxph command, thanks [[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] character string as object name
Can someone please tell me why the following (last line) doesn't work (as I expect it to :-) library(quantmod) a = getSymbols(MSFT,from=2009-3-01) a MSFT eval(as.name(a)) MSFT$MSFT.Adjusted b=paste(a,'$MSFT.Adjusted',sep='') b eval(as.name(b)) Why does this last line not work the way the earlier eval does? 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] Fast Fourier Transform w.r.t. CreditRisk+
schmway and morgan time series analysis with R examples is a good intro to fourier analysis. Also there are probably references in the help for ?fft Stephen On Thu, Mar 5, 2009 at 5:48 AM, Maithili Shiva maithili_sh...@yahoo.com wrote: Dear R Helpers, Is there any literaure available (including R code) on Fast Fourier Transform being used in CreditRisk+? I need to learn how to apply the Fast Fourier Transform. I agree I am too vaue in my question and sincerely apologize for the same, but I am not able to understand as to where do I start for this particular assignment. I tried to search google for CRAN and Fast Fourier Transform, but I got something for FFT image. Basically I need to understand what is Fast Fourier Transform is and its use in CreditRisk+? With regards and tahnking in advance Maithili __ 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. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ 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] character string as object name
b is character string: as.name(b) `MSFT$MSFT.Adjusted` Note the backticks: that is a valid (if non-syntatatic) name, but you don't have an object of that name. On Thu, 5 Mar 2009, Fuchs Ira wrote: Can someone please tell me why the following (last line) doesn't work (as I expect it to :-) The question is rather why you are misinformed about how it works. Since you didn't explain how you think it does work, we have little idea what your error was. If it helps, MSFT$MSFT.Adjusted is a call (to `$`). It also helps to explain what you are trying to do rather than just what you did. library(quantmod) a = getSymbols(MSFT,from=2009-3-01) a MSFT eval(as.name(a)) MSFT$MSFT.Adjusted b=paste(a,'$MSFT.Adjusted',sep='') b eval(as.name(b)) Why does this last line not work the way the earlier eval does? 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. -- 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] Time Series - ARIMA differencing problem
Hi, I have been using this website ( http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm ) to help me to fit ARIMA models to my data. At the moment I have two possible methods to use. Method 1 If I use arima(ts.data, order=c(1,2,0), xreg=1:length(ts.data)) then the wrong value for the intercept/mean is given (checked on SPSS and Minitab) and also, this is produced In sqrt(diag(x$var.coef)) : NaNs produced Which means that the t-values (for the coefficients) are NaNs, which in turn means that the p-values are NaNs. Although, using this method gives the correct forecast (using predict) and enables ts.plot to show the forecast and 95% CI's. Method 2 If I use diff(diff(ts.dat)) and then apply an ARIMA(1,0,0) to it, then this gives the correct coefficients but the forecasts are wrong (ie they are flat and do not follow the trend). Could anyone think of a way to get both the coefficients AND the forecasts correct? Thanks. -- View this message in context: http://www.nabble.com/Time-Series---ARIMA-differencing-problem-tp22354071p22354071.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] Fast Fourier Transform w.r.t. CreditRisk+
Hello, You have a link on the subject here: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1122844 The author has extra literature and code on the subject. Also, there was a thread in R-SIG-Finance list on the subject a few months ago. Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Thu, 2009-03-05 at 03:48 -0800, Maithili Shiva wrote: Dear R Helpers, Is there any literaure available (including R code) on Fast Fourier Transform being used in CreditRisk+? I need to learn how to apply the Fast Fourier Transform. I agree I am too vaue in my question and sincerely apologize for the same, but I am not able to understand as to where do I start for this particular assignment. I tried to search google for CRAN and Fast Fourier Transform, but I got something for FFT image. Basically I need to understand what is Fast Fourier Transform is and its use in CreditRisk+? With regards and tahnking in advance Maithili __ 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] FW: flow control
William Dunlap wrote: The help page for ?for says that: The index seq in a for loop is evaluated at the start of the loop; changing it subsequently does not affect the loop. The variable var has the same type as seq, and is read-only: assigning to it does not alter seq. The help file is not right when seq is a list() or other recursive type. In that case var has the type of seq[[i]] where i is the current iteration count. (I think this is true in general, since [ and [[ act the same for nonrecursive types when the indices are such that a scalar would be returned. However that explanation is unnecessarily complicated in the nonrecursive case.) Also, the variable var is not really read-only. You can alter it but it gets reset to the next value in seq at the start of each iteration. You cannot affect the meaning of 'next' to force it to, e.g, omit or repeat iterations. Thank. We've put something more sensible into R-devel. Take a look at http://svn.r-project.org/R/trunk/src/library/base/man/Control.Rd -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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] Does R have function or method to finish my task?
Dear all, Does R have function or method to finish the following task. Say i have a dataset. The response variable is Y, and the indepedent variables are X1, X2, X3, and YEAR. See an example. Y X1X2X3 X4YEAR 13.4 2.8 3.5 2.5 1.8 1990 10.51.82.4 2 3 1991 . In ecology, Y may be not only related with X1, X2, X3 in the same year as Y, but also may be related with X1, X2, X3 and Y in the previous one , two or more years as Y. But which year has the closest relationship is not know and this may be one of the analysis aim. Take Year=1995 as an example, Y_1995 may be related with X1_1995 , X2_1995 , X3_1995, X1_1994 , X2_1994 , X3_1994, Y_1994, (previous one year) X1_1993 , X2_1993 , X3_1993, Y_1993 (previous two years) ... ... (previous more years) Pay attention to the situation that Y itself may also affect its own value of the next several years. Anybody knows whether R have functions or methods to finish the above task. I hope i have explained it clearly. Any suggestions or help are greatly appreciated. [[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] character string as object name
Does the first item on page 52 of 'The R Inferno' explain it for you? If not, can you give some hints about how to improve the explanation? 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) Fuchs Ira wrote: Can someone please tell me why the following (last line) doesn't work (as I expect it to :-) library(quantmod) a = getSymbols(MSFT,from=2009-3-01) a MSFT eval(as.name(a)) MSFT$MSFT.Adjusted b=paste(a,'$MSFT.Adjusted',sep='') b eval(as.name(b)) Why does this last line not work the way the earlier eval does? 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. __ 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 on netbooks et al?
Jim == Jim Lemon j...@bitwrit.com.au writes: I've got R on my little EeePC as well. Great for most jobs and I highly recommend a DC/DC convertor for plugging into your car's cigarette lighter to get around the crap battery problem. I run R on my Eee PC as well - no problems there. At less than $400 US and just barely larger than my copy of Venables and Ripley, it has been real value. Eee PC 1000HA, 5 hour battery life (I've never used it long enough to run out of juice), 95% sized keyboard (a bit cramped), dual 1.6GHz atom processors, 140 Gbyte drive, 1 Gbyte ram, R, emacs, IDL, TeX/LaTeX, cygwin, python, openoffice, acrobat, msoffice. Plus, with external monitor, keyboard and mouse, it functions well as a full workstation for me at home. Mike __ 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] dummy variable encoding
can anyone tell me why an encoding of 1/2 for a dummy variable for two groups (e.g. gender) seems to be preferred over 0/1? It's been bugging me for a while, 0/1 seems more natural, but I have been told (without explanation) that 1/2 is better. Why? The best encoding depends upon which language you would like to manipulate the variable in. In R, genders are most naturally represented as factors. That means that in an external data source (like a spreadsheet of data), you should ideally have the gender recorded as human-understandable text (male and female, or M and F). Once the data is read into R, by default R will convert the string to factors (keeping the human readable labels). This way you avoid having to remember that 1 means male (or whatever). If you were manipulating the data in a different language that didn't have factors, then it might be more appropriate to use an integer. Which integers you use doesn't matter, you need to have a look-up table to know what each number refers to, whatever you choose. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ 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
Hi All, I have about one hundred patients and all the patients had their glucose measured on three different days. The days are all the same for all he patients. So I have three measurement for each patient . I want to know whether the day when the glucose was measured has an effect on the measurements. I was thinking to use a single factor analysis of variance but I am not sure how to do it in R. any other suggestion on dealing with this problem is welcome. Thanks, -- View this message in context: http://www.nabble.com/ANOVA-tp22353919p22353919.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 2.9.0 is scheduled for April 17
This is to announce that we plan to release R version 2.8.0 on Friday, April 17, 2009. Release procedures start Tuesday March 17. The detailed schedule can be found on http://developer.r-project.org The source tarballs will be made available daily (barring build troubles) and the tarballs can be picked up at http://cran.r-project.org/src/base-prerelease/ a little later. Binary builds are expected to appear starting Friday, March 20. For the Core Team Peter Dalgaard -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 ___ r-annou...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ 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] Time Series - ARIMA differencing problem
Hi, I have been using this website ( http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm ) to help me to fit ARIMA models to my data. At the moment I have two possible methods to use. Method 1 If I use arima(ts.data, order=c(1,2,0), xreg=1:length(ts.data)) then the wrong value for the intercept/mean is given (checked on SPSS and Minitab) and also, this is produced In sqrt(diag(x$var.coef)) : NaNs produced Which means that the t-values (for the coefficients) are NaNs, which in turn means that the p-values are NaNs. Although, using this method gives the correct forecast (using predict) and enables ts.plot to show the forecast and 95% CI's. Method 2 If I use diff(diff(ts.dat)) and then apply an ARIMA(1,0,0) to it, then this gives the correct coefficients but the forecasts are wrong (ie they are flat and do not follow the trend). Could anyone think of a way to get both the coefficients AND the forecasts correct? Thanks. -- View this message in context: http://www.nabble.com/Time-Series---ARIMA-differencing-problem-tp22353903p22353903.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] missings
I have a file where the missings are coded as NA or blank. how can I tell R to read the data set and to consider the missings NA or a blank. I tried the following data-read.table(data.txt, sep='\t', header=T, na.strings=c(NA,)) is it correct? I am new to R and I am not sure if R is condisering the blanks as missings in the above. Thanks for the help -- View this message in context: http://www.nabble.com/missings-tp22354037p22354037.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] R editor that will work with Rcmdr
Peter, I see that you do not think Rcmdr should be used to as a program editor for R code. I understand that modifying Rmcdr to make it an editor would be an enormous undertaking, nevertheless, having a program editor that works with Rcmdr would be a wonderful addition to what is already an outstanding package. It would be nice to know that my R code was automatically formatted as I enter it into Rcmdr. John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) John Fox j...@mcmaster.ca 3/5/2009 11:18 AM Dear Peter, I've resisted trying to make the script window a full-fledged editor but it's been moving in that direction (right-click context menu, line wrapping, etc). I don't think that the Ctext widget is currently provided via the tcltk package. I still think that people who want a real programming editor are better off not using the Rcmdr for that purpose. Best, John -Original Message- From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk] Sent: March-05-09 8:29 AM To: John Fox Cc: 'John Sorkin'; r-help@r-project.org Subject: Re: [R] R editor that will work with Rcmdr John Fox wrote: Dear John, I'm not entirely sure what you have in mind. Any editor or IDE that communicates with the R process and is compatible with the tcltk package will work in parallel with the Rcmdr. That is, when you submit R code from the editor, it will go directly to R and not to the Rcmdr script window. One fun prospect would be to integrate the Ctext widget as the built-in script editor. Some assembly required though. -p Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin Sent: March-05-09 7:18 AM To: r-help@r-project.org Subject: [R] R editor that will work with Rcmdr R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:10}} __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ 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] Sending an alert / email when R finished?
Hi, Not sure if this is the best section to post it in. I'm doing lengthy runs on a 30GB data set - I would like to know if it is possible through any means for R to send an email / text message or anything when it has finished running a source file. Any suggestions would be appreciated. Nick. -- View this message in context: http://www.nabble.com/Sending-an-alert---email-when-R-finished--tp22354235p22354235.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] Boostrapping
Hi Everybody, I am trying to use the no parametric boostrapping methos to validate a logistic regression model. My idea is to randomly select the observations of a dataset and estimating the coefficients of the model for each random selection. Do you have any idea about that? Please, Let me know. Marcella -- View this message in context: http://www.nabble.com/Boostrapping-tp22354346p22354346.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] R editor that will work with Rcmdr
Dear Peter, I've resisted trying to make the script window a full-fledged editor but it's been moving in that direction (right-click context menu, line wrapping, etc). I don't think that the Ctext widget is currently provided via the tcltk package. I still think that people who want a real programming editor are better off not using the Rcmdr for that purpose. Best, John -Original Message- From: Peter Dalgaard [mailto:p.dalga...@biostat.ku.dk] Sent: March-05-09 8:29 AM To: John Fox Cc: 'John Sorkin'; r-help@r-project.org Subject: Re: [R] R editor that will work with Rcmdr John Fox wrote: Dear John, I'm not entirely sure what you have in mind. Any editor or IDE that communicates with the R process and is compatible with the tcltk package will work in parallel with the Rcmdr. That is, when you submit R code from the editor, it will go directly to R and not to the Rcmdr script window. One fun prospect would be to integrate the Ctext widget as the built-in script editor. Some assembly required though. -p Regards, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin Sent: March-05-09 7:18 AM To: r-help@r-project.org Subject: [R] R editor that will work with Rcmdr R 2.8.1 Windows XP Fedora Linux. I would like a suggestion for an editor that will help format my R code that can be used with Rcmdr. Is there anything I need to know about running or installing an editor when using Rcmdr? I run R on both Windows and Linux (Fedora). Thank you, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:10}} __ 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. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ 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] hatvalues?
I am struiggling a bit with this function 'hatvalues'. I would like a little more undrestanding than taking the black-box and using the values. I looked at the Fortran source and it is quite opaque to me. So I am asking for some help in understanding the theory. First, I take the simplest case of a single variant. For this I turn o John Fox's book, Applied Regression Analysis and Generalized Linear Models, p 245 and generate this 'R' code: library(car) attach(Davis) # remove the NA's narepwt - repwt[!is.na(repwt)] meanrw - mean(narepwt) drw - narepwt - meanrw ssrw - sum(drw * drw) h - 1/length(narepwt) + (drw * drw)/ssrw h This gives me a array of values the largest of which is order(h, decreasing=TRUE) [1] 21 52 17 93 30 62 158 113 175 131 182 29 106 125 123 146 91 99 So the largest hatvalue is h[21] [1] 0.1041207 Which doesn't match the 0.714 value that is reported in the book but I will probably take that up with the author later. Then I use more of 'R' and I get fit - lm(weight ~ repwt) hr - hatvalues(fit) hr[21] 21 0.1041207 So this matches which is reasusing. My question is this, given the QR transformation and the residuals derived from that transformation what is a simple matrix formula for the hatvalues? From http://en.wikipedia.org/wiki/Linear_regression I get residuals = y - Hy = y(I - H) or H = -(residuals/y - I) fit - lm(weight ~ repwt) h - -(residuals(fit)/weight[as.numeric(names(residuals(fit)))] - diag(1,length(residuals(fit)), length(residuals(fit This generates a matrix but I cannot see any coerrelation between this hat-matrix and the return from hatvalues. Comments? Thank you. Kevin __ 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] programing for partial maximum likelihood for cox models with two covariate
On Mar 5, 2009, at 10:08 AM, Kourosh Ks wrote: dears, I like two write a program with R to estimate the coefficients of covariate,I like two know the original program for this programing for partial maximum likelihood for cox models with two co variate. I did it with coxph command, library(survival) Loading required package: splines coxph function (formula = formula(data), data = parent.frame(), weights, subset, na.action, init, control, method = c(efron, breslow, exact), singular.ok = TRUE, robust = FALSE, model = FALSE, x = FALSE, y = TRUE, ...) { method - match.arg(method) call - match.call() m - match.call(expand.dots = FALSE) temp - c(, formula, data, weights, subset, na.action) m - m[match(temp, names(m), nomatch = 0)] special - c(strata, cluster) Terms - if (missing(data)) Output that goes on for about 3.5 pages was truncated -- David Winsemius thanks [[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] character string as object name
I thought that's what I had: b [1] MSFT$MSFT.Adjusted eval(as.name(b)) Error in eval(expr, envir, enclos) : object MSFT$MSFT.Adjusted not found However, Patrick's suggestion of eliminating the '$' gave me what I was looking for: b=paste(a,'.Adjusted',sep='') eval(as.name(a))[,b] MSFT.Adjusted 2009-03-02 15.79 2009-03-03 15.88 2009-03-04 16.12 Thanks for your help. On Mar 5, 2009, at 11:33 AM, Wacek Kusnierczyk wrote: Fuchs Ira wrote: Can someone please tell me why the following (last line) doesn't work (as I expect it to :-) library(quantmod) a = getSymbols(MSFT,from=2009-3-01) a MSFT eval(as.name(a)) MSFT$MSFT.Adjusted b=paste(a,'$MSFT.Adjusted',sep='') b eval(as.name(b)) Why does this last line not work the way the earlier eval does? because eval(as.name(b)) looks for `MSFT$MSFT.Adjusted`, not for `MSFT`$`MSFT.Adjusted`: 'MSFT$MSFT.Adjusted' = 'rubbish' eval(as.name(b)) # rubbish 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] identify() and postscript output
Prof Brian Ripley wrote: If instead, I use dev.copy2eps() after getting output to the screen, the point labels do not appear in the resulting .eps graph. Why? Is there a workaround? I don't think that is true: plot(1:10) identify(1:10) ## Click near points 6 and 7 dev.copy2eps(test.eps) and the points I selected are marked in test.eps. Since Michael ignored the posting guide (again) we have no idea of what version etc of R he used: I checked on 2.8.1 on Linux and also on Mac OS. This was once a bug, fixed a while ago. My bad. Thanks for Ripleying me. I'm using Win XP, R 2.8.1 with packages shown under sessionInfo() below. plot(1:10) identify(1:10) ## Click near points 6 and 7 dev.copy2eps(test.eps) Error in device(...) : unknown family 'test.eps' I get output on WinXP by specifying file= dev.copy2eps(file=test.eps) windows 2 But still no joy -- test.eps *does not* contain the point labels (I clicked on 7 8). It's not a viewer problem -- I checked with gv on Linux. Perhaps that bug wasn't fixed on WinXP? I also attach a .png screen shot of the R graphics window. sessionInfo() R version 2.8.1 (2008-12-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] grid stats graphics grDevices utils datasets methods base other attached packages: [1] gnm_0.9-8vcdExtra_0.3-4 vcd_1.2-2colorspace_1.0-0 MASS_7.2-45 nnet_7.2-45 [7] lattice_0.17-20 car_1.2-12 loaded via a namespace (and not attached): [1] qvcalc_0.8-4 tools_2.8.1 -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA test.eps Description: PostScript document inline: test.png__ 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] character string as object name
Fuchs Ira wrote: Can someone please tell me why the following (last line) doesn't work (as I expect it to :-) library(quantmod) a = getSymbols(MSFT,from=2009-3-01) a MSFT eval(as.name(a)) MSFT$MSFT.Adjusted b=paste(a,'$MSFT.Adjusted',sep='') b eval(as.name(b)) Why does this last line not work the way the earlier eval does? because eval(as.name(b)) looks for `MSFT$MSFT.Adjusted`, not for `MSFT`$`MSFT.Adjusted`: 'MSFT$MSFT.Adjusted' = 'rubbish' eval(as.name(b)) # rubbish 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.
[R] Overriding contributed package functions
The tsdiag function in the TSA package overrides the tsdiag function in the stats package. There are a few annoying bugs in the TSA's version of the function so I would like to use the stats function but still have access to other TSA functions. I have tried using stats::tsdiag( ) but as long as the TSA package is attached the function from the TSA package is called. I believe the problem is the result of the TSA package not having a namespace. The only solution I have found is to detach the TSA package, (detach(package:TSA)) , which results in the loss of all the TSA specific functions. Does anyone have another solution? The following code illustrates the problem: Y1-arima.sim(n=100,list(ar=c(.95,-0.2))) model1-arima(Y1,order=c(2,0,0)) tsdiag(model1) library(TSA) tsdiag(model1) stats::tsdiag(model1) detach(package:TSA) tsdiag(model1) R Saba __ 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] Sending an alert / email when R finished?
On Thu, 5 Mar 2009, nhawrylyshyn wrote: Hi, Not sure if this is the best section to post it in. I'm doing lengthy runs on a 30GB data set - I would like to know if it is possible through any means for R to send an email / text message or anything when it has finished running a source file. Any suggestions would be appreciated. See ?system also, the undocumented function utils:::create.post HTH, Chuck Nick. -- View this message in context: http://www.nabble.com/Sending-an-alert---email-when-R-finished--tp22354235p22354235.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. 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] Date conversion
Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for first record, etc..)? My data set has 1 million records. DATE 11DEC2006 11SEP2006 01APR2007 02DEC2007 Thanks in advance for any help! -- View this message in context: http://www.nabble.com/Date-conversion-tp22355788p22355788.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] text at the upper left corner outside of the plot region
In addition to the other responses that you have received, you can use the grconvertX and grconvertY functions to convert between the different coordinate systems, the upper left corner will be 0,1 in ndc (whole device/page), nfc (figure region), npc (plot region), or nic (inside the outer margins) coordinates, convert this to user coordinates and use the text function. You may need to turn off clipping, see the xpd entry under ?par. 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 batho...@googlemail.com Sent: Wednesday, March 04, 2009 5:06 PM To: r-help@r-project.org Subject: [R] text at the upper left corner outside of the plot region Hi, is there a way to place text at the upper left corner (or another corner) of the plot? I want to place it really at the upper left corner of the whole plot (the file I get), not at the upper left corner of the plot-region. I tried text() and mtext(), and corner.label() of the plotrix package but it didn't work out. 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. __ 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] Import the files.
Dear all, I am a newcomer to R programming, I met the problem: I have a lot of .txt files in my directory. Firstly, I check whether the file satisfies the conditions: 1.empty 2.the Rep column of the file has no useractivity_idle or useractivity_act 3.even The rep has both of them, numbers of useractivity_idle==numbers of useractivity_act==1 If the file has one of those conditions, skip this file, jump to and read the next .txt file: I made the programming as: name-list.files(path = ., pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE) for(k in 1:length(name)){ log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) x-which(log1$Rep==useractivity_act) y-which(log1$Rep==useractivity_idle) while(all(log1$Rep!=useractivity_act)||all(log1$Rep!=useractivity_idle)||(length(x)==1 length(y)==1)||(file.info(name[k])$size== 0)){ k=k+1 log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) } } But I always get the following information: Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'NA': No such file or directory I have been exploring this for long time, any help would be appreciated. Thanks a lot! Tammy _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx [[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] hatvalues?
Dear Kevin, If you do the same regression as in the text then you'll get the same hat-values; the regression is the one on the top of p. 244: mod - lm(repwt ~ weight*sex, data=Davis) max(hatvalues(mod)) [1] 0.7141856 As to making sense of the computations: X - model.matrix(mod) head(X) (Intercept) weight sexM weight:sexM 1 1 771 77 2 1 580 0 3 1 530 0 4 1 681 68 5 1 590 0 6 1 761 76 H - X %*% solve( t(X) %*% X ) %*% t(X) h - diag(H) max(h) [1] 0.7141856 I hope this helps, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rkevinbur...@charter.net Sent: March-05-09 11:40 AM To: r-h...@stat.math.ethz.ch Subject: [R] hatvalues? I am struiggling a bit with this function 'hatvalues'. I would like a little more undrestanding than taking the black-box and using the values. I looked at the Fortran source and it is quite opaque to me. So I am asking for some help in understanding the theory. First, I take the simplest case of a single variant. For this I turn o John Fox's book, Applied Regression Analysis and Generalized Linear Models, p 245 and generate this 'R' code: library(car) attach(Davis) # remove the NA's narepwt - repwt[!is.na(repwt)] meanrw - mean(narepwt) drw - narepwt - meanrw ssrw - sum(drw * drw) h - 1/length(narepwt) + (drw * drw)/ssrw h This gives me a array of values the largest of which is order(h, decreasing=TRUE) [1] 21 52 17 93 30 62 158 113 175 131 182 29 106 125 123 146 91 99 So the largest hatvalue is h[21] [1] 0.1041207 Which doesn't match the 0.714 value that is reported in the book but I will probably take that up with the author later. Then I use more of 'R' and I get fit - lm(weight ~ repwt) hr - hatvalues(fit) hr[21] 21 0.1041207 So this matches which is reasusing. My question is this, given the QR transformation and the residuals derived from that transformation what is a simple matrix formula for the hatvalues? From http://en.wikipedia.org/wiki/Linear_regression I get residuals = y - Hy = y(I - H) or H = -(residuals/y - I) fit - lm(weight ~ repwt) h - -(residuals(fit)/weight[as.numeric(names(residuals(fit)))] - diag(1,length(residuals(fit)), length(residuals(fit This generates a matrix but I cannot see any coerrelation between this hat- matrix and the return from hatvalues. Comments? Thank you. Kevin __ 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] RV: help
Dear Sirs, I want to estimate the survival mean of a few specific teams. I'm trying to calculate it through a Kaplan Meier estimator. For doing so, I load the survival package and run the following instructions: options(survfit.print.mean=TRUE) allows showing the mean and mean standard error KM=survfit(Surv(Dias,Censura)) runs the model KM shows the model It is in this very moment when it shows the mean value and the mean standard error. I'd like to know if there is any instruction that returns the mean value and its standard error, something like: KM$rmean Thank you very much in advanced. Sincerely yours, Alejandro G. Lobo __ 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] including tabular information with a plot in R Graphics
Also see the addtable2plot in the plotrix package. -- 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 R User R User Sent: Thursday, March 05, 2009 3:15 AM To: r-help@r-project.org Subject: [R] including tabular information with a plot in R Graphics Hi all, I have a presentation problem that I cannot find a solution to in the documetnation. I have a nice barplot. Below this I would also like a table with some information relating to the plot. My idea was to have the plot and table on the same graphics window so I can output them as an image file for a report. Does anybody know how to include tabular information from a dataset or table into the graphics device? Is there a better/more correct way to output tables and graphics to a single file? Thanks very much, Richie [[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] missings
This seems to work fine without the na.strings. Can you include the data that you were reading: x - read.table(textConnection(1,2,3,4 + 5,,6,NA + ,7,NA,8 + ,,NA,9), sep=',') closeAllConnections() x V1 V2 V3 V4 1 1 2 3 4 2 5 NA 6 NA 3 NA 7 NA 8 4 NA NA NA 9 On Thu, Mar 5, 2009 at 10:37 AM, kayj kjaj...@yahoo.com wrote: I have a file where the missings are coded as NA or blank. how can I tell R to read the data set and to consider the missings NA or a blank. I tried the following data-read.table(data.txt, sep='\t', header=T, na.strings=c(NA,)) is it correct? I am new to R and I am not sure if R is condisering the blanks as missings in the above. Thanks for the help -- View this message in context: http://www.nabble.com/missings-tp22354037p22354037.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. -- 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] a few scatter plots for a specific correlation value
See the run.cor.examp function in the TeachingDemos package (in addition to the mvrnorm function in MASS). 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 June Kim Sent: Thursday, March 05, 2009 4:47 AM To: r-help@r-project.org Subject: [R] a few scatter plots for a specific correlation value Hello, Is there a simple way to draw a few random sample scatter plots from a given specific correlation coefficient(say, 0.18)? __ 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] Date conversion
Pele wrote: Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for first record, etc..)? My data set has 1 million records. DATE 11DEC2006 11SEP2006 01APR2007 02DEC2007 Since I am not in the correct locale: Sys.setlocale(locale=C) date - strptime(DATE, %d%B%Y) format(date, %Y) format(date, %W) # which is certainly not 52 Uwe Ligges Thanks in advance for any 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] Does R have function or method to finish my task?
I think that the dynlm package was designed for just such a problem. I also would not be surprised if there are tools in the zoo package to do this. You should probably check out the time series task view on CRAN as well. 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 zhijie zhang Sent: Thursday, March 05, 2009 8:56 AM To: r-h...@stat.math.ethz.ch Subject: [R] Does R have function or method to finish my task? Dear all, Does R have function or method to finish the following task. Say i have a dataset. The response variable is Y, and the indepedent variables are X1, X2, X3, and YEAR. See an example. Y X1X2X3 X4 YEAR 13.4 2.8 3.5 2.5 1.8 1990 10.51.82.4 2 3 1991 . In ecology, Y may be not only related with X1, X2, X3 in the same year as Y, but also may be related with X1, X2, X3 and Y in the previous one , two or more years as Y. But which year has the closest relationship is not know and this may be one of the analysis aim. Take Year=1995 as an example, Y_1995 may be related with X1_1995 , X2_1995 , X3_1995, X1_1994 , X2_1994 , X3_1994, Y_1994, (previous one year) X1_1993 , X2_1993 , X3_1993, Y_1993 (previous two years) ... ... (previous more years) Pay attention to the situation that Y itself may also affect its own value of the next several years. Anybody knows whether R have functions or methods to finish the above task. I hope i have explained it clearly. Any suggestions or help are greatly appreciated. [[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] Date conversion
Hi, There are possibly several ways to do this. My approach would be: dates - strptime(as.character(DATE), %d%b%Y) year - dates$year + 1900 week - floor(dates$yday/365 * 52) HTH, --sundar On Thu, Mar 5, 2009 at 8:58 AM, Pele drdi...@yahoo.com wrote: Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for first record, etc..)? My data set has 1 million records. DATE 11DEC2006 11SEP2006 01APR2007 02DEC2007 Thanks in advance for any help! -- View this message in context: http://www.nabble.com/Date-conversion-tp22355788p22355788.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] Overriding contributed package functions
Have you tried using the pos argument in the library function to load the TSA package after the stats package? -- 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 Richard Saba Sent: Thursday, March 05, 2009 9:52 AM To: r-help@r-project.org Subject: [R] Overriding contributed package functions The tsdiag function in the TSA package overrides the tsdiag function in the stats package. There are a few annoying bugs in the TSA's version of the function so I would like to use the stats function but still have access to other TSA functions. I have tried using stats::tsdiag( ) but as long as the TSA package is attached the function from the TSA package is called. I believe the problem is the result of the TSA package not having a namespace. The only solution I have found is to detach the TSA package, (detach(package:TSA)) , which results in the loss of all the TSA specific functions. Does anyone have another solution? The following code illustrates the problem: Y1-arima.sim(n=100,list(ar=c(.95,-0.2))) model1-arima(Y1,order=c(2,0,0)) tsdiag(model1) library(TSA) tsdiag(model1) stats::tsdiag(model1) detach(package:TSA) tsdiag(model1) R Saba __ 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] Inference for R Spam
Rolf == Rolf Turner r.tur...@auckland.ac.nz writes: My impression --- and I could be wrong --- is that physicists understanding of randomness is very narrow and constrained. They tend to think along the lines of chaotic dynamical systems (although perhaps not consciously; and they may not explicitly express themselves in this way). They also tend to think exclusively in terms of measurement error as the source of variability. Which may be appropriate in the applications with which they are concerned, but is pretty limited. Also they're a rather arrogant bunch. E.g. Rutherford (???): ``If I need statistics to analyze my data I need more data.'' This is an interesting discussion all around, but as one of those physicists I feel a need to jump back in ;-) Just as in any multidisciplinary endeavor, much of the fun comes from bridging communication gaps that arise from our certainty that everyone knows what we mean when we say what we say. First, I counter with a quote from my list of interesting sayings :-) We must be careful not to confuse data with the abstractions we use to analyze them. --- William James I went through an interesting transition when I moved from basic physics (medium energy nuclear/particle physics) to biomedical applications (cardiology and then imaging sciences/radiology). There is an important difference between physics-y statistical analysis and biomedical-y statistical analysis that I was not aware of before I crossed over to the biomedical side. That my biomedical and biostatisticians colleagues didn't have the same background didn't make their perspective invalid, just as my not having a background in biomedical statistics didn't make me arrogant. That we were unaware that we were sometimes speaking different languages made up of the same words lead to some adventures. I had to learn two things. One, that biomedical systems tend to have broad distributions while many physical systems have very narrow distributions. Two, that physics models are based on physics theories and that biomedical/biostats models are purely phenomonological and only model the data - they often do not have a basis in underlying physical theory. Simple, but not stressed in my statistical physics or biomedical statistics training. Perhaps the key example is statistical mechanics, both classical and quantum mechanical. A fundamental physics-y concept is that a single object has no statistical properties. Statistical is a word reserved for properties of ensembles. Statistical mechanics can only be applied to ensembles of objects where their joint behavior leads to (highly) predictable results. The density of states for any macroscopic ensemble of like objects is extremely sharply peaked, leading to wonderfully reliable theoretical predictions. Just the opposite of what we tend to see in biomedical systems. For those who are interested in a physics-y perspective, I'd suggest taking a crack at Statistical Methods in Experimental Physics (F. James) and some of the many statistical mechanics texts out there. My favorites are still F. Mandl's Statistical Physics and K. Huang's Statistical Mechanics, but there are many, many more. Another nice little book is Observational Foundations of Physics by Cook. It addresses in part the question of why mathematics is so startlingly effective in physics. It is a result of the correspondence between physical processes in the natural world and mathematical groups. As far as I know, a similar correspondence does not exist in the biomedical realm, nor in many other domains. That lack of correspondence leads to purely phenomonological models that model the data but are not based on underlying physical theory - all that is left is statistical modeling. I suspect this is the source of the sort of statement you attributed to Rutherford. I hear him simply saying that we can do perfectly respectable statistical modeling without physics, but then it is not physics. And if our goal is to do physics, then we aught to get back to the lab and observe reality some more. Which is where the fun is for many of us scientists! Regards, Mike -- Michael A. Miller mmill...@iupui.edu Department of Radiology, Indiana University School of Medicine __ 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] Sending an alert / email when R finished?
You could send a message to Twitter, see: http://finzi.psych.upenn.edu/R/Rhelp08/2009-February/187822.html Regards Markus -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Charles C. Berry Sent: 05 March 2009 17:03 To: nhawrylyshyn Cc: r-help@r-project.org Subject: Re: [R] Sending an alert / email when R finished? On Thu, 5 Mar 2009, nhawrylyshyn wrote: Hi, Not sure if this is the best section to post it in. I'm doing lengthy runs on a 30GB data set - I would like to know if it is possible through any means for R to send an email / text message or anything when it has finished running a source file. Any suggestions would be appreciated. See ?system also, the undocumented function utils:::create.post HTH, Chuck Nick. -- View this message in context: http://www.nabble.com/Sending-an-alert---email-when-R-finished--tp223542 35p22354235.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. 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. ** The information in this E-Mail and in any attachments is...{{dropped:27}} __ 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] Date conversion
Hi Uwe, You are correct - that was a type O (52) and thanks for you your suggestion that works.. Pele wrote: Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for first record, etc..)? My data set has 1 million records. DATE 11DEC2006 11SEP2006 01APR2007 02DEC2007 Thanks in advance for any help! -- View this message in context: http://www.nabble.com/Date-conversion-tp22355788p22356526.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] R on netbooks et al?
I'm having similar experiences on my Acer Aspire One. Everything will work good. Only thing that takes a lot of time is compiling R if you are in the habit of doing so. herrdittm...@yahoo.co.uk wrote: Dear useRs, With the rise of netbooks and 'lifestyle laptops I am tempted to get one of these to mainly run R on it. Processor power and hard disk space seem to be ok. What I wonder is the handling and feel with respect to R. Has anyone here installed or is running R on one of these, and if so, what is your experience? Would it be more of a nice looking gadget than a feasable platform to do some stats on? Many thanks, Bernd __ 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] Error in var(x, na.rm = na.rm) : no complete element pairs
Carlos Morales wrote: Hello, I still have the same error which I have written in the Subject field, I leave here the code and I hope you can help me with this: [removed] the lengthy code example does not make it easier to help you, in particular without the data you used. All the commented out code should have been removed before posting. My guess is that you use R 2.8.0 and generate a vector s which contains only NAs. Try to inspect your function filter.clones by putting a browser() call somewhere before the sd() call and run it again. See ?browser and ?trace. And you could vectorize this (and other parts), e.g. the last loop would be rewritten as tripliclones.info$Estandar_desviation - apply(tripliclones.info[ ,2:4], 1, function(x) sd(as.numeric(x), na.rm=TRUE)) Regards, Matthias R version 2.7.1 (2008-06-23) b - rep(NA,4) sd(b) Error in var(x, na.rm = na.rm) : missing observations in cov/cor sd(b, TRUE) Error in var(x, na.rm = na.rm) : no complete element pairs R version 2.8.1 (2008-12-22) b- rep(NA,4) sd(b) [1] NA sd(b, TRUE) [1] NA -- Matthias Burger Project Manager/ Biostatistician Epigenomics AGKleine Praesidentenstr. 110178 Berlin, Germany phone:+49-30-24345-0fax:+49-30-24345-555 http://www.epigenomics.com matthias.bur...@epigenomics.com -- Epigenomics AG Berlin Amtsgericht Charlottenburg HRB 75861 Vorstand: Geert Nygaard (CEO/Vorsitzender) Oliver Schacht PhD (CFO) Aufsichtsrat: Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender) __ 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 dump plots as bas64 strings?
Patrick Meyer wrote: Here's the solution I'm using now, but it is not very clean: png(out.png) plot(c(1,2,3)) dev.off() system(base64 -w0 out.png out.base64) b64txt - readLines(file(out.base64,rt)) It would be nice to have an internal solution, even if this exactly does what I want. I'm not certain which bit of this you are referring to when you say internal. It would be covenient to have graphics devices be able to write to a buffer as well a file and it wouldn't be terribly difficult to do, but hasn't been a big enough problem so far. As far calling the executable base64, why not use the function in either the caTools or RCurl packages. D. Patrick Gabor Grothendieck wrote: On Wed, Mar 4, 2009 at 9:17 AM, Patrick Meyer pater...@gmail.com wrote: Hello My question might sound awkward, but I am looking for a way to somehow convert a plot in R into a base64 string. Here's an idea, but it is not at all satisfying. 1. write the plot to the harddisk: --- png(toto.png) plot(c(1,2,3)) dev.off() --- 2. somehow reload that file from the disk and transform it into a base64 string: --- bin-readBin(file(toto.png,rb), raw(), n=1000,endian = little) This isn't much of an improvement and does not even address the main concern but as no one has answered note that we can pass the filename as a character string and it will get rb automatically and we can just use raw if we like. Also n can be any size larger than the file size (see ?readBin) so if the file size is 1 or less: readBin(toto.png, raw, n = 1, endian = little) __ 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] Installing the Rstem package
Hello, I am trying to install the Rstem package, but I have problems. I am using Windows XP and the 2.8.1 version of R. I have read the Add-on packages chapter of the R Installation and Administration manual, and also have tried several things, which worked for other people on the mailing list having faced the same problem (http://tolstoy.newcastle.edu.au/R/help/06/03/22889.html). I paste below the things, which I have tried and the results. I don't understand what the message installation of package 'Rstem' had non-zero exit status mean, which I get on my last try below. Could anyone advise me what should I do? Thank you. p.s. I have successfully installed the lsa package, which depends on the Rstem package. ## First Try ## chooseCRANmirror() install.packages(c(Rstem, lsa)) trying URL 'http://cran.at.r-project.org/bin/windows/contrib/2.8/lsa_0.61.zip' Content type 'application/zip' length 205671 bytes (200 Kb) opened URL downloaded 200 Kb package 'lsa' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\Administrator\Local Settings\Temp\RtmpdBelSq\downloaded_packages updating HTML package descriptions Warning message: package ‘Rstem’ is not available ## Second Try install.packages(Rstem, repos = http://www.omegahat.org/R;) Warning: unable to access index for repository http://www.omegahat.org/R/bin/windows/contrib/2.8 Warning message: package ‘Rstem’ is not available ## Third Try ## install.packages(Rstem, repos = http://www.omegahat.org/Rstem/;) Warning: unable to access index for repository http://www.omegahat.org/Rstem/bin/windows/contrib/2.8 Warning message: package ‘Rstem’ is not available The Rstem package could be found here: http://www.omegahat.org/Rstem/ ## Fourth Try ## install.packages(Rstem, repos = http://www.omegahat.org/R;, type = source) trying URL 'http://www.omegahat.org/R/src/contrib/Rstem_0.3-1.tar.gz' Content type 'application/x-gzip' length 606408 bytes (592 Kb) opened URL downloaded 592 Kb tar (child): Cannot open archive /cygdrive/C\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RtmpdBelSq/downloaded_packages/Rstem_0.3-1.tar.gz: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error exit delayed from previous errors Error: cannot untar the package The downloaded packages are in C:\Documents and Settings\Administrator\Local Settings\Temp\RtmpdBelSq\downloaded_packages Warning message: In install.packages(Rstem, repos = http://www.omegahat.org/R;, : installation of package 'Rstem' had non-zero exit status ## __ 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] File checking problem
Dear all, I am a newcomer to R programming, I met the problem: I have a lot of .txt files in my directory. Firstly, I check whether the file satisfies the conditions: 1.empty 2.the Rep column of the file has no useractivity_idle or useractivity_act 3.even The rep has both of them, numbers of useractivity_idle==numbers of useractivity_act==1 If the file has one of those conditions, skip this file, jump to and read the next .txt file: I made the programming as: name-list.files(path = ., pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE) for(k in 1:length(name)){ log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) x-which(log1$Rep==useractivity_act) y-which(log1$Rep==useractivity_idle) while(all(log1$Rep!=useractivity_act)||all(log1$Rep!=useractivity_idle)||(length(x)==1 length(y)==1)||(file.info(name[k])$size== 0)){ k=k+1 log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) } } But I always get the following information: Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'NA': No such file or directory I have been exploring this for long time, any help would be appreciated. Thanks a lot! Tammy _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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] Overriding contributed package functions
The problem is that tsdiag is a generic (the same in both packages), and package TSA sets methods for it (and methods for classes in package stats which has already registered methods). stats:::tsdiag.Arima(model1) ought to work (it does for me in your example), but please take with up with the maintainer of package TSA. (I would be inclined to copy out of package TSA the parts your want and not load the rest.) On Thu, 5 Mar 2009, Richard Saba wrote: The tsdiag function in the TSA package overrides the tsdiag function in the stats package. There are a few annoying bugs in the TSA's version of the function so I would like to use the stats function but still have access to other TSA functions. I have tried using stats::tsdiag( ) but as long as the TSA package is attached the function from the TSA package is called. I believe the problem is the result of the TSA package not having a namespace. The only solution I have found is to detach the TSA package, (detach(package:TSA)) , which results in the loss of all the TSA specific functions. Does anyone have another solution? The following code illustrates the problem: Y1-arima.sim(n=100,list(ar=c(.95,-0.2))) model1-arima(Y1,order=c(2,0,0)) tsdiag(model1) library(TSA) tsdiag(model1) stats::tsdiag(model1) detach(package:TSA) tsdiag(model1) R Saba __ 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] File checking problem
2009/3/5 ling ling metal_lical...@live.com: Dear all, I am a newcomer to R programming, I met the problem: I have a lot of .txt files in my directory. Firstly, I check whether the file satisfies the conditions: 1.empty 2.the Rep column of the file has no useractivity_idle or useractivity_act 3.even The rep has both of them, numbers of useractivity_idle==numbers of useractivity_act==1 If the file has one of those conditions, skip this file, jump to and read the next .txt file: I made the programming as: name-list.files(path = ., pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE) for(k in 1:length(name)){ log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) x-which(log1$Rep==useractivity_act) y-which(log1$Rep==useractivity_idle) while(all(log1$Rep!=useractivity_act)||all(log1$Rep!=useractivity_idle)||(length(x)==1 length(y)==1)||(file.info(name[k])$size== 0)){ k=k+1 log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) } } But I always get the following information: Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'NA': No such file or directory I have been exploring this for long time, any help would be appreciated. Thanks a lot! You are trying to read one more file than you have! Simplified your code looks like this: name = list.files(...) for(k in 1:length(name)){ log1 = read.table(name[k],) while(something){ k =k + 1 log1 = read.table(name[k],...) # 1 } } What will happen is that when the last file is read at point #1, the loop goes round again, k becomes more than the length of name, and it will fail at #1 again. I think you've overcomplicated it. You just need one loop with an 'if' in it. I'd write it as: processFiles = function(){ name-list.files(path = ., pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE) for(k in 1:length(name)){ log1-read.table(name[k],header=TRUE,stringsAsFactors=FALSE) if(testCondition(log1)){ cat(Processing ,name[k],\n) processLog(log1) }else{ cat(Skipping ,name[k],\n) } } } Then you need two more functions, testCondition and processLog. testCondition takes a data frame and decides whether you want to process it or note. I'm not sure I've got the test logic right here, but you should get the idea: `testCondition` - function(log1){ ## test for Rep column: if(!any(names(log1)==Rep))return(FALSE) ## test active/idle count nAct = sum(log1$Rep == useractivity_act) nIdle = sum(log1$Rep == useractivity_idle) ## if we have no active or idle, return False if(nAct + nIdle == 0)return(FALSE) ## if we only have one of either, return False if(nAct == 1 || nIdle ==1) return(FALSE) ## maybe some other tests here? return(TRUE) } here is a simple processLog function that just prints the summary of the data frame. Put whatever you want in here: `processLog` - function(log1){ ## for example: print(summary(log1)) } How's that? Note the use of comments and breaking the code up into small independent, testable functions. Barry __ 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.