-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_input_data.R
More file actions
66 lines (54 loc) · 1.55 KB
/
generate_input_data.R
File metadata and controls
66 lines (54 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# ORDER OF RUN: #2
# Set path to data, run for each csv separately
# Change files to 90, 100, 120, 140, 160, 180, 200
df = read.csv('D:\\Projects\\Python\\PycharmProjects\\tf28\\symulacja_tlumu\\gotowe\\NA_GITHUB\\data\\results_to_file_b200.txt', sep=";")
out_file = 'D:\\Projects\\Python\\PycharmProjects\\tf28\\symulacja_tlumu\\gotowe\\NA_GITHUB\\data\\results_to_file_imp_b200.txt'
out_file_no_zero = 'D:\\Projects\\Python\\PycharmProjects\\tf28\\symulacja_tlumu\\gotowe\\NA_GITHUB\\data\\results_to_file_imp_no_zero_b200.txt'
t_xy_n = sqrt(df$t_x ^ 2 + df$t_y ^ 2)
df$t_xn = df$t_x
df$t_yn = df$t_y
for (a in 1:length(df$t_xn))
{
if (t_xy_n[a] > 0)
{
df$t_xn[a] = df$t_xn[a] / t_xy_n[a]
df$t_yn[a] = df$t_yn[a] / t_xy_n[a]
}
}
cd = function(x,y) {
xr = round(x)
yr = round(y)
res = 0
if (xr == 0 && yr == 0)
res = 0
if (xr == 1 && yr == 0)
res = 1
if (xr == 1 && yr == 1)
res = 2
if (xr == 0 && yr == 1)
res = 3
if (xr == -1 && yr == 1)
res = 4
if (xr == -1 && yr == 0)
res = 5
if (xr == -1 && yr == -1)
res = 6
if (xr == 0 && yr == -1)
res = 7
if (xr == 1 && yr == -1)
res = 8
return (res)
}
df$t_dir = rep(0, length(df$key))
for (a in 1:length(df$t_dir))
{
df$t_dir[a] = cd(df$t_xn[a], df$t_yn[a])
}
df$ff_dir = rep(0, length(df$key))
for (a in 1:length(df$t_dir))
{
df$ff_dir[a] = cd(df$ff_x[a], df$ff_y[a])
}
df_no_Zero = df[df$t_dir != 0,]
write.csv(df_no_Zero, out_file_no_zero, sep=";",quote = FALSE, row.names = FALSE)
write.csv(df, out_file, sep=";",quote = FALSE, row.names = FALSE)