Re: [R] standard errors of regression coefficients

2007-10-03 Thread Jeffrey Robert Spies
stderr_int <- summary(lm(y ~ x))$coefficients[1,2] stderr_slope <- summary(lm(y ~ x))$coefficients[2,2] Jeff. On Oct 3, 2007, at 3:01 AM, Alexander Moreno wrote: > Hi, > > If I have two vectors x and y and I do lm(y~x) and now I want to > define > variables that are the standard errors of the

Re: [R] mean of subset of rows

2007-10-01 Thread Jeffrey Robert Spies
You were on the right track with the for loop, but often you can do the same thing looplessly (I know, it's not really a word) in R: If your data is like this: data<-data.frame(ID=rep(letters[1:4], 5), size=runif(20)) then apply either tapply(data$size, data$ID, mean) or aggregate(data$size

Re: [R] convert time series to data.frame

2007-09-30 Thread Jeffrey Robert Spies
Hi Edna, Can you send a small subset of the data as an example and the function call you used to read the data in originally? It might be helpful in understanding why you're losing the "time element". Jeff. On Oct 1, 2007, at 12:27 AM, Edna Bell wrote: > Dear R gurus > > I would like to ta

Re: [R] simple matching with R

2007-09-28 Thread Jeffrey Robert Spies
I hope this will change by and by. The more examples you see and play with, the more you'll understand. > So I would be very pleased if you could help me once again. > > Greetings > > Birgit Cheers, Jeff. > > Am 28.09.2007 um 18:25 schrieb Jeffrey Robert Spies: &

Re: [R] simple matching with R

2007-09-28 Thread Jeffrey Robert Spies
Not sure how you want to handle the NAs, but you could try the following: #start MalVar29_37 <- read.table(textConnection("V1 V2 V3 V4 V5 V6 V7 V8 V9 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 NA NA NA NA NA NA NA NA NA 0 1 0 0 0 1 0 0 0"), header=TRUE)

Re: [R] A matrix multiplication

2007-09-27 Thread Jeffrey Robert Spies
How about this: a <- matrix(cbind(rep(2, 500), rep(3, 500)), 500, 2) b <- matrix(cbind(rep(5, 500), rep(6, 500), rep(7, 500)), 500, 3) matrix(apply(a, c(2), "*", b), nrow=500, ncol=6) We apply the multiplier (quoted as specified in the apply help) with argument b to every column of a as specif

Re: [R] Need help on "date"

2007-09-19 Thread Jeffrey Robert Spies
, this site is quite useful: http://www.cs.utah.edu/dept/old/texinfo/regex/regex_toc.html. Make sense? Jeff. On Sep 18, 2007, at 10:46 AM, Arun Kumar Saha wrote: > Dear Jeffrey, > > Your syntax looks very extraordinary to me. I would be very happy > if you can explain this notation. &g

Re: [R] Need help on "date"

2007-09-18 Thread Jeffrey Robert Spies
And one using regular expressions: x <- "2005-09-01" pattern <- '([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})' y <- sub(pattern, '\\1', x) m <- sub(pattern, '\\2', x) d <- sub(pattern, '\\3', x) -- Jeff. On Sep 18, 2007, at 5:00 AM, Arun Kumar Saha wrote: > Dear all, > > I have a variable

Re: [R] removing a specific number of digist from a character string

2007-09-17 Thread Jeffrey Robert Spies
For the sake of absolute correctness: > sub('[[:digit:]]{4}\.tif', '', test) should be sub('[[:digit:]]{4}\\.tif', '', test) -- Jeff. On Sep 17, 2007, at 11:59 AM, Jeffrey Robert Spies wrote: > test <- c("060907_17_3_5_1_1_2909.tif&quo

Re: [R] data frame

2007-09-17 Thread Jeffrey Robert Spies
I believe you're looking for: dim(a) dim(a)[1] # Number of observations, in your example, 12 dim(a)[2] # Number of variables per observation, in your example, 9 --Jeff. On Sep 17, 2007, at 12:05 PM, Alfredo Alessandrini wrote: > Hi everybody, > > If I've a data frame like this: > > datafram

Re: [R] removing a specific number of digist from a character string

2007-09-17 Thread Jeffrey Robert Spies
test <- c("060907_17_3_5_1_1_2909.tif", "060907_17_3_5_2_1_2910.tif", "060907_17_3_5_3_1_2911.tif") sub('[[:digit:]][[:digit:]][[:digit:]][[:digit:]]\.tif', '', test) or test <- c("060907_17_3_5_1_1_2909.tif", "060907_17_3_5_2_1_2910.tif", "060907_17_3_5_3_1_2911.tif") sub('[[:digit:]]{4}\.ti