[R] Dates to numeric in for loop

2017-11-14 Thread Mikkel Grum
ot; [1] "Date" Why is this apparently not a bug? Are there other types that change type when looped over? Kind regards Mikkel _ *Mikkel Grum* +44 7377337321 (mobile) mikkelgrum (Skype) [[alternative HTML version deleted]] ___

[R] RODBC not connecting from my Mac

2013-10-13 Thread Mikkel Grum
iODBC appears no longer to come standard with OSX, so I installed unixodbc and set it up following instructions here:  http://www.boriel.com/en/2013/01/16/postgresql-odbc-connection-from-mac-os-x/ I connected to my remote database with isql -v mydsn. No problem. Then I tried from R:

Re: [R] Loop over factor returns NA

2013-10-13 Thread Mikkel Grum
You'll need to tell us what class you time variable is in, e.g. the output of str(AB), but the following might work: for (i in unique(as.character(AB$time)) { Intervall - AB[as.character(AB$time) ==i, ] ... } Depending on the format, as.numeric( ) might work too. Regards Mikkel On Saturday,

Re: [R] Looping over names of multiple data frames in an R for() loop XXXX

2013-10-13 Thread Mikkel Grum
You might want to try: assign(d[1], read.csv(yourfile.csv)) ... write.csv(d1, yourfile.csv, append = FALSE) Regards Mikkel On Friday, October 11, 2013 2:53 PM, Dan Abner dan.abne...@gmail.com wrote: Hi everybody, I thought I was using the get() fn correctly here to loop over multiple data

[R] RODBC on Mac

2013-10-13 Thread Mikkel Grum
iODBC appears no longer to come standard with OSX, so I installed unixodbc and set it up following instructions here:  http://www.boriel.com/en/2013/01/16/postgresql-odbc-connection-from-mac-os-x/ I connected to my remote database with isql -v mydsn. No problem. Then I tried from R:

Re: [R] Loop over factor returns NA

2013-10-13 Thread Mikkel Grum
You'll need to tell us what class you time variable is in, e.g. the output of str(AB), but the following might work: for (i in unique(as.character(AB$time)) { Intervall - AB[as.character(AB$time) ==i, ] ... } Depending on the format, as.numeric( ) might work too. Regards Mikkel On Saturday,

Re: [R] R plotting

2013-10-13 Thread Mikkel Grum
Hi This seems to work: spdata$color - ifelse(spdata$change 0, red, green) plot(spdata$date, log(spdata$close), col = spdata$color) Regards Mikkel On Friday, October 11, 2013 5:14 PM, Mubar simon.keu...@student.unisg.ch wrote: Hi I have a question regarding plots in R. I have data from the

Re: [R] axis.Date language

2012-07-09 Thread Mikkel Grum
, Mikkel Grum wrote: Dear useRs I need to do graphs with dates in different languages on Ubuntu. In Windows the following will plot the date axis labels in Spanish: random.dates - as.Date(2001/1/1) + 70*sort(stats::runif(100)) language - Spanish Sys.setlocale(LC_TIME, language) plot(random.dates

[R] axis.Date language

2012-07-08 Thread Mikkel Grum
Dear useRs I need to do graphs with dates in different languages on Ubuntu. In Windows the following will plot the date axis labels in Spanish: random.dates - as.Date(2001/1/1) + 70*sort(stats::runif(100)) language - Spanish Sys.setlocale(LC_TIME, language) plot(random.dates, 1:100, xaxt=n)

Re: [R] Deleting Rows based on Factor and Time Period

2011-09-14 Thread Mikkel Grum
alldat$yearmonth - substr(alldat$mydate, 1, 7) From: Anna Dunietz anna.duni...@gmail.com Cc: r-help@r-project.org r-help@r-project.org Sent: Wednesday, September 14, 2011 3:21 AM Subject: Re: [R] Deleting Rows based on Factor and Time Period Mikkel - thank you

Re: [R] Image processing and analysis with R

2011-09-14 Thread Mikkel Grum
http://www.sciviews.org/zooimage/ might be useful. From: Jose Bustos Melo jbustosm...@yahoo.es To: r-help@r-project.org r-help@r-project.org Sent: Wednesday, September 14, 2011 4:06 PM Subject: [R] Image processing and analysis with R Hello everyone,  I'm

Re: [R] help with hclust and cutree

2011-09-13 Thread Mikkel Grum
plot(clust) rect.hclust(clust, h = 0.65) Is that what you wanted? - Original Message - From: Madeleine Seeland madeleine.seel...@in.tum.de To: r-help@r-project.org Cc: Sent: Tuesday, September 13, 2011 9:25 AM Subject: [R] help with hclust and cutree Hello, I would like to cut a

Re: [R] Deleting Rows based on Factor and Time Period

2011-09-13 Thread Mikkel Grum
The following will get you the first stock in each week. Is that useful? install.packages(surveillance) library(surveillance) alldat$year - isoWeekYear(alldat$mydate)$ISOYear alldat$week - isoWeekYear(alldat$mydate)$ISOWeek alldat - alldat[order(alldat$year, alldat$week), ]

Re: [R] Selecting row indices from a data.frame by a factor and simple calculation (miniumum)

2011-09-13 Thread Mikkel Grum
Code - c(rep(NY14/3070, 3), rep(NY14/5459, 2)) Code - as.factor(Code) absdiff - c(2, 4, 1, 5, 7) df - data.frame(Code, absdiff) which(     paste(df$Code, df$absdiff) ==      paste(         aggregate(df$absdiff, by = list(df$Code), min)$Group.1,         aggregate(df$absdiff, by = list(df$Code),

Re: [R] space in directory name

2011-09-13 Thread Mikkel Grum
You are missing \\ between Documents and settings and Administrator. - Original Message - From: dbonneau daronnebonn...@gmail.com To: r-help@r-project.org Cc: Sent: Tuesday, September 13, 2011 10:59 AM Subject: [R] space in directory name Hi, I am trying to read a text file located in

[R] Superimposing titles on dotcharts

2011-09-12 Thread Mikkel Grum
I've created a chart with times that employees have entered data on named tasks as in the following example: Employee - c(rep(Tom, 127),  rep(Dick, 121),  rep(Sally, 130) ) Time - c(seq(as.POSIXct(2011-09-12 07:00:00), as.POSIXct(2011-09-12 14:00:00), 200), seq(as.POSIXct(2011-09-12 07:00:00),

[R] process id of an R script

2011-09-07 Thread Mikkel Grum
I have a script that runs as a cron job every minute (on Ubuntu 10.10 and R 2.11.1), querying a database for new data. Most of the time it takes a few seconds to run, but once in while it takes more than a minute and the next run starts (on the same data) before the previous one has finished.

Re: [R] Time and db precision

2011-05-26 Thread Mikkel Grum
--- On Thu, 5/26/11, Marc Schwartz marc_schwa...@me.com wrote: From: Marc Schwartz marc_schwa...@me.com Subject: Re: [R] Time and db precision To: Mikkel Grum mi2kelg...@yahoo.com Cc: R Help r-help@r-project.org Date: Thursday, May 26, 2011, 8:22 AM On May 25, 2011, at 6:25 PM, Mikkel Grum

[R] Time and db precision

2011-05-25 Thread Mikkel Grum
I have a loop that regularly checks for new data to analyse in my database. In order to facilitate this, the database table has a timestamp column with the time that the data was inserted into the database. Something like this: while () { load(timetoken.Rdata) df - sqlQuery(con,

[R] tryCatch?

2011-05-04 Thread Mikkel Grum
I would like to do inserts into a database table, but do updates in the fairly rare cases in which the inserts fail. I thought tryCatch might be the way to do it, but I honestly do not understand the help file for tryCatch at all. I thought something like this might work: for (i in seq(along =

Re: [R] tryCatch?

2011-05-04 Thread Mikkel Grum
...@stats.ox.ac.uk wrote: From: Prof Brian Ripley rip...@stats.ox.ac.uk Subject: Re: [R] tryCatch? To: Mikkel Grum mi2kelg...@yahoo.com Cc: R Help r-help@r-project.org Date: Wednesday, May 4, 2011, 12:21 PM Start with try(): you may find it easier to understand. if(inherits(try(call1), try-error

[R] INSERT OR UPDATE

2011-05-02 Thread Mikkel Grum
I'm trying to insert rows of a data.frame into a database table, or update where the key fields of a record already exist in the table. I've come up with a possible solution below, but would like to hear if anyone has a better solution. # The problem demonstrated: # Create a data.frame with

Re: [R] INSERT OR UPDATE

2011-05-02 Thread Mikkel Grum
Subject: Re: [R] INSERT OR UPDATE To: Mikkel Grum mi2kelg...@yahoo.com Cc: R Help r-help@r-project.org Date: Monday, May 2, 2011, 5:15 PM Rather than selecting all the keys, then having R loop through them, why not have postgres do it for you with something like:   #go through each line in our entry

Re: [R] Problem with combined two data frame.

2011-01-23 Thread Mikkel Grum
If you want all your NAs in the column GPAX to be 2.36, you could also say df2$GPAX[is.na(df2$GPAX)] - 2.36 If you want only that specific NA to be 2.36, you are probably better off using df2$GPAX[rownames(df2) == 156] - 2.36. --- On Sun, 1/23/11, Den d.kazakiew...@gmail.com wrote: From: Den

[R] batch file output

2010-12-28 Thread Mikkel Grum
I run a batch file with the following command in Windows XP: C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore C:\users\me\file.R C:\users\me\file.out 21 Is there any way to get only the output of R in file.out, without getting all the code from file.R too? Any help greatly appreciated,

Re: [R] batch file output

2010-12-28 Thread Mikkel Grum
...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] batch file output To: David Winsemius dwinsem...@comcast.net Cc: Mikkel Grum mi2kelg...@yahoo.com, r-help@r-project.org Date: Tuesday, December 28, 2010, 8:30 AM On Dec 28, 2010, at 8:27 AM, David Winsemius wrote

[R] need for speed on grid.rect

2010-10-20 Thread Mikkel Grum
When I use grid.rect to print a multi-coloured grid, it is incredibly slow compared to a single colour grid, or even a two colour grid. I've set out some simplified examples below. This is something I run literally thousands of times a day, so I would greatly appreciate any hints on how I

Re: [R] need for speed on grid.rect

2010-10-20 Thread Mikkel Grum
the pdfs. I'm not sure to what extent the Windows graphics drivers affects the png and pdf drivers? Mikkel --- On Wed, 10/20/10, Paul Murrell p.murr...@auckland.ac.nz wrote: From: Paul Murrell p.murr...@auckland.ac.nz Subject: Re: [R] need for speed on grid.rect To: Mikkel Grum mi2kelg

[R] Saving long character variable to database saves timestamp instead

2010-09-18 Thread Mikkel Grum
attached packages: [1] RODBC_1.3-1Revobase_3.2.0 All assistance appreciated. Best regards, Mikkel *** Mikkel Grum [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

[R] Pausing calculations for a fixed amount of time

2010-05-19 Thread Mikkel Grum
Is there any way to pause R for a gvien time period, i.e. without the need for user intervention? I've got a loop that I want to have work as hard as it can as long as there is data coming in, but when there is no new data, I would like it to pause before checking again. Something like in the

[R] tickmarks with time in dotplots

2010-02-22 Thread Mikkel Grum
Hi, I'm drawing lattice dotplots with time along the x-axis as in: C -data.frame(c(A, B),Sys.time()+ rnorm(50)*3600) names(C) - c(Name, Time) dotplot(Name ~ Time, data = C, horizontal = TRUE) On my display, the x-axis shows tick marks every two hours. I would like to show something more

[R] rterm user command line input

2009-12-07 Thread Mikkel Grum
? *** Mikkel Grum +254 20 2345285 +254 720639599 (mobile) mikkelgrum (Skype) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

[R] conout

2009-12-06 Thread Mikkel Grum
? *** Mikkel Grum +254 20 2345285 +254 720639599 (mobile) mikkelgrum (Skype) [[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

Re: [R] ftables package, zero rows

2008-09-03 Thread Mikkel Grum
Does this help? a - c(1,1,1,1,1,2,2,2,2,2) b - c(4,5,6,5,4,7,8,9,8,7) c - c(a,b,c,d,a,b,b,a,d,d) A - cbind(a,b,c) test - ftable(a,b,c) test.df - data.frame(test) test.df[test.df$Freq != 0, ] Doesn't quite give the layout you seem to want, but effectively removes the zeros. Mikkel

[R] Date formats

2007-12-29 Thread Mikkel Grum
Is the following expected behaviour for a date used in an ifelse function? date - Sys.Date() date [1] 2007-12-30 ifelse(TRUE, date-1, date) [1] 13876 ifelse(FALSE, date-1, date) [1] 13877 ifelse(TRUE, as.character(date-1), date) [1] 2007-12-29 if (TRUE) {date} [1] 2007-12-30 It would seem

Re: [R] truncated fields with RODBC

2007-12-15 Thread Mikkel Grum
and what size of number I was looking for. cheers, Mikkel - Original Message From: Prof Brian Ripley [EMAIL PROTECTED] To: Mikkel Grum [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Sunday, November 25, 2007 2:05:37 PM Subject: Re: [R] truncated fields with RODBC You need to study

Re: [R] truncated fields with RODBC

2007-11-25 Thread Mikkel Grum
will get the default of varchar(255)). The 64k limit is for reading, not writing. As ever, full details and a reproducible example are needed for people to help you fully. On Sat, 24 Nov 2007, Mikkel Grum wrote: I'm changing some functions from storing data in SQLite (using

[R] truncated fields with RODBC

2007-11-24 Thread Mikkel Grum
I'm changing some functions from storing data in SQLite (using RSQLite) to storing it in PostgreSQL (using RODBC). When trying to store very long character fields I get the following message: sqlSave(pg, Grids, rownames = FALSE, append = TRUE) Warning messages: 1: In odbcUpdate(channel,

[R] How to avoid saving the row index of a data.frame into MySQL ?

2007-10-11 Thread Mikkel Grum
?dbWriteTable row.names = F Tonight's top picks. What will you watch tonight? Preview the hottest shows on Yahoo! TV. http://tv.yahoo.com/ __

[R] clipping viewports

2007-09-30 Thread Mikkel Grum
Dear useRs, Why are the rotated blue and yellow boxes in the example below clipped outside of 6 x 6 inch window in the middle of the page?? Where does the 6 x 6 inch window come from? I would like to make use of the entire page. library(grid) pdf(file = FarmMaps.pdf, paper = a4)