How to prevent dropping dimensions in a matrix/array?

When you create a matrix in the usual way like this, > a <- matrix(rnorm(10),2,5) > a        [,1]      [,2]       [,3]       [,4]       [,5] [1,]  1.3488918 0.6225795 -0.7444514  1.3130491  1.7877849 [2,] -0.2385392 0.5656759  0.9037435 -0.2217444 -0.2656875 the dimension dropped after picking up a single row or column in this way, > b <- a[,1] > b… Continue reading How to prevent dropping dimensions in a matrix/array?

Published
Categorized as Default, R

How to crop an eps file?

When you create a figure (in e.g. eps format) with R, the margins around the main context are always too wide. To save the space in the final documents, e.g. LaTeX generated pdf file. I have figured out two ways of reducing the margins.If you just want to shrink the white margin of an eps… Continue reading How to crop an eps file?

Published
Categorized as Default, R

Common R traps

I will show some R traps here.  The purpose of this page is not going to tell you how “crappy” R is. R is great indeed and also these kind of “traps” can happen in any other languages. if(a<-5) Assume you want make a condition to check if “a is smaller than negative five“, then… Continue reading Common R traps

Published
Categorized as Default, R