[R] combing list objects

2012-09-03 Thread chris20
Hi, I am trying to combine a long list but I can't work out how to do it, for example: abun<-list(rep(0,5),rep(0,7),rep(0,4),rep(0,10)) nb<-c(5,5,1,8) fill.abun <- function(x, y) { set <- sample(1:length(x), size = y) x[set] <- rlnorm(length(set)) return(x) }

[R] centre two graphs on one plot

2011-06-29 Thread chris20
Hi, I am trying to put together a biplot using symbols and different colours instead of text as points. Someone has previously suggested using this code: PC <- prcomp (iris[,1:4]) lambda <- PC$sdev * sqrt(nrow(PC$x)) plot (t(t(PC$x)/lambda),pch=16,col=as.numeric(iris[,5])) par (new=T) Rot <- t(t

Re: [R] deleting rows containing a letter

2011-05-11 Thread chris20
Excellant! Thanks both for your replies. I've never used grep, I do use negative indexing but usually: -which(. %in% -- View this message in context: http://r.789695.n4.nabble.com/deleting-rows-containing-a-letter-tp3514473p3514829.html Sent from the R help mailing list archive at Nabb

[R] deleting rows containing a letter

2011-05-11 Thread chris20
Hi I have dataframe with different plot numbers in and different subplots as letters at the end of the plot number i.e. 1a, 1b 2-1a etc. I want to delete all rows that end in a specific letter eg... treat<-c("1a","1b","1c","2a","2b","2c","2-1a","2-1b","2-1c") a1<-1:9 b1<-9:1 d1<-data.frame(treat,a

[R] biplot breakdown help

2011-03-09 Thread chris20
Hi, I am trying to understand how the biplot.prcomp is constructed so I can manipulate it to emphasise particular observations and reduce the number of variables shown. The prcomp model I have ran has cor=TRUE and scale=TRUE I have worked out from looking at str(prcomp.model) that... prcomp.mode

[R] dataframes from a function

2011-02-04 Thread chris20
Hi, I'm trying to create a function to return three dataframes for later use in a graphic so I want the return from the function to give me dataframes and with unique names relating to the variable they are based on. For example. sub<-c("6-1a","6-1a","6-1a","9-2b","9-2b","9-2b","7c","7c","7c"

Re: [R] functions and multiple levels

2010-08-19 Thread chris20
Thanks for the replies, it wasn't quite what I wanted but it has given me some more code for working out averages. I have managed to construct something that nearly works level.1 level.2 observation 1 1 0.5 1 1

[R] functions and multiple levels

2010-08-18 Thread chris20
Hi, I am trying to write a function; I want to subtract the mean of each class in level 2 from the mean of each class in level 1 and square the answer, eg. level.1 level.2 observation 1 1 0.5 1 1 0.2 1

Re: [R] barchart with stacked and beside bars

2010-01-21 Thread chris20
I want n0 side by side then a gap and then n96 like in the first script "barplot(bio,beside=T)" I have done it in Excel but I had to put in some artifical zeros to produce the gap and i will have to change the axis labels, but i was wondering if there was a neater way of doing it in R http://n4.

[R] barchart with stacked and beside bars

2010-01-20 Thread chris20
Hi, Is there a way to stack bars in a barchart as well as "beside" bars for the same treatment? eg I have one barchart like this: bio<-matrix(c(10,23,9,25),nrow=2,byrow=T) ntreat<-c("n0","n96") colnames(bio)<-ntreat barplot(bio,beside=T) now i want a similar barchart but with stacked bars: