Update docs/source/r.rst

This commit is contained in:
AcuGIS 2024-08-31 22:59:57 +00:00
parent 12d891f4ec
commit df905fd349
1 changed files with 27 additions and 26 deletions

View File

@ -151,7 +151,7 @@ Give your R code a Name and Description.
Example Example
-------------- --------------
The three main components are the plotly, ggplot2, and htmlwidgets function The three main components are the plotly, ggplot2, and htmlwidgets function.
.. code-block:: R .. code-block:: R
@ -165,50 +165,51 @@ The three main components are the plotly, ggplot2, and htmlwidgets function
#saveWidget #saveWidget
htmlwidgets::saveWidget(as_widget(p), file="index.html") htmlwidgets::saveWidget(as_widget(p), file="index.html")
An example of a Plotly app is included in the installation.
An example of a Plotly app is included in the installation. Here, we add the RPostgreSQL library to connect to PostgreSQL.
.. code-block:: R .. code-block:: R
library(plotly) library(plotly)
library(ggplot2) library(ggplot2)
library(RPostgreSQL)
library(htmlwidgets) library(htmlwidgets)
set.seed(100) conn <- RPostgreSQL::dbConnect("PostgreSQL", host = "localhost", dbname = "r_examples", user = "admin1", password = "4eA7hDlgYF")
d <- diamonds[sample(nrow(diamonds), 1000), ]
p <- plot_ly(d, x=~carat, y=~price, text=~paste("Clarity: ", clarity), mode="markers", color=~carat, size=~carat) query_res <- dbGetQuery(conn, 'SELECT * FROM "sensor_readings";');
sensor_readings <- as.data.frame(query_res);
# sensor_readings$timestamp <- as.Date(sensor_readings$timestamp)
p <- plot_ly(sensor_readings, x=~timestamp, y=~humidity, text=~paste("Sensor: ", sensor_name), mode="markers", color=~humidity, size=~humidity) %>%
layout(
plot_bgcolor='#e5ecf6',
xaxis = list( matches='x',
zerolinecolor = '#ffff',
zerolinewidth = 2,
gridcolor = 'ffff',
range = list( min(sensor_readings$timestamp),
max(sensor_readings$timestamp))
),
yaxis = list(
zerolinecolor = '#ffff',
zerolinewidth = 2,
gridcolor = 'ffff')
)
htmlwidgets::saveWidget(as_widget(p), file="index.html") htmlwidgets::saveWidget(as_widget(p), file="index.html")
There are three options for creating a Map. There are three options for creating a Map.
Option 1: FTP.
------------
FTP Uploads are qgis2web maps you have uploaded directly via FTP.
It can also maps you uploaded via any FTP client.
.. image:: images/Map-2.png
Option 2: Archive (Upload)
------------
Archive is a zipped archive file you can upload.
.. image:: images/Map-3.png
Option 3: Paste
------------
Paste your R Leaflet code into the code box.
.. image:: images/Map-3.png