Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-23 Thread Joshua Wiley
Maybe efficiency is less of an issue than I thought, on 2 million rows, it only took a bit over a minute, and my system only jumped up ~ 600 MB of memory so it wasn't much of a strain there either. > data.test <- matrix( + sample(seq(min(yourdata),max(yourdata)), size = 1000, replace = TRUE),

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-23 Thread Joshua Wiley
Hi, Here is a little function that will do what you want and return a nice output: #Function To calculate top two values and return my.finder <- function(mydata) { my.fun <- function(data) { strongest <- which.max(data) secondstrongest <- which.max(data[-strongest]) strongestantenna

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-23 Thread jim holtman
try this: > x <- read.table(textConnection(" value0 value60 value120 value180 value240 > value300 + 1 -13007 -11707 -11072 -12471 -12838 -13357 + 2 -12838 -13210 -11176 -11799 -13210 -13845 + 3 -12880 -11778 -3 -12439 -13089 -13880 + 4 -12805 -11653 -11071

Re: [R] union data in column

2010-07-23 Thread jim holtman
try this: > x <- read.table(textConnection(" GENEID col1 col2 > col3col4 + G234064 1 0 0 0 + G234064 1 0 0 0 + G234064 1 0

[R] union data in column

2010-07-23 Thread Fahim Md
Is there any function/way to merge/unite the following data GENEID col1 col2 col3col4 G234064 1 0 0 0 G234064 1 0 0 0 G234064 1

[R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-23 Thread mpward
I have a data frame with a couple million lines and want to retrieve the largest and second largest values in each row, along with the label of the column these values are in. For example row 1 strongest=-11072 secondstrongest=-11707 strongestantenna=value120 secondstrongantenna=value60 Below

[R] glm - prediction of a factor with several levels

2010-07-23 Thread blackscorpio
Dear community, I'm currently attempting to predict the occurence of an event (factor) having more than 2 levels with several continuous predictors. The model being ordinal, I was waiting the glm function to return several intercepts, which is not the case when looking to my results (I only have o

[R] densityplot on date objects

2010-07-23 Thread Jack T.
Hi, I'm looking for a way to use densityplot in the lattice package on Date data or manipulate the labels for tick marks. Here's an example: #generate psuedo dates dat.Date <- as.Date('2009-12-31')+as.integer(abs(rnorm(1))*100) #convert to a julian date for densityplot #because it doesn'

[R] , Updating Table

2010-07-23 Thread Marcus Liu
Hi everyone, Is there any command for updating table withing a loop?  For instance, at i, I have a table as ZZ = table(data.raw[1:ind[i]]) where "ind" = c(10, 20, 30, ...).  Then , ZZ will be as follow "A" "B" "C"  3    10   2 At (i + 1), ZZ = table(data.raw[(ind[i]+1):ind[i+1]]) "A" "B" "D"

Re: [R] 64 bit use of odbcConnectExcel

2010-07-23 Thread mdsumner
Try using odbcConnectExcel2007, instead of odbcConnectExcel. That has worked for me. Cheers, Mike. > Message: 60 > Date: Thu, 22 Jul 2010 09:14:23 -0700 (PDT) > From: "Jack T." > To: r-help@r-project.org > Subject: [R] 64 bit use of odbcConnectExcel > Message-ID: <1279815263840-2298927.p...@

Re: [R] greek letters in rgl plot3d

2010-07-23 Thread Duncan Murdoch
On 23/07/2010 7:39 AM, james.fo...@diamond.ac.uk wrote: Dear RGL experts, I haven't been able to add greek letters to my rgl plot3d. I have tried "expression" with no success. Here is the interested bit: > library(rgl) > cb <- cube3d() > plot3d(cb,xlab=expression(alpha),ylab="",zlab="",box=FALS

[R] (no subject)

2010-07-23 Thread w 霍
Dear R list, I use the constrOptim to maximize a function with four constriants but the answer does not leave from the starting value and there is only one outer iteration. The function is defined as follows: tm<-function(p){ p1<-p[1]; p2<-p[2]; p3<-p[3]; p4<-1-p1-p2-p3; p1*p2*p3*p4} ##the con

Re: [R] Tutorial Tinn-R

2010-07-23 Thread Tom La Bone
Seems to be a relevant and reasonable question to me. -- View this message in context: http://r.789695.n4.nabble.com/Tutorial-Tinn-R-tp2300451p2300648.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] how to calculate the product of every two elements in two vectors

2010-07-23 Thread aegea
Thanks in advance! A=c(1, 2,3) B=c (9, 10, 11, 12) I want to get C=c(1*9, 1*10, 1*11, 1*12, ., 3*9, 3*10, 3*11, 3*12)? C is still a vector with 12 elements Is there a way to do that? -- View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-the-product-of-every-two-el

Re: [R] How to import simple java/mathematica expression to R

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 10:29 PM, jim holtman wrote: Well, I took you equation and put the following at the start: Power <- function(x,y) x^y EE <- function(x) x alp <- 2 x <- 900*Power(-0.2030178326474623 + 0.23024073983368956*(1 - alp) + 0.2807352820970084*(1 - alp)*(1 - alp*(1 + EE(1

Re: [R] How to import simple java/mathematica expression to R

2010-07-23 Thread jim holtman
Well, I took you equation and put the following at the start: Power <- function(x,y) x^y EE <- function(x) x alp <- 2 x <- 900*Power(-0.2030178326474623 + 0.23024073983368956*(1 - alp) + 0.2807352820970084*(1 - alp)*(1 - alp*(1 + EE(1))) + 0.2145643524071315*(1 - alp)* Power(1 - alp*(

[R] latent class analysis with mixed variable types

2010-07-23 Thread Donald Braman
As an alternative to Latent GOLD, I'm wondering if anyone knows of and R package that can manage Latent Class Analysis with mixed variable types (continuous, ordinal, and nominal/binary). [[alternative HTML version deleted]] __ R-help@r-project.

[R] UseR! 2010 - my impressions

2010-07-23 Thread Ravi Varadhan
Dear UseRs!, Everything about UseR! 2010 was terrific! I really mean "everything" - the tutorials, invited talks, kaleidoscope sessions, focus sessions, breakfast, snacks, lunch, conference dinner, shuttle services, and the participants. The organization was fabulous. NIST were gracious hosts

Re: [R] sink function

2010-07-23 Thread Matt Shotwell
I had addressed a problem similar to this only a few days ago. Please see the following URL: http://tolstoy.newcastle.edu.au/R/e11/help/10/07/1677.html On Fri, 2010-07-23 at 08:45 -0400, nuncio m wrote: > I have the following code to write the output from auto.arima function. The > issue is not

Re: [R] Reconciling 2 datasets

2010-07-23 Thread Bert Gunter
Have you read AN INTRODUCTION TO R? ?%in% Bert Gunter Genentech Nonclinical Statistics > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of chipmaney > Sent: Friday, July 23, 2010 3:39 PM > To: r-help@r-project.org > Subject: [R]

Re: [R] Reconciling 2 datasets

2010-07-23 Thread Jorge Ivan Velez
Try Empirical.df[Empirical.df$ID %in% Samples.v,] See ?"%in%" for more informartion. HTH, Jorge On Fri, Jul 23, 2010 at 6:38 PM, chipmaney <> wrote: > > I have a dataframe: > > Empirical.df <- data.frame(ID=c("MCUP1-2","MCUP2-5", "MCUP3-3", > "MCUP4-3","MCUP5-9"), Cover=c(60,40,45,68,72)) > >

[R] Reconciling 2 datasets

2010-07-23 Thread chipmaney
I have a dataframe: Empirical.df <- data.frame(ID=c("MCUP1-2","MCUP2-5", "MCUP3-3", "MCUP4-3","MCUP5-9"), Cover=c(60,40,45,68,72)) However, I only want to use a subset of Cover.df for my analysis. The samples I want to use are: Samples.v <- c("MCUP1-2", "MCUP4-3","MCUP5-9") How do I use index

Re: [R] Convert Row Names to data.frame column

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 6:18 PM, chipmaney wrote: Here is an example dataset: ZoneCover.df<- data.frame(Value=c(1,2)) row.names(ZoneCover.df) <- c("Floodplain1.Tree", "Floodplain1.Shrub") I want to Export the Row.Names to a column in the dataframe: ZoneCover.df$ID <- names(ZoneCover.df) which

[R] Convert Row Names to data.frame column

2010-07-23 Thread chipmaney
Here is an example dataset: ZoneCover.df<- data.frame(Value=c(1,2)) row.names(ZoneCover.df) <- c("Floodplain1.Tree", "Floodplain1.Shrub") I want to Export the Row.Names to a column in the dataframe: ZoneCover.df$ID <- names(ZoneCover.df) which yields this: > ZoneCover.df V

Re: [R] re-ordering bwplot

2010-07-23 Thread Steven McKinney
Here's one way - you can reorder the levels of a factor variable by specifying the levels the way you want them. > require("lattice") Loading required package: lattice > bwplot( conc ~ Type : Treatment, data = CO2 ) > str(CO2$Type) Factor w/ 2 levels "Quebec","Mississippi": 1 1 1 1 1 1 1 1 1 1

Re: [R] Survival analysis MLE gives NA or enormous standard errors

2010-07-23 Thread Charles C. Berry
On Fri, 23 Jul 2010, Christopher David Desjardins wrote: Sorry. I should have included some data. I've attached a subset of my data (50/192) cases in a Rdata file and have pasted it below. Running anova I get the following: anova(sr.reg.s4.nore) Df Deviance Resid. Df-2*

Re: [R] sparsity

2010-07-23 Thread Allan Engelhardt
The functions {summary,bandwidth}.rq() in the package quantreg looks promising, but it is not really my area... http://lmgtfy.com/?q=Hall-Sheater+sparsity+%22r-project%22 Hope this helps a little. Allan On 23/07/10 21:02, Nathalie Gimenes wrote: Hi All, I would like to estimate the "sparsit

Re: [R] Figures in Latex

2010-07-23 Thread Felipe Carrillo
Hannah: I am not sure if this is what you need but you can use an array to do that. Copy and paste the below code to your latex code. \newpage \begin{landscape} \begin{figure}[h] \begin{center}$ \begin{array}{cc} \includegraphics[width=2in]{yourgraphicname} & \includegraphics[width=2in]{yourgraphi

[R] sparsity

2010-07-23 Thread Nathalie Gimenes
Hi All, I would like to estimate the "sparsity function" using Hall Sheater bandwidth. Is there any command for this? Thanks, NGS [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo

Re: [R] Figures in Latex

2010-07-23 Thread Kingsford Jones
to make the desired within R's plotting device rather than in latex try: par(mfrow = c(3, 2)) and you'll probably want to adjust other mar, parameters as well (e.g. mar, cex.lab, etc). Or, take advantage of the flexibility offered by the graphics package by studying ?layout hth, Kingsford On

Re: [R] Survival analysis MLE gives NA or enormous standard errors

2010-07-23 Thread Christopher David Desjardins
Sorry. I should have included some data. I've attached a subset of my data (50/192) cases in a Rdata file and have pasted it below. Running anova I get the following: > anova(sr.reg.s4.nore) Df Deviance Resid. Df-2*LL P(>|Chi|) NULL NA NA45 33.89

Re: [R] Tutorial Tinn-R

2010-07-23 Thread Kingsford Jones
I found the user guide available at Help > Main > User Guide > Html to be quite useful for getting started. I don't think this was available when first I looked at Tinn-R a couple years ago, at which point I too felt the help files were very poor. But under 2.3.5.2 the file is there, and Tinn-R i

Re: [R] Survival analysis MLE gives NA or enormous standard errors

2010-07-23 Thread Charles C. Berry
On Fri, 23 Jul 2010, Christopher David Desjardins wrote: Hi, I am trying to fit the following model: sr.reg.s4.nore <- survreg(Surv(age_sym4,sym4), as.factor(lifedxm), data=bip.surv) Next time include a reproducible example. i.e. something we can run. Now, Google "Hauck Donner Effect" to und

Re: [R] Figures in Latex

2010-07-23 Thread Saeed Abu Nimeh
http://nixtricks.wordpress.com/2009/11/09/latex-multiple-figures-under-the-same-caption-using-subfigure/ "It will create two rows of subfigures with two subfigures on each row" On Fri, Jul 23, 2010 at 6:43 AM, li li wrote: > Hi all, >   I want to add 6 plots in the format of 2 columns and 3 rows

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Gabor Grothendieck
On Fri, Jul 23, 2010 at 2:07 PM, Dimitri Liakhovitski wrote: > David/Gabor, > > you helped me a lot. > Gabor - I've run table(OrigData$Month) - and it looked weird. > I went back to my file and changed the format of the date (Month) in > Excel. I have no idea what it does - but after I saved it ag

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Dimitri Liakhovitski
David/Gabor, you helped me a lot. Gabor - I've run table(OrigData$Month) - and it looked weird. I went back to my file and changed the format of the date (Month) in Excel. I have no idea what it does - but after I saved it again, it worked. Thanks a lot! I'll open another thread where I'll ask ho

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 1:50 PM, Dimitri Liakhovitski wrote: I am expecting to see the week names as row labels of z and the corresponding values (like in the "monthly" example). I am pretty sure - in order to get it one needs to install the latest version of zoo. I've done it just a couple of days

Re: [R] re-ordering bwplot

2010-07-23 Thread Peter Ehlers
On 2010-07-23 11:36, Deepayan Sarkar wrote: On Fri, Jul 23, 2010 at 10:02 AM, Eck, Bradley J wrote: Dear list: I'm using bwplot to compare concentrations by location and treatment as in: # using built in data bwplot( conc ~ Type : Treatment, data = CO2 ) I would like the order of the plots

[R] Survival analysis MLE gives NA or enormous standard errors

2010-07-23 Thread Christopher David Desjardins
Hi, I am trying to fit the following model: sr.reg.s4.nore <- survreg(Surv(age_sym4,sym4), as.factor(lifedxm), data=bip.surv) Where age_sym4 is the age that a subject develops clinical thought problems; sym4 is whether they develop clinical thoughts problems (0 or 1); and lifedxm is mothe

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Gabor Grothendieck
On Fri, Jul 23, 2010 at 1:39 PM, Dimitri Liakhovitski wrote: > Very sorry - I mistunderstood and confused split with index.column - > totally my fault. > Ok, now I've run this line: > > z <- read.zoo(OrigData, index.column = 2, split = "Brand") > > And I am getting: > Error in merge.zoo(` Plus` =

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Dimitri Liakhovitski
I am expecting to see the week names as row labels of z and the corresponding values (like in the "monthly" example). I am pretty sure - in order to get it one needs to install the latest version of zoo. I've done it just a couple of days ago. I am getting the error - and nothing is produced. Can i

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 1:39 PM, Dimitri Liakhovitski wrote: Very sorry - I mistunderstood and confused split with index.column - totally my fault. Ok, now I've run this line: z <- read.zoo(OrigData, index.column = 2, split = "Brand") And I am getting: Error in merge.zoo(` Plus` = c(NA, 98L, 95L,

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Dimitri Liakhovitski
Very sorry - I mistunderstood and confused split with index.column - totally my fault. Ok, now I've run this line: z <- read.zoo(OrigData, index.column = 2, split = "Brand") And I am getting: Error in merge.zoo(` Plus` = c(NA, 98L, 95L, 97L, NA, 98L, 97L, 98L, NA, : series cannot be merged wit

Re: [R] re-ordering bwplot

2010-07-23 Thread Deepayan Sarkar
On Fri, Jul 23, 2010 at 10:02 AM, Eck, Bradley J wrote: > Dear list: > > I'm using bwplot to compare concentrations by location and treatment as in: > > # using built in data > bwplot( conc ~ Type : Treatment, data = CO2 ) > > I would like the order of the plots to be: 3,4,1,2.   I can't seem to f

Re: [R] How to import simple java/mathematica expression to R

2010-07-23 Thread Andrey Siver
Hello, 2010/7/23 jim holtman : > It would be nice if you could post what the data looks like that you > want to import.  R can import any text file and then you have string > manipulation that you can do to parse it.  So the basic answer is > probably yes, but we do need to understand the format o

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread David Winsemius
But, but, but Did you read my message about the need to correctly specify index columns? The problem is that read.zoo is reading your first column as an index and it's actually the second column that should be used for that purpose. -- David. On Jul 23, 2010, at 1:01 PM, Dimitri Liak

[R] re-ordering bwplot

2010-07-23 Thread Eck, Bradley J
Dear list: I'm using bwplot to compare concentrations by location and treatment as in: # using built in data bwplot( conc ~ Type : Treatment, data = CO2 ) I would like the order of the plots to be: 3,4,1,2. I can't seem to figure this out with index.cond or permc.cond. Any help is appreciate

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Dimitri Liakhovitski
Strange, I did attach. Attaching again. Maybe the file just doesn't go through? I have: names(OrigData): [1] "Brand" "Month" "Value" I read ?read.zoo According to that index should be the column number. I thought it should be split = 1 in my case - because I am splitting by Brand. But neither spl

Re: [R] Tutorial Tinn-R

2010-07-23 Thread Bert Gunter
Google on "tinn-r tutorial." However, I believe that you will find that the answer is no, there isn't anything useful out there. Moreover, TINN-R's help files are minimal and terrible, even though the package itself is quite useful (I find). Please Do NOT post further TINN-R questions to this list

Re: [R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread David Winsemius
?read.zoo You didn't specify the index column correctly. On Jul 23, 2010, at 12:36 PM, Dimitri Liakhovitski wrote: Hello! I have a data set similar to the data set "monthly" in the example below: monthly<- data .frame (month = c (20090301,20090401,20090501,20100301,20100401,20090301,

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread Gabor Grothendieck
On Fri, Jul 23, 2010 at 12:35 PM, wrote: > David, Stephen, > You're right - it's the time zone conventions that threw me as well. I tried > those round() operations earlier, but inevitably ended up being either an > hour behind. Even when I specified my time zone, it didn't make any > differen

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-23 Thread Allan Engelhardt
On 23/07/10 17:36, Duncan Murdoch wrote: On 23/07/2010 12:10 PM, babyfoxlo...@sina.com wrote: [...] You probably won't get much faster than read.table with all of the colClasses specified. It will be a lot slower if you leave that at the default NA setting, because then R needs to figure ou

[R] Tutorial Tinn-R

2010-07-23 Thread suse
Hi, does anyone know a tutorial for Tinn-R? During all my search I only found R-Tutorials... The problem now is: I would like to make Tinn-R an autosave. But since I had several questions before concerning Tinn-R (for example, how to have Tinn-R and R in one window or how do the new versions work

Re: [R] class

2010-07-23 Thread schuster
Hi, Strange, there seems to be different behavior of "old style" classes and S4 classes. This worked just like you expected (but it's not the same thing, no S4 classes) f2=function(x,...) UseMethod("fxy") fxy.default=function(x,...){ print("default") } fxy.X=function(x,...) {

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-23 Thread Allan Engelhardt
read.table is not very inefficient IF you specify the colClasses= parameter. scan (with the what= parameter) is probably a little more efficient. In either case, save the data using save() once you have it in the right structure and it will be much more efficient to read it next time. (In fa

[R] Error produced by read.zoo: "bad entries"

2010-07-23 Thread Dimitri Liakhovitski
Hello! I have a data set similar to the data set "monthly" in the example below: monthly<-data.frame(month=c(20090301,20090401,20090501,20100301,20100401,20090301,20090401,20090501,20100301,20100401),monthly.value=c(100,200,300,101,201,10,20,30,11,21),market=c("Market A","Market A", "Market A","M

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-23 Thread Duncan Murdoch
On 23/07/2010 12:10 PM, babyfoxlo...@sina.com wrote:  Hi there, Sorry to bother those who are not interested in this problem. I'm dealing with a large data set, more than 6 GB file, and doing regression test with those data. I was wondering are there any efficient ways to read those data? Ins

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread Murali.Menon
David, Stephen, You're right - it's the time zone conventions that threw me as well. I tried those round() operations earlier, but inevitably ended up being either an hour behind. Even when I specified my time zone, it didn't make any difference. So there's something else that I'm missing. I'll

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread Allan Engelhardt
The arithmetic that David describes should work fine (POSIXct is internally in UTC) unless you are in the Chatham Islands (which has a UTC+12:45 time zone [1]) or Nepal (UTC+05:45 [2]) or some such place with a funny idea about when the 1/2 hour mark is. The formatting of the output may be tr

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread Jeff Newmiller
This truncates to quarter-hour rather than rounding to half-hour. "stephen sefick" wrote: >If you have a zoo series this should work. If it doesn't then please >tell me because I think it works. > >snap2min <- function(zoo, min="00:15:00"){ >min15 <- times(min) >a <- aggregate(zoo, trunc(time(z

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread Jeff Newmiller
By entering "trunc.POSIXt" at the R commandline, you can see the standard truncate implementation. Riffing on this, roundhalfhour <- function( x ) { x <- as.POSIXlt( x + as.difftime( 15, units="mins" ) ) x$sec <- 0 x$min <- 30*(x$min %/% 30) as.POSIXct(x) } The as.double approach ought to w

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 12:04 PM, stephen sefick wrote: If you have a zoo series this should work. If it doesn't then please tell me because I think it works. snap2min <- function(zoo, min="00:15:00"){ min15 <- times(min) a <- aggregate(zoo, trunc(time(zoo), min15), function(x) mean(x, na.rm=TR

Re: [R] Syntax Highlightning and Editor for Linux

2010-07-23 Thread schuster
Rkward is great. If you are a programmer then have a look at the StatET plugin for eclipse (Java). Not so simple to set up. On Friday 23 July 2010 02:17:36 pm Alaios wrote: > I would like to thank you for your immediate reply. > Actually I do not like vim and emacs.. I am trying to find an ed

[R] How to deal with more than 6GB dataset using R?

2010-07-23 Thread babyfoxlove1
 Hi there, Sorry to bother those who are not interested in this problem. I'm dealing with a large data set, more than 6 GB file, and doing regression test with those data. I was wondering are there any efficient ways to read those data? Instead of just using read.table()? BTW, I'm using a 64bit

Re: [R] decimal seperator

2010-07-23 Thread Jennifer Sabatier
Wow, that's even better! Thanks to you both. I know both options will come in handy! Jen On Fri, Jul 23, 2010 at 11:58 AM, David Winsemius wrote: > > On Jul 23, 2010, at 11:32 AM, Jennifer Sabatier wrote: > > Hi R-List, >> >> I have a question regarding R-language formats, I think. I am pr

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread stephen sefick
If you have a zoo series this should work. If it doesn't then please tell me because I think it works. snap2min <- function(zoo, min="00:15:00"){ min15 <- times(min) a <- aggregate(zoo, trunc(time(zoo), min15), function(x) mean(x, na.rm=TRUE)) } hth Stephen Sefick On Fri, Jul 23, 2010 at 11:00

Re: [R] decimal seperator

2010-07-23 Thread Jennifer Sabatier
Worked like a charm! Thanks a lot! Jen On Fri, Jul 23, 2010 at 11:48 AM, Alain Guillet wrote: > Hi, > > I am sure there is a better solution but a possibility is that you use > sub("\\.",",",as.character(newdata)) instead of newdata in the text calls. > > HTH, > Alain > > > > > On 23-Jul-10

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 11:35 AM, David Winsemius wrote: On Jul 23, 2010, at 11:20 AM, > wrote: Hi folks, I've got a POSIXct datum as follows: Sys.time() [1] "2010-07-23 11:29:59 BST" I want to convert this to the nearest half-hour, i.e., to "2010-07-23 11:30:00 BST" (If the time were

Re: [R] decimal seperator

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 11:32 AM, Jennifer Sabatier wrote: Hi R-List, I have a question regarding R-language formats, I think. I am producing a series of graphs (using plot, barplot, barchart, and bwplot, using either text or mtext to place values on the graphs) and tables for a Francophone

Re: [R] converting a time to nearest half-hour

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 11:20 AM, > wrote: Hi folks, I've got a POSIXct datum as follows: Sys.time() [1] "2010-07-23 11:29:59 BST" I want to convert this to the nearest half-hour, i.e., to "2010-07-23 11:30:00 BST" (If the time were "11:59:ss", I want to convert to "12:00:00"). How to a

[R] decimal seperator

2010-07-23 Thread Jennifer Sabatier
Hi R-List, I have a question regarding R-language formats, I think. I am producing a series of graphs (using plot, barplot, barchart, and bwplot, using either text or mtext to place values on the graphs) and tables for a Francophone country. In fact, I have already done so. However, while they

Re: [R] Correct statistical inference for linear regression modelswithout intercept in R

2010-07-23 Thread Setlhare Lekgatlhamang
In addition, there are 'theoretical' reasons for excluding intercept from the model that must be considered. The reasons related to the regressor(s) and depend on the phenomenon being modelled. For example, whereas the intercept can be excluded in a bivariate model on the expenditure of an individu

Re: [R] randomness using runif

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 11:16 AM, Brigid Mooney wrote: I'm working on a problem where I'm introducing random error and have been using the built in function runif to provide that random error. However, I realized that I seem to be getting some unexpected behavior out of the function and was hoping

Re: [R] randomness using runif

2010-07-23 Thread Duncan Murdoch
On 23/07/2010 11:16 AM, Brigid Mooney wrote: I'm working on a problem where I'm introducing random error and have been using the built in function runif to provide that random error. However, I realized that I seem to be getting some unexpected behavior out of the function and was hoping someone

[R] converting a time to nearest half-hour

2010-07-23 Thread Murali.Menon
Hi folks, I've got a POSIXct datum as follows: > Sys.time() [1] "2010-07-23 11:29:59 BST" I want to convert this to the nearest half-hour, i.e., to "2010-07-23 11:30:00 BST" (If the time were "11:59:ss", I want to convert to "12:00:00"). How to achieve this? Thanks, Murali

[R] randomness using runif

2010-07-23 Thread Brigid Mooney
I'm working on a problem where I'm introducing random error and have been using the built in function runif to provide that random error. However, I realized that I seem to be getting some unexpected behavior out of the function and was hoping someone could share some insight. I don't know the ru

Re: [R] FW: recoding problem

2010-07-23 Thread Joshua Wiley
Hi Tom, This seems to work like I'd expect: HGlt10RawPerc2008 <- read.table(textConnection(" -5 0 -1 -1 0 2 3 -5 -2 0 2 0 1 -2 3 0 4 1 4 2 ")) recode(HGlt10RawPerc2008 ,"-100:0.0 = 10; 0:1.0 = 8; 1.001:3.0 = 6; 3.001:4.0 = 4; 4.001:5.0 = 2; else = 0") I wonder if your data might n

[R] FW: recoding problem

2010-07-23 Thread Heiman, Thomas J.
Hi, I am trying to recode the output from a matrix(here is a small snippet of it): HGlt10RawPerc2008[1:20] [1] -5 0 -1 -1 0 2 3 -5 -2 0 2 0 1 -2 3 0 4 1 4 2 H

[R] recoding problem

2010-07-23 Thread Heiman, Thomas J.
Hi, I am trying to recode the output from a matrix(here is a small snippet of it): HGlt10RawPerc2008[1:20] [1] -5 0 -1 -1 0 2 3 -5 -2 0 2 0 1 -2 3 0 4 1 4 2 Her

Re: [R] Regex in an IF statement?

2010-07-23 Thread Allan Engelhardt
help("difftime") is probably what you want. If not, please post a standalone example Allan On 23/07/10 15:18, Jim Hargreaves wrote: Dear List I have the POSIX timestamps of two events, A and B respectively. I want an expression that tests if A occurs within 4 weeks of B. Something like: i

[R] overriding axis limits in hexbin plot?

2010-07-23 Thread Ben Bolker
[cc'd to package maintainer] This feels like a fairly straightforward question, so I'm surprised not to have found an answer so far (RSiteSearch, package help, vignette ...) It seems fairly hard (without some fairly serious hacking) to hard-code the axis limits in a hexbin plot from the hexb

[R] Regex in an IF statement?

2010-07-23 Thread Jim Hargreaves
Dear List I have the POSIX timestamps of two events, A and B respectively. I want an expression that tests if A occurs within 4 weeks of B. Something like: if (ts_A "is between" ts_B + 4(weeks) and ts_B - 4) ... Can probably done by regex but the regex docu for R says nothing about if state

Re: [R] Midpoint between coordinates

2010-07-23 Thread Mafalda Viana
Dear David and R users, Thank you very much for the help. There is a function in the suggested package called "midPoint" which does what I need. df<- data.frame(lon1=c(-4.568,-4.3980), lat1=c(59.235,56.369), lon2=c(-5.123,-4.698), lat2=c(60.258,59.197) ) library(geosphere) p1 <- matrix(c(df$lo

Re: [R] Syntax Highlightning and Editor for Linux

2010-07-23 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 23/07/2010 15:56, Alaios wrote: > I would like oto thank everyone for the replies. > I instaled rkward.. It looks like an editor.. Is it possible to execute Yes > also your code from the text editor. Look into the "Run" menu > If there is a functi

Re: [R] Syntax Highlightning and Editor for Linux

2010-07-23 Thread Alaios
I would like oto thank everyone for the replies. I instaled rkward.. It looks like an editor.. Is it possible to execute also your code from the text editor. If there is a function call myfunc inside my file test.R Is it possible to exectute the function from the rwkard? Best Regards Alex ___

Re: [R] Figures in Latex

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 9:43 AM, li li wrote: Hi all, I want to add 6 plots in the format of 2 columns and 3 rows as one figure in latex. The plots are in .eps file. I know how to add 2 plots side by side, but could not figure out how to do multiple rows. I know this may not be the right plac

Re: [R] Syntax Highlightning and Editor for Linux

2010-07-23 Thread Federico Andreis
I have been trying emacs with ess, Kate, plain gedit..nothing really satisfied me.. but then I found a nice plugin for gedit: Rgedit ! it supports split screen with R terminal window (you can also personalize colour if, like me, do like to stick with old habits :) ), moreover gedit has a brackets

[R] Figures in Latex

2010-07-23 Thread li li
Hi all, I want to add 6 plots in the format of 2 columns and 3 rows as one figure in latex. The plots are in .eps file. I know how to add 2 plots side by side, but could not figure out how to do multiple rows. I know this may not be the right place to ask such a question. But I do not know who

Re: [R] legend in R plot

2010-07-23 Thread li li
Thank you all for your kind reply and help. I changed the legend function as Mr. Peter Ehlers suggested and the plots look good. Thank you again. Hannah 2010/7/22 Peter Ehlers > On 2010-07-21 22:06, li li wrote: > >> Hi all, >> I am have some difficulty with the legend

Re: [R] start and end times to yes/no in certain intervall

2010-07-23 Thread Allan Engelhardt
I like loops for this kind of thing so here is one: df<- structure(list(start = c("15:00", "15:00", "15:00", "11:00", "14:00", "14:00", "15:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00"), end = c("16:00", "16:00", "16:00",

Re: [R] Midpoint between coordinates

2010-07-23 Thread David Winsemius
On Jul 23, 2010, at 8:58 AM, Mafalda Viana wrote: The arithmetic mean was my first approach and to nearby points it doesn't make much difference. However, when the distance between the 2 points gets bigger this is no longer accurate enough. So yes, I was thinking on spherical geometry, midpoint

Re: [R] Midpoint between coordinates

2010-07-23 Thread Mafalda Viana
The arithmetic mean was my first approach and to nearby points it doesn't make much difference. However, when the distance between the 2 points gets bigger this is no longer accurate enough. So yes, I was thinking on spherical geometry, midpoint considering the great circle distance or similar. Th

[R] specify heat.colors

2010-07-23 Thread syrvn
Hi, I use heatmap.2 and heat.colors. Is it possible to specify the colors in that way that all values below, for instance, 1.5 should be coloured red, values between 1.5 and 1.7 green and above 1.7 black? Many thanks -- View this message in context: http://r.789695.n4.nabble.com/specify-heat-c

Re: [R] How to get vector of poitions in a vector ?

2010-07-23 Thread Martyn Byng
(1:length(a))[a != 0] -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of vikrant Sent: 23 July 2010 12:13 To: r-help@r-project.org Subject: [R] How to get vector of poitions in a vector ? I have a vector a = c(1,0,0,0,1,0,4,0,0,0) Now

Re: [R] Question about a perceived irregularity in R syntax

2010-07-23 Thread Duncan Murdoch
On 23/07/2010 7:14 AM, Duncan Murdoch wrote: Nordlund, Dan (DSHS/RDA) wrote: >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Peter Dalgaard >> Sent: Thursday, July 22, 2010 3:13 PM >> To: Pat Schmitz >> Cc: r-help@r-projec

Re: [R] model.tables call fails with "Error in inherits(object, "formula")"

2010-07-23 Thread Prof Brian Ripley
The error message actually is Error in inherits(object, "formula") : object 'frmlc' not found and it is the omitted-by-you part after the colon that matters: the body of model.tables does not have 'frmlc' in its scope. Here is one approach to using dynamic formulae that works in a lot of sim

[R] sink function

2010-07-23 Thread nuncio m
I have the following code to write the output from auto.arima function. The issue is not in finding the model but to divert its out put fit to a file order_fit.txt. code runs but nothing is written to order_fit.txt where am I going wrong library(forecast) for (i in 1:2) { filen = paste("file",i,"

Re: [R] Syntax Highlightning and Editor for Linux

2010-07-23 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 23/07/2010 14:17, Alaios wrote: > I would like to thank you for your immediate reply. > Actually I do not like vim and emacs.. I am trying to find an editor with a > gui > that will work fine in Linux. Well - you are missing out with not using ema

Re: [R] How to import simple java/mathematica expression to R

2010-07-23 Thread jim holtman
It would be nice if you could post what the data looks like that you want to import. R can import any text file and then you have string manipulation that you can do to parse it. So the basic answer is probably yes, but we do need to understand the format of the data to give a more precise answer

Re: [R] start and end times to yes/no in certain intervall

2010-07-23 Thread jim holtman
try this: > char2hr <- function(time){ + mat <- do.call(rbind, strsplit(time, ":")) + mode(mat) <- 'numeric' + mat %*% c(1, 1/60) # convert to hours + } > # convert to hours > x.hr <- apply(x, 2, char2hr) > # generate a set of sequences to set values > x.seq <- apply(x.hr, 1, function

  1   2   >