You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
p("Farmers around the world, face many challenges. We often hear about problems of insect pests or deadly diseases destroying crops worldwide. But in fact, one of the biggest problems faced by farmers is weed control."),
13
+
img(src='bg.png', align="centre", width="500"),
14
+
p("This plant is called black-grass and it is one that is extremely well-known to farmers across north-west Europe. Black-grass is an especially problematic grass weed found in cereal crops, like wheat. To help farmers plan how to manage their fields better we need to be able to predict how many blackgrass plants will grow each year. To do this we can build a", strong("model.")),
15
+
p("A model is simply a mathematical description of something that we can observe in the real-world. Here we are going to describe how the number of black-grass plants in year 2 is related to the number of black-grass plants in year 1."),
16
+
p("We can build 3 different models, each with a little bit more complexity than the first."),
p("We can go to lots of fields in 2 consecutive years and count the number of plants. We can then look at these data to see if there is a connection between the number of plants counted in year 1 and the number of plants counted in year 2."),
21
+
p("Click on the", strong("Simple Model"), "tab at the top of the page to explore these data and build a simple model. When you have finished come back here by clicking on the", strong("Introduction"), "tab.")),
p("A simple model works well if we need an answer quickly and we have some data to help us make the prediction. However, sometimes we want to predict things that will happen in the future or in different circumstances. "),
24
+
p("If this is the case we must dig deeper into the biology of the plant. If we can understand the processes that lead to an increase in the number of plants from one year to the next we can describe these processes mathematically giving us more control over our model."),
25
+
p("Click on the", strong("Life-cycle Model"), "tab at the top of the page to explore this type of model further. When you have finished come back here by clicking on the", strong("Introduction"), "tab.")),
p("A scenario model is basically the same as a life-cycle model but rather than use generic data for each step in the life-cycle we can use different numbers according to a particular scenario.For example - what if we want to use our model to predict what will happen somewhere else where the weather is very different to the fields we went to? In this case we may have done some experiments to see what happens to each process within the life-cycle if there is more rain. "),
28
+
p("Click on the", strong("Scenario Model"), "tab at the top of the page to explore this type of model further. When you have finished come back here by clicking on the", strong("Introduction"), "tab."))
29
+
)
30
+
31
+
)),
32
+
33
+
##Simple Model
34
+
tabPanel("Simple Model",
35
+
fluidPage(
36
+
fluidRow(
37
+
h1("Fitting a simple Model"),
38
+
p("Here we are going to predict how many black-grass plants will grow in year 2, based on how many grow in year 1. We can fit a linear model to these data. Use the sliders on the right to find the line of best fit.")),
39
+
#scatterplot and slider inputs
40
+
column(8, plotOutput(outputId="abscatter")),
41
+
column(3, offset=1, sliderInput(inputId="mparam",
42
+
label="Choose a value for the 'm' parameter",
43
+
value=5, min=1, max=10),
44
+
sliderInput(inputId="cparam",
45
+
label="Choose a value for the 'c' parameter",
46
+
value=35, min=10, max=60,step=5))),
47
+
fluidRow(#predict y2 based on y1
48
+
h1("Using the model to make predictions"),
49
+
p("We can use this model to predict how many black-grass plants will grow in year 2 for any given number of blackgrass plants in year 1"),
50
+
numericInput(inputId="y1plants",label="Number of plants in year 1",value="20"),
51
+
textOutput("y2plants"),
52
+
textOutput("simplemodwarning"))),
53
+
54
+
##Life-cycle Model
55
+
tabPanel("Life-cycle Model",
56
+
fluidPage(
57
+
fluidRow(p("If we want to be able to adapt our predictions to different circumstances we need to have a slightly more detailed model. One common solution is to describe the life-cycle of the plant mathematically." ),
p("Put simply, plants produce seeds which can then grow into more plants and the process starts again. We can describe each of these stages mathematically and so this model is very similar to the previous simple model, only there are more steps along the way."),
60
+
p("Let's start with 100 plants and predict how many plants there will be after one year. You need to look at the data for each stage of the life cycle using the tabs below and complete the exercises to describe the process mathematically. The numbers in the panel on the left will update automatically as you do so you can begin to predict how many adult plants will grow."),
61
+
62
+
sidebarLayout(
63
+
## Side panel - The life cycle will go in here and auto update
64
+
sidebarPanel( h3("Plants in year 1"),
65
+
textOutput("lcstartplants"),
66
+
h3("Seeds produced"),
67
+
textOutput("lcseedprod"),
68
+
h3("Plants in year 2"),
69
+
textOutput("lcendplants")),
70
+
71
+
72
+
73
+
##Main panel - will have tabs for each stage of the life cycle
74
+
mainPanel(
75
+
tabsetPanel(type="tabs",
76
+
tabPanel("Plants to seed",
77
+
p("The number of seeds each plant produces depends on how many plants are nearby. If it is very crowded there is not enough space for the plants to grow big and so they produce fewer seeds. We did an experiment where we grew different numbers of plants together in one pot and counted the number of seeds they produced. You can see these data summarised in the graph below. Do you recognise the shape of this curve? There are lots of different equations we can use to fit curves to our data.", strong("Select the best option from the three given."), "We can then use this equation to predict the number of seeds produced for any number of plants."),
78
+
plotOutput(outputId="seedprodscatter"),
79
+
radioButtons("lcseedprodtype", "Choose the equation type that best fits the data",
80
+
c("Linear"="lin",
81
+
"Quadratic"="quad",
82
+
"Reciprocal"="rec"))
83
+
),
84
+
tabPanel("Seed to plants",
85
+
p("Not all seeds will start growing. To find out what percentage of seeds will grow we did an experiment. We counted out 100 seeds and gave them enough water and light to start growing. After 14 days we counted how many shoots we could see. We repeated this 10 times. Here you can see the data we collected, and below it are some summary values. How could you use this data to decide what percentage of seeds typically grow into seedlings?", strong("Calculate the percentage of seeds which grow"), "and put your answer in the box below. If you are stuck try looking at some of the summary statistics by clicking the button."),
numericInput(inputId="germpercent",label="What percentage of seeds start to grow?",value="50",min=1, max=100),
91
+
p("Think about what effect this might have on our life-cycle model and then take a look on the left hand side of the page and see if you were right")
92
+
93
+
))))))),
94
+
95
+
96
+
97
+
98
+
##Scenario Model
99
+
tabPanel("Scenario Model",
100
+
fluidPage(
101
+
fluidRow(p("We can use the life-cycle model we built to predict what will happen to the number of black-grass plants for many years into the future. This allows us to investigate how we might be able to manage this weed without having to do lots and lots of experiments year after year."),
102
+
p("Here is how our life cycle model looks when we loop through it multiple times - in other words we put the number of plants we get out at the end back into the beginning."),
103
+
plotOutput(outputId="loopmod2"),
104
+
p("We can also explore other scenarios. Select the scenario you would like to explore from the options below. "),
105
+
radioButtons("scenariochoice", "Which scenario would you like to explore?",
106
+
c("Try to guess what might happen to the model before you look at the output."="none",
107
+
"You apply a herbicide which kills 70% of plants before they produce seed each year."="herb",
108
+
"Wet weather in the Autumn allows 10% more seeds to germinate."="wet"))
109
+
110
+
111
+
)))
112
+
)
113
+
114
+
##Behind the scenes
115
+
server<-function(input,output){
116
+
117
+
##Calculations for simple model
118
+
#Generate the data
119
+
adata<- rnorm(50,mean=25,sd=5)
120
+
bdata<-adata*7+22+(rnorm(50, mean=0, sd=10))
121
+
#create the scatter plot
122
+
output$abscatter<- renderPlot(#code to get saved to the hist output
123
+
{ #the {} creates a code block - can be multiple lines
124
+
plot(adata,bdata,xlim=c(0,40),ylim=c(0,275),xlab="Number of plants in year 1",ylab="Number of plants in year 2")
0 commit comments