Using AI

Using Artifical Intelligence (AI) for coding

AI is becoming useful coding tool. I have found myself using more and more to find code examples that something I just cannot find using Google. It has probably become my go to for finding R coding information.

There are lots of AI platforms out there and have not used most. The one I use most is Copilot (Microsoft) since we get access to that through DEECA.

A few AI options

Below is a list of a few AI that I have tinkered with (except Copilot (Github) but been recommended to me). [If someone has one that they find really useful, let me know and I can add here].

Tips for working with AI

For those not regularly using AI, there are a few things that can help when running your searches for help:

Copilot examples

To you Copilot, go to copilot.

Below are a couple examples…

Example of the output

I got a working interface…


Below is the code AI gave me…see day 4 lecture for explanation of code.


library(shiny)

# Define UI
ui <- fluidPage(
  titlePanel("Grazing and Wetland Management"),
  
  sidebarLayout(
    sidebarPanel(
      selectInput("grazing", "Grazing Type:", 
                  choices = c("Rotational", "Continuous", "Deferred")),
      selectInput("fence", "Fence Type:", 
                  choices = c("Electric", "Barbed Wire", "Wooden")),
      numericInput("year", "Year:", value = 2024, min = 2000, max = 2100),
      selectInput("wetland", "Wetland Type:", 
                  choices = c("Marsh", "Swamp", "Bog", "Fen"))
    ),
    
    mainPanel(
      tabsetPanel(
        tabPanel("Tab 1", h3("Content for Tab 1")),
        tabPanel("Tab 2", h3("Content for Tab 2")),
        tabPanel("Tab 3", h3("Content for Tab 3")),
        tabPanel("Tab 4", h3("Content for Tab 4"))
      )
    )
  )
)

# Define server logic
server <- function(input, output) {
  # Server logic will go here
}

# Run the application 
shinyApp(ui = ui, server = server)