[R] start and end times to yes/no in certain intervall

2010-07-23 Thread Stefan Uhmann
Hi List, I have start and end times of events structure(list(start = c("15:00", "15:00", "15:00", "11:00", "14:00", "14:00", "15:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00", "12:00"), end = c("16:00", "16:00", "16:00", "12:00",

Re: [R] how to delete columns with NA values?

2010-04-14 Thread Stefan Uhmann
Hi muting, # your data muting <- data.frame(col1 = c(1,1,2,1,2,1), col2=c(NA,1,2,1,2,NA)) # 1. finding rows with NA is.na(muting) # 2. counting the NAs per column colSums(is.na(muting)) # 3. keeping only the ones without NAs muting[,colSums(is.na(muting)) == 0] Regards, Stefan schrieb muting, A

[R] fitting a quadratic function - poly?

2010-04-14 Thread Stefan Uhmann
Hi List, I can not get my head around the following problem. I want to fit a quadratic function to some data and stumbled across poly(). What exactly does it, i.e. why are there different results for fit1 and fit2? x = seq(-10, 10) y = x^2 fit1 = lm(y ~ x + I(x^2)) fit2 = lm(y ~ poly(x, 2))

Re: [R] sort dates within a factor

2009-10-15 Thread Stefan Uhmann
t;] <- NA Xavier - Mail Original - De: "Stefan Uhmann" À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 13h15:10 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [R] sort dates within a factor Hi Xavier, thank you for your suggestion, it'

Re: [R] sort dates within a factor

2009-09-29 Thread Stefan Uhmann
nd(test, index = c(2,1,NA,3,NA,1,1,2,1)) # tapply does not treat NAs as intended unlist(tapply(test$date, test$nr, function(x){order(x, decreasing = T)})) Kind Regards, Stefan xavier.char...@free.fr schrieb, Am 29.09.2009 12:12: Is this what you want? test[order(test$nr, -as.integer(test$date)),

[R] sort dates within a factor

2009-09-29 Thread Stefan Uhmann
Dear List, I have the following data: >> test <- data.frame(date = as.Date(c('2007-01-01','2008-03-24','2003-03-02','2008-05-03','2002-05-23','2001-06-30','2005-12-04')), nr = c(2000,2000,2000,2001,2002,2003,2003)) test date nr 1 2007-01-01 2000 2 2008-03-24 2000 3 2003-03-02

Re: [R] quoting a table name due to a special character in sqlQuery (RODBC)

2009-09-15 Thread Stefan Uhmann
il Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 15 Sep 2009, Stefan Uhmann wrote: Dear List, I have a problem wit

[R] quoting a table name due to a special character in sqlQuery (RODBC)

2009-09-15 Thread Stefan Uhmann
Dear List, I have a problem with RODBC on a Paradox-DB, sqlQuery, and special characters in table names. Unfortunately, some of the latter include the underscore <_>. And I am not able to change them. That's not a problem, when I quote the table name: > sqlQuery(channel2, 'SELECT * FROM "anme

Re: [R] RODBC does not like table names >11/12 characters [sqlFetch vs. sqlQuery]

2009-09-15 Thread Stefan Uhmann
Just in case sb. has the same problem, using sqlQuery instead of sqlFetch solved the problem for me with RODBC 1.3-0. Seems as the implementation of sqlFetch does something bad to long table names - just a guess. Stefan Stefan Uhmann schrieb, Am 14.08.2009 14:12: Hi List, I used to access

[R] RODBC does not like table names >11/12 characters

2009-08-14 Thread Stefan Uhmann
Hi List, I used to access a Paradox database using RODBC, but since last week I am not able anymore to fetch any table which has a name longer than 11 or 12 characters. Here is the the pattern of my code, nothing spectacular: library(RODBC) channel2<-odbcDriverConnect('DSN=xxx') #table names

[R] tapply with cbinded x

2009-06-16 Thread Stefan Uhmann
Dear List, why does this not work? df <- data.frame(var1 = c(3,2,1), var2 = c(6,5,4), var3 = c(9,8,7), fac = c('A', 'A', 'B')) tapply(cbind(df$var1, df$var2, df$var3), df$fac, mean) Thank you, Stefan __ R-help@r-project.org mailing list https

[R] file.move?

2009-05-27 Thread Stefan Uhmann
Dear list, I want to move some files that should keep their time stamps, which is not the case if I use file.copy in combination with file.remove. file.move would be nice, is there a package providing such a function? Regards, Stefan __ R-help@r-pr

[R] code patterns in vector

2009-02-19 Thread Stefan Uhmann
Dear List, I have this column/vector: vec <- c("function", "missing", "string") and want to compute a second column/vector: - value if the pattern "unc" is found: 1 - value if the pattern "iss" is found: 2 - value if none of the patterns is found: 0 This should be the result: > vec2 [1] 1 2 0

Re: [R] radial.plot(plotrix) - plotting multiple polygons?

2009-01-15 Thread Stefan Uhmann
Dear List, Dear Jim, is it possible to draw multiple polygons with different line types? lty=c or line.lty=c do not work with radial.plot (in the matrix case) as well as add=TRUE. Stefan Jim Lemon schrieb, Am 14.11.2008 10:38: Jeremy Claisse wrote: Is it possible to plot multiple polygons

[R] merging data.frames columnwise (rbind with different variables, lengths)

2008-12-11 Thread Stefan Uhmann
Dear List, I have two dataframes with overlapping colnames and want to merge them. Actually, what I want is more similar to rbind, but the dataframes differ in their columns. Here are the examples: df1 <- data.frame(A = c(1,2), B = c("m","f"), C = c("at home", "away")) df2 <- data.frame(A =

Re: [R] access (exactly/only) one dimension of a multidimensional table

2008-11-05 Thread Stefan Uhmann
n the future. Great, thank you again! Stefan Jim Lemon schrieb, Am 05.11.2008 11:53: Stefan Uhmann wrote: Dear list, I have a multi(3)dimensional table, which is printed as two tables: table.a , , = female not at all a little medium heavy no 53 27 8 6 yes

[R] access (exactly/only) one dimension of a multidimensional table

2008-11-05 Thread Stefan Uhmann
Dear list, I have a multi(3)dimensional table, which is printed as two tables: > table.a , , = female not at all a little medium heavy no 53 27 8 6 yes 30 67 6166 , , = male not at all a little medium heavy no 31

Re: [R] Is there anyway to clip the bottom of a barplot?

2008-10-24 Thread Stefan Uhmann
Dear list, are there any (late) sugestions on this issue? I'm trying to produce a bad example for my students and I am not able to produce it using R! Would not have been a problem with SPSS. Mighty R .. Regards, Stefan Arthur Roberts schrieb, Am 29.07.2008 06:23: Hi, all, I need to show o

Re: [R] Type I and Type III SS in anova

2008-09-26 Thread Stefan Uhmann
Dear list, slightly OT: can you recommend me any sources where I can find more about this Type I - II - III anova problem? It seems as my statistics courses did not cover this issue, so I feel rather naive and have this sort of feeling that some of my analyses might be complete nonsense. Reg

Re: [R] juxtaposed and stacked bars in one barplot?

2008-08-28 Thread Stefan Uhmann
hadley wickham schrieb: Hi Stefan, Could you be a bit more explicit? Do you have an example dataset that you are trying to visualise? Right, thanks for pointing out the obvious. So here's my code: >> library(gplots) quarter <- as.factor(sample(c("Q1", "Q2", "Q3", "Q4"), 100, repla

[R] juxtaposed and stacked bars in one barplot?

2008-08-27 Thread Stefan Uhmann
Hi, anybody any hints how to get a barplot with both juxtaposed and stacked bars? /Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html an

Re: [R] centroid of radial.plot differs from centroid.polygon

2008-08-21 Thread Stefan Uhmann
Jim Lemon schrieb: On Wed, 2008-08-20 at 13:36 +0200, Stefan Uhmann wrote: Dear R-Helpers, I need the centroid of circular data and (because the function used does not provide the centroid coordinates, or did I miss sth.?) tried it via the indirect way and just computed the cartesian

[R] centroid of radial.plot differs from centroid.polygon

2008-08-20 Thread Stefan Uhmann
Dear R-Helpers, I need the centroid of circular data and (because the function used does not provide the centroid coordinates, or did I miss sth.?) tried it via the indirect way and just computed the cartesian coordinates: >>> library(plotrix) library(maps) #generate data data1<-matrix(c(1.8

[R] rearrange data

2008-06-25 Thread Stefan Uhmann
Dear HelpeRs, i have a data.frame df as follows: > df <- data.frame(id=rep(1:3,rep(10,3)), emoqu=as.factor(rep(c(0,0,1,1,2,2,3,3,4,4),3)), x=rnorm(30), y=runif(30)) Now, I would like to rearrange the data and it works - regarding the variables/columns I would l

Re: [R] Function for subset of cases/lines

2008-05-15 Thread Stefan Uhmann
iostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message ----- From: "Stefan Uhmann" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 15, 2008 10:07 AM Subject: [R] Function for subset of cases/lines Hi, I have a vector: q1<-c(4660,562

[R] Function for subset of cases/lines

2008-05-15 Thread Stefan Uhmann
Hi, I have a vector: q1<-c(4660,5621,5629,8030,8080,8180,8501,8190,8370,8200) The following command gives me the mean of its elements: mean(q1) [1] 7346.1 What can I do to do the same for the variable 'height', but only for the cases/rows which have one of the elements of q1 as 'number':