hi Arun,
Thanks for this. This solution works great.
Knid Regards
Anup
On Sun, Jul 14, 2013 at 8:07 PM, arun wrote:
> Hi,
> You could try this: (if I understand it correctly)
> dat1<- read.table(text="
> yearid var ans
> 2010 1 1 1
> 2010 2 0 0
> 2010 1 0 1
> 2010 1 0 1
>
Hi,
You could try this: (if I understand it correctly)
dat1<- read.table(text="
year id var ans
2010 1 1 1
2010 2 0 0
2010 1 0 1
2010 1 0 1
2011 2 1 1
2011 2 0 1
2011 1 0 0
2011 1 0 0
",sep="",header=TRUE,stringsAsFactors=FALSE)
dat1$newres<-with(dat1,ave(var,id,ye
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
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
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
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
hey thanks
I did solve it already, it had more mistakes as you see :S
bye
Arantzazu Blanco Bernardeau
Dpto de Química Agrícola, Geología y Edafología
Universidad de Murcia-Campus de Espinardo
> Date: Thu, 3 Jun 2010 14:40:30 +
> From: bt_jan...@yahoo.de
> Subject: AW: [R] Creating du
Was that the original code that you ran? As there appear to be several mistakes
in the code:
1. In the gipsisoil stuff, there is a ')' too much
2. In the gambisoil stuff both > signs point in the same direction, you
probably want one > and one <
My general suggestion would be to skip the loops
Is your variable Clarity a categorical with 4 levels? Thus, the need for
k-1 (3) dummies? Your error may be the result of creating k instead of
k-1 dummies, but can't be sure from the example.
In R, you don't have to (unless you really want to) explicitly create
separate variables. You can use the
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
19 matches
Mail list logo