---
> From: Anup Nandialath
> To: r-help@r-project.org
> Cc:
> Sent: Sunday, July 14, 2013 7:30 AM
> Subject: [R] creating dummy variables based on conditions
>
> Hello everyone,
>
> I have a dataset which includes the first three variables from the demo
> data below (yea
0
A.K.
- Original Message -
From: Anup Nandialath
To: r-help@r-project.org
Cc:
Sent: Sunday, July 14, 2013 7:30 AM
Subject: [R] creating dummy variables based on conditions
Hello everyone,
I have a dataset which includes the first three variables from the demo
data below (year, id and
Hello,
Your data seems to be of class 'matrix'. The following code needs it to
be a data.frame.
dat <- as.data.frame(your input matrix)
res <- do.call(rbind, lapply(split(dat, list(dat$id, dat$year)),
function(x){
x$ans <- if(any(x$var == 1)) 1 else 0
x}))
rownames(res) <- N
Hello everyone,
I have a dataset which includes the first three variables from the demo
data below (year, id and var). I need to create the new variable ans as
follows
If var=1, then for each year (where var=1), i need to create a new dummy
ans which takes the value of 1 for all corresponding id'
R is for dummies (like me, but I don't use dummy variables) or for the
non-Dummies like all experts who help us all the time@@.. so dummy
variables are not needed! :)
QED...
On Sat, Apr 20, 2013 at 6:16 PM, Rolf Turner wrote:
> On 21/04/13 10:56, Eva Prieto Castro wrote:
>
>> Hi,
>>
>> Why do y
On 21/04/13 10:56, Eva Prieto Castro wrote:
Hi,
Why do you write that dummy variables are not needed in R?. I would like you
explain it.
As others have said --- do some self-study. But a brief answer is that
in any
"reasonable" modelling problem in which dummy variables might arise, R
crea
iables are not needed in R?. I would like
> you explain it.
>
> Thanks,
>
> Eva
>
> --- El *dom, 21/4/13, David Winsemius * escribió:
>
>
> De: David Winsemius
> Asunto: Re: [R] creating dummy variables
> Para: "Bert Gunter"
> CC: "r-help@R-p
avid Winsemius escribió:
>
> De: David Winsemius
> Asunto: Re: [R] creating dummy variables
> Para: "Bert Gunter"
> CC: "r-help@R-project.org" , "shyam basnet"
>
> Fecha: domingo, 21 de abril, 2013 00:38
>
>
> On Apr 20, 2
Hi,
Why do you write that dummy variables are not needed in R?. I would like you
explain it.
Thanks,
Eva
--- El dom, 21/4/13, David Winsemius escribió:
De: David Winsemius
Asunto: Re: [R] creating dummy variables
Para: "Bert Gunter"
CC: "r-help@R-project.org" , &q
On Apr 20, 2013, at 2:03 PM, Bert Gunter wrote:
> Dummy variables are not needed in R.
>
> Bert
>
Bert is correct on this point, but if you what to know how the regression
functions in R do this "behind the scenes" then you could always look at:
?model.matrix # where _some_ of the the au
Hello Shyam,
if your data is stored in variable "dataset", for example, the following
code will create the desired dummy-coded variables and attach them to the
dataset:
##
#init vars
SWHE=BARL <- vector(length=nrow(dataset))
SWHE[]=BARL[] <- 0 #initialize dummy-coded vars wi
Dummy variables are not needed in R.
Bert
Sent from my iPhone -- please excuse typos.
On Apr 20, 2013, at 11:23 AM, shyam basnet wrote:
> Hello R-users,
>
> The below is a snippet of my data:
>
>
> fid crop year value
> 5_1_1 SWHE 1995 171
> 5_1_1 SWHE 1997 696
> 5_1_1
Hello R-users,
The below is a snippet of my data:
fid crop year value
5_1_1 SWHE 1995 171
5_1_1 SWHE 1997 696
5_1_1 BARL 1996 114
5_1_1 BARL 1997 344
5_2_2 SWHE 1995 120
5_2_2 SWHE 1996 511
5_2_2 BARL 1996 239
5_2_2 BARL 1997 349
Here,
On Jan 30, 2013, at 04:58 , Bert Gunter wrote:
> You almost never need dummy variables in R. R creates them
> automatically from factors given model and possibly contrasts
> specification.
>
> ?contrasts ## for some technical details.
>
> If you have not read "An Introduction to R" do so now.
You almost never need dummy variables in R. R creates them
automatically from factors given model and possibly contrasts
specification.
?contrasts ## for some technical details.
If you have not read "An Introduction to R" do so now. Pay particular
attention to the chapter on modeling and categor
Hello,
Semi-new r user here and still learning the ropes. I am creating dummy
variables for a dataset on stock prices in r. One dummy variable is
called prev1 and is:
prev1 <- ifelse(ret1 >= .5, 1, 0)
where ret1 is the previous day's return.
The variable "prev1" is created fine and works in my
AM
To: bt_jan...@yahoo.de; r-help@r-project.org
Subject: Re: [R] Creating dummy variables
hey thanks
I did solve it already, it had more mistakes as you see :S
bye
Arantzazu Blanco Bernardeau
Dpto de Qummica Agrmcola, Geologma y Edafologma
Universidad de Murcia-Campus de Espinardo
> D
i]>=3.3){datos$cambi[i]=1}else{0}
> > }
>
> --- Arantzazu Blanco Bernardeau schrieb am Do,
> 3.6.2010:
>
> > Von: Arantzazu Blanco Bernardeau
> > Betreff: [R] Creating dummy variables
> > An: r-help@r-project.org
> > Datum: Donnerstag, 3. Juni, 2010 1
(i in
> 1:length(datos$cambi)){if(datos$codsuelo[i]>=3.1
> &&
> datos$codsuelo[i]>=3.3){datos$cambi[i]=1}else{0}
> }
--- Arantzazu Blanco Bernardeau schrieb am Do, 3.6.2010:
> Von: Arantzazu Blanco Bernardeau
> Betreff: [R] Creating dummy variables
> An: r-he
Hello R project
I am a R beginner trying to create a dummy variable to clasificate soil types.
So, I have a column in my database called codtipo (typecode in english) where
soil type is coded as
1.1 to 1.4 arenosol (I have 4 types)
2.1 to 2.3 calcisols
4.1 to 4.4 fluvisols
and so on
To make dum
om: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of whitaker m. (mw1006)
Sent: Wednesday, December 16, 2009 8:59 AM
To: r-help@r-project.org
Subject: [R] Creating Dummy Variables in R
Hi,
I am trying to create a set of dummy variables to use within a multiple
linear
On Wed, 16 Dec 2009, whitaker m. (mw1006) wrote:
Hi,
I am trying to create a set of dummy variables to use within a multiple linear
regression and am unable to find the codes within the manuals.
For example i have:
Price Weight Clarity
IF VVS1VVS2
5
On 12/16/2009 03:58 PM, whitaker m. (mw1006) wrote:
> Hi,
> I am trying to create a set of dummy variables to use within a multiple
> linear regression and am unable to find the codes within the manuals.
>
> For example i have:
> Price Weight Clarity
> IF
Hi,
I am trying to create a set of dummy variables to use within a multiple linear
regression and am unable to find the codes within the manuals.
For example i have:
Price Weight Clarity
IF VVS1VVS2
5008 1 0 0
1000
24 matches
Mail list logo