0

As still in junior level in R programming I am trying to finish my first project.

I have those data (2000 values) (Dft is dry film thickess)

Quarter DFT
1st 1,61
1st 2,35
1st 1,74
2nd 2,56
2nd 1,79
2nd 1,84
2nd 1,69
3rd 1,85
3rd 1,73
3rd 2,62
3rd 2,43
3rd 1,85

What I want is to produce a vector of random values of a specific area, lets say 0 to 3 (which actually is meters) and those values will be assigned in the existing table with the criteria :

The nearest to 0 the lowest the DFT value.

This way I will create a diagram DFT - Meter with 4 lines regarding the quarter.

The second question can be how this diagramme can be in 3d so I will have a visualize of a pipeline as a cylinder with the different thickness which actually would need the perimeter as well instead of the name "Quarter"

1 Answers1

0

Quick answer for the first part of the question:

Sort your data by column DFT:

df <- df[order(df$DFT),]

> df
   Quarter  DFT
1      1st 1,61
7      2nd 1,69
9      3rd 1,73
3      1st 1,74
5      2nd 1,79
6      2nd 1,84
8      3rd 1,85
12     3rd 1,85
2      1st 2,35
11     3rd 2,43
4      2nd 2,56
10     3rd 2,62

Now generate a random uniformly distributed vector of length 12 with minimum 0 and maximum 3, sort it and bind it to your data:

df$rand <- sort(runif(12, 0, 3))

> df
   Quarter  DFT      rand
1      1st 1,61 0.3421256
7      2nd 1,69 0.3853747
9      3rd 1,73 1.3841690
3      1st 1,74 1.4411375
5      2nd 1,79 1.5034130
6      2nd 1,84 1.6584415
8      3rd 1,85 2.1692523
12     3rd 1,85 2.6551129
2      1st 2,35 2.6630062
11     3rd 2,43 2.7236042
4      2nd 2,56 2.8132505
10     3rd 2,62 2.8572364

Voila. Or should the value of the random variable functionally depend on DFT? If so, you would need to provide a distribution function.

LAP
  • 6,605
  • 2
  • 15
  • 28