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

2009-09-30 Thread Michael Knudsen
On Wed, Sep 30, 2009 at 8:40 PM, Michael Knudsen 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 possi

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

2009-09-30 Thread Michael Knudsen
e 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://si

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

2009-09-30 Thread Michael Knudsen
lternative > a = (1: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 -- Micha

Re: [R] Use of R in Schools

2009-09-19 Thread Michael Knudsen
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://lifeofknu

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 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, M

Re: [R] R on Multi Core

2009-09-13 Thread Michael Knudsen
lmed 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] A matrix calculation

2009-08-23 Thread Michael Knudsen
On Sun, Aug 23, 2009 at 8:53 PM, Bogaso 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 Knudse

Re: [R] Package read large file

2009-08-19 Thread Michael Knudsen
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 PL

Re: [R] Plot(x,y)

2009-08-18 Thread Michael Knudsen
On Tue, Aug 18, 2009 at 6:59 PM, David Winsemius 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

Re: [R] graph label greek symbol failure

2009-08-18 Thread Michael Knudsen
On Mon, Aug 17, 2009 at 12:51 PM, e-letter 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

Re: [R] Plot(x,y)

2009-08-18 Thread Michael Knudsen
On Sun, Aug 16, 2009 at 9:19 PM, malcolm Crouch 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, M

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

2009-08-14 Thread Michael Knudsen
ees > 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

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

2009-08-14 Thread Michael Knudsen
rest algorithm is very robust 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 Knud

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

2009-08-13 Thread Michael Knudsen
On Thu, Aug 13, 2009 at 3:07 PM, Gabor Grothendieck wrote: > See the split argument in ?sink Thanks! I actually did check the manual for sink (it's true!) but somehow I managed to overlook the split argument. -- Michael Knudsen micknud...@gmail.com http://lifeofknudsen.blog

Re: [R] Matrix addition function

2009-08-13 Thread Michael Knudsen
= function(X) { 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

[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 -- Micha

Re: [R] downsampling

2009-07-24 Thread Michael Knudsen
e 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 PLEASE do read

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

2009-07-22 Thread Michael Knudsen
ical "NULL" value.  Thoughts? I 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/ _

Re: [R] Find multiple elements in a vector

2009-07-22 Thread Michael Knudsen
On Wed, Jul 22, 2009 at 9:37 PM, Chuck Cleland 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/ ___

[R] Find multiple elements in a vector

2009-07-22 Thread Michael Knudsen
guess 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.

Re: [R] Multi-line comments?

2009-07-22 Thread Michael Knudsen
hat 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 htt

Re: [R] Multi-line comments?

2009-07-22 Thread Michael Knudsen
self. 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

Re: [R] heatmap plot

2009-07-21 Thread Michael Knudsen
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/r

Re: [R] writte file doubt

2009-07-21 Thread Michael Knudsen
e > 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-pro

Re: [R] Merging lot of zoo objects

2009-07-21 Thread Michael Knudsen
eN = list_of_prices[[N]] 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. -- Michae

Re: [R] heatmap plot

2009-07-20 Thread Michael Knudsen
2009/7/21 Markus Mühlbacher : > 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.co

Re: [R] mahalanobis distance

2009-07-20 Thread Michael Knudsen
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/r-hel

[R] kmeans.big.matrix

2009-07-20 Thread Michael Knudsen
g required package: 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 Kn

Re: [R] heatmap plot

2009-07-20 Thread Michael Knudsen
2009/7/20 Markus Mühlbacher : > 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://lifeofknud

Re: [R] heatmap plot

2009-07-20 Thread Michael Knudsen
d be fairly 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] mahalanobis distance

2009-07-20 Thread Michael Knudsen
I 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://lifeofknu

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

2009-07-20 Thread Michael Knudsen
g 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-project.org

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

2009-07-20 Thread Michael Knudsen
% instead of %do%, if you want to take 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, m

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

2009-07-20 Thread Michael Knudsen
art 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-guide.ht

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

2009-07-20 Thread Michael Knudsen
On Mon, Jul 20, 2009 at 10:23 AM, Michael Knudsen wrote: > Thanks! The shared.big.matrix was exactly what I needed. It still > remains 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" opti

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

2009-07-20 Thread Michael Knudsen
l remains 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 m

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

2009-07-20 Thread Michael Knudsen
be able to build 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 pos

[R] Building a big.matrix using foreach

2009-07-18 Thread Michael Knudsen
mbine option. I have 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/ ___

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

2009-07-17 Thread Michael Knudsen
On Fri, Jul 17, 2009 at 10:37 PM, PDXRugger 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!")]

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

2009-07-17 Thread Michael Knudsen
x1 = rep(1,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/ __

Re: [R] Transformation of data!

2009-07-17 Thread Michael Knudsen
ver want to do 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

Re: [R] Transformation of data!

2009-07-16 Thread Michael Knudsen
-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 m

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

2009-07-16 Thread Michael Knudsen
ou 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://lifeofknud

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 Schwartz 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://lifeofknudsen.blogspot.

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

2009-07-16 Thread Michael Knudsen
ernatively you could write: /Users/username/Desktop/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 posti

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

2009-07-15 Thread Michael Knudsen
you 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
On Tue, Jul 14, 2009 at 2:29 PM, Gabor Grothendieck 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/ __ R-

Re: [R] Nested for loops

2009-07-14 Thread Michael Knudsen
ession (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://stat.e

[R] R2WinBUGS on fedora linux question

2009-07-14 Thread Michael Knudsen
# This mail is forwarded from Mark Leeds (markle...@verizon.net) who is experiencing troubles sending to the list himself. # Hi:  I went through Soren Buhl's documentation for installing and running R2WinBUGS in linux. Thank you Soren for the nice documentation. I installed wine

Re: [R] Nested for loops

2009-07-13 Thread Michael Knudsen
On Tue, Jul 14, 2009 at 8:20 AM, Michael Knudsen wrote: > What do you mean? It looks a like a very general solution to me. Just got an email suggesting using the functions col and row. For example temp = matrix(c(1:36),nrow=6) which(col(temp)>row(temp)) This gives the indices (in the

Re: [R] Nested for loops

2009-07-13 Thread Michael Knudsen
ot 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 PLEA

[R] Nested for loops

2009-07-13 Thread Michael Knudsen
than 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

Re: [R] graph: axis label font

2009-07-13 Thread Michael Knudsen
teresting 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 micknu

Re: [R] Combine two matricies

2009-07-13 Thread Michael Knudsen
[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-