Re: [R] How to replace strings in data frames by condition

2015-09-19 Thread sakko
Hi Jim, I just tried the code and it worked perfectly! You brought me a huge step nearer to my bachelors degree ;) thank you very much! Robert -- View this message in context: http://r.789695.n4.nabble.com/How-to-replace-strings-in-data-frames-by-condition-tp4712469p4712491.html Sent from the

Re: [R] How to replace strings in data frames by condition

2015-09-18 Thread Jim Lemon
Hi Robert, In your example, all of the numeric values are single digit. If this is the case in the real data, I think this will do: # assume edf is the name of the data frame levels(edf$q_1_SQ009)<-c(levels(edf$q_1_SQ009),"0") edf$q_1_SQ009[is.na(edf$q_1_SQ009)]<-"0" get_first_char<-function(x) re

[R] How to replace strings in data frames by condition

2015-09-18 Thread sakko
Hi, this is my first post in this forum and I am new to Ra. I am desperately seeking for help. There is a data frame given in which I want to replace some values like following: Existing data frame: q_1_SQ009 1 4 2 3