




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
R studio language and R using to analysis data frame sports
Typology: Assignments
1 / 8
This page cannot be seen from the preview
Don't miss anything!
sports <- read.csv(file.choose(), header=TRUE) head(sports) Country X100m X200m X400m X800m X1500m X3000m marathon GDP 1 argentina 11.61 22.94 54.50 2.15 4.43 9.79 178.52 76961923741 2 australia 11.20 22.35 51.08 1.98 4.13 9.08 152.37 150000000000 3 austria 11.43 23.09 50.62 1.99 4.22 9.34 159.37 81861232823 4 belgium 11.41 23.04 52.00 2.00 4.14 8.88 157.85 128000000000 5 bermuda 11.46 23.05 53.30 2.16 4.58 9.81 169.98 613299968 6 brazil 11.31 23.17 52.80 2.10 4.49 9.77 168.75 235000000000 Population 1 28105. 2 14692. 3 7549. 4 9859. 5 54. 6 121159. sports <- read.csv(file="sports2.csv", row.names=1) head(sports) X100m X200m X400m X800m X1500m X3000m marathon GDP argentina 11.61 22.94 54.50 2.15 4.43 9.79 178.52 76961923741 australia 11.20 22.35 51.08 1.98 4.13 9.08 152.37 150000000000 austria 11.43 23.09 50.62 1.99 4.22 9.34 159.37 81861232823 belgium 11.41 23.04 52.00 2.00 4.14 8.88 157.85 128000000000 bermuda 11.46 23.05 53.30 2.16 4.58 9.81 169.98 613299968 brazil 11.31 23.17 52.80 2.10 4.49 9.77 168.75 235000000000 Population argentina 28105. australia 14692. austria 7549. belgium 9859. bermuda 54. brazil 121159.
dim(sports) [1] 53 9 nrow(sports) [1] 53 ncol(sports)
class(sports) [1] "data.frame" colnames(sports) [1] "X100m" "X200m" "X400m" "X800m" "X1500m" [6] "X3000m" "marathon" "GDP" "Population" rownames(sports) [1] "argentina" "australia" "austria" "belgium" "bermuda" [6] "brazil" "burma" "canada" "chile" "china" [11] "colombia" "costarica" "czech" "denmark" "domrep" [16] "finland" "france" "gdr" "frg" "gbni" [21] "greece" "guatemala" "hungary" "india" "indonesia" [26] "ireland" "israel" "italy" "japan" "kenya" [31] "korea" "dprkorea" "luxembourg" "malaysia" "mauritius" [36] "mexico" "netherlands" "newzealand" "norway" "papua" [41] "philippines" "poland" "portugal" "romania" "singapore" [46] "spain" "sweden" "switzerland" "taipei" "thailand" [51] "turkey" "usa" "ussr" x=nrow(sports) y=ncol(sports) x*y
First we do it as Extract the first three rows sports[c(1,2,3),] X100m X200m X400m X800m X1500m X3000m marathon GDP argentina 11.61 22.94 54.50 2.15 4.43 9.79 178.52 76961923741 australia 11.20 22.35 51.08 1.98 4.13 9.08 152.37 150000000000 austria 11.43 23.09 50.62 1.99 4.22 9.34 159.37 81861232823 Population argentina 28105. australia 14692. austria 7549.
now we 2) Extract the first three rows, and the first three columns together
sports[c(1,2,3),c(1,2,3)]
sports[c(1:52),(8:9)]
malaysia 2.448803e+10 13798. mauritius 1.136544e+09 966. mexico 1.940000e+11 69360. netherlands 1.930000e+11 14149. newzealand 2.324551e+10 3112. norway 6.443938e+10 4085. papua 2.545983e+09 3304. philippines 3.245040e+10 47396. poland NA 35574. portugal 3.289976e+10 9766. romania NA 22242. singapore 1.189362e+10 2413. spain 2.320000e+11 37491. sweden 1.400000e+11 8310. switzerland 1.190000e+11 6319. taipei NA 18030. thailand 3.235351e+10 47385. turkey 6.878929e+10 43975. usa 2.860000e+12 227225.
sports[,1:4] <- list(NULL) head(sports) X1500m X3000m marathon GDP Population argentina 4.43 9.79 178.52 76961923741 28105. australia 4.13 9.08 152.37 150000000000 14692. austria 4.22 9.34 159.37 81861232823 7549. belgium 4.14 8.88 157.85 128000000000 9859. bermuda 4.58 9.81 169.98 613299968 54. brazil 4.49 9.77 168.75 235000000000 121159.
subset(sports, select=c(X800m,X1500m,X3000m,marathon,GDP,Population), +Population > 5000)+sports[,(10.1000)] X800m X1500m X3000m marathon GDP Population 1 28108.04 9770.74 17481.93 9821.02 7.696290e+10 255330. 2 14693.98 22246.78 373.23 7435.83 1.496550e+11 277128. 3 7551.42 2418.17 13807.47 10870.49 8.186124e+10 35655. 4 9861.24 37495.31 974.92 696941.37 1.275080e+11 24551. 6 56.77 8315.02 69370.64 147659.11 2.350250e+11 128709.
sum((is.na(sports$GDP))) [1] 9
is.na(sports$GDP) [[1] FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE [13] TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE [49] TRUE FALSE FALSE FALSE TRUE
mean(sports$X100m) ; sd(sports$X100m) [1] 11. [1] 0. mean(sports$X200m) ; sd(sports$X200m) [1] 23. [1] 0. mean(sports$X400m) ; sd(sports$X400m) [1] 53. [1] 2. mean(sports$X800m) ; sd(sports$X800m) [1] 2.
[1] 0.
mean(sports$X1500m) ; sd(sports$X1500m) [1] 4. [1] 0. mean(sports$X3000m) ; sd(sports$X3000m) [1] 9. [1] 0. mean(sports$marathon) ; sd(sports$marathon) [1] 169. [1] 23. mean(sports$GDP) ; sd(sports$GDP) [1] NA [1] NA mean(sports$Population) ; sd(sports$Population) [1] 65975. [1] 165580. summary(sports) X100m X200m X400m X800m Min. :10.79 Min. :21.71 Min. :47.99 Min. :1. 1st Qu.:11.25 1st Qu.:22.82 1st Qu.:51.50 1st Qu.:2. Median :11.58 Median :23.52 Median :53.26 Median :2.