Re: [R] Extract values from vector and repeat by group

2013-11-18 Thread Benjamin Gillespie
November 2013 16:48 To: R help Cc: Berend Hasselman; Benjamin Gillespie Subject: Re: [R] Extract values from vector and repeat by group Hi, ?merge() sometimes change the order. For example: df1 <- df[-12,] df2 <- df1 merge(df1, df1[df1$time == 4, c("group", "var")], by.x

[R] Extract values from vector and repeat by group

2013-11-17 Thread Benjamin Gillespie
Hi all, I hope you can help. I have a data frame 'df': group=c(rep(1,8),rep(2,10),rep(3,11)) var=rnorm(29) time=c(seq(1,8),seq(1,10),seq(1,11)) df=data.frame(group,var,time) I would like to extract the value from 'var' for each 'group' at 'time'=4 and repeat these extracted values in a new vec

Re: [R] Possible loop/ if statement query

2013-10-11 Thread Benjamin Gillespie
868 7641 o---o http://www.geog.leeds.ac.uk/ o-o @RiversBenG o--o From: PIKAL Petr [petr.pi...@precheza.cz] Sent: 11 October 2013 14:06 To: Benjamin Gillespie; r-help@R-project.org

Re: [R] Splitting times into groups based on a range of times

2013-10-11 Thread Benjamin Gillespie
e(dt,id) Would you be able to suggest any workarounds for a situation like this? Many thanks in advance, Ben Gillespie, Research Postgraduate o---o School of Geography, University of Leeds, Leeds, LS2 9JT o------

[R] Splitting times into groups based on a range of times

2013-10-10 Thread Benjamin Gillespie
Hi all, I hope you can help with this one! I have a dataframe: 'df' that consists of a vector of times: 'dt2' and a vector of group id's: 'group': dates2=rep("01/02/13",times=8) times2=c("12:00:00","12:30:00","12:45:00","13:15:00","13:30:00","14:00:00","14:45:00","17:30:00") y =paste(dates2, ti

Re: [R] Possible loop/ if statement query

2013-10-10 Thread Benjamin Gillespie
: Benjamin Gillespie Cc: R help Subject: Re: [R] Possible loop/ if statement query Hi, Try: b1<- b b1[!b1>=7]<- NA lst1 <- split(b1,cumsum(c(0,abs(diff(b>=7) indx <- as.logical(((seq_along(lst1)-1)%%2)) lst1[indx]<- lapply(seq_along(lst1[indx]),function(i) {lst1[indx]

[R] Possible loop/ if statement query

2013-10-09 Thread Benjamin Gillespie
Dear r genii, I hope you can help. I have vector 'b': b=c((1:10),sort(1:9,decreasing=TRUE),(2:12),sort(6:11,decreasing=TRUE),(7:13)) and, from 'b' I wish to create vector 'c': c=c( NA,NA,NA,NA,NA,NA,1,1,1,1,1,1,1,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,2,2,2,2,2,2,2,2,2,2,2,NA,3,3,3,3,3,3,3) The

Re: [R] Statistical test for heteroscedasticity for an object of class "gls"

2013-04-18 Thread Benjamin Gillespie
LS2 9JT o---o http://www.geog.leeds.ac.uk/ o-o @RiversBenG o--o ____ From: Benjamin Gillespie Sent: 18 April 2013 15:38 To: r-help@R-project.org Subject: Statistical test for heteroscedastic

[R] Statistical test for heteroscedasticity for an object of class "gls"

2013-04-18 Thread Benjamin Gillespie
Hi there, Does anyone know of a statistical test for heteroscedasticity for an object of class "gls"? (or alternative objective methods). Thanks in advance, Ben Gillespie, Research Postgraduate o---o School of Geography, University

Re: [R] Superscript followed by number then superscript in text

2013-03-19 Thread Benjamin Gillespie
Thanks to Dennis, Thomas and Rui - I was missing the "~". Many thanks, Ben Gillespie Research Postgraduate From: Dennis Murphy [djmu...@gmail.com] Sent: 18 March 2013 20:47 To: Benjamin Gillespie Subject: Re: [R] Superscript followed by n

[R] Superscript followed by number then superscript in text

2013-03-18 Thread Benjamin Gillespie
Hi all, I'm having problems finding the correct format for a command. I would like to write some text on a plot. I'm using the following command: text(x,y,"text here", srt=90) I would like the text to read: capacity 10^3 m^3 (with ^ denoting superscript (i.e. each '3' as superscript). I've

Re: [R] Script for conditional sums of vectors

2013-02-04 Thread Benjamin Gillespie
zopou...@erasmusmc.nl] Sent: 04 February 2013 09:35 To: Benjamin Gillespie Cc: r-help@r-project.org Subject: Re: [R] Script for conditional sums of vectors try this: a <- c(1,1,1,1,1,1,2,2,2,2,2,2) b <- c(1,1,1,2,3,4,1,1,2,2,3,4) c <- c(400,200,300,100,500,300,200,100,500,400,200,100) DF <

[R] Script for conditional sums of vectors

2013-02-04 Thread Benjamin Gillespie
Hi guys, I hope you can help me with this (probably) simple query: I have a data frame: -- a=c(1,1,1,1,1,1,2,2,2,2,2,2) b=c(1,1,1,2,3,4,1,1,2,2,3,4) c=c(400,200,300,100,500,300,200,100,500,400,200,100) data=data.frame(a=a,b=b,c=c) -- And I wou

Re: [R] Code to fetch summary info from vector

2013-01-15 Thread Benjamin Gillespie
ac.uk/ From: William Dunlap [wdun...@tibco.com] Sent: 15 January 2013 16:51 To: Benjamin Gillespie; r-help@r-project.org Subject: RE: Code to fetch summary info from vector I don't completely understand the question, but if you are looking for the lengths of the runs

[R] Code to fetch summary info from vector

2013-01-15 Thread Benjamin Gillespie
Hi all, Thanks in advance for any help. I have a vector "b": b=c(1,1,1,2,3,4,3,2,1,1,1,1,1,2,3,4,5,4,3.5,3,2,1,1,1) Imagine b is river flow throughout time. I would like some code that will generate the following information: number of individual 'periods' where b>1 (= 2 in this case) period

Re: [R] Script to count unique values from two linked matricies

2012-09-25 Thread Benjamin Gillespie
ember 2012 17:04 To: Benjamin Gillespie Cc: R help Subject: Re: [R] Script to count unique values from two linked matricies Hi Ben, No problem. The code could be collapsed to 2 steps: library(data.table) library(reshape) datm<-merge(melt(dat1),melt(dat2),by="Species") dat3<-dat

Re: [R] Script to count unique values from two linked matricies

2012-09-25 Thread Benjamin Gillespie
14:22 To: Benjamin Gillespie Cc: PIKAL Petr; Rui Barradas; Heramb Gadgil; R help Subject: Re: [R] Script to count unique values from two linked matricies Hi Ben, Just a modification of Petr's solution with library(data.table): dat1<-data.frame(Species=paste0("Species",1:3),Site1

Re: [R] Script to count unique values from two linked matricies

2012-09-25 Thread Benjamin Gillespie
ol of Geography University of Leeds Leeds LS2 9JT Tel: +44(0)113 34 33345 Mob: +44(0)770 868 7641 http://www.geog.leeds.ac.uk/ From: Heramb Gadgil [heramb.gad...@gmail.com] Sent: 25 September 2012 10:38 To: Benjamin Gillespie Cc: arun; r-help@r-project.org

Re: [R] Script to count unique values from two linked matricies

2012-09-25 Thread Benjamin Gillespie
you need any further information, Ben Gillespie Research Postgraduate School of Geography University of Leeds Leeds LS2 9JT Tel: +44(0)113 34 33345 Mob: +44(0)770 868 7641 http://www.geog.leeds.ac.uk/ From: arun [smartpink...@yahoo.com] Sent: 24 Septem

Re: [R] List creation based on matrix

2012-09-24 Thread Benjamin Gillespie
15:35 To: Benjamin Gillespie; arun Cc: R help Subject: Re: [R] List creation based on matrix If you don't have paste0() then you should upgrade to the current version of R. --- Jeff Newmiller

Re: [R] List creation based on matrix

2012-09-24 Thread Benjamin Gillespie
uate School of Geography University of Leeds Leeds LS2 9JT Tel: +44(0)113 34 33345 Mob: +44(0)770 868 7641 http://www.geog.leeds.ac.uk/ From: arun [smartpink...@yahoo.com] Sent: 24 September 2012 14:01 To: Benjamin Gillespie Cc: PIKAL Petr; R help Subject: Re

Re: [R] List creation based on matrix

2012-09-24 Thread Benjamin Gillespie
[petr.pi...@precheza.cz] Sent: 24 September 2012 13:39 To: Benjamin Gillespie; r-help@r-project.org Subject: RE: [R] List creation based on matrix Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of benrgillespie >

Re: [R] Script to count unique values from two linked matricies

2012-09-24 Thread Benjamin Gillespie
: PIKAL Petr [petr.pi...@precheza.cz] Sent: 24 September 2012 13:34 To: Benjamin Gillespie; r-help@r-project.org Subject: RE: [R] Script to count unique values from two linked matricies Hi I have no access to Nabble so it is difficult to understand what do you want. > -Original Mess