Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
Many, many thanks Erik! For anyone who is searching around looking for a way to recode in R, here's the full code Erik provided: var_list <- c("HEQUAL", "EWEALTH", "ERADEQ", "HREVDIS1", "EDISCRIM", "HREVDIS2") ## my original list of variables mdf <- data.frame(replicate(length(var_list), sample(

Re: [R] recoding data with loops

2008-05-19 Thread Erik Iverson
Got it, I did not know of the 'recode' function in car. So you would like to recode those specific columns then? Once again, we can do it without a loop, this time with the help of a function called lapply, which applies a function to each item in a list in turn. Try: reverse_me_varnames <-

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
Erik, Your example was just what I needed to generate the data -- many, many thanks! The names() function was something I had not grasped fully. I now have this and it works very nicely: var_list <- c("HEQUAL", "EWEALTH", "ERADEQ", "HREVDIS1", "EDISCRIM", "HREVDIS2") mdf <- data.frame(replicate(

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
Many thanks -- You are right; I had rnorm() and sample() mixed up in my code. I'll work on generating a normal ordinal sample next. Cheers, Don On Mon, May 19, 2008 at 4:07 PM, Erik Iverson <[EMAIL PROTECTED]> wrote: > Hello - > > Donald Braman wrote: > >> # I'm new to R and am trying to get th

Re: [R] recoding data with loops

2008-05-19 Thread Erik Iverson
Hello - Donald Braman wrote: # I'm new to R and am trying to get the hang of how it handles # dataframes & loops. If anyone can help me with some simple tasks, # I'd be much obliged. # First, i'd like to generate some random data in a dataframe # to efficiently illustrate what I'm up to. # let'

Re: [R] recoding data with loops

2008-05-19 Thread Donald Braman
Thanks for quick response! I have done. I have tried many configurations of the various examples given there, but the examples are pretty short and none explain how to loop through nonconsecutive variables in a data frame. I've also read dozens of pages that come up when I google "data.frame rno

Re: [R] recoding data with loops

2008-05-19 Thread Bert Gunter
If you're serious, start by reading the docs, especially "An Introduction to R." There are also other learning resources listed on CRAN. -- Bert gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Donald Braman Sent: Monday, May 19, 2008 12