[R] averaging rows on a data.frame according to a factor

2013-11-22 Thread john d
Dear all, I apologize for the newbie question, but I'm stuck. I have a data frame in the following form: dat-as.data.frame(cbind(c(a,a,a,b,b), c(1,2,3,3,2),c(4,3,5,4,4))) I need a way to generate a new dataframe with the average for each factor. The result should look like:

[R] histogram with bars colored according to a vector of values

2013-07-25 Thread john d
Dear all, Let's say I have the following data.frame: dat-data.frame(x=rnorm(100), y=rnorm(100,2)) and I plot a histogram of variable x, somethink like: hist(dat$x, breaks=-5:5) Now, I'd like to color each bar according to the mean of the cases according to y. For instance, the color of the bar

[R] help with PCA

2013-03-16 Thread john d
Dear all, If I do a PCA like this: dat-matrix(rnorm(30),ncol=3) res-prcomp(dat) Now, imagine that I got new data that I want to project onto the original PC axes. How do I do that? Thanks! John __ R-help@r-project.org mailing list

[R] multiple values in one column

2012-04-06 Thread John D. Muccigrosso
I have some data files in which some fields have multiple values. For example first last sex major John Smith M ANTH Jane DoeF HIST,BIOL What's the best R-like way to handle these data (Jane's major in my example), so that I can do things like summarize the other fields by

Re: [R] multiple values in one column

2012-04-06 Thread John D. Muccigrosso
On Apr 6, 2012, at 9:09 AM, John D. Muccigrosso wrote: I have some data files in which some fields have multiple values. For example first last sex major John Smith M ANTH Jane DoeF HIST,BIOL What's the best R-like way to handle these data (Jane's major in my

[R] circles()

2012-03-26 Thread John D. Muccigrosso
I cannot for the life of me figure this out: What's the parameter to fill in with color circles made with circles()? col changes the line color, but all I see in the help is a reference to additional graphic parameters, and no examples via google. Thanks! John Muccigrosso

[R] barplot and NA

2012-03-12 Thread John D. Muccigrosso
Am I wrong that barplot is supposed to just skip NAs, and continue with the rest of the data in a matrix column? That's how I read various posts on the subject. But that's not what happens for me with R64.app (on a Mac, obviously). For example: d0 - as.matrix(c(2,3,4)) d1 -

Re: [R] barplot and NA

2012-03-12 Thread John D. Muccigrosso
On 12 Mar 2012, at 12:47 , S Ellison wrote: Yes, to the extent that the default barplot plots the height of the bar so far as the sum of teh values so far, starting at teh first. For your first vector, no problem; for your second, the highest value is undefiuned, for the third, the sum is