[R] Checking for duplicate rows in data frame efficiently

2010-07-13 Thread david hilton shanabrook
I wrote something to check for duplicate rows in a data frame, but it is too inefficient. Is there a way to do this without the nested loops? This code correctly indicates rows 1-7, 1-8, 2-9 and 7-8 are duplicates. m - matrix(c(1,1,1,1,1, 2,2,2,2,2, 6,6,6,6,6, 3,3,3,3,3, 4,4,4,4,4,

[R] shifted window of string

2010-06-14 Thread david hilton shanabrook
basically I need to create a sliding window in a string. a way to explain this is: v - c(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) window - 5 shift - 2 I want a matrix of characters with window columns filled with v by filling a row, then shifting over shift and continuing to

[R] color2D.matplot not giving colors

2010-03-06 Thread david hilton shanabrook
I am using color2D.matplot to plot a matrix about 400 by 200. The values in the matrix are 0:5 and NA. The resulting plot is not color, but shaded b/w. I tried to figure out how to add colors, I would like something like c(blue, green, red, cyan, green) #example motifx - matrix(NA,

[R] aggregate by factor

2010-01-30 Thread david hilton shanabrook
I have a data frame with two columns, a factor and a numeric. I want to create data frame with the factor, its frequency and the median of the numeric column head(motifList) events score 1 aeijm -0.2500 2 begjm -0.2500 3 afgjm -0.2500 4 afhjm -0.2500 5 aeijm

Re: [R] aggregate by factor

2010-01-30 Thread david hilton shanabrook
On 30 Jan 2010, at 4:20 PM, David Winsemius wrote: On Jan 30, 2010, at 4:09 PM, david hilton shanabrook wrote: I have a data frame with two columns, a factor and a numeric. I want to create data frame with the factor, its frequency and the median of the numeric column head(motifList

[R] function in aggregate applied to specific columns only

2010-01-03 Thread david hilton shanabrook
I want to use aggregate with the mean function on specific columns gender - factor(c(m, m, f, f, m)) student - c(0001, 0002, 0003, 0003, 0001) score - c(50, 60, 70, 65, 60) basicSub - data.frame(student, gender, score) basicSubMean - aggregate(basicSub, by=list(basicSub$student), FUN=mean,