Re: [R] convert sas date format

2012-01-28 Thread peter dalgaard
What does this have to do with date formats?? Please do not use reply to discuss unrelated matters; even if you change the header, threading mail readers will become confused. Approach is a non-factor (the output says so), so treated as numerical, i.e. you are effectively doing a linear

Re: [R] date arithmetic discrepancy

2012-01-28 Thread peter dalgaard
On Jan 28, 2012, at 07:25 , Berend Hasselman wrote: On 27-01-2012, at 21:45, Ty Canuck wrote: What accounts for the different result? as.numeric(as.POSIXct(2012-01-13 08:10:00) - as.POSIXct(2012-01-13 00:00:00) , units='secs') [1] 29400 trunc(as.numeric(as.POSIXct(2012-01-13

Re: [R] automated libR location

2012-01-28 Thread Prof Brian Ripley
'library' in R has a different meaning: I've altered the subject to be more accurate 'libR'. This is what R CMD SHLIB is for: it does all this for you in a portable way. But if you want to DIY, you can use R CMD config to find out the appropriate linker incantation. BTW, I think it is

[R] Graph digitisation / tracing

2012-01-28 Thread cpolwart
I want to take some published graphs and digitise them to allow me to run some analysis on them. Is this possible using any of R's plugins. I don't think it is but I never cease to be amazed at what R can do and it'd be great if it was as it would almost certainly be more powerful than doing

[R] fatal error unable to restore data

2012-01-28 Thread PUTRI AYU OCTAVIANI
Dear R help team, I am trying to open R 2.13.0 to continue my analysis but it doesn't want to open and I get this message fatal error unable to restore saved data in .rdata. I don't know what went wrong ( iam using Windows 7). Could you please help me on this? Thanks a lot Putri -Indonesia-

Re: [R] finding rows in a matrix that match a vector

2012-01-28 Thread Florent D.
Try this: mine - 1:6 table.combos - matrix(data = 1:12, nrow = 10, ncol = 6, byrow) row.is.a.match - apply(table.combos, 1, identical, mine) match.idx - which(row.is.a.match) total.matches - sum(row.is.a.match) On Sat, Jan 28, 2012 at 2:10 AM, Jason J. Pitt pit...@uchicago.edu wrote: Hi

Re: [R] Subsetting for the ten highest values by group in a dataframe

2012-01-28 Thread Hadley Wickham
On Fri, Jan 27, 2012 at 1:26 PM, Sam Albers tonightstheni...@gmail.com wrote: Hello, I am looking for a way to subset a data frame by choosing the top ten maximum values from that dataframe. As well this occurs within some factor levels. ## I've used plyr here but I'm not married to this

Re: [R] fatal error unable to restore data

2012-01-28 Thread Duncan Murdoch
On 12-01-28 4:45 AM, PUTRI AYU OCTAVIANI wrote: Dear R help team, I am trying to open R 2.13.0 to continue my analysis but it doesn't want to open and I get this message fatal error unable to restore saved data in .rdata. I don't know what went wrong ( iam using Windows 7). Could you please

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-28 Thread Peter Langfelder
ehm... this doesn't take very many ideas. x = runif(n=10e6, min=0, max=1000) x = round(x) system.time( { y = x[-1] - x[-length(x)] }) I get about 0.5 seconds on my old laptop. HTH Peter On Fri, Jan 27, 2012 at 4:15 PM, Kevin Ummel kevinum...@gmail.com wrote: Hi everyone, Speed is the

Re: [R] Graph digitisation / tracing

2012-01-28 Thread Sarah Goslee
Hi, On Sat, Jan 28, 2012 at 5:42 AM, cpolw...@wittongilbert.free-online.co.uk wrote: I want to take some published graphs and digitise them to allow me to run some analysis on them. You can do this manually with locator(), but it's more efficient to use something like ImageJ if you have a

Re: [R] Subsetting for the ten highest values by group in a dataframe

2012-01-28 Thread Gabor Grothendieck
On Fri, Jan 27, 2012 at 2:26 PM, Sam Albers tonightstheni...@gmail.com wrote: Hello, I am looking for a way to subset a data frame by choosing the top ten maximum values from that dataframe. As well this occurs within some factor levels. ## I've used plyr here but I'm not married to this

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-28 Thread Hans W Borchers
R. Michael Weylandt michael.weylandt at gmail.com writes: I'd write your own diff() that eliminates the method dispatch and argument checking that diff - diff.default does. x[-1] - x[-len(x)] # is all you really need. (# you could also try something like c(x[-1], NA) - x which may be

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-28 Thread Dirk Eddelbuettel
On 28 January 2012 at 16:20, Hans W Borchers wrote: | R. Michael Weylandt michael.weylandt at gmail.com writes: | | I'd write your own diff() that eliminates the method dispatch and | argument checking that diff - diff.default does. | | x[-1] - x[-len(x)] # is all you really need. | (#

[R] Using the digest and t distribution.

2012-01-28 Thread Rohit Pandey
Hello R community, I have two questions: The first might be one of the silliest ever posted here and I apologize if I've missed some thing very obvious. It relates to using this digest. When I subscribed to the forum, I had chosen the digest option that bundles all mails every day into a single

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-28 Thread Dirk Eddelbuettel
On 28 January 2012 at 11:46, Dirk Eddelbuettel wrote: | | On 28 January 2012 at 16:20, Hans W Borchers wrote: | | R. Michael Weylandt michael.weylandt at gmail.com writes: | | | | I'd write your own diff() that eliminates the method dispatch and | | argument checking that diff - diff.default

Re: [R] Using the digest and t distribution.

2012-01-28 Thread David Winsemius
On Jan 28, 2012, at 1:08 PM, Rohit Pandey wrote: Hello R community, I have two questions: The first might be one of the silliest ever posted here and I apologize if I've missed some thing very obvious. It relates to using this digest. When I subscribed to the forum, I had chosen the digest

Re: [R] Error from Brugs 'r for windows gui front-end has stopped working''

2012-01-28 Thread Uwe Ligges
On 25.01.2012 18:50, Jin Minming wrote: Hello Uwe, Yes. These packages are what I used for the test in Windows 7 and vista system: R-2.14.1 in 32-bit BRugs version 0.7-5 OpenBUGS version (3.2.1) On a Win 7 32 bit with the same software as described above, I cannot reproduce a crash

Re: [R] laod multichannel-audio-files with readWave (tuneR)

2012-01-28 Thread Uwe Ligges
On 27.01.2012 11:04, Alex Hofmann wrote: Hi, I have a huge collection of 6-channel .wav files containing audio and sensor recordings, which I need to analyse, across all 6 channels. I'm thinking about what will be easier to do. 1. Just split the channels in an external audio-editor and than

Re: [R] cryptic error message: Error in embed(y, lag) : wrong embedding dimension

2012-01-28 Thread Uwe Ligges
Is there a reason you answer a 3.5 years old message? Uwe Ligges On 27.01.2012 12:37, kingsly wrote: According to the source code of embed function, it will stop work if dimention is1 orn . Part of the embed source code is mention below for your reference. if ((dimension 1) | (dimension

Re: [R] Generating repeated network measures in R

2012-01-28 Thread R. Michael Weylandt
It might help if you say what exactly you are struggling with. Even better would be to provide code and data using dput() (just for the data -- copy and paste the code). If you can write a function to do whatever it is use need on a single year, then tapply() will be useful for splitting by year,

[R] logical subsetting, indexes and NAs

2012-01-28 Thread Federico Calboli
Dear All, just a quick example: x = 1:25 x[12] = NA x [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 y = x[x10] y [1] 1 2 3 4 5 6 7 8 9 NA Is there any way of NOT getting NA for y = x[x10]? Similarly y = x[x15] y [1] 1 2 3 4 5 6 7

Re: [R] Graph digitisation / tracing

2012-01-28 Thread Derek Ogle
I have successfully used the digitize package for this purpose ... http://cran.r-project.org/web/packages/digitize/index.html cpolw...@wittongilbert.free-online.co.uk wrote: I want to take some published graphs and digitise them to allow me to run some analysis on them. Is this possible

Re: [R] logical subsetting, indexes and NAs

2012-01-28 Thread R. Michael Weylandt
x[which(x 10)] Michael On Sat, Jan 28, 2012 at 3:36 PM, Federico Calboli f.calb...@imperial.ac.uk wrote: Dear All, just a quick example: x  = 1:25 x[12] = NA x  [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 y = x[x10] y  [1]  1  2  3  4  5  6  7  8  9 NA

Re: [R] logical subsetting, indexes and NAs

2012-01-28 Thread baptiste auguie
Hi, which(x 15) omits the NA (treated as false). HTH, b. On 29 January 2012 09:36, Federico Calboli f.calb...@imperial.ac.uk wrote: Dear All, just a quick example: x  = 1:25 x[12] = NA x  [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 y = x[x10] y  [1]  1

Re: [R] logical subsetting, indexes and NAs

2012-01-28 Thread Dimitris Rizopoulos
how about x[x 10 !is.na(x)] I hope it helps. Best, Dimitris On 1/28/2012 9:36 PM, Federico Calboli wrote: Dear All, just a quick example: x = 1:25 x[12] = NA x [1] 1 2 3 4 5 6 7 8 9 10 11 NA 13 14 15 16 17 18 19 20 21 22 23 24 25 y = x[x10] y [1] 1 2 3 4 5

Re: [R] logical subsetting, indexes and NAs

2012-01-28 Thread David Winsemius
On Jan 28, 2012, at 3:45 PM, Dimitris Rizopoulos wrote: how about x[x 10 !is.na(x)] Besides this and the which() strategy there is also: subset(x, x10) I hope it helps. Best, Dimitris On 1/28/2012 9:36 PM, Federico Calboli wrote: Dear All, just a quick example: x = 1:25

Re: [R] Horizontal stacked 100% bars with ggplot2

2012-01-28 Thread Carlos Ortega
Hello, If it helps...: Lines - pet gender dog male dog female dog male cat female cat female cat male d.f - read.table(textConnection(Lines), header=T, as.is = TRUE) d.tab-table(d.f$pet, d.f$gender) d.f.tab-as.data.frame(table(d.f$pet, d.f$gender)) names(d.f.tab)-c('pet','gender', 'Freq')

[R] wireframe_box_axis

2012-01-28 Thread Branimir Hackenberger
Dear all! I am using wireframe function from lattice package. Is it possible to remove box around the plot but to keep axis (x, y, z)? Thanks in advance! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] wireframe_box_axis

2012-01-28 Thread David Winsemius
On Jan 28, 2012, at 5:06 PM, Branimir Hackenberger wrote: Dear all! I am using wireframe function from lattice package. Is it possible to remove box around the plot but to keep axis (x, y, z)? First hit on a search make box transparent lattice sarkar:

[R] Compiling R code to native code?

2012-01-28 Thread Gregory Propf
Simple question: is there a way to compile R scripts to native code?  If not is there anything else that might improve speed?  I'm not even sure that R compiles internally to byte code or not.  I assume it does since all modern languages seem to do this.  Maybe there's a JIT compiler?  Yes, I

Re: [R] Compiling R code to native code?

2012-01-28 Thread Jeff Newmiller
Nope. Most users get speed by using vectorized calculations. If you have already identified how to get correct answers, the next step is something like Rcpp or linking to a shared library written in your language of choice. But seriously, vectorizing is enough for most applications, and making

Re: [R] Compiling R code to native code?

2012-01-28 Thread Bert Gunter
Facts: 1. R does not by default compile bytecode. It uses a read-parse-eval cycle as described in the R Language Manual. 2. However, as of 2.14.0 (anyway) there is a compiler package that is shipped as part of the standard distribution. Written by Luke Tierney and his graduate student minions,

Re: [R] percentage from density()

2012-01-28 Thread Greg Snow
If you use logspline estimation (logspline package) instead of kernel density estimation then this is simple as there are cumulative area functions for logspline fits. If you need to do this with kernel density estimates then you can just find the area over your region for the kernel centered

Re: [R] calculating distance between latitude and longitude

2012-01-28 Thread R. A. Bilonick
On 01/27/2012 07:40 AM, uday wrote: I have some satellite data which contains latitude and longitude information . From this data I would like to calculate distance between first location (scalar latitude and longitude) and all other (vectors latitude and longitude) How I should solve this

Re: [R] Need very fast application of 'diff' - ideas?

2012-01-28 Thread Kevin Ummel
Thanks. I've played around with pure R solutions. The fastest re-write of diff (for the 1 lag case) I can seem to find is this: diff2 = function(x) { y = c(x,NA) - c(NA,x) y[2:length(x)] } #Compiling via 'cmpfun' doesn't seem to help (or hurt): require(compiler) diff2 = cmpfun(diff2) But

Re: [R] Graph Titles

2012-01-28 Thread chuck.01
Hard to help without a short example dataset (please read posting guide!) posted with dput(). You likely want to paste together a title for your graph. see ?paste Rambler1 wrote Another simple question that is driving me crazy: I have a for loop that loops through a matrix and pulls data

[R] For Loop Error

2012-01-28 Thread Melrose2012
Hi Again, I am writing a 'for loop' to create a matrix of randomly sampled colors. I've written this loop in matlab and it works fine. I then tried to do it in R and apparently there is something wrong with my syntax b/c every time I run the script, the for loop blows up at a different point in

Re: [R] Compiling R code to native code?

2012-01-28 Thread Ben Bolker
Jeff Newmiller jdnewmil at dcn.davis.ca.us writes: Nope. Most users get speed by using vectorized calculations. If you have already identified how to get correct answers, the next step is something like Rcpp or linking to a shared library written in your language of choice. But seriously,

Re: [R] Why does the order of terms in a formula translate into different models/ model matrices?

2012-01-28 Thread Ben Bolker
cberry at tajo.ucsd.edu writes: Alexandra alku at imm.dtu.dk writes: [snip] Close, but not quite. The problem lies in terms() Here are the attr(terms(...),factors) matrices: attributes(terms(Y ~ x:A + A:B,data=dat))$factors x:A A:B Y 0 0 x 2 0 A 2 2 B 0 1