Re: [R] Odd results with %% and conserving memory

2010-04-06 Thread JustinNabble
Thanks for the response. I read through the Inferno and there's a lot of useful stuff in there. However I think you may have missed something. Having some experience with other languages, I know that floating point numbers aren't represented exactly, the issue is that R is off by much more than w

[R] Odd results with %% and conserving memory

2010-03-27 Thread JustinNabble
Can anyone explain this? I have a matrix with double components. It's taking up a lot of memory, so I want to multiply then turn it to integers. I'm pretty certain that there are only 2 decimal places, but I wanted to check by using modulo. E.g. mat = matrix(11:50/100, ncol=4,nrow=10) #Matrix wi

[R] How to get minimum value by group

2010-01-11 Thread JustinNabble
I'd like to get a long data set of minimum values from groups in another data set. The following almost does what I want. (Note, I'm using the word factor differently from it's meaning in R; bad choice of words) myframe = data.frame(factor1 = rep(1:2,each=8), factor2 = rep(c("a","b"),each=4, time

[R] How do you test if a number is in a list of numbers?

2009-10-11 Thread JustinNabble
Hi, I want to subset a data frame if one of the variables matches any in a list. I could of course do something like this: subset(dataset, var == 1 | var == 2 | var ==3) but that's tedious. I tried varlist = c(1,2,3,4) subset(dataset, any(var == varlist)) but it doesn't work because 'any' doesn't