bioinfolec_8th_20071012

837 views

Published on

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

bioinfolec_8th_20071012

  1. 1. > 1+1 [1] 2 > 2*3 [1] 6 > 5/3 [1] 1.666667 > 2^4 [1] 16 > log(2) [1] 0.6931472 > log(100,10) [1] 2 > exp(2) [1] 7.389056
  2. 2. >c(148,152,175) [1] 148 152 175 > mean(c(148,152,175)) [1] 158.3333 mean > median(c(148,152,175)) [1] 152 median > sd(c(148,152,175)) [1] 14.57166 var > var(c(148,152,175)) [1] 212.3333 sd > min(c(148,152,175)) [1] 148 min > max(c(148,152,175)) [1] 175 max > sum(c(148,152,175)) [1] 475 sum > length(c(148,152,175)) [1] 3 length
  3. 3. >heights <- c(148,152,175) >heights [1] 148 152 175 > mean(heights) [1] 158.3333 > sd(heights) [1] 14.57166 > max(heights) [1] 175
  4. 4. > heights <- c(159.6,159.3,150.9,158.8,154.8,149.9,153.2,159.3, 167.7,154.9) > mean(heights) [1] 156.84 > sd(heights) [1] 5.229447 > hist(heights) > hist(heights, c(140,145,150,152,154,156,158,160,165,170)) Histogram of heights Histogram of heights 0.20 4 0.15 3 Frequency Density 0.10 2 0.05 1 0.00 0 145 150 155 160 165 170 140 145 150 155 160 165 170 heights heights
  5. 5. > weights <- c(56.2,59.0,44.4,52.4,53.7,38.7,48.7,40.1,52.8,50.7) > mean(weights) [1] 49.67 > sd(weights) [1] 6.707218 > hist(weights) > plot(heights,weights) Histogram of weights 4 55 3 Frequency weights 50 2 45 1 40 0 35 40 45 50 55 60 150 155 160 165 weights heights
  6. 6. > result <- lm(weights ~ heights) > plot(heights, weights) 55 > abline(result) > summary(result) weights 50 Call: 45 lm(formula = weights ~ heights) Residuals: 40 Min 1Q Median 3Q Max 150 155 160 165 -11.144 -3.232 1.418 4.141 7.756 heights Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -50.709 61.664 -0.822 0.435 heights 0.640 0.393 1.629 0.142 Residual standard error: 6.165 on 8 degrees of freedom Multiple R-Squared: 0.249, Adjusted R-squared: 0.1551 F-statistic: 2.652 on 1 and 8 DF, p-value: 0.1420
  7. 7. > heights * 2 [1] 319.2 318.6 301.8 317.6 309.6 299.8 306.4 318.6 335.4 309.8 > heights + 10 [1] 169.6 169.3 160.9 168.8 164.8 159.9 163.2 169.3 177.7 164.9 > (heights / 100)^2 [1] 2.547216 2.537649 2.277081 2.521744 2.396304 2.247001 2.347024 [8] 2.537649 2.812329 2.399401 > weights / heights [1] 0.3521303 0.3703704 0.2942346 0.3299748 0.3468992 0.2581721 [7] 0.3178851 0.2517263 0.3148479 0.3273079 > weights / ((heights / 100)^2) [1] 22.06330 23.24987 19.49865 20.77927 22.40951 17.22296 20.74968 [8] 15.80203 18.77447 21.13027
  8. 8. > mheights <- c(182.6,172.3,169.1,161.6,175.6,167.8,171.0,171.2, 170.2,164.3) > t.test(heights,mheights,var.equal=T) Two Sample t-test data: heights and mheights t = -5.5568, df = 18, p-value = 2.828e-05 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -18.921092 -8.538908 sample estimates: mean of x mean of y 156.84 170.57
  9. 9. > matrix(c(1,2,3,4,5,6), nrow = 2) [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 > matrix(c(1,2,3,4,5,6), nrow = 3) [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 > m <- matrix(c(1,2,3,4,5,6,7,8), nrow = 2) >m [,1] [,2] [,3] [,4] [1,] 1 3 5 7 [2,] 2 4 6 8 > m[2,2] [1] 4 > m[1,] [1] 1 3 5 7 > m[,1] [1] 1 2 > m[,c(2,4)] [,1] [,2] [1,] 3 7 [2,] 4 8
  10. 10. > ctable <- matrix(c(60,180,40,20), nrow=2) > ctable [,1] [,2] [1,] 60 40 [2,] 180 20 > chisq.test(ctable, correct=FALSE) Pearson's Chi-squared test data: ctable X-squared = 37.5, df = 1, p-value = 9.141e-10

×