[R] cor & logistic regression

Jan_Svatos@eurotel.cz Jan_Svatos at eurotel.cz
Wed Jan 23 16:37:33 CET 2002


Hi Christian,

the for loop should be written as
> for (i in 1:length(mnoModell))
instead of
> for( i in length(mnoModell)),

just type
> ?"for"
on R command line.

Not sure with

> cor(names(mnoModell)[i],Q41.1,use="complete.obs")

construction, too.
names
returns _strings_, while cor needs _data_,
use

> cor(mnoModell[,i],Q41.1,use="complete.obs")

or (little bit more complicated)

> cor(mnoModell[,names(mnoModell)[i]],Q41.1,use="complete.obs")

if you want to compute correlations between i-th column of mnoModell and
Q41.1

Jan



- - - Original message: - - -
From: owner-r-help at stat.math.ethz.ch
Send: 23/01/2002 4:21:33 PM
To: r-help <r-help at lists.r-project.org>
Subject: [R] cor & logistic regression

mnoModell <- as.data.frame(mnoModell0)
$ attach(mnoModell)
$ cor(Q31.1,Q41.1,use="pairwise.complete.obs")
[1] 0.0833
$
$ for( i in length(mnoModell)) {
+       cor(names(mnoModell)[i],Q41.1,use="complete.obs")
+       }
Error in cor(x, y, na.method) : incompatible dimensions


In addition: Warning message:
NAs introduced by coercion
$
$ names(mnoModell)[3]
[1] "Q31.3"

Hello ,
(1) What can i do that the  loop works ?
Perhaps anything with lapply ?

(2) Is it correct that is not very useful  works with logistic regression
when sample < 100 cases ?

thanks for advance &
regards, Christian Schulz


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list