CSV-file used for this script: ~/Data/brushing_v2.csv


1. Goal of the script

This script formats the output of the resulting CSV-file from applying a template computing ISO25178 parameters in ConfoMap. The script will:

  1. Read in the original CSV-file (step #3)
  2. Format the data (step #4)
  3. Write an XLSX-file and save an R object ready for further analysis in R (step #5)

All files will be saved in a subfolder “Data” within the directory of the present Rmd file, i.e. “~/Data”.


3. Read in original CSV-file

The imported file is: “~/Data/brushing_v2.csv”
Its modification, ‘last status change’ (= ‘creation’ on Windows) and last access times are, respectively: “2019-10-23 18:30:50”, “2019-10-24 09:45:18” and “2019-10-24 09:45:18”.


4. Format data

4.2. Add headers

 [1] "Measurement.date"                    
 [2] "Analysis.date"                       
 [3] "Analysis.time"                       
 [4] "Name.of.the.studiable"               
 [5] "Axis.length.X"                       
 [6] "Axis.size.X"                         
 [7] "Axis.spacing.X"                      
 [8] "Axis.length.Y"                       
 [9] "Axis.size.Y"                         
[10] "Axis.spacing.Y"                      
[11] "Axis.length.Z"                       
[12] "Axis.size.Z"                         
[13] "Axis.spacing.Z"                      
[14] "NMP.ratio.Z"                         
[15] "Length.scale.anisotropy.epLsar"      
[16] "Fractal.complexity.Asfc"             
[17] "Scale.of.max.complexity.Smfc"        
[18] "HAsfc9.HAsfc9"                       
[19] "HAsfc81.HAsfc81"                     
[20] "Sq"                                  
[21] "Ssk"                                 
[22] "Sku"                                 
[23] "Sp"                                  
[24] "Sv"                                  
[25] "Sz"                                  
[26] "Sa"                                  
[27] "Smr.c.1000.nm.under.the.highest.peak"
[28] "Smc.p.10"                            
[29] "Sxp.p.50.q.97.5"                     
[30] "Sal.s.0.2"                           
[31] "Str.s.0.2"                           
[32] "Std.Reference.angle.0"               
[33] "Sdq"                                 
[34] "Sdr"                                 
[35] "Vm.p.10"                             
[36] "Vv.p.10"                             
[37] "Vmp.p.10"                            
[38] "Vmc.p.10.q.80"                       
[39] "Vvc.p.10.q.80"                       
[40] "Vvv.p.80"                            
[41] "Maximum.depth.of.furrows"            
[42] "Mean.depth.of.furrows"               
[43] "Mean.density.of.furrows"             
[44] "Isotropy"                            
[45] "First.Direction"                     
[46] "Second.Direction"                    
[47] "Third.Direction"                     
[48] "Isotropy"                            
[49] "Periodicity"                         
[50] "Period"                              
[51] "Direction.of.period"                 
[52] "Sq"                                  
[53] "Ssk"                                 
[54] "Sku"                                 
[55] "Sp"                                  
[56] "Sv"                                  
[57] "Sz"                                  
[58] "Sa"                                  
[59] "Smr.c.1000.nm.under.the.highest.peak"
[60] "Smc.p.10"                            
[61] "Sxp.p.50.q.97.5"                     
[62] "Sal.s.0.2"                           
[63] "Str.s.0.2"                           
[64] "Std.Reference.angle.0"               
[65] "Sdq"                                 
[66] "Sdr"                                 
[67] "Vm.p.10"                             
[68] "Vv.p.10"                             
[69] "Vmp.p.10"                            
[70] "Vmc.p.10.q.80"                       
[71] "Vvc.p.10.q.80"                       
[72] "Vvv.p.80"                            
[73] "Maximum.depth.of.furrows"            
[74] "Mean.depth.of.furrows"               
[75] "Mean.density.of.furrows"             
[76] "Isotropy"                            
[77] "First.Direction"                     
[78] "Second.Direction"                    
[79] "Third.Direction"                     
[80] "Isotropy"                            
[81] "Periodicity"                         
[82] "Period"                              
[83] "Direction.of.period"                 

4.10. Exclude FLT3-8_Area1 (“before” wrongly acquired )

4.12. Ignore some columns and reorder columns

4.13. Add units as comment()

Type comment(data.final) to check the units of the columns.

4.14. Check the result

'data.frame':   30 obs. of  89 variables:
 $ Material                   : Factor w/ 2 levels "Flint","Quartzite": 1 1 1 1 1 1 1 2 2 2 ...
 $ Sample                     : Factor w/ 8 levels "FLT3-10","FLT3-13",..: 1 1 2 2 3 4 4 5 5 6 ...
 $ Brush                      : Factor w/ 2 levels "No","Yes": 2 2 1 1 1 2 2 2 2 1 ...
 $ Dirt                       : Factor w/ 2 levels "No","Yes": 2 2 2 2 1 1 1 2 2 1 ...
 $ Before.after               : Factor w/ 2 levels "Before","After": 2 2 2 2 2 2 2 2 2 2 ...
 $ Area                       : Factor w/ 2 levels "Area1","Area2": 1 2 1 2 2 1 2 1 2 1 ...
 $ Objective                  : Factor w/ 1 level "50x-0.95": 1 1 1 1 1 1 1 1 1 1 ...
 $ Measurement.date           : POSIXct, format: "2019-03-28 15:19:32" "2019-03-28 16:11:01" ...
 $ Analysis.date              : Date, format: "2019-10-23" "2019-10-23" ...
 $ Analysis.time              : 'times' num  12:25:46 12:35:13 12:44:37 12:54:02 13:18:27 ...
  ..- attr(*, "format")= chr "h:m:s"
 $ Axis.length.X              : num  255 255 255 255 255 ...
 $ Axis.size.X                : num  3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 ...
 $ Axis.spacing.X             : num  0.0852 0.0852 0.0852 0.0852 0.0852 ...
 $ Axis.length.Y              : num  255 255 255 255 255 ...
 $ Axis.size.Y                : num  3000 3000 3000 3000 3000 3000 3000 3000 3000 3000 ...
 $ Axis.spacing.Y             : num  0.0852 0.0852 0.0852 0.0852 0.0852 ...
 $ Axis.length.Z              : num  22180 24153 16689 18953 22314 ...
 $ Axis.size.Z                : num  65532 65532 65531 65531 65532 ...
 $ Axis.spacing.Z             : num  0.338 0.369 0.255 0.289 0.341 ...
 $ NMP.ratio.Z                : num  0 0 0 0.134 0.142 ...
 $ epLsar                     : num  0.0171 0.0174 0.0175 0.0174 0.0174 ...
 $ Asfc                       : num  19.6 17.2 21 18.7 20.6 ...
 $ Smfc                       : num  0.233 0.233 0.169 0.169 0.233 ...
 $ HAsfc9                     : num  0.1801 0.2036 0.0725 0.0941 0.2992 ...
 $ HAsfc81                    : num  0.251 0.264 0.119 0.134 0.323 ...
 $ Sq.SL                      : num  1548 1336 1294 1102 1334 ...
 $ Ssk.SL                     : num  0.279 -0.957 -0.023 0.106 -0.577 ...
 $ Sku.SL                     : num  6.29 5.08 4.95 4.06 4.77 ...
 $ Sp.SL                      : num  6781 4282 5693 4320 4841 ...
 $ Sv.SL                      : num  7249 6431 6070 4502 6343 ...
 $ Sz.SL                      : num  14030 10713 11762 8821 11183 ...
 $ Sa.SL                      : num  1092 995 972 847 994 ...
 $ Smr.SL                     : num  0.36 0.294 0.374 0.754 0.313 ...
 $ Smc.SL                     : num  1665 1454 1528 1312 1575 ...
 $ Sxp.SL                     : num  2840 3486 2624 2122 3097 ...
 $ Sal.SL                     : num  19.5 19.3 15 15.9 16.3 ...
 $ Str.SL                     : num  0.543 0.583 0.613 0.793 0.605 ...
 $ Std.SL                     : num  93 65 155.2 106.8 86.5 ...
 $ Sdq.SL                     : num  0.718 0.695 0.713 0.663 0.75 ...
 $ Sdr.SL                     : num  16.7 15.4 17.7 15.8 17.8 ...
 $ Vm.SL                      : num  0.135 0.0528 0.0763 0.0689 0.0602 ...
 $ Vv.SL                      : num  1.8 1.51 1.6 1.38 1.63 ...
 $ Vmp.SL                     : num  0.135 0.0528 0.0763 0.0689 0.0602 ...
 $ Vmc.SL                     : num  1.06 1.058 1.031 0.924 1.064 ...
 $ Vvc.SL                     : num  1.61 1.28 1.44 1.25 1.44 ...
 $ Vvv.SL                     : num  0.188 0.227 0.162 0.129 0.198 ...
 $ Maximum.depth.of.furrows.SL: num  6038 6970 6609 4969 5851 ...
 $ Mean.depth.of.furrows.SL   : num  1875 1612 1791 1518 1784 ...
 $ Mean.density.of.furrows.SL : num  7781 7577 7787 7703 7753 ...
 $ Isotropy.SL                : num  54.3 58.3 61.3 79.3 60.5 ...
 $ First.Direction.SL         : num  90.009 90.005 90.002 0.184 90.02 ...
 $ Second.Direction.SL        : num  44.985 45.019 0.172 89.982 0.209 ...
 $ Third.Direction.SL         : num  135.019 0.213 45.003 135.031 45.019 ...
 $ Isotropy.SL.1              : num  68.7 70.2 80.8 78.9 75.5 ...
 $ Periodicity.SL             : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Period.SL                  : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Direction.of.period.SL     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ Sq.SF                      : num  607 367 400 284 528 ...
 $ Ssk.SF                     : num  -0.03013 0.10126 0.00249 0.14301 0.66318 ...
 $ Sku.SF                     : num  2.72 3.52 3.02 2.43 2.82 ...
 $ Sp.SF                      : num  1676 1023 1038 677 1543 ...
 $ Sv.SF                      : num  1390 1232 1175 665 843 ...
 $ Sz.SF                      : num  3067 2255 2214 1342 2386 ...
 $ Sa.SF                      : num  490 284 314 232 433 ...
 $ Smr.SF                     : num  12.7 45.6 46.3 86.9 16.6 ...
 $ Smc.SF                     : num  775 496 498 395 742 ...
 $ Sxp.SF                     : num  1307 712 802 503 677 ...
 $ Sal.SF                     : num  48.9 35.4 43.2 43.9 46.8 ...
 $ Str.SF                     : num  0.58 0.595 0.671 0.492 0.666 ...
 $ Std.SF                     : num  85.7 23.8 15.5 104.2 54.5 ...
 $ Sdq.SF                     : num  0.0201 0.0161 0.0161 0.0114 0.0207 ...
 $ Sdr.SF                     : num  0.0202 0.0129 0.013 0.0065 0.0215 ...
 $ Vm.SF                      : num  0.0283 0.0206 0.023 0.011 0.0319 ...
 $ Vv.SF                      : num  0.803 0.516 0.52 0.406 0.774 ...
 $ Vmp.SF                     : num  0.0283 0.0206 0.023 0.011 0.0319 ...
 $ Vmc.SF                     : num  0.603 0.297 0.36 0.26 0.483 ...
 $ Vvc.SF                     : num  0.741 0.475 0.474 0.378 0.746 ...
 $ Vvv.SF                     : num  0.062 0.0412 0.0462 0.0288 0.0283 ...
 $ Maximum.depth.of.furrows.SF: num  322 382 333 271 345 ...
 $ Mean.depth.of.furrows.SF   : num  160 136 133 96 179 ...
 $ Mean.density.of.furrows.SF : num  104 123 110 120 105 ...
 $ Isotropy.SF                : num  58 59.5 67.1 49.2 66.6 ...
 $ First.Direction.SF         : num  85.5 8.75 37 104.25 45.5 ...
 $ Second.Direction.SF        : num  94.5 171.3 104.2 53 111.5 ...
 $ Third.Direction.SF         : num  18.2 176.2 21.5 175.5 54.3 ...
 $ Isotropy.SF.1              : num  78.9 40.9 77 82.6 56.9 ...
 $ Periodicity.SF             : num  27.8 39.8 25.1 NA 30.6 ...
 $ Period.SF                  : num  99.5 126.9 148.1 NA 140.3 ...
 $ Direction.of.period.SF     : num  143 22.5 52.9 NA 134.8 ...
 - attr(*, "comment")= Named chr  "µm" "points" "µm" "µm" ...
  ..- attr(*, "names")= chr  "Axis length - X" "Axis size - X" "Axis spacing - X" "Axis length - Y" ...
   Material  Sample Brush Dirt Before.after  Area Objective    Measurement.date
4     Flint FLT3-10   Yes  Yes        After Area1  50x-0.95 2019-03-28 15:19:32
5     Flint FLT3-10   Yes  Yes        After Area2  50x-0.95 2019-03-28 16:11:01
6     Flint FLT3-13    No  Yes        After Area1  50x-0.95 2019-03-28 11:44:28
7     Flint FLT3-13    No  Yes        After Area2  50x-0.95 2019-03-28 14:08:52
9     Flint  FLT3-8    No   No        After Area2  50x-0.95 2019-03-21 14:31:50
10    Flint  FLT3-9   Yes   No        After Area1  50x-0.95 2019-03-21 15:53:59
   Analysis.date Analysis.time Axis.length.X Axis.size.X Axis.spacing.X
4     2019-10-23      12:25:46      255.4748        3000     0.08518666
5     2019-10-23      12:35:13      255.4748        3000     0.08518666
6     2019-10-23      12:44:37      255.4748        3000     0.08518666
7     2019-10-23      12:54:02      255.4748        3000     0.08518666
9     2019-10-23      13:18:27      255.4748        3000     0.08518666
10    2019-10-23      13:28:07      255.4748        3000     0.08518666
   Axis.length.Y Axis.size.Y Axis.spacing.Y Axis.length.Z Axis.size.Z
4       255.4748        3000     0.08518666      22180.42       65532
5       255.4748        3000     0.08518666      24153.08       65532
6       255.4748        3000     0.08518666      16689.44       65531
7       255.4748        3000     0.08518666      18953.32       65531
9       255.4748        3000     0.08518666      22314.21       65532
10      255.4748        3000     0.08518666      17853.52       65532
   Axis.spacing.Z NMP.ratio.Z     epLsar     Asfc      Smfc     HAsfc9
4       0.3384670   0.0000000 0.01714716 19.56945 0.2332067 0.18005092
5       0.3685692   0.0000000 0.01735469 17.23687 0.2332067 0.20357394
6       0.2546801   0.0000000 0.01748232 21.01142 0.1693019 0.07250272
7       0.2892268   0.1338556 0.01735057 18.70799 0.1693019 0.09413337
9       0.3405086   0.1417000 0.01737891 20.55407 0.2332067 0.29923168
10      0.2724396   0.0000000 0.01744802 20.87535 0.3212329 0.10230478
     HAsfc81    Sq.SL      Ssk.SL   Sku.SL    Sp.SL    Sv.SL     Sz.SL
4  0.2514574 1547.995  0.27899188 6.292930 6780.848 7249.286 14030.134
5  0.2638315 1336.182 -0.95741563 5.078233 4281.668 6431.164 10712.832
6  0.1188184 1293.781 -0.02300918 4.946463 5692.610 6069.791 11762.401
7  0.1342448 1102.412  0.10567406 4.060327 4319.603 4501.816  8821.419
9  0.3227291 1333.949 -0.57722755 4.772413 4840.670 6342.654 11183.324
10 0.1751943 1327.697  0.27391767 7.594889 6635.540 7074.713 13710.253
       Sa.SL    Smr.SL   Smc.SL   Sxp.SL   Sal.SL    Str.SL    Std.SL    Sdq.SL
4  1092.3567 0.3600017 1665.410 2839.798 19.48807 0.5433402  92.99391 0.7179665
5   995.0547 0.2944130 1454.259 3486.000 19.29139 0.5825679  65.01043 0.6946692
6   972.4787 0.3738135 1528.417 2624.185 15.04753 0.6133658 155.24925 0.7130941
7   846.8755 0.7540504 1311.523 2122.182 15.91403 0.7932008 106.75015 0.6633986
9   994.2861 0.3131865 1574.797 3096.992 16.27671 0.6047282  86.49890 0.7498406
10  934.3642 0.3670132 1448.824 2296.308 18.46236 0.8210036  35.98873 0.7981448
     Sdr.SL      Vm.SL    Vv.SL     Vmp.SL    Vmc.SL   Vvc.SL    Vvv.SL
4  16.71961 0.13498926 1.800286 0.13498926 1.0597621 1.612096 0.1881894
5  15.43765 0.05280878 1.507006 0.05280878 1.0575692 1.280265 0.2267406
6  17.70261 0.07630900 1.604746 0.07630900 1.0307427 1.442711 0.1620358
7  15.80641 0.06887440 1.380449 0.06887440 0.9239193 1.251934 0.1285151
9  17.75498 0.06015525 1.634807 0.06015525 1.0642306 1.437145 0.1976610
10 16.75480 0.10536882 1.554121 0.10536882 0.9448575 1.396761 0.1573595
   Maximum.depth.of.furrows.SL Mean.depth.of.furrows.SL
4                     6037.574                 1875.439
5                     6969.644                 1611.658
6                     6609.204                 1790.851
7                     4968.628                 1517.898
9                     5850.704                 1784.425
10                    7377.666                 1827.509
   Mean.density.of.furrows.SL Isotropy.SL First.Direction.SL
4                    7780.699    54.33402         90.0093393
5                    7576.945    58.25679         90.0045412
6                    7787.424    61.33658         90.0023654
7                    7703.471    79.32008          0.1836484
9                    7753.074    60.47282         90.0199459
10                   8036.763    82.10036         90.0028614
   Second.Direction.SL Third.Direction.SL Isotropy.SL.1 Periodicity.SL
4           44.9853711        135.0186951      68.70564             NA
5           45.0192443          0.2125054      70.23738             NA
6            0.1721761         45.0032528      80.78772             NA
7           89.9820795        135.0313277      78.86668             NA
9            0.2094917         45.0186261      75.49428             NA
10          44.9955354        135.0064403      80.84302             NA
   Period.SL Direction.of.period.SL    Sq.SF       Ssk.SF   Sku.SF     Sp.SF
4         NA                     NA 607.4917 -0.030127269 2.721561 1676.0886
5         NA                     NA 367.3208  0.101259713 3.516685 1022.7795
6         NA                     NA 399.5542  0.002493731 3.024096 1038.3308
7         NA                     NA 283.6608  0.143007021 2.431880  677.3693
9         NA                     NA 528.0274  0.663177444 2.824713 1542.8444
10        NA                     NA 488.7831 -0.310542781 2.462864 1154.0544
       Sv.SF    Sz.SF    Sa.SF   Smr.SF   Smc.SF    Sxp.SF   Sal.SF    Str.SF
4  1390.4225 3066.511 489.7923 12.72203 775.0712 1307.1396 48.90428 0.5801547
5  1231.7583 2254.538 284.2922 45.56146 495.5479  712.4680 35.35515 0.5948142
6  1175.3487 2213.680 313.8163 46.30507 497.5722  802.4142 43.22707 0.6705867
7   664.6433 1342.013 232.3183 86.94368 395.4773  503.1003 43.87200 0.4924656
9   843.4398 2386.284 432.7235 16.56863 741.8203  676.5278 46.75734 0.6656710
10 1150.2402 2304.295 402.5779 43.17200 550.3637 1089.4114 47.56912 0.8452929
      Std.SF     Sdq.SF      Sdr.SF      Vm.SF     Vv.SF     Vmp.SF    Vmc.SF
4   85.74960 0.02010226 0.020199438 0.02834208 0.8032595 0.02834208 0.6034480
5   23.75012 0.01606905 0.012913453 0.02061729 0.5161148 0.02061729 0.2968719
6   15.49991 0.01612422 0.013001249 0.02299213 0.5204720 0.02299213 0.3595907
7  104.24980 0.01140020 0.006497785 0.01100687 0.4063571 0.01100687 0.2601938
9   54.50003 0.02073750 0.021498439 0.03187325 0.7738147 0.03187325 0.4830335
10  58.75001 0.01788598 0.015991329 0.02002959 0.5702776 0.02002959 0.5131546
      Vvc.SF     Vvv.SF Maximum.depth.of.furrows.SF Mean.depth.of.furrows.SF
4  0.7412814 0.06197803                    322.2206                159.80265
5  0.4749120 0.04120278                    381.8377                135.90639
6  0.4742320 0.04624001                    332.6122                133.18782
7  0.3775514 0.02880575                    270.7163                 95.97446
9  0.7455215 0.02829324                    344.9352                178.64364
10 0.5185744 0.05170320                    308.4017                132.88460
   Mean.density.of.furrows.SF Isotropy.SF First.Direction.SF
4                    103.9757    58.01547          85.501240
5                    123.1478    59.48142           8.749987
6                    110.1888    67.05867          37.001054
7                    119.5835    49.24656         104.249854
9                    104.5475    66.56710          45.500127
10                   126.5249    84.52929          94.498948
   Second.Direction.SF Third.Direction.SF Isotropy.SF.1 Periodicity.SF
4            94.499133           18.24953      78.86858       27.84658
5           171.252249          176.24633      40.90620       39.78308
6           104.250000           21.50003      77.02578       25.14123
7            52.999902          175.50089      82.56818             NA
9           111.499768           54.25038      56.87549       30.64392
10            4.499641           15.25028      86.29519       36.76192
   Period.SF Direction.of.period.SF
4   99.47019               142.9792
5  126.91010                22.4552
6  148.12072                52.8743
7         NA                     NA
9  140.28410               134.8198
10 118.52956               154.8647

5. Save data

5.1. Format name of output file

The files will be saved as “~/Data/brushing_v2.[ext]”.

5.2. Write to XLSX

The exported XLSX-file is: “brushing_v2.xlsx”
Its modification, ‘last status change’ (= ‘creation’ on Windows) and last access times are, respectively: “2020-01-21 08:58:08”, “2019-10-24 11:24:36” and “2020-01-21 08:58:08”.

5.3. Save R object

The exported Rbin-file is: “brushing_v2.Rbin”
Its modification, ‘last status change’ (= ‘creation’ on Windows) and last access times are, respectively: “2020-01-21 08:58:08”, “2020-01-21 08:58:08” and “2020-01-21 08:58:08”.


R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252 
[2] LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] tools     stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] chron_2.3-54      R.utils_2.9.2     R.oo_1.23.0       R.methodsS3_1.7.1
[5] openxlsx_4.1.4   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3      digest_0.6.23   magrittr_1.5    evaluate_0.14  
 [5] zip_2.0.4       rlang_0.4.2     stringi_1.4.3   rmarkdown_2.0  
 [9] stringr_1.4.0   xfun_0.11       yaml_2.2.0      compiler_3.6.2 
[13] htmltools_0.4.0 knitr_1.26     

RStudio Version 1.2.5019


END OF SCRIPT