scattermap: Scatter plot of map and no-map data

Description Usage Arguments Value Author(s) References Examples

View source: R/scatter.R

Description

The scattermap function plots an attribute of a map and non-map data. It also returns tabular data

Usage

1
2
3
4
5
6
7
8
9
scattermap(source,layer='',attributes,type='',label="",col='')
## Default S3 method:
scattermap(source,layer='',attributes,type='',label="",col='')
## S3 method for class 'scattermap'
print(x,...)
## S3 method for class 'scattermap'
summary(object,...)
## S3 method for class 'scattermap'
plot(x,...)

Arguments

source

Folder path of the layer or map. Please quote the full folder path with forward slash "/". You can use R object as a source but you must set the layer parameter to "nofile"; see below

layer

The layer map in the folder that you want to work with. It is the file name of map. This is case sensitive, please. In case you want to use non spatial data such as ".csv", ".txt", "dat" or ".tab" insert the full file name as layer. In case of using R object as a source set the "layer" parameter to "nofile"

type

The type of scatter chart you want to use. Set the "type" to "map" if you want a map to be drawn for the attribute

attributes

The attributes or variables of the map name of the layer or the map you want use. In case of using non spatial data such as ".csv", ".txt", "dat" or ".tab" attributes are variables or column names

label

The labeling title of the chart.

col

The colour of the chart

x

an object of class "scattermap", i.e., a fitted model.

object

an object of class "scattermap", i.e., a fitted model.

...

any other R parameters can be added

Value

Objects of the class that basically list its elements

data

Original data for the model

table

Frequency of the original data

source

Folder path of the layer or map

layer

The layer map in the source folder

attribute

The attribute name of the layer or the map that was used.

label

The labeling title of the chart.

Author(s)

George Owusu

References

Bivand, R. S., Pebesma, E. J., Gomez-Rubio, V. (2008) Applied Spatial Data Analysis with R. Springer Kabacoff, I. R. (2011) R in Action. Data Analysis and Graphics with R. Manning Publications Co

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
source<- system.file("external", package = "mgraph")
layer="farms"
attributes='Age,FArea'
graph=scattermap(source,layer,attributes,type="l",col='black',label="")
summary(graph)
print(graph)

#example two: using R object
data(meuse.all, package="gstat")
scattermap(meuse.all,layer="nofile",attributes="zinc,copper")
plot(graph)

## End(Not run)

Example output

Loading required package: rgdal
Loading required package: sp
rgdal: version: 1.2-10, (SVN revision 673)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 1.10.1, released 2013/08/26
 Path to GDAL shared files: /usr/share/gdal/1.10
 Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
 Path to PROJ.4 shared files: (autodetected)
WARNING: no proj_defs.dat in PROJ.4 shared files
 Linking to sp version: 1.2-3 
OGR data source with driver: ESRI Shapefile 
Source: "/usr/local/lib/R/site-library/mgraph/external", layer: "farms"
with 62 features
It has 64 fields
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Call:
scattermap.default(source = source, layer = layer, attributes = attributes, 
    type = "l", label = "", col = "black")

 correlation between [1] "Age,FArea"

Linear relationship

Call:
lm(formula = x$x ~ x$y)

Residuals:
    Min      1Q  Median      3Q     Max 
-46.830  -7.655   1.286   8.440  29.863 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  44.5220     2.2395  19.880   <2e-16 ***
x$y           1.9229     0.7954   2.418   0.0187 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 13.77 on 60 degrees of freedom
Multiple R-squared:  0.08876,	Adjusted R-squared:  0.07357 
F-statistic: 5.844 on 1 and 60 DF,  p-value: 0.01868

Call:
scattermap.default(source = source, layer = layer, attributes = attributes, 
    type = "l", label = "", col = "black")

Call: Data
NULL

 Table  
 [1]  0.80  2.00  0.80  1.40  1.60  0.00  2.80  2.80  0.20  0.80  0.80  4.00
[13]  2.40  1.60  4.60  0.00  2.80 14.00  4.60  4.00  8.80  3.32  0.60  0.50
[25]  0.40  0.80  1.00  0.60  0.80  0.40  0.80  0.40  2.00  0.80  1.40  0.40
[37]  0.40  2.80  0.80  1.60  0.60  0.40  1.00  0.80  1.20  0.80  1.60  0.40
[49]  1.20  5.60  1.20  1.60  1.20  1.40  0.80  1.00  1.00  0.00  1.80  0.00
[61]  1.20  3.60
Call:
scattermap.default(source = meuse.all, layer = "nofile", attributes = "zinc,copper")

Call: Data
NULL

 Table  
  [1]  85  81  68  81  48  61  31  29  37  24  25  25  93  31  27  86  74  69
 [19]  69  95  53  35  35  24  26  22  27  24  22  21  29  21  27  26  27  21
 [37]  32  50  67  77 108  32  21  22  21  51  50  38  26  24  32  24  47 128
 [55] 117 104  76  36  34  90  80  78  77  65  66  72  75  47  75  25  27  23
 [73]  21  20  22  55  20  26  47  46  55  49  39  45  48  36  36  68  88  85
 [91]  36  41  33  27  38  37  34  19  22  26  25  22  24  18  23  22  20  23
[109]  23  23  18  20  22  27  25  30  23  24  21  24  21  23  76  53  33  22
[127]  23  25  30  47  31  20  16  17  26  34  20  14  18  46  29  19  31  27
[145]  29  22  20  20  29  38  39  35  42  24  20  20  39  31  21  63  18  23
[163]  32  27
OGR data source with driver: ESRI Shapefile 
Source: "/usr/local/lib/R/site-library/mgraph/external", layer: "farms"
with 62 features
It has 64 fields
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Call:
scattermap.default(source = x$source, layer = x$layer, attributes = x$attributes, 
    type = x$type, label = x$label, col = x$colour)

Call: Data
NULL

 Table  
 [1]  0.80  2.00  0.80  1.40  1.60  0.00  2.80  2.80  0.20  0.80  0.80  4.00
[13]  2.40  1.60  4.60  0.00  2.80 14.00  4.60  4.00  8.80  3.32  0.60  0.50
[25]  0.40  0.80  1.00  0.60  0.80  0.40  0.80  0.40  2.00  0.80  1.40  0.40
[37]  0.40  2.80  0.80  1.60  0.60  0.40  1.00  0.80  1.20  0.80  1.60  0.40
[49]  1.20  5.60  1.20  1.60  1.20  1.40  0.80  1.00  1.00  0.00  1.80  0.00
[61]  1.20  3.60

mgraph documentation built on May 29, 2017, 7:52 p.m.

Related to scattermap in mgraph...