I have a problem with combining data frames which share the same rows. I imported rasters from different folders and converted them into data frames and tried to combine them together but the data don't line together and I don't know why!? Does anyone have the answer, please?
Fun <- function(f) {
df <- stack(f)
}
files <- dir("mypath", recursive=TRUE, full.names=TRUE, pattern=".tif$")
All <- sapply(files, Fun)
for(i in All){
df1 <- lapply(All, as.data.frame, xy = TRUE)
all <- dplyr::bind_rows(df1)
}
Now. for addational
R1
x y R1
1 696060 -3327450 66
2 696090 -3327450 71
3 696120 -3327450 69
4 696150 -3327450 65
5 696180 -3327450 67
6 696210 -3327450 68
7 696240 -3327450 67
8 696270 -3327450 68
9 696300 -3327450 69
10 696330 -3327450 0
R2
x y R2
1 696060 -3327450 66
2 696090 -3327450 71
3 696120 -3327450 69
4 696150 -3327450 65
5 696180 -3327450 67
6 696210 -3327450 68
7 696240 -3327450 67
8 696270 -3327450 68
9 696300 -3327450 69
10 696330 -3327450 0
R1
x y R1
1 753810 -3339930 109
2 753840 -3339930 108
3 753870 -3339930 108
4 753900 -3339930 109
5 753930 -3339930 108
6 753960 -3339930 109
7 753990 -3339930 109
8 754020 -3339930 109
9 754050 -3339930 110
10 754080 -3339930 109
R2
x y R2
1 753810 -3339930 109
2 753840 -3339930 108
3 753870 -3339930 108
4 753900 -3339930 109
5 753930 -3339930 108
6 753960 -3339930 109
7 753990 -3339930 109
8 754020 -3339930 109
9 754050 -3339930 110
10 754080 -3339930 109
The output will be like that:
x y R1 R2
1 696060 -3327450 66 NA
2 696090 -3327450 71 NA
3 696120 -3327450 69 NA
4 696150 -3327450 65 NA
5 696180 -3327450 67 NA
6 696210 -3327450 68 NA
7 696240 -3327450 67 NA
8 696270 -3327450 68 NA
9 696300 -3327450 69 NA
10 696330 -3327450 0 NA
11 696060 -3327450 NA 66
12 696090 -3327450 NA 71
13 696120 -3327450 NA 69
14 696150 -3327450 NA 65
15 696180 -3327450 NA 67
16 696210 -3327450 NA 68
17 696240 -3327450 NA 67
18 696270 -3327450 NA 68
19 696300 -3327450 NA 69
20 696330 -3327450 NA 0
21 753810 -3339930 109 109
22 753840 -3339930 108 108
23 753870 -3339930 108 108
24 753900 -3339930 109 109
25 753930 -3339930 108 108
26 753960 -3339930 109 109
27 753990 -3339930 109 109
28 754020 -3339930 109 109
29 754050 -3339930 110 110
30 754080 -3339930 109 109
Any idea about what is going on or suggestion what should I do?