Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- setwd("C:/Users/Jan/Documents/R/")
- install.packages("readr")
- library(readr)
- install.packages("ggplot2")
- library(ggplot2)
- install.packages("openxlsx")
- library(openxlsx)
- ##### BODENPROBEN #####
- bodenproben = read.xlsx("C:/Users/user/Documents/R/Boden Paysan.xlsx", sheet = "alle_werte")
- boden_r_a = read.xlsx("C:/Users/user/Documents/R/Boden Paysan.xlsx", sheet = "r. acetosa")
- boden_d_g = read.xlsx("C:/Users/user/Documents/R/Boden Paysan.xlsx", sheet = "d. glomerata")
- boden_a_p = read.xlsx("C:/Users/user/Documents/R/Boden Paysan.xlsx", sheet = "a. pratensis")
- boden_a_s = read.xlsx("C:/Users/user/Documents/R/Boden Paysan.xlsx", sheet = "a. sylvestris")
- boden_r_o = read.xlsx("C:/Users/user/Documents/R/Boden Paysan.xlsx", sheet = "r. obtusifolius")
- ##### mittlere Nährstoffwerte pro Zielart #####
- pH_r_a = mean(boden_r_a [,8])
- p1_r_a = mean(boden_r_a [,2])
- p2_r_a = mean(boden_r_a [,3])
- k1_r_a = mean(boden_r_a [,4])
- k2_r_a = mean(boden_r_a [,5])
- mg1_r_a = mean(boden_r_a [,6])
- mg2_r_a = mean(boden_r_a [,7])
- pH_d_g = mean(boden_d_g [,8])
- p1_d_g = mean(boden_d_g [,2])
- p2_d_g = mean(boden_d_g [,3])
- k1_d_g = mean(boden_d_g [,4])
- k2_d_g = mean(boden_d_g [,5])
- mg1_d_g = mean(boden_d_g [,6])
- mg2_d_g = mean(boden_d_g [,7])
- pH_a_p = mean(boden_a_p [,8])
- p1_a_p = mean(boden_a_p [,2])
- p2_a_p = mean(boden_a_p [,3])
- k1_a_p = mean(boden_a_p [,4])
- k2_a_p = mean(boden_a_p [,5])
- mg1_a_p = mean(boden_a_p [,6])
- mg2_a_p = mean(boden_a_p [,7])
- pH_a_s = mean(boden_a_s [,8])
- p1_a_s = mean(boden_a_s [,2])
- p2_a_s = mean(boden_a_s [,3])
- k1_a_s = mean(boden_a_s [,4])
- k2_a_s = mean(boden_a_s [,5])
- mg1_a_s = mean(boden_a_s [,6])
- mg2_a_s = mean(boden_a_s [,7])
- pH_r_o = mean(boden_r_o [,8])
- p1_r_o = mean(boden_r_o [,2])
- p2_r_o = mean(boden_r_o [,3])
- k1_r_o = mean(boden_r_o [,4])
- k2_r_o = mean(boden_r_o [,5])
- mg1_r_o = mean(boden_r_o [,6])
- mg2_r_o = mean(boden_r_o [,7])
- boden_charge1 = data.frame(matrix(nrow=5, ncol=5))
- colnames(boden_charge1) = c("Zielart", "P", "K", "Mg", "pH")
- boden_charge1[,1] = c("Rumex acetosa", "Dactylis glomerata", "Alopecurus pratensis", "Anthriscus sylvestris", "Rumex obtusifolius")
- boden_charge1[,2] = c(p1_r_a, p1_d_g, p1_a_p, p1_a_s, p1_r_o)
- boden_charge1[,3] = c(k1_r_a, k1_d_g, k1_a_p, k1_a_s, k1_r_o)
- boden_charge1[,4] = c(mg1_r_a, mg1_d_g, mg1_a_p, mg1_a_s, mg1_r_o)
- boden_charge1[,5] = c(pH_r_a, pH_d_g, pH_a_p, pH_a_s, pH_r_o)
- #plot(boden_charge1[,1], type="b", main="Durchschnittliche Nährstoffwerte an Standorten der Zielarten", names= c("Rumex acetosa", "Dactylis glomerata", "Alopecurus pratensis", "Anthriscus sylvestris", "Rumex obtusifolius"), las=2)
- #install.packages("reshape2")
- #library(reshape2)
- #boden_charge1test = data.frame(
- # Zielart = c("Rumex acetosa", "Dactylis glomerata", "Alopecurus pratensis", "Anthriscus sylvestris", "Rumex obtusifolius"),
- # P=c(p1_r_a, p1_d_g, p1_a_p, p1_a_s, p1_r_o),
- #K=c(k1_r_a, k1_d_g, k1_a_p, k1_a_s, k1_r_o),
- #Mg=c(mg1_r_a, mg1_d_g, mg1_a_p, mg1_a_s, mg1_r_o),
- #pH=c(pH_r_a, pH_d_g, pH_a_p, pH_a_s, pH_r_o)
- #)
- #boden_charge1test$Zielart = factor(boden_charge1test$Zielart, levels = c("Rumex acetosa", "Dactylis glomerata", "Alopecurus pratensis", "Anthriscus sylvestris", "Rumex obtusifolius"))
- #df_long = reshape2::melt(boden_charge1test, id.vars = "Zielart")
- #ggplot(df_long, aes(x=boden_charge1test, y=value, color=variable, group=variable))+
- # geom_line()+
- # geom_point()+
- # scale_x_discrete(limits =c("Rumex acetosa", "Dactylis glomerata", "Alopecurus pratensis", "Anthriscus sylvestris", "Rumex obtusifolius"))+
- #labs(x="Zielart", y="Nährstoffe [mg/100g Substanz]")
- boden_charge1$Zielart <- factor(boden_charge1$Zielart,
- levels = c("Rumex acetosa", "Dactylis glomerata",
- "Alopecurus pratensis", "Anthriscus sylvestris",
- "Rumex obtusifolius"))
- ggplot(boden_charge1, aes(x = Zielart, group = 1)) +
- geom_point(aes(y = P, color = "1")) +
- geom_line(aes(y = P, color = "1"), linetype = 1, size = 1) +
- geom_point(aes(y = K, color = "2")) +
- geom_line(aes(y = K, color = "2"), linetype = 1, size = 1) +
- geom_point(aes(y = Mg, color = "3")) +
- geom_line(aes(y = Mg, color = "3"), linetype = 1, size = 1) +
- labs(y = "Nährstoffe [mg/100g Substanz]",
- title = "Durchschnittliche Nährstoffgehälter an Standorten der Zielarten") +
- theme(plot.title = element_text(hjust = 0.5)) +
- scale_color_manual(values = c("darkgreen", "firebrick", "steelblue"),
- name = "Legende:",
- labels = c("P", "K", "Mg")) +
- theme(legend.position = "bottom")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement