[R] Variance is different in R vs. Excel?

2015-02-09 Thread Karl Fetter
Hello everyone, I have a simple question. when I use the var() function in R to find a variance, it differs greatly from the variance found in excel using the =VAR.S function. Any explanations on what those two functions are actually doing? Here is the data and the results: dat<-matrix(c(402,908,

[R] identifying which column an observation comes from?

2013-10-16 Thread Karl Fetter
Hello, I have a matrix of samples (rows) and haplotypes (columns), where 0 indicates that a sample does not posses that columns haplotype and 1 indicates it does. So sample1 has 0's for every column, except the column that represents haplotype X, and it has a 1. I want a length(sample) x 2 dataf

[R] order() not producing results as I expect

2013-10-10 Thread Karl Fetter
Hello, I'm using R version 3.0.0 on a mac. I'm having trouble getting order to behave as I expect it should. I'm trying to sort a data.frame according to a character vector. I'm able to sort the data.frame, but it retruns an unexpected result. I have no idea where the order that is being produced