rsconnect::setAccountInfo(name='ooclsa-luisa0f-beltr0n0r',
              token='2C7C186F64575939BF031FD9765143B4',
              secret='VYwfZR59YTNIA02/eAvOLQB+J2//P4nsmZem0CB/')
              
rsconnect::deployApp("C:\\Users\\luisa\\Documents\\R LUISA\\MODULO 4\\ACTIVIDAD 1 SHINYAPP.Rmd")
## Warning: The `appDir` argument of `deployApp()` takes a directory, not a document, as of
## rsconnect 1.0.0.
## ℹ Please use `deployDoc()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## ℹ Discovering document dependencies...
## ✔ Document dependencies discovered
## ── Preparing for deployment ────────────────────────────────────────────────────
## ✔ Re-deploying "actividad_1_shinyapp" to "server: shinyapps.io / username: ooclsa-luisa0f-beltr0n0r"
## ℹ Looking up application with id "10065121"...
## ✔ Found application <https://ooclsa-luisa0f-beltr0n0r.shinyapps.io/actividad_1_shinyapp/>
## ℹ Bundling 1 file: 'ACTIVIDAD 1 SHINYAPP.Rmd'
## ℹ Capturing R dependencies with renv
## ✔ Found 58 dependencies
## ✔ Created 33,092b bundle
## ℹ Uploading bundle...
## ✔ Uploaded bundle with id 7755674
## ── Deploying to server ─────────────────────────────────────────────────────────
## Waiting for task: 1341768184
##   building: Building image: 9235523
##   building: Fetching packages
##   building: Installing packages
##   building: Installing files
##   building: Pushing image: 9235523
##   deploying: Starting instances
##   terminating: Stopping old instances
## ── Deployment complete ─────────────────────────────────────────────────────────
## ✔ Successfully deployed to <https://ooclsa-luisa0f-beltr0n0r.shinyapps.io/actividad_1_shinyapp/>

ACTIVIDAD 2 HOUSEPRICEDATA SHINYAPP

library(shiny)
library(shinythemes)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# Cargar el conjunto de datos
HousePriceData <- read.csv("C:\\Users\\luisa\\Documents\\R LUISA\\MODULO 4\\HousePriceData.csv")

ui <- fluidPage(theme = shinytheme("spacelab"),
                navbarPage("APPS",
                  tabPanel("Precio inmueble"),
                  sidebarPanel(
                    tags$h5("Ingresa las especificaciones sobre las características de hogar soñado:"),
                    sliderInput("Dist_Taxi", "Selecciona la distancia a la que te gustaría tener un taxi en mts:", 0, 17000, 8500),
                    sliderInput("Dist_Hospital", "Selecciona la distancia a la que te gustaría tener un hospital en mts:", min=0, max=25000, value=12500),
                    sliderInput("Carpet", "Selecciona los m2 que te gustaría en tu piso:", min=0, max=25000, value=12500),
                    sliderInput("Builtup", "Cuantos m2 te gustaría que fuera tu construcción?", min=0, max=15000, value=7500),
                    selectInput("Parking", "Te gustaría tener estacionamiento?:", choices = c("Open", "Not Provided", "Covered", "No Parking")),
                    selectInput("City_Category", "En qué categoría de ciudad te gustaría vivir?:", choices = c("CAT A", "CAT B", "CAT C")),
                    sliderInput("Rainfall", "Qué tanta precipitación te gustaría en el área donde vivas?:", min=-200, max=2000, value=900)
                  ),
                  mainPanel(
                    h1("Esto costaría tu casa soñada:"),
                    verbatimTextOutput("valor")
                  )
                )
)
## Warning: Navigation containers expect a collection of
## `bslib::nav_panel()`/`shiny::tabPanel()`s and/or
## `bslib::nav_menu()`/`shiny::navbarMenu()`s. Consider using `header` or `footer`
## if you wish to place content above (or below) every panel's contents.

## Warning: Navigation containers expect a collection of
## `bslib::nav_panel()`/`shiny::tabPanel()`s and/or
## `bslib::nav_menu()`/`shiny::navbarMenu()`s. Consider using `header` or `footer`
## if you wish to place content above (or below) every panel's contents.
server <- function(input, output) {
  output$valor <- renderPrint({
    # Crear un nuevo conjunto de datos con los valores ingresados por el usuario
    new_data <- data.frame(
      Dist_Taxi = input$Dist_Taxi,
      Dist_Hospital = input$Dist_Hospital,
      Carpet = input$Carpet,
      Builtup = input$Builtup,
      Parking = input$Parking,
      City_Category = input$City_Category,
      Rainfall = input$Rainfall
    )
    
    # Realizar la predicción utilizando el modelo de regresión previamente entrenado
    regresion <- lm(House_Price ~ Dist_Taxi + Dist_Hospital + Carpet + Builtup + Parking + City_Category + Rainfall, data = HousePriceData)
    predicted_price <- predict(regresion, newdata = new_data)
    
    return(predicted_price)
  })
}

shinyApp(ui = ui, server = server)
## PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.
Shiny applications not supported in static R Markdown documents