Re: [R] data.frame transformation

2011-03-14 Thread andrija djurovic
; q1q2q3q4 > 1 . . check . > 2 . 33.33 check35 > 3 33.33 check25 100 > 4 check . 100 check > > > > Bill Venables. > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] &g

Re: [R] data.frame transformation

2011-03-14 Thread Bill.Venables
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Tuesday, 15 March 2011 6:29 AM To: andrija djurovic Cc: r-help@r-project.org Subject: Re: [R] data.frame transformation On Mar 14, 2011, at 3:51 PM, andrija djurovic wrote: > I would like t

Re: [R] data.frame transformation

2011-03-14 Thread andrija djurovic
David, thank you very much. I changed little bit my code and now it works. The magic word was stringsASfactor=FALSE and i didn't realize at the first time. Andrija On Mon, Mar 14, 2011 at 9:28 PM, David Winsemius wrote: > > On Mar 14, 2011, at 3:51 PM, andrija djurovic wrote: > > I would like

Re: [R] data.frame transformation

2011-03-14 Thread David Winsemius
On Mar 14, 2011, at 3:51 PM, andrija djurovic wrote: I would like to hide cells with values less the 10%, so "." or just "" doesn't make me any difference. Also I used apply combined with as.character: apply(df, 2, function(x) ifelse(as.character(x) < 10,".",x)) This is, probably not a goo

Re: [R] data.frame transformation

2011-03-14 Thread andrija djurovic
I would like to hide cells with values less the 10%, so "." or just "" doesn't make me any difference. Also I used apply combined with as.character: apply(df, 2, function(x) ifelse(as.character(x) < 10,".",x)) This is, probably not a good solution, but it works except that I lose row names and

Re: [R] data.frame transformation

2011-03-14 Thread David Winsemius
On Mar 14, 2011, at 2:52 PM, andrija djurovic wrote: Hi R users, I have following data frame df<-data.frame(q1=c(0,0,33.33,"check"),q2=c(0,33.33,"check",9.156), q3=c("check","check",25,100),q4=c(7.123,35,100,"check")) and i would like to replace every element that is less then 10 with . (d

Re: [R] data.frame transformation

2011-03-14 Thread Joshua Wiley
Dear Andrija, You could convert the factors to numeric class in order to test, get an index of cells and then replace those. I wonder though if it wouldn't be easier to do this at some step *before* the numbers are combined with strings? At any rate, take a look at ?which ?factor ?as.numeric ?

[R] data.frame transformation

2011-03-14 Thread andrija djurovic
Hi R users, I have following data frame df<-data.frame(q1=c(0,0,33.33,"check"),q2=c(0,33.33,"check",9.156), q3=c("check","check",25,100),q4=c(7.123,35,100,"check")) and i would like to replace every element that is less then 10 with . (dot) in order to obtain this: q1q2q3q4 1

Re: [R] data.frame transformation

2008-01-30 Thread Gavin Simpson
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO Hi Christian, Use the fact that 0 * lat[i] == 0 and 1 * lat[i] == lat[i], where lat[i] is one of your lat values. Also use the fact that R is vectorized. So we have: grid.id<-c(1:4) lat<-c(10,12,13,15) species1<-c(0,0,0,1) species2<-c(1,1,0,0) specie

Re: [R] data.frame transformation

2008-01-30 Thread Peter Alspach
Christian Try: data.frame(data[,1:2], data[,3:5]*data[,2]) Peter Alspach > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Christian Hof > Sent: Thursday, 31 January 2008 7:48 a.m. > To: r-help@r-project.org > Subje

[R] data.frame transformation

2008-01-30 Thread Christian Hof
Dear all, maybe somebody can provide some help for this problem: Example: I've got the following dataframe "data": grid.id<-c(1:4) lat<-c(10,12,13,15) species1<-c(0,0,0,1) species2<-c(1,1,0,0) species3<-c(1,1,1,1) data<-data.frame(cbind(grid.id,lat,species1,species2,species3)) How can I, out of