Skip to content
Back to formatted view

Raw Message

Message-ID: <OF038CA1D9.0F0CDFAB-ONC1257A05.00467B21-C1257A05.0046E190@precheza.cz>
Date: 2012-05-21T12:52:42Z
From: PIKAL Petr
Subject: Replace a variable by its value
In-Reply-To: <1337599458321-4630734.post@n4.nabble.com>

Hi

> 
> I have a dataset called "raw-data" . I am trying to use the following 
code -
> 
> 
> col_name<-names(raw_data)
> for (i in 1:(length(names(raw_data))-2))
> {
>   tbl=table(raw_data$Pay.Late.Dummy, raw_data$col_name[i])
> 
>   chisqtest<-chisq.test(tbl)
> }
> 
> 
> Say the 1st column of my raw_data is Column1. The idea is when i=1 then
> raw_data$col_name[i] will automatically become raw_data$Column1 , which 
is

Why do you think so? raw_data$col_name[i] is most probably one value.

Maybe you want

tbl=table(raw_data$Pay.Late.Dummy, raw_data[,i])

Regards
Petr


> not happening. Kindly help?
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Replace-a-
> variable-by-its-value-tp4630734.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org 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.