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(
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 <-
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(
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
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'
esources 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:42 PM
> To: r-help@r-project.org
> Subject: [R] recoding data with
y, May 19, 2008 12:42 PM
To: r-help@r-project.org
Subject: [R] recoding data with loops
# 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 so
# 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's say I have six variables as li
8 matches
Mail list logo