SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #install.packages("readxl")
  2. library(readxl)
  3. library(ggplot2)
  4. library(knitr)
  5. library(dplyr)
  6. library(sp)
  7. library(rworldmap)
  8. library(gridExtra)
  9. library(ggmap)
  10.  
  11.  
  12.  
  13. setwd(dir="y:/ProfileS/DESktop/mth_pt2")
  14.  
  15. data = read_xlsx(path = "1902788_1907065_1897637.xlsx",
  16.                  range = cell_cols("A:K"))
  17.  
  18.  
  19.  
  20.  
  21. class(data)
  22. summary(data)
  23.  
  24.  
  25.  
  26. # definir les categories de meteorites
  27. ChondriteOrdinaire <- "^L|^H|^LL|^Chondrite-fusion crust|^OC|^Chondrite"
  28. ChondriteCarbonee <-  "^CI|^CM-CO|^CM|^CO|^CV-CK|^CV|^CK|^CV-oxA|^CV-oxB|^CV-red|^CR|^CH|^CB|^CBa|^CBb|^C3-ung|^C2-ung|^C4-ung|^C"
  29. ChondriteEnstatite <- "^EH|^EL|^E3|^E-an|^E4|^E5|^E6|^E"
  30. ChondriteAutre <- "^R|^K"
  31. Achondrite <- "^Acapulcoite|^Lodranite|^Winonaite|^Howardite|^Eucrite|^Diogenite|^Angrite|^Aubrite|^Ureilite|^Brachinite|^Lunar|^Martian|^Shergottites|^Nakhlites|^Chassignites|^Achondrite-ung|^Enst achon"
  32. Mixte <- "^Pallasites|^Pyroxene|^Eagle|^Mesosiderite|^Pallasite"
  33. Ferreuse <- "^Magmatic|^Iron|^IC|^IIAB|^IIC|^IID|^IIF|^IIG|^IIIAB|^IIIE|^IIIF|^IVA|^IVB|^Non-magmatic|^sLL|^sLM|^sLH|^sHH|^sHL"
  34. Rocheuse <- "^Stone-uncl|^Stone-ung"
  35. #Inconnue <- "^Unknown"
  36.  
  37.  
  38. ChondriteOrdinaire <- data[grep(ChondriteOrdinaire, data$classe),]
  39. ChondriteOrdinaire$categorie <- factor("Chondrite ordinaire")
  40.  
  41. ChondriteCarbonee <- data[grep(ChondriteCarbonee, data$classe),]
  42. ChondriteCarbonee$categorie <- factor("Chondrite carbonee")
  43.  
  44. ChondriteEnstatite <- data[grep(ChondriteEnstatite, data$classe),]
  45. ChondriteEnstatite$categorie <- factor("Chondrite a enstatite")
  46.  
  47. ChondriteAutre <- data[grep(ChondriteAutre, data$classe),]
  48. ChondriteAutre$categorie <- factor("Autre chondrite")
  49.  
  50. Achondrite <- data[grep(Achondrite, data$classe),]
  51. Achondrite$categorie <- factor("Achondrite")
  52.  
  53. Mixte <- data[grep(Mixte, data$classe),]
  54. Mixte$categorie <- factor("Mixte")
  55.  
  56. Ferreuse <- data[grep(Ferreuse, data$classe),]
  57. Ferreuse$categorie <- factor("Ferreuse")
  58.  
  59. Rocheuse <- data[grep(Rocheuse, data$classe),]
  60. Rocheuse$categorie <- factor("Rocheuse")
  61.  
  62. #Inconnue <- data[grep(Inconnue, data$classe),]
  63. #Inconnue$categorie <- factor("Inconnue")
  64.  
  65.  
  66.  
  67. dataMerged = rbind(ChondriteOrdinaire,
  68.                    ChondriteCarbonee,
  69.                    ChondriteEnstatite,
  70.                    ChondriteAutre,
  71.                    Achondrite,
  72.                    Mixte,
  73.                    Ferreuse,
  74.                    Rocheuse)
  75.  
  76. barplot(prop.table(table(dataMerged$categorie)))
  77.  
  78. dataMerged[,13] = as.numeric(unlist(dataMerged["categorie"]))
  79.  
  80. hist(dataMerged$categorie)
  81.  
  82. table(dataMerged$categorie)
  83.  
  84.  
  85. hist(dataMerged$masse)
  86.  
  87. boxplot(data$masse,
  88.         horizontal = TRUE,
  89.         outline = FALSE)
  90.  
  91. qqnorm(data$masse)
  92. qqline(data$masse, col="red", lwd=2)
  93.  
  94. hist(data$masse)
  95.  
  96.  
  97.  
  98. coords2country = function(points){
  99.   countriesSP <- getMap(resolution='low')
  100.   pointsSP = SpatialPoints(points, proj4string=CRS(proj4string(countriesSP)))
  101.   indices = over(pointsSP, countriesSP)
  102.   indices$ADMIN
  103. }
  104.  
  105.  
  106. coords <- data.frame('Long' = data$longitude, 'Lat' = data$latitude)
  107.  
  108. data$country <- coords2country(coords)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top