[R] Adding bars to barplots

2008-10-08 Thread Kay, Winston
I'm trying to add stacked bars to a third column of a barplot and using the following code: year <- c(2004, 2005, 2006, 2007, 2008) nlic <- c(5,8,6,4,2) allow <- c(5,8,6,4,2) shot <- c(1,6,0,1,0) farm <- c(0,0,0,0,0) dfs <-matrix(data=c(nlic, allow), nrow=5, ncol=2) barplot(t(dfs), beside=T, nam

[R] Query in Cuminc - stratification

2008-12-08 Thread kay frances
Hello everyone,   I am a very new user of R and I have a query about the cuminc function in the package cmprsk. In particular I would like to verify that I am interpreting the output correctly when we have a stratification variable.   Hypothetical example:   group : fair hair, dark hair fsta

[R] (no subject)

2008-11-17 Thread Salas, Andria Kay
I need help generating all possible combination of a vector of randomly assigned values of 1 and -1. For example, a vector of 20 randomly placed 1s and -1s, and all possibilities (which would amount to 2^20 total vectors). I am able to generate one such vector (via sample(c(-1,1),20,replace=TR

[R] (no subject)

2008-11-18 Thread Salas, Andria Kay
I need help with another problem I am having that deals with the generation of vectors that I asked about yesterday. I now need to have each value in the vector (all values either 1 or -1) have a probability p that it will switch signs (so, say, each value has a 50% chance of switching from -1

[R] random value changes in a vector

2008-11-18 Thread Salas, Andria Kay
To clear up a question regarding my earlier posting regarding random changes in a vector: Say you have a vector (1, -1, -1, 1, 1, -1). I want each value in the vector to have a probability that it will change signs when this vector is regenerated. For example, probability = 50%. When the vec

[R] unique columns in a matrix and number of each

2008-11-22 Thread Salas, Andria Kay
I need help determining the unique columns of a matrix and the numbers of each unique column. For example, let's say I have a matrix with 6 columns, 2 of these are filled with the value of 1 and the other 4 are filled with the value of 0. I would then like to have a command that tells me what

[R] matching matrix columns to a vector

2008-11-24 Thread Salas, Andria Kay
I need help with (hopefully) just one more thing. I have been fussing with this for quite some time and have decided just to give up and ask! I want to match a column in a matrix to a vector. I found a "which" command that I thought would be helpful as it does the following: > g=c(1,5,3,2,7)

[R] if then statement problem

2008-11-27 Thread Salas, Andria Kay
I really need help with an if then statement I am having trouble with. A brief explanation of what I am trying to do: I have a p matrix of all permutations of a vector of length 3 filled with either 1s or -1s (these make up the columns). The p.unique matrix is the unique columns of the p matri

[R] controlling the number of times a script is repeated in a loop

2008-11-30 Thread Salas, Andria Kay
I am running a large for loop and at the end of each iteration a matrix is produced. The program changes the columns in the matrix, and each time a column is added the name of that column is "y". All original columns have no column name. Due to the nature of the program, all original columns