[Qgis-user] How to shorten this in Field Calculator

Willem Korevaar wereldvak at gmail.com
Wed Aug 28 04:58:02 PDT 2019


I would like to shorten the following proces (= workaround)  of calculating
a simple  Rs (Spearman Rank correlation) in the Field Calculator .
https://drive.google.com/file/d/1vuW50nm1h4LduaAO01ThO6Nv-VXUGBo9/view?usp=sharing

[image: image.png]
and as an example:

[image: image.png]

Its about two columnsin the table  (X-Y in the example )  : P_00_14_JR (age
0-14 in %) and  P-N_W_AL (people from outside W-Europe in %).
I know that it can be done with an R- script, but as I m working with
students and I want to show them how the formula works and R is not working
anymore on the schoolsystem I tried a workaround. It works, but there are
too many steps.
My workaround is in 2.18.9 :


   1. using the plugin Sort and number and ranking both columns. So two
   more fields : r_014 and r_nw (rang x and y)
   2. make kolom 6 ((x-y)2) using Field Calculator:
   (  "r_0-14"   - "r_nw_ll"   ) ^ 2
   3. create new field in FC named RS:
   1- (  ( 6 * (  sum( "kolom6"  ) ) / ( ( (count(  "BU_NAAM" ) ^ 2) * (
   count(  "BU_NAAM" ) ) ) - count( "BU_NAAM"  ) ) ) )
   In which 'BU_NAAM' = n (number of objects in this case names of
   neighbourhoods in Den Haag) but this one can be any other fieldname.
   New fieldname = RS and with 'Real' and precision 5
   4. in this case Rs = 0,488 which means a little correlation
   (I know that there should be no ties in the values, but that would make
   the proces more complicated in case of

Is there a way in the FC I can do it in less steps?
This is the link to the table used in QGIS and the Rs formula in the
example:
https://drive.google.com/file/d/1vuW50nm1h4LduaAO01ThO6Nv-VXUGBo9/view?usp=sharing
I hope this all wil make sense :-)


Gr
Willem Korevaar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190828/a459203e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 20802 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190828/a459203e/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3215 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190828/a459203e/attachment-0003.png>


More information about the Qgis-user mailing list