[R] weight

John Kane jrkrideau at yahoo.ca
Sun Apr 29 00:55:28 CEST 2007


IIRC you have a yes/no smoking variable scored 1/2 ?  

It is possibly being read in as a factor not as an
integer.  

try
 class(df$smoking.variable)
to see .  


--- Natalie O'Toole <notoole at mtroyal.ca> wrote:

> Hi,
> 
> I'm getting an error message:
> 
> Error in df[, 1:4] * df[, 5] : non-numeric argument
> to binary operator
> In addition: Warning message:
> Incompatible methods ("Ops.data.frame",
> "Ops.factor") for "*" 
> 
> here is my code:
> 
> 
> ##reading in the file
> happyguys<-read.table("c:/test4.dat", header=TRUE,
> row.names=1)
> 
> ##subset the file based on Select If
> 
> test<-subset(happyguys, PROV==48 & GRADE == 7  &
> Y_Q10A < 9)
> 
> ##sorting the file
> 
> mydata<-test
> mydataSorted<-mydata[ order(mydata$Y_Q10A), ]
> print(mydataSorted)
> 
> 
> ##assigning  a different name to file
> 
> happyguys<-mydataSorted
> 
> 
> ##trying to weight my data
> 
> data.frame<-happyguys
> df<-data.frame
> df1<-df[, 1:4] * df[, 5]
> 
> ##getting error message here??
> 
> Error in df[, 1:4] * df[, 5] : non-numeric argument
> to binary operator
> In addition: Warning message:
> Incompatible methods ("Ops.data.frame",
> "Ops.factor") for "*" 
> 
> Does anyone know what this error message means?
> 
> I've been reviewing R code all day & getting more
> familiar with it
> 
> Thanks,
> 
> Nat
> 

>
------------------------------------------------------------------------------------------------------------------------
> 
> 
> This communication is intended for the use of the
> recipient to which it is 
> addressed, and may
> contain confidential, personal, and or privileged
> information. Please 
> contact the sender
> immediately if you are not the intended recipient of
> this communication, 
> and do not copy,
> distribute, or take action relying on it. Any
> communication received in 
> error, or subsequent
> reply, should be deleted or destroyed.
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list