[R] from data.frame to Venn diagram

2012-02-27 Thread Lara Poplarski
Hello All, I have a data.frame with this structure: m <- matrix(sample(c(rep('yes', 10, replace = TRUE), rep('no', 10, replace = TRUE), NA), 500, replace = TRUE), nrow = 100, ncol = 5) colnames(m) <- colnames(m, do.NULL = FALSE, prefix = "col") m <- as.data.frame(m) I need to generate a Venn dia

[R] function recode within sapply

2011-10-02 Thread Lara Poplarski
Dear List, I am using function recode, from package car, within sapply, as follows: L3 <- LETTERS[1:3] (d <- data.frame(cbind(x = 1, y = 1:10), fac1 = sample(L3, 10, replace=TRUE), fac2 = sample(L3, 10, replace=TRUE), fac3 = sample(L3, 10, replace=TRUE))) str(d) d[, c("fac1", "fac2")] <- sapply(

[R] subsetting a list of matrices

2011-08-23 Thread Lara Poplarski
Hi all, I have an object that looks (roughly) like the following: l <- list(a = matrix(rnorm(9), 3), b = matrix(rnorm(9), 3), c = matrix(rnorm(9), 3)) l$a[3,] <- sample(c("Message 1", "Message 2", "Message 3")) l$b[3,] <- sample(c("Message 1", "Message 2", "Message 3")) l$c[3,] <- sample(c("Mess

[R] kronecker sum

2011-06-05 Thread Lara Poplarski
Dear All, Could someone please suggest how to find the Kronecker sum of two 2x2 matrices, i.e. given two matrices: -A A a -a and -B B b -b I need: -A-BA B 0 a -a-B 0 B b0 -A-b A 0b a-a-b Many thanks, Lara [[alternat

Re: [R] subsetting a list of dataframes

2011-05-17 Thread Lara Poplarski
m(x)[1]>1) > > should give you a vector with the elements of the list that you seek marked > with TRUE. > > This vector can then be used to extract a subset from your list by: > > data.reduced=data[entries.with.nrows] > > Or similar > > > HTH > Jann

[R] subsetting a list of dataframes

2011-05-17 Thread Lara Poplarski
Hello All, I have a list of dataframes, and I need to subset it by keeping only those dataframes in the list that meet a certain criterion. Specifically, I need to generate a second list which only includes those dataframes whose number of rows is > 1. Could someone suggest how to do this? I have

[R] applying a function to output a matrix

2011-01-25 Thread Lara Poplarski
Dear List, I am using function distCosine from package geosphere to a list of lat/lon coordinates, and I want to calculate the great circle distance between a pair of coordinates in the list and all other pairs --- essentially, the output should be a matrix. I have been able to achieve this with t

[R] diverting output from nested loops

2010-11-24 Thread Lara Poplarski
Dear List, I have a series of nested loops with the structure shown below, and I am struggling to figure out how to divert output to folders created with dir.create() within the loops. What I need is for the output to end up as topNameK/subNameL/objNameM.pdf; what I get instead is a series of dir

[R] negative axis values in image() and scalebar in cor.plot() {psych}

2010-11-18 Thread Lara Poplarski
Dear List, I sent a related message yesterday, but did not receive it through the mailing list; on the R-help archives it reads as "An embedded and charset-unspecified text was scrubbed...". So here it is again, with the (little) progress I have made since then. Any help would be greatly appreciat

[R] modify the scalebar in cor.plot {psych}?

2010-11-17 Thread Lara Poplarski
Dear List, I am working with a relatively large correlation matrix (~1600*1600), which I am looking to plot with function cor.plot in package psych. cor.plot draws a scalebar with as many tick marks/subdivisions as there are rows in the matrix, which makes the values unreadable even for relativel

Re: [R] rotate column names in large matrix

2010-11-16 Thread Lara Poplarski
=c(1,1,5,1), xpd=TRUE) > > # display image without the 90 degree counter clockwise rotation > image(t(x[nrow(x):1,]), axes=FALSE) > > ## add 100 column names > y<-paste("column", 1:100) > text( seq(0,1,length=100) , 1.01, y, pos = 2, srt = 270, offset=0, cex=.7)

[R] rotate column names in large matrix

2010-11-15 Thread Lara Poplarski
Dear List, I have a large (1600*1600) matrix generated with symnum, that I am using to eyeball the structure of a dataset. I have abbreviated the column names with the abbr.colnames option. One way to get an even more compact view of the matrix would be to display the column names rotated by 90

[R] exploratory analysis of large categorical datasets

2010-11-11 Thread Lara Poplarski
Dear List, I am looking to perform exploratory analyses of two (relatively) large datasets of categorical data. The first one is a binary 80x100 matrix, in the form: matrix(sample(c(0,1),25,replace=TRUE), nrow = 5, ncol=5, dimnames = list(c( "group1", "group2","group3", "group4","group5"), c("V