[R] Replace a variable by its value
Petr PIKAL
petr.pikal at precheza.cz
Mon May 21 14:52:42 CEST 2012
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.
More information about the R-help
mailing list