[R] Rounding error in seq(...)

2009-09-30 Thread Michael Knudsen
:9)/10 works just fine. Are there any good guides out there on how to deal with issues like this? I am normally aware of rounding errors, but it really surprised me to see that an elementary function like seq would behave in this way. Thanks, Michael Knudsen -- Michael Knudsen micknud

Re: [R] Rounding error in seq(...)

2009-09-30 Thread Michael Knudsen
to but not equal to 1/10 (because 1/10 is not exactly representable in R), so you got something different. Well, the problem is that I don't know how seq is implemented. I just assumed that it wouldn't behave like this. -- Michael Knudsen micknud...@gmail.com http://sites.google.com/site

Re: [R] Rounding error in seq(...)

2009-09-30 Thread Michael Knudsen
On Wed, Sep 30, 2009 at 8:40 PM, Michael Knudsen micknud...@gmail.com wrote: a = seq(0.1,0.9,by=0.1) a [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 a[1] == 0.1 [1] TRUE a[2] == 0.2 [1] TRUE a[3] == 0.3 [1] FALSE A friend of mine just pointed out a possible solution: a=seq(0.1,0.9,by=0.1

Re: [R] Use of R in Schools

2009-09-19 Thread Michael Knudsen
read this paper http://www.ploscompbiol.org/article/info%3Adoi%2F10.1371%2Fjournal.pcbi.1000482 some days ago. It's quite interesting, and it links to some excellent slides that look great as templates for making your own R course. Best, Michael -- Michael Knudsen micknud...@gmail.com http

Re: [R] R on Multi Core

2009-09-13 Thread Michael Knudsen
overwhelmed by enthusiasm: http://lifeofknudsen.blogspot.com/2009/07/most-of-work-i-do-in-r-has-to-do-with.html It's very basic, but maybe you'll find it useful. Best, Michael Knudsen -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] how to determine if a variable is already set?

2009-09-13 Thread Michael Knudsen
On Fri, Sep 11, 2009 at 7:15 PM, carol white wht_...@yahoo.com wrote: It might be a primitive question but how it is possible to determine if a variable is initialized in an environment? What about this? x %in% ls() [1] FALSE x = 41 x %in% ls() [1] TRUE Best, Michael -- Michael Knudsen

Re: [R] A matrix calculation

2009-08-23 Thread Michael Knudsen
On Sun, Aug 23, 2009 at 8:53 PM, Bogasobogaso.christo...@gmail.com wrote: No no, I actually want following result : 7,   14,   21, 6,   13,   20, 5,   12,   19, How about this? x = c() for (i in 7:1) x = c(x,mat[i,]) Guess that would do the trick. Best, Michael -- Michael

Re: [R] Package read large file

2009-08-19 Thread Michael Knudsen
-- if that is the case, maybe the package bigmemory can alleviate your pain. Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Plot(x,y)

2009-08-18 Thread Michael Knudsen
On Sun, Aug 16, 2009 at 9:19 PM, malcolm Crouchmalcolm.crouc...@gmail.com wrote: plot(V6,V5, col=red) or plot(V6,V5) It seems that V5 and V6 are column names in your data matrix. If your matrix is called data, you should use plot(x$V6,x$V5,col=red) instead. Best, Michael -- Michael

Re: [R] graph label greek symbol failure

2009-08-18 Thread Michael Knudsen
On Mon, Aug 17, 2009 at 12:51 PM, e-letter inp...@gmail.com wrote: I have tried to add the delta (δ) symbol to the y axis label and the result is D, using the command: ...ylab=δt... Try ylab = expression(delta*t) instead. Best, Michael -- Michael Knudsen micknud...@gmail.com http

Re: [R] Plot(x,y)

2009-08-18 Thread Michael Knudsen
On Tue, Aug 18, 2009 at 6:59 PM, David Winsemiusdwinsem...@comcast.net wrote: ITYM: plot(data$V6, data$V5, col=red) Yup! My mistake. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list

Re: [R] randomForest question--problem with ntree

2009-08-14 Thread Michael Knudsen
and apparently 500 trees are usually more than enough. Therefore you don't get better results by using 2000 trees, and often it doesn't affect the performance if you use fewer trees (e.g. 200). Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] randomForest question--problem with ntree

2009-08-14 Thread Michael Knudsen
trees according to the output and identical results when you set the seed before the call. While results are expected to be similar they should not be identical if the number of trees was actuallly changed. Oops! You have written n.tree instead of ntree. Best, Michael -- Michael Knudsen

[R] Output to screen and file at the same time

2009-08-13 Thread Michael Knudsen
Hello! Using the sink function, output from R may be written to a file instead of the screen. I would really like to write my output to a file while running an R script and at the same time view the output live on my screen. Is there are way to do that? Thanks, Michael -- Michael Knudsen

Re: [R] Matrix addition function

2009-08-13 Thread Michael Knudsen
) { N = length(X) if (N==2) return(X[[1]]+X[[2]]) else return(matrixSum(X[[1:(N-1)]],X[[N]])) } I guess that one should do the trick. Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r

Re: [R] downsampling

2009-07-24 Thread Michael Knudsen
to sample 100 random entries from x? sample(sample(1:5,115,replace=TRUE),100,replace=FALSE)) -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Re placing null values (#NULL!)

2009-07-23 Thread Michael Knudsen
would like to test it myself, but I haven't succeeded in copying your data to a text file readable by R. If you can email it to me, I'll give it a try. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org

Re: [R] Multi-line comments?

2009-07-22 Thread Michael Knudsen
. It seems that the answer is negative, so I have ended up using if (1==0) { # code goes here } although is not really nice to look at. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list

Re: [R] Multi-line comments?

2009-07-22 Thread Michael Knudsen
that cmd+/ will make a block comment. By default it adds '//' instead of '#', but I guess that it can be fixed somehow. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch

[R] Find multiple elements in a vector

2009-07-22 Thread Michael Knudsen
was y=c(2,3) which(x==y) integer(0) which doesn't work. I haven't found any clue in the R manual. Thanks! -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] Find multiple elements in a vector

2009-07-22 Thread Michael Knudsen
On Wed, Jul 22, 2009 at 9:37 PM, Chuck Clelandcclel...@optonline.net wrote:  How about this? which(x %in% c(2,3)) Thanks to you all! I had never thought about using %% in this context. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] heatmap plot

2009-07-21 Thread Michael Knudsen
2009/7/21 Markus Mühlbacher muehli...@yahoo.com: So just that I understand right. x and y are the scalings of the x and y axis and the matrix represents the color of the points at each gridpoint? Precisely! Try ?image for more details. -- Michael Knudsen micknud...@gmail.com http

Re: [R] Merging lot of zoo objects

2009-07-21 Thread Michael Knudsen
]] you could easily define a recursive function to do the job for you. Would it difficult for you to read the data into a list? When dealing with only a few sets, numbering objects as you do is no problem, but for many objects it can become very cumbersome. -- Michael Knudsen micknud...@gmail.com

Re: [R] writte file doubt

2009-07-21 Thread Michael Knudsen
write(tmp,file=tmp.xls) You have to add an ncolumns option like write(tmp,file=tmp.xls,ncolumns=100). The default is five columns. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https

Re: [R] heatmap plot

2009-07-21 Thread Michael Knudsen
! If you can send me the matrix as a text file -- ready to import in R -- I can give it a try. Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo

Re: [R] Building a big.matrix using foreach

2009-07-20 Thread Michael Knudsen
the matrix row by row in a parallel way. Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] Building a big.matrix using foreach

2009-07-20 Thread Michael Knudsen
for me, though, to check if I run into memory problems anyway. It doesn't seem as if there's a don't return anything option in the foreach function (also mentioned in my previous post in this thread). Best, Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] Building a big.matrix using foreach

2009-07-20 Thread Michael Knudsen
(ks.test(first_x,second_x)$statistic) } y = attach.big.matrix(desc) y[i,] = these_distances } The error message from R was: *** caught segfault *** address (nil), cause 'memory not mapped' /Michael -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] what is meaning of the bubbles in boxplots?

2009-07-20 Thread Michael Knudsen
? They are outliers and part of your data. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ 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

Re: [R] I might be dumb : a simple question about foreach

2009-07-20 Thread Michael Knudsen
advantage of multiple cores. While being totally ecstatic after discovering foreach, I wrote the following (very simple) guide: http://lifeofknudsen.blogspot.com/2009/07/most-of-work-i-do-in-r-has-to-do-with.html Maybe you'll find it useful, maybe not. -- Michael Knudsen micknud...@gmail.com http

Re: [R] I might be dumb : a simple question about foreach

2009-07-20 Thread Michael Knudsen
is slowly waking up now, so cross your fingers :-) -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

Re: [R] mahalanobis distance

2009-07-20 Thread Michael Knudsen
guess that the matrix is therefore considered non-invertible by R. Recall that S must be invertible http://en.wikipedia.org/wiki/Mahalanobis_distance to work as a covarinace matrix in the definition of the Mahalanobis distance. -- Michael Knudsen micknud...@gmail.com http

Re: [R] heatmap plot

2009-07-20 Thread Michael Knudsen
easy to fit your data into that one. I guess that this should work: x = 1:length(activity.matrix) y = 1:length(activity.matrix) image(x, y, activity.matrix, col=heat.colors(100)) -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] heatmap plot

2009-07-20 Thread Michael Knudsen
2009/7/20 Markus Mühlbacher muehli...@yahoo.com: Gives the attached image. Again I am missing the white diagonal. Is there some kind of sorting that I do not consider? Maybe col=c(white,heat.colors(100)) will do the trick? -- Michael Knudsen micknud...@gmail.com http

[R] kmeans.big.matrix

2009-07-20 Thread Michael Knudsen
: bigmemory kmeans.big.matrix Error: object 'kmeans.big.matrix' not found Does anybody know how to get the kmeans.big.matrix() function? Are there other cluster algorithms out there ready to accept a big.matrix as input? Thanks! -- Michael Knudsen micknud...@gmail.com http

Re: [R] mahalanobis distance

2009-07-20 Thread Michael Knudsen
zero. Maybe I just don't get the point of the mahalanobis() function in R. It looks quite weird to me :-( -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo

Re: [R] Re placing null values (#NULL!)

2009-07-18 Thread Michael Knudsen
On Fri, Jul 17, 2009 at 10:37 PM, PDXRuggerj_r...@hotmail.com wrote: So i need to replace the the #NULL! with 0.  I have tried: Props_pct_vacant-Props_pct_vacant[Props_$pct_vacant !=#NULL!] Try this instead: Props_$pct_vacant[which(Props_$pct_vacant==#NULL!)] = 0 -- Michael Knudsen micknud

[R] Building a big.matrix using foreach

2009-07-18 Thread Michael Knudsen
checked out the big.matrix manual, but I can't find a function suitable for just that. Actually, I wouldn't even know how to do it for a usual matrix. Any clues? Thanks! -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help

Re: [R] Transformation of data!

2009-07-17 Thread Michael Knudsen
that. Here the proposed by R-guy solution  mydata - data.frame(W21) Where is your function, and what is W21? -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] dot plot with several points for 2 categories

2009-07-17 Thread Michael Knudsen
,times=length(y1)) x2 = rep(2,times=length(y2)) plot(c(x1,x2),c(y1,y2),xaxt=n) axis(side=1,at=c(1,2),labels=c(label1,label2)) It looks like a hack, but it should work. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r

Re: [R] loading a file in R in mac OS X

2009-07-16 Thread Michael Knudsen
/schools.txt -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ 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

Re: [R] loading a file in R in mac OS X

2009-07-16 Thread Michael Knudsen
On Thu, Jul 16, 2009 at 3:04 PM, Marc Schwartzmarc_schwa...@me.com wrote: Actually, by default, the OSX HFS+ file system is not case sensitive: Sorry. I just took that for granted, as Mac (at least in a terminal) is very similar to Linux. -- Michael Knudsen micknud...@gmail.com http

Re: [R] loading a file in R in mac OS X

2009-07-16 Thread Michael Knudsen
to Desktop, you can just type read.table(school.txt,...) I would, however, suggest that you move your files to a directory specifically dedicated to your R project in order not to clutter up your desktop. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] Transformation of data!

2009-07-16 Thread Michael Knudsen
 8.528219e-04 That it a vector of length 15. How is it possible to transform the data to get a vector as following 10   0.017511063 11   0.017819918 12   0.017944472 That looks like a 3x2 matrix. How do you get that from the vector above? -- Michael Knudsen micknud...@gmail.com http

Re: [R] The greatest common divisor between more than two integers

2009-07-15 Thread Michael Knudsen
want to calculate the greatest common divisor of. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

Re: [R] Nested for loops

2009-07-14 Thread Michael Knudsen
. This is not the general solution, (...) What do you mean? It looks a like a very general solution to me. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Nested for loops

2009-07-14 Thread Michael Knudsen
(in the matrix viewed as a vector) of the above-diagonal entries. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] Nested for loops

2009-07-14 Thread Michael Knudsen
expression (1:N^2)[which((1:N^2)!=seq(0,(N-1)*N,by=N)+(1:N))] to get the indices of the non-diagonal entries of a matrix :-) -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https

Re: [R] Nested for loops

2009-07-14 Thread Michael Knudsen
On Tue, Jul 14, 2009 at 2:29 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: seq. - function(from, to) seq(from = from, length = max(0, to - from + 1)) Really nice! Thank you! -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com

Re: [R] Combine two matricies

2009-07-13 Thread Michael Knudsen
))]=a[which(is.na(x))] -- Michael Knudsen micknud...@gmail.com http://www.google.com/profiles/micknudsen __ 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

Re: [R] graph: axis label font

2009-07-13 Thread Michael Knudsen
Interesting question, I didn't know the answer to, so I tried to look it up. There might be some help towards the bottom of this page: http://www.statmethods.net/advgraphs/parameters.html It seems to be specific for Windows, so I can't test it myself. -- Michael Knudsen micknud...@gmail.com

[R] Nested for loops

2009-07-13 Thread Michael Knudsen
B is in R interpreted as the numbers from B to A in reverse order. Is there a clever way to make nested loops like the one above in R? -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blogspot.com/ __ R-help@r-project.org mailing list https