Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. # Problem 3 #
  2. dat3 = read.csv("http://course1.winona.edu/bdeppa/DSCI%20415/Data/Dune%20with%20Environmentals.csv")
  3. attach(dat3)
  4.  
  5. install.packages("tidyr")
  6. library(vegan)
  7. library(proxy)
  8. library(dplyr)
  9. library(tidyr)
  10. library(MASS)
  11.  
  12. names(dat3)
  13. dim(dat3)
  14.  
  15. spec.mat = dat3 %>% select(Achimill:Callcusp)
  16.  
  17. rowS = rowSums(spec.mat)
  18. spec.count = colSums(spec.mat)
  19.  
  20. site.dist = dist(spec.mat,method="Bray")
  21. site.iso = isoMDS(site.dist,k=2)
  22. plot(site.iso$points,type = "n")
  23. text(site.iso$points,as.character(Site),col=as.numeric(Moisture)+1) #not sure about moisture
  24.  
  25. colSums(spec.mat)
  26.  
  27. ##how can we make bubble for different managment sites or use
  28. tspec.mat = t(spec.mat)
  29. spec.dist = dist(tspec.mat,method = "Bray")
  30. spec.iso = isoMDS(spec.dist,k=2)
  31. plot(spec.iso$points,type="n")
  32. text(spec.iso$points,as.character(row.names(tspec.mat)),col=as.numeric(Moisture)+1,cex=.7)
  33.  
  34. ##tried to do bubbles, gave up, gg rip
  35. install.packages("plotly")
  36. library(plotly)
  37. p <- plot_ly(dat3, x = spec.iso$points[,1], y = spec.iso$points[,2], text = as.character(row.names(tspec.mat)),col=as.numeric(dat3$Moisture), type = 'scatter', mode = 'markers',
  38. marker = list(size = as.numeric(dat3$Management)*5, opacity = 0.5)) %>%
  39. layout(title = 'Gender Gap in Earnings per University',
  40. xaxis = list(showgrid = FALSE),
  41. yaxis = list(showgrid = FALSE))
  42. p
  43.  
  44. detach(dat3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement