search for: percent1

Displaying 2 results from an estimated 2 matches for "percent1".

Did you mean: percent
2008 Mar 13
4
a more elegant way to get percentages?
...10 > loc1 <- x$locat > n <- length(loc1) > locuniq1 <- unique(loc1) > m <- length(locuniq1) > counts <- seq(1:m) > > for (i in 1:m) { + count <- 0 + for (j in 1:n) { + if (loc1[j]==locuniq1[i]) count <- count+1 + counts[i] <- count + } + } > > percent1 <- rep(0,n) > j <- 0 > for (i in 1:m) { + + b <- x[(j+1):(j+counts[i]),] + total <- sum(b$val) + percent1[(j+1):(j+counts[i])] <- round(apply(as.matrix(b$val), 1, function(x) {x*100/total}),2) + j = j+counts[i] + } > x1 <- cbind(x, percent1) # this is the result i wan...
2001 Mar 16
1
combine dataset
Hi, I have two data sets look like below: ========================== state count1 percent1 CA 19 0.34 TX 22 0.35 FL 11 0.24 OR 34 0.42 GA 52 0.62 MN 12 0.17 NC 19 0.34 state count2 percent2 FL 22 0.35 MN 22 0.35 CA 11 0.24 TX 52 0.62 ========================== How to combine these two data set and make it look like belo...