jbkunst / shiny-apps-educational

Shiny apps for educational purposes.
https://jkunst.com/shiny-apps-educational
56 stars 51 forks source link

Update ww-eqs global.r #2

Closed ValentinChCloud closed 6 years ago

ValentinChCloud commented 6 years ago

Hello, I discovered your work and I'm very interested 👍 . @jbkunst I tried on my side one of your apps, ww-eqs, and I got

Loading required package: xml2

Attaching package: ‘DT’

The following objects are masked from ‘package:shiny’:

    dataTableOutput, renderDataTable

Loading required package: sp
Checking rgeos availability: FALSE
        Note: when rgeos is not available, polygon geometry     computations in maptools depend on gpclib,
        which has a restricted licence. It is disabled by default;
        to enable gpclib, type gpclibPermit()

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

Warning: use rgdal::readOGR or sf::st_read
Regions defined for each Polygons

Listening on http://127.0.0.1:36252
Warning: 'html' is deprecated.
Use 'read_html' instead.
See help("Deprecated")
Warning: Error in : `location_map` contains unknown variables
Stack trace (innermost first):
    58: <Anonymous>
    57: stop
    56: .abort
    55: glubort
    54: bad_args
    53: rename_vars
    52: rename.data.frame
    51: rename
    50: function_list[[i]]
    49: freduce
    48: _fseq
    47: eval
    46: eval
    45: withVisible
    44: %>%
    43: download_data [/opt/shiny-server/samples/sample-apps/SIG/global.r#27]
    42: server [/opt/shiny-server/samples/sample-apps/SIG/server.R#4]
     1: runApp
Error : `location_map` contains unknown variables

I checked your code ( by th eway I learn a lot) and the data , a litle fixe it's needed on the data name as you can see

> url <- "http://ds.iris.edu/seismon/eventlist/index.phtml"
>
>   data <- read_html(url) %>%
+     html_node("table") %>%
+     html_table(fill = TRUE) %>%
+ tbl_df()
c> colnames(data)
[1] "DATE and TIME (UTC)"
[2] "LAT"
[3] "LON"
[4] "MAG"
[5] "DEPTHkm"
[6] "LOCATION   \n                           (Shows interactive map)"
[7] "IRIS ID  (Other info)"
>   names(data) <- tolower(names(data))
>   names(data) <- gsub("\\(.*\\)", "", names(data))
>   names(data) <- stri_trim(names(data))
>   names(data) <- str_replace_all(names(data), "\\s+", "_")
> names(data)[7] <- "event_id"
> colnames(data)
[1] "date_and_time" "lat"           "lon"           "mag"
[5] "depthkm"       "location"      "event_id"

I hope it will help, please continue what you do.

jbkunst commented 6 years ago

Hi @ValentinChCloud

Thanks for update! Now, I'm not so sure to add the docker files :wink: ;) Can you remove that commit?

ValentinChCloud commented 6 years ago

Oh yes, I'm sorry I added it today I forget about this PR ^^ It should be ok now

jbkunst commented 6 years ago

Nice! Thanks @ValentinChCloud