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'
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
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
7 matches
Mail list logo