[R] Ack! Odd correlation matrix problem

Chris Bergstresser chris at subtlety.com
Sat Apr 16 04:00:27 CEST 2005


Hi all --

    Obviously, I'm missing something frightfully basic with the 
following.  What's likely going wrong?

 > cr = cor(cluster.data, use = "complete.obs");
 > cr["tax", "spend"]
[1] -0.6138096
 > cor(cluster.data[["tax"]], cluster.data[["spend"]],
+     use = "complete.obs")
[1] -0.4925006

 > df = data.frame(tax = cluster.data$tax,
+                 spend = cluster.data$spend);
 > cr = cor(df, use = "complete.obs");
 > cr["tax", "spend"]
[1] -0.4925006
 > cor(df[["tax"]], df[["spend"]], use = "complete.obs")
[1] -0.4925006

-- Chris




More information about the R-help mailing list