Re: [R] rounding down with as.integer

2015-01-01 Thread Duncan Murdoch
On 01/01/2015 2:43 PM, Mike Miller wrote: On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 01/01/2015 1:21 PM, Mike Miller wrote: On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 31/12/2014 8:44 PM, David Winsemius wrote: On Dec 31, 2014, at 3:24 PM, Mike Miller wrote: This is probably a FAQ,

Re: [R] rounding down with as.integer

2015-01-01 Thread Mike Miller
On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 01/01/2015 1:21 PM, Mike Miller wrote: On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 31/12/2014 8:44 PM, David Winsemius wrote: On Dec 31, 2014, at 3:24 PM, Mike Miller wrote: This is probably a FAQ, and I don't really have a question about it,

Re: [R] rounding down with as.integer

2015-01-01 Thread Richard M. Heiberger
Interesting. Following someone on this list today the goal is input the data correctly. My inclination would be to read the file as text, pad each number to the right, drop the decimal point, and then read it as an integer. 0 1 2 0.325 1.12 1.9 0.000 1.000 2.000 0.325 1.120 1.900 1000 2000

Re: [R] rounding down with as.integer

2015-01-01 Thread Mike Miller
On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 31/12/2014 8:44 PM, David Winsemius wrote: On Dec 31, 2014, at 3:24 PM, Mike Miller wrote: This is probably a FAQ, and I don't really have a question about it, but I just ran across this in something I was working on: as.integer(1000*1.003)

Re: [R] normalmixEM does not produce the same results when run twice using the same data.

2015-01-01 Thread Berend Hasselman
On 01-01-2015, at 05:52, John Sorkin jsor...@grecc.umaryland.edu wrote: Windows 7 I am running normalmixEM to fit two normal curves to my data. For some reason, that I don't understand, the results of running the function twice, on the same data, results in two different (although

Re: [R] rle with data.table - is it possible?

2015-01-01 Thread Jeff Newmiller
Thank you for attempting to encode what you want using R syntax, but you are not really succeeding yet (too many errors). Perhaps another hand generated result would help? A new input data frame might or might not be needed to illustrate desired results. Your second and third lines are

Re: [R] rle with data.table - is it possible?

2015-01-01 Thread Kate Ignatius
Is it possible to add the following code or similar in data.table: childseg-0 x:=sumchild -0 span-rle(x)$lengths[rle(x)$values==TRUE childseg[x]-rep(seq_along(span), times = span) childseg[childseg == 0]-'' I was hoping to do this code by Group for mum, dad and child. The problem I'm having is

Re: [R] rounding down with as.integer

2015-01-01 Thread Duncan Murdoch
On 31/12/2014 8:44 PM, David Winsemius wrote: On Dec 31, 2014, at 3:24 PM, Mike Miller wrote: This is probably a FAQ, and I don't really have a question about it, but I just ran across this in something I was working on: as.integer(1000*1.003) [1] 1002 I didn't expect it, but maybe I

[R] Select subtree with vector of leaves using zoom function of the ape package

2015-01-01 Thread Luigi Marongiu
Dear all, I am drawing a phylogenetic tree using the zoom() function of the ape package. Since I have 476 sequences in my alignment, this allows me to have the outlook of the main tree and then highlight a portion of it, and this works fine. At the moment I am using the approach of indicating

[R] add scale bar using add.scale.bar() on the main plot drawn with zoom() of the ape package

2015-01-01 Thread Luigi Marongiu
Dear all, I am drawing a phylogenetic tree using the zoom() function of the ape package. Since I have 476 sequences in my allagnment, this allows me to have the outlook of the main tree and then highlight a portion of it, and this works fine. However I would like to draw a scale bar using

Re: [R] rounding down with as.integer

2015-01-01 Thread Duncan Murdoch
On 01/01/2015 1:21 PM, Mike Miller wrote: On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 31/12/2014 8:44 PM, David Winsemius wrote: On Dec 31, 2014, at 3:24 PM, Mike Miller wrote: This is probably a FAQ, and I don't really have a question about it, but I just ran across this in something I

Re: [R] rle with data.table - is it possible?

2015-01-01 Thread David Winsemius
On Jan 1, 2015, at 5:07 PM, Kate Ignatius kate.ignat...@gmail.com wrote: Apologies - mix up of syntax all over the place, a habit of mine. The last line was in there because of code beforehand so it really doesn't need to be there. Here is the proper code I hope: childseg-0 x-sumchild

Re: [R] rle with data.table - is it possible?

2015-01-01 Thread Kate Ignatius
Apologies - mix up of syntax all over the place, a habit of mine. The last line was in there because of code beforehand so it really doesn't need to be there. Here is the proper code I hope: childseg-0 x-sumchild ==0 span-rle(x)$lengths[rle(x)$values==TRUE] childseg[x]-rep(seq_along(span),

Re: [R] rounding down with as.integer

2015-01-01 Thread Mike Miller
On Thu, 1 Jan 2015, Duncan Murdoch wrote: On 01/01/2015 1:21 PM, Mike Miller wrote: I understand that it's all about the problem of representing digital numbers in binary, but I still find some of the results a little surprising, like that list of numbers from the table() output. For

Re: [R] rounding down with as.integer

2015-01-01 Thread Mike Miller
I'd have to say thanks, but no thanks, to that one! ;-) The problem is that it will take a long time and it will give the same answer. The first time I did this kind of thing, a year or two ago, I manipulated the text data to produce integers before putting the data into R. The data were a

Re: [R] rounding down with as.integer

2015-01-01 Thread Ted Harding
I've been followeing this little tour round the murkier bistros in the back-streets of R with interest! Then it occurred to me: What is wrong with [using example data]: x0 - c(0,1,2,0.325,1.12,1.9,1.003) x1 - as.integer(as.character(1000*x0)) n1 - c(0,1000,2000,325,1120,1900,1003) x1 -

Re: [R] rounding down with as.integer

2015-01-01 Thread Mike Miller
Yes, Ted, that also works, but it's very slow: # read in values: data - scan( file=RECIP_IN, what=double(), nmax=recip_N*16000) Read 48013406 items # convert to integer by adding .5 and rounding down: ptm - proc.time() ; ints - as.integer( 1000 * data + .5 ) ; proc.time()-ptm user