[R] How to *completely* stop a script after stop()?

2011-01-15 Thread Marius Hofert
Dear expeRts, is there a neat way to *completely* stop a script after an error occured? For example, consider the following script: ## file.R for(i in 1:10){ print(i) if(i == 5) stop(i == 5) } for(i in 11:100) print(i) ## stop() behaves like it

Re: [R] CSV value not being read as it appears

2011-01-15 Thread bgreen
David, Thanks. When I am back at work I will try to find out some specifics regarding the original data base and how the reports are generated. The differencs are not apparent via manual inspection. I will look at the csv file in an editor as well and look into xlsReadWrite. I agree EXCEL

[R] Question about scatterplot in package car

2011-01-15 Thread David Perlman
I am getting an error message from scatterplot: library(car) scatterplot(Prestige$income~Prestige$type) Error in Summary.factor(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, : range not meaningful for factors In addition: Warning message: In Ops.factor(x[floor(d)], x[ceiling(d)]) : + not

[R] write.dta and export of variable labels

2011-01-15 Thread Andrew Owen
When I import a data file in stata format using read.dta, the full variable labels (e.g. variable= inc2000; variable label= Total household income in year 2000). When I then export the same data file using write.dta, the variable labels are not included in the new .dta file. Is there any way to

Re: [R] test

2011-01-15 Thread romzero
Thank you all for the precious help. Finally i could start the writing of a first part of my script, but now i have a new question for you. Need i to repeat the write.table portion for all the 15 lines or can i use a short cut? Example: file.open - C:\\test.txt file.save - C:\\results.txt

[R] Truetype and Opentype font in pdf device

2011-01-15 Thread Kohske Takahashi
Deal all, I want to know if truetype or opentype fonts are available in pdf device (i.e., pdf() or dev.copy2pdf()), and if so, how to do it? Now I can do as followings: 1. convert ttf to afm using ttf2afm, e.g.: $ ttf2afm Impact.ttf Impact.afm 2. put the afm file in

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-15 Thread surreyj
Thanks so much for your help everyone, got it sorted now :) this is what I used in the end: timeofonlyfirstresponseafterrft-testdata$Time[test-which(!diff(as.numeric(factor(Stat, levels = c(MagDwn, Resp)] timeofonlyfirstresponseafterrft1-as.POSIXct(timeofonlyfirstresponseafterrft,

Re: [R] How to *completely* stop a script after stop()?

2011-01-15 Thread Taras Zakharko
I take you don't use source() to execute your scripts. When using source, stop() aborts the complete script, just as you indent to. -- View this message in context: http://r.789695.n4.nabble.com/How-to-completely-stop-a-script-after-stop-tp3218808p3218823.html Sent from the R help mailing list

Re: [R] Problems with TeachingDemos package

2011-01-15 Thread gaiarrido
R2wd is working but i received an alarm: wdtxtStart() Error en R2wd::wdGet() : tentativa de aplicar una no-función The translation is attempt to apply a no-function - Mario Garrido Escudero PhD student Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola

Re: [R] Question about scatterplot in package car

2011-01-15 Thread John Fox
Dear David, scatterplot() isn't intended to produce parallel boxplots with a factor on the RHS of the formula (though that's a reasonable feature request) but rather, as the name implies, to make scatterplots. For boxplots with labelled outliers, use the car function Boxplot(), as in

[R] getting R-readable data , not pictures, from US OTS data pages

2011-01-15 Thread Mike Marchywka
Does anyone know offhand if the OTS has an FTP site or other pages off in a corner somewhere to make data downloading and integration with R easy? They have mailing lists to which you can subscribe that announce new data but then you get these things like PDF files with tables of numbers and the

Re: [R] Rounding variables in a data frame

2011-01-15 Thread Pete B
Bill, Joshua, Phil Thanks for the suggestions. Very much appreciated. Kind regards Pete -- View this message in context: http://r.789695.n4.nabble.com/Rounding-variables-in-a-data-frame-tp3218729p3219060.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Rounding variables in a data frame

2011-01-15 Thread Joshua Wiley
On Fri, Jan 14, 2011 at 11:16 PM, Phil Spector spec...@stat.berkeley.edu wrote: Is sapply really necessary here? Apparently not, and it is certainly more cumbersome. Because data frames can contain a mix of classes, I thought that round() did not have a method for them (in retrospect that does

[R] R scheduling request

2011-01-15 Thread Alessandro Oggioni
Dear all, I have used R.rps to produce a Google API chart (googleVis) with a data request in another server. But i don't understand how is possible to scheduling a request data to the server and after produce a update of the charts. Thanks in advance. Alessandro Oggioni

[R] access to right time unit when checking for time execution

2011-01-15 Thread Christine SINOQUET
Hello, I really wonder how to distinguish between secs and mins in the example below. In other terms, how can I access the time unit in variable d ? start1 - Sys.time(); stop1 - Sys.time(); d - stop1-start1; print(d); v-unlist(strsplit(as.character(d), split= )); print(v) Time difference

Re: [R] piecewise regression

2011-01-15 Thread Federico Bonofiglio
Thank u Doctor Muggeo, I was just getting familiar with your package this morning..i find it interesting 'cause so far is the only one that allows estimations for the single slope parameters between brakepoints, by the slope() function. Contrarily, supposing only one knot in a linear regression,I

Re: [R] Help on a Display function

2011-01-15 Thread Hans W Borchers
William Dunlap wdunlap at tibco.com writes: But it fails on this: my_names - c(Bill, William) display(rev(my_names)) rev(my_names) = Error in cat(list(...), file, sep, fill, labels, append) : argument 3 (type 'list') cannot be handled by 'cat' This is because you call eval()

Re: [R] access to right time unit when checking for time execution

2011-01-15 Thread Uwe Ligges
On 15.01.2011 12:57, Christine SINOQUET wrote: Hello, I really wonder how to distinguish between secs and mins in the example below. In other terms, how can I access the time unit in variable d ? start1 - Sys.time(); stop1 - Sys.time(); d - stop1-start1; print(d);

[R] interactive graphics from the O/S Shell prompt

2011-01-15 Thread analys...@hotmail.com
I have a function called plotID(ID) that would generate a plot for customerID = ID. I can run it repeatedly from within R without any problems. Would it be possible to run this function from the O/S command prompt; each time you enter an ID , it would open a graphics window with the plot for

Re: [R] access to right time unit when checking for time execution

2011-01-15 Thread David Winsemius
On Jan 15, 2011, at 6:57 AM, Christine SINOQUET wrote: Hello, I really wonder how to distinguish between secs and mins in the example below. In other terms, how can I access the time unit in variable d ? start1 - Sys.time(); stop1 - Sys.time(); d - stop1-start1; str(d) Class

Re: [R] interactive graphics from the O/S Shell prompt

2011-01-15 Thread David Winsemius
On Jan 15, 2011, at 9:42 AM, analys...@hotmail.com wrote: I have a function called plotID(ID) that would generate a plot for customerID = ID. I can run it repeatedly from within R without any problems. Would it be possible to run this function from the O/S command prompt; each time you enter

Re: [R] piecewise regression

2011-01-15 Thread Achim Zeileis
On Sat, 15 Jan 2011, vito.muggeo wrote: dear all, The package segmented allows to estimate piecewise linear relationships (*connected* lines, i.e. a gradual change in the slope) with several breakpoints (known or unknown) within (generalized) linear models.. The package also includes some

Re: [R] survreg vs. aftreg (eha) - the relationship between fitted coefficients?

2011-01-15 Thread Andrew Jackson
Dear Göran I too have been working on this for the last couple of weeks and this is a great help thanks. I wonder can you advise on how the covariance matrix of estimated parameters in phreg relates to those estimated in survreg. Im hoping you can just put your finger on this. Your eha

[R] How to *completely* stop a script after stop()?

2011-01-15 Thread Carl Witthoft
Somehow this reminds me of a famous FORTRAN code snippet: 10 STOP STOP STOP ! IN CASE STILL SKIDDING GOTO 10 quote From: Marius Hofert m_hofert_at_web.de Date: Sat, 15 Jan 2011 09:09:20 +0100 Dear expeRts, is there a neat way to *completely* stop a script after an error occured? For

Re: [R] How to *completely* stop a script after stop()?

2011-01-15 Thread Mike Marchywka
Date: Sat, 15 Jan 2011 11:29:20 -0500 From: c...@witthoft.com To: r-help@r-project.org Subject: [R] How to *completely* stop a script after stop()? Somehow this reminds me of a famous FORTRAN code snippet: 10 STOP STOP STOP ! IN CASE

[R] Fortune! (Was: How to *completely* stop a script after stop()?)

2011-01-15 Thread Dirk Eddelbuettel
On 15 January 2011 at 11:29, Carl Witthoft wrote: | | Somehow this reminds me of a famous FORTRAN code snippet: | | 10 STOP | STOP | STOP | ! IN CASE STILL SKIDDING | GOTO 10 Immediate candidate for the fortunes package! Dirk | quote | From: Marius Hofert m_hofert_at_web.de | Date: Sat,

Re: [R] How to *completely* stop a script after stop()?

2011-01-15 Thread Ista Zahn
Hi Carl, If you wrap the whole script in brackets the script will not proceed past the stop() function: { for(i in 1:10){ print(i) if(i == 5) stop(i == 5) } for(i in 11:100) print(i) } best, Ista On Sat, Jan 15, 2011 at 4:29 PM, Carl Witthoft c...@witthoft.com wrote: Somehow

Re: [R] How to *completely* stop a script after stop()?

2011-01-15 Thread Phil Spector
Marius - Do you get the behaviour you want if you substitute if(i == 5){cat('i==5\n');quit(save='n')} for the line with the call to stop? - Phil Spector Statistical Computing Facility

Re: [R] How to *completely* stop a script after stop()?

2011-01-15 Thread Uwe Ligges
On 15.01.2011 18:17, Ista Zahn wrote: Hi Carl, If you wrap the whole script in brackets the script will not proceed past the stop() function: { for(i in 1:10){ print(i) if(i == 5) stop(i == 5) } for(i in 11:100) print(i) } Yes, or write it inside a function (since I

[R] median by geometric mean

2011-01-15 Thread Skull Crossbones
Hi All, I need to calculate the median for even number of data points.However instead of calculating the arithmetic mean of the two middle values,I need to calculate their geometric mean. Though I can code this in R, possibly in a few lines, but wondering if there is already some built in

[R] color palette for heatmap?

2011-01-15 Thread BD
Hi, Does anyone know how I can specify the colors based on the data values in heatmap? I have values ranging from -4 to 25 and I want to specify colors as: -4 = white 0 = white/snow 10 =darkblue 20 = red 25 = dark red the command line that I am currently using is (which is close to what I want

Re: [R] median by geometric mean

2011-01-15 Thread Hadley Wickham
exp(median(log(x)) ? Hadley On Sat, Jan 15, 2011 at 10:26 AM, Skull Crossbones witch.of.agne...@gmail.com wrote: Hi All, I need to calculate the median for even number of data points.However instead of calculating the arithmetic mean of the two middle values,I need to calculate their

[R] get list element names within lapply / sapply call

2011-01-15 Thread Jonathan Flowers
Hi all, I would like to iterate through a list with named elements and access the names within an lapply / sapply call. One way to do this is iterate through the names and index the list with the name. Is there a way to iterate through the list elements themselves and access the element names

Re: [R] How to disable using enter key to exit the browser in debugging mode

2011-01-15 Thread Gene Leynes
Regarding the issue of inserting a newline during debugging: If I remember correctly, this issue didn't happen in older versions of R. and it seems connected to some other issues. There generally seems to be something different with how the R Console is being rendered, and it doesn't seem to be

Re: [R] get list element names within lapply / sapply call

2011-01-15 Thread Gene Leynes
I one tried to write a function to do that, but it wasn't worth it / didn't work I found this to be a better solution: mynames = names(sapply(mylist, names)) for(nm in mynames){ print(mylist[nm]) # or do other stuff } You can use browser to look inside sapply, and the objects available

Re: [R] get list element names within lapply / sapply call

2011-01-15 Thread Jonathan Flowers
Thanks Gene. I'll look into the Browse option. Best, Jonathan On Sat, Jan 15, 2011 at 4:36 PM, Gene Leynes gleyne...@gmail.comgleynes%...@gmail.com wrote: I one tried to write a function to do that, but it wasn't worth it / didn't work I found this to be a better solution: mynames =

Re: [R] Fortune! (Was: How to *completely* stop a script after stop()?)

2011-01-15 Thread Achim Zeileis
On Sat, 15 Jan 2011, Dirk Eddelbuettel wrote: On 15 January 2011 at 11:29, Carl Witthoft wrote: | | Somehow this reminds me of a famous FORTRAN code snippet: | | 10 STOP | STOP | STOP | ! IN CASE STILL SKIDDING | GOTO 10 Immediate candidate for the fortunes package! Thx, added on R-Forge. Z

Re: [R] get list element names within lapply / sapply call

2011-01-15 Thread David Winsemius
On Jan 15, 2011, at 4:06 PM, Jonathan Flowers wrote: Hi all, I would like to iterate through a list with named elements and access the names within an lapply / sapply call. One way to do this is iterate through the names and index the list with the name. Is there a way to iterate

Re: [R] get list element names within lapply / sapply call

2011-01-15 Thread David Winsemius
On Jan 15, 2011, at 5:37 PM, David Winsemius wrote: On Jan 15, 2011, at 4:06 PM, Jonathan Flowers wrote: Hi all, I would like to iterate through a list with named elements and access the names within an lapply / sapply call. One way to do this is iterate through the names and index the

[R] (OT) System admin of Rweb at Tama University

2011-01-15 Thread Yihui Xie
Hi, Sorry to bother all, but recently I found an interesting application of Rweb (although there are many other fancier web applications of R). We can submit some simple code to Rweb to create an HTML page containing animations. Most of Rweb servers I can find are still using very old versions of

Re: [R] RSQLite - How to express(or save) a dataframe as an output?

2011-01-15 Thread Michael Bedward
Hi Amelia, You statement... dbGetPreparedQuery(con, INSERT INTO output(df) VALUES (?), data.frame(output)) ...is the problem. To insert an entire data.frame into the database use dbWriteTable. To insert with debSendPreparedQuery or dbGetPreparedQuery, the number of ? in the VALUES specifier