Re: [R] data.frame transformation

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Mon, 14 Mar 2011 12:00:40 -0700

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 ?lapply for some functions to do my first suggestion

On Mar 14, 2011, at 11:52, andrija djurovic <djandrija_at_gmail.com> 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 . (dot)
> in order to obtain this:
>
> q1 q2 q3 q4
> 1 . . check .
> 2 . 33.33 check 35
> 3 33.33 check 25 100
> 4 check . 100 check
>
> I had a lot of difficulties because each variable is factor.
> Could someone help me with this?
>
> Thanks in advance for any help.
>
> Andrija
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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
> and provide commented, minimal, self-contained, reproducible code.



R-help_at_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 and provide commented, minimal, self-contained, reproducible code. Received on Mon 14 Mar 2011 - 19:11:26 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Mar 2011 - 19:20:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive