Using a Unique Identifier, Match Row Values with Column Names in R - r

Master
StoreNumber Online Pressure MON TUE WED ... SUN ...
1 0.2 50 0 0 0 ... 0
2 0.8 20 0 0 0 ... 0
3 1.2 10 0 0 0 ... 0
...
Hours
BranchNumber Day ... Time
1 MON 7.50
1 TUE 6.00
1 WED 8.50
3 MON 2.00
3 TUE 1.00
3 WED 2.50
...
NB There are many branch numbers about 10,500 due to being 7 days in a week so one branch number may occur 7 times for each day of the week, but some may only have 6 or 5 etc.
The idea is I want to populate the days of the week "Mon", "Tue", "Wed"... "Sun" etc in the 'Master' table from the 'Time' data in the 'Hours' Table. The match should check that the StorenNumber matches the BranchNumber...then the day of the week, if there is 'Mon' in the hours table then it should match it to the column 'Mon' in the Master table.
So the output will look something like this
StoreNumber Online Pressure MON TUE WED ... Hours
1 0.2 50 7.50 6.00 8.50 ... 53
2 0.8 20 0 0 0 ... 30
3 1.2 10 2.00 1.00 2.50 ... 20
...
As an example BranchNumber 2 doesnt exist in the Hours table so it should just skip each column and leaves the inputs as 0
I have tried the R based code below but am struggling to get an output...Once running the code I get zero errors but the Master Table remains unchanged and all days of the week columns remain as 0
merged <- Master%>% select(-
c("MON","TUE","WED","THU","FRI","SAT","SUN")) %>%
left_join(
Hours %>% pivot_wider(names_from = Day, values_from =
Time),
by = c("StoreNumber" = "BranchNumber"))
merged <- merged %>% replace(is.na(.),0)
Dput(Master)
Pressure = c(0, 0, 0, 0, 0, 0, 0, 0, 0.23, 0,
0.19, 0, 0, 0, 0.56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0.42, 0, 0, 0, 0, 0.37, 0, 0, 0.92, 0, 0, 0, 0,
0.04, 0.15, 0.12, 0.12, 0.06, 0.02, 0.19, 0.12, 0.08, 0.15,
0.02, 0.46, 0.25, 0.02, 0.17, 0.06, 0.25, 0.08, 0, 0.08,
0, 0.12, 0.23, 0.02, 0.04, 0.02, 0.15, 0, 0.02, 0.1, 0, 0,
0.04, 0.02, 0.23, 0.48, 0.19, 0.06, 0.02, 0.02, 0.08, 0.13,
0, 0.02, 0.08, 0.06, 0.15, 0.42, 0.06, 0.04, 0.04, 0.44,
0.06, 0.42, 0.06, 0.13, 0.46, 0, 0.81, 0.12, 0.25, 0.5, 0.06,
0.23, 0.02, 0.19, 0.33, 0, 0.06, 0.13, 0.12, 0.27, 0.04,
0.17, 0.13, 0.08, 0.12, 0.1, 0.21, 0.31, 0.17, 0, 0, 0.04,
0.1, 0.29, 0.13, 0.38, 0.15, 0.17, 0.58, 0.02, 0.02, 0.08,
1.15, 0.08, 0.1, 0.4, 0.58, 0.35, 0.12, 0.12, 0.5, 0.17,
0.6, 0.04, 0.06, 0.13, 0.12, 0.06, 0.19, 0.25, 0.06, 0.06,
0.1, 0, 0.29, 0.58, 0.02, 0.08, 1.4, 0.15, 0.21, 0.15, 0.1,
0.02, 0, 0, 0.08, 0, 0.02, 0.23, 0.1, 0.6, 0, 0.08, 0.37,
0, 0.17, 0.21, 0.44, 0.77, 0.33, 0.42, 0, 0.12, 0.12, 0.1,
0.12, 0.06, 0.02, 0.04, 0.17, 0.13, 0.02, 0.12, 0.25, 0.06,
0.04, 0.04, 0.17, 0.17, 0.6, 0.06, 0.37, 0, 0.15, 0.13, 0.08,
0.21, 0, 0.13, 0.02, 0.15, 0, 0.4, 0.23, 0.27, 0.08, 0.1,
0.19, 0.04, 0.02, 0.1, 0.17, 0.85, 0.56, 0, 0.56, 0.56, 0.06,
0.06, 0, 0.21, 0.02, 0.33, 0, 0.04, 0.13, 0.1, 0.12, 0, 0,
0.13, 0.17, 0.08, 0.02, 0.12, 0.06, 0.38, 0.21, 0.1, 0, 0.13,
0.17, 0, 0.1, 0.12, 0.17, 0, 0.42, 0.15, 0.15, 0.42, 0.04,
0.04, 0.69, 0.15, 0, 0, 0.17, 0.4, 0.23, 0.27, 0.04, 0.17,
0.06, 0, 0, 0.06, 0.21, 0.04, 0.29, 0.04, 0.19, 0, 0.19,
0.02, 0.02, 0.29, 0.35, 0.19, 0.23, 0.42, 0.02, 0.35, 0.29,
0.02, 0.17, 0.1, 0.06, 0.17, 0.1, 0.38, 0.02, 0.15, 0.17,
0.29, 0.04, 0.02, 0.38, 0.12, 0.17, 0.02, 0, 0.06, 0.12,
0.08, 0.13, 0.12, 0.1, 0.33, 0.23, 0.29, 0.31, 0.19, 0.17,
0, 0.33, 0.17, 0.38, 0.02, 0.21, 0.17, 0.19, 0.06, 0.29,
0.12, 0.02, 0.15, 0.13, 0.17, 0.25, 0.02, 0.15, 0.65, 0.48,
0.29, 0.02, 0.19, 0.29, 0.27, 0.06, 0.02, 0.29, 0.21, 0.15,
0.12, 0.19, 0.44, 0.1, 0.04, 0.12, 0.15, 0.27, 0.1, 0.15,
0.1, 0.06, 0.15, 0.06, 0.15, 0.13, 0.54, 0.19, 0.04, 0.33,
0.06, 0.25, 0.17, 0.29, 0.12, 0.25, 0.1, 0.31, 0.13, 0.1,
0.1, 0.02, 0.25, 0.02, 0.15, 0.13, 0.29, 0.15, 0.77, 0.1,
0.08, 0.38, 0.4, 0.02, 0.37, 0, 0.12, 0.27, 0.25, 0.46, 0,
0.02, 0.12, 0, 0.27, 0.02, 0, 0.13, 0.04, 0.08, 0.13, 0.25,
0.08, 0.06, 0, 0.06, 0.12, 0.33, 0.15, 0.67, 0.04, 0.31,
0.21, 0.19, 0.25, 0.27, 0.02, 0.1, 0.1, 0.06, 0.44, 0.35,
0.23, 0.1, 0.15, 0.21, 0.08, 0.02, 0.37, 0.27, 0.17, 0.1,
0.04, 0.19, 0.42, 0.27, 0.29, 0.63, 0.54, 0.29, 0.02, 0.44,
0.35, 1.35, 0, 0.4, 0.25, 0.04, 0.02, 0.02, 0.17, 0.19, 0.17,
0.1, 0.42, 0.13, 0.13, 0.1, 0.1, 0.06, 0.04, 0.04, 0.44,
0.06, 0.04, 0.1, 0.21, 0.06, 0.02, 0.19, 0.27, 0.44, 0.02,
0.17, 0.06, 0.02, 0.17, 0.15, 0.15, 0.15, 0.12, 0.02, 0,
0, 0.21, 0.02), Online = c(1.63, 2.6, 0.48, 1.9, 5.27, 1.23,
1.87, 4.56, 3.71, 2.4, 9.62, 1.15, 1.5, 1.96, 2.5, 10.37,
2.62, 7.44, 2.71, 1.48, 16.94, 3.92, 2.9, 4.44, 2.69, 6.04,
2.69, 1.44, 0.52, 0.48, 1.44, 0.85, 4.56, 1.81, 9.25, 3.12,
5.56, 2.33, 4.67, 2.54, 3.73, 1.63, 3.4, 1.9, 1.15, 1.08,
6.27, 2.23, 3.13, 2.02, 0.63, 3.31, 2.96, 4.56, 3.19, 2.62,
6.21, 8.6, 2.23, 2.33, 0.9, 2.6, 0.94, 1.58, 0.85, 3.38,
4.04, 6.46, 3.17, 4.79, 7.92, 6.58, 1.63, 5.88, 5.06, 6.42,
2.69, 4.4, 2.08, 2.81, 3.23, 1.6, 3.08, 5.77, 1.65, 2.56,
3.81, 4.08, 3.65, 5.06, 1.15, 1.15, 1.08, 3.77, 2.75, 2.6,
2.56, 4.37, 4.92, 2.12, 1.58, 0.1, 1.87, 1.44, 4.02, 2.5,
1.29, 2.33, 6.12, 4.62, 1.98, 5.77, 3.19, 0.9, 1.5, 9.77,
7.63, 5.37, 0.79, 1.17, 4.23, 2.81, 4.31, 2.71, 3.4, 6.38,
2.75, 1.23, 4.77, 2.4, 6.04, 0.58, 0.79, 8.08, 2.13, 1.75,
0.87, 2.19, 1.38, 2.54, 2.71, 1.65, 3.5, 1.85, 18.52, 2.08,
0.33, 3.19, 6.69, 1.06, 3.08, 1.81, 1.06, 0.48, 0.85, 3.65,
1.44, 1.63, 1.71, 3.5, 2.12, 9.62, 1.96, 7.48, 1.65, 3.19,
11.04, 1.81, 3.4, 3.73, 6.1, 0.9, 10.31, 4.46, 2.27, 1.17,
0.94, 2.02, 2.75, 6.38, 3.83, 4.98, 3.77, 2.71, 5.63, 1.21,
3.31, 0, 9.35, 5.56, 1.79, 6.15, 1.9, 3.4, 6.52, 0.63, 1.37,
4.25, 1.71, 0.69, 0.75, 1.23, 2.69, 2.02, 1.79, 3.56, 0.75,
0.75, 0.52, 1.21, 1.12, 0.69, 1.79, 4.56, 1.23, 4.83, 5.04,
2.38, 1.23, 5.4, 3.13, 2.62, 1.08, 13.38, 3.52, 5.19, 3.62,
1.08, 4.5, 10.19, 2.33, 4.73, 1.87, 9.4, 11.21, 1.65, 2.29,
2.9, 35.94, 3.19, 2.4, 1.79, 7.58, 5.4, 4.73, 1.21, 1.54,
1.75, 2.98, 2.27, 2.08, 2.08, 4.35, 5.85, 3.12, 1.63, 5.06,
1.65, 4.92, 4.77, 5.06, 5, 5.27, 8.75, 3.56, 5.77, 6.21,
10.13, 6, 7.69, 1.92, 3.81, 7.92, 1.63, 4.29, 3.46, 7.65,
8.35, 1, 6.27, 6.96, 2.17, 14.81, 10.65, 0.04, 2.54, 1.38,
0.85, 5.79, 3.5, 6.6, 6.04, 2.13, 4.04, 5.63, 4.94, 1.27,
2.5, 6.42, 4.83, 4.35, 3.19, 4.1, 1.38, 1.63, 2.4, 6.96,
0.63, 2.12, 8.65, 3.67, 1.9, 2.08, 5.46, 3.71, 1.69, 2.81,
0.6, 2.06, 5.1, 2.87, 5.27, 6.54, 2.56, 0.42, 0.33, 1.12,
1.06, 1.6, 1.37, 2.23, 1.08, 1.75, 0.6, 0.9, 5.1, 2.27, 0.73,
1.33, 1.06, 1.96, 1.98, 3.98, 1.75, 1.87, 9.73, 12, 1.15,
1.23, 3.29, 1.92, 6.06, 4.44, 2.48, 1.37, 5.58, 2.12, 1.81,
1.17, 0.27, 1.6, 4.85, 1.17, 2.48, 1.63, 2.17, 1.71, 4.15,
0.48, 1.44, 1.08, 4.67, 4.56, 0.52, 6.06, 1.63, 2.35, 1.23,
1.96, 14.35, 0.58, 1.54, 1.5, 1.9, 2.54, 2.48, 2.77, 19.6,
3.35, 0.73, 1.69, 1.17, 0.85, 3.23, 0.17, 2.27, 3.71, 2.27,
2.4, 1.37, 1.5, 2.02, 0.12, 0.25, 0.38, 17.13, 2.65, 0.31,
1.85, 3.13, 1.54, 3.38, 2.98, 3.71, 2.23, 4.58, 3.29, 1.02,
7.12, 1.96, 1.85, 0.85, 2.69, 1.81, 1.21, 1.06, 3.13, 1.44,
2.71, 3.4, 3.98, 3.08, 0.9, 5, 0, 0, 0, 0, 0, 2.06, 0.75,
5.25, 2.06, 3.38, 3.04, 7.9, 4.73, 1.44, 10.67, 0.06, 7.42,
2.19, 4.5, 2.44, 3.13, 3.52, 2.75, 0.27, 7.1, 5.63, 0.52,
1.15, 2.48, 2.48, 3.71, 1.6, 1.98, 2.06, 1.5, 4.56, 1.08,
0.25, 1.15, 4.79, 2.6, 4.73, 2.6, 0.15, 0.15, 5.27, 1.21,
5, 1.29, 3.38, 0.85, 2.27, 0, 0.73, 0.38, 0.38, 0.94, 0.38,
2.08, 1.71, 4.29, 0.94, 5.62, 2.23, 0.38, 1.23, 2.06, 0.65,
4.71, 2.19, 3.08, 1.21, 1.38, 2.06, 0.54, 0.81, 1.08, 4.35,
12.6, 8.98, 1.87, 1.58, 0.27, 0.46, 19.65, 0.38, 1.37, 2.06,
1.98, 0.31, 0.46, 0.6, 0.38, 0.31, 3.77, 2.5, 15.56, 5.27,
12.58, 7.33, 11.06, 9.33, 12.79, 15.29, 7.12, 7.23, 14.17,
12.06, 12, 6.54, 6, 15.35, 10.71, 14.69, 6.94, 6.12, 5.73,
7.17, 4.15, 15.77, 7.02, 12.75, 11.56, 8.12, 6.46, 7.12,
9.02, 11.04, 10.79, 10.08, 8.08, 8.21, 9.81, 8.92, 10.73,
10.15, 9.35, 8.62, 6.27, 13.23, 14.02, 14.13, 6.25, 7.37,
6.06, 21.4, 6.63, 7.1, 8.62, 17.29, 8.4, 7.44, 5.77, 10.77,
56.38, 9.77, 11.98, 8.9, 6.06, 5.77, 13.48, 14.23, 8.17,
9.62, 11.62, 6, 12.38, 7.42, 7.23, 5.79, 8.08, 8.35, 4.73,
7.58, 6.15, 6.88, 15.65, 13.02, 7.71, 18.33, 5.69, 4.5, 7.96,
5.35, 21.17, 4.29, 9.17, 13.96, 8.69, 8.5, 12.94, 7.1, 6.15,
19.94, 7.54, 13.9, 11.56, 11.4, 11.31, 19.6, 8.83, 11.19,
9.94, 7.5, 8, 6, 4.85, 6.15, 9.94, 8.02, 11.15, 15.13, 7.06,
10.37, 10.04, 27.02, 8.17, 13.6, 11.04, 11.15, 6.1, 4.37,
7.02, 15.5, 13.15, 7.75, 9.19, 11.48, 8.81, 10.23, 12.1,
5.96, 8.13, 12.48, 8.21, 9.44, 13.15, 9.54, 19.9, 4.71, 4.63,
23.63, 24.31, 10.79, 15.35, 12.79, 10.31, 20.85, 9.02, 15.04,
9.4, 4.63, 11.27, 5.96, 40.12, 8.77, 7.79, 8.27, 7.1, 11.62,
3.81, 5.67, 5.35, 8.6, 7.33, 7.6, 8.87, 17.77, 7.92, 5.9,
6.85, 12.54, 21.08, 15.08, 9.02, 3.98, 11.67, 32.79, 5.21,
5, 6.38, 10.31, 21.35, 18.06, 13.17, 16.52, 17.04, 10.4,
4.29, 21.19, 8.71, 8.75, 14.5, 5, 8.29, 9.19, 19.87, 4.5,
3.87, 6.73, 6.75, 22.87, 8.4, 13.38, 16.79, 3.31, 8.5, 12.48,
6.33, 10.25, 9.87, 6.04, 14.33, 6.04, 5.79, 5.63, 10.73,
13.58, 8.87, 11.88, 9.12, 12.21, 10.08, 7.5, 13.9, 10.92,
8.4, 9.65, 9.25, 13.75, 9.46, 12.33, 10.02, 98.77, 11.21,
5.77, 5.19, 12.9, 10.1, 10.56, 6.12, 6.17, 7.44, 2.08, 0.65,
2.92, 0.42, 4.1, 8.62, 1.37, 2.35, 2.56, 1.15, 2.17, 0.69,
4.02, 1.81, 1.37, 2.87, 3.29, 2.96, 1.42, 2.62, 0.48, 2.35,
5.27, 2.23, 1.38, 3.31, 8.87, 3.25, 2.98, 3.94, 2.13, 1.85,
5.19, 2.9, 2.23, 2.38, 0.9, 2.92, 0.96, 0.75, 2.33, 4.88,
4.08, 3.65, 7.87, 11.35, 2.83, 3.62, 3.12, 4.79, 4.62, 5.27,
5.25, 6, 2.29, 1.44, 1.06, 2.44, 1.42, 2.6, 4.67, 4.1, 1.06,
2.83, 2.87, 1.5, 1.5, 0.87, 0.73, 3.83, 2.71, 0.65, 2.35,
1.37, 4.23, 2.17, 1.81, 2.77, 1.23, 1.96, 1.37, 4.44, 3.35,
1.96, 2.33, 1.33, 1.38, 6.67, 2.75, 1.48, 2.62, 1.65, 2.29,
5, 1.81, 2.08, 1.27, 3.4, 1.42, 2.23, 0.37, 1.69, 2.23, 2.83,
0.69, 4.71, 1.85, 1.23, 2.71, 8.12, 1.87, 2.62, 0.85, 3.12,
4.88, 1.23, 2.13, 0.52, 4.73, 4.31, 1.23, 0.38, 0.48, 0.58,
1.27, 3.31, 12.46, 2.4, 5.13, 2.81, 2.87, 2.44, 6.69, 1.85,
5.1, 2.29, 4.35, 1.6, 3.25, 3.13, 1.98, 1.79, 2.87, 2.33,
4.31, 0.73, 0.46, 2.83, 1.06, 0.73, 3.94, 0.42, 6.48, 2.4,
5.37, 2.71, 3.38, 1.81, 1.87, 5.13, 0.87, 0.9, 3.38, 0.81,
1.06, 0.96, 0.63, 2.87, 1.5, 1.29, 4.1, 1.54, 2.13, 6.42,
3.17, 3.25, 2.44, 3.19, 1.81, 2.4, 3.83, 3.71, 2.71, 3.04,
15.13, 4.73, 3.17, 2.62, 8.69, 7.1, 2.13, 2.02, 1.42, 2.19,
3.44, 3.56, 3.67, 8.17, 0.63, 3.35, 1.9, 0.87, 1.75, 4.4,
7.12, 3.46, 4.56, 2.81, 1.08, 0.81, 2.27, 2.23, 0.94, 4.92,
3.44, 2.87, 2.65, 6.31, 2.5, 1.85, 1.44, 1.71, 1.15, 1.37,
0.31, 2.9, 3.5, 3.17, 0.48, 0.85, 1.65, 3.56, 6.81, 1.17,
0, 4.02, 2.71, 1.96, 3.44, 10.23, 2.98, 2.54, 4.1, 1.65,
2.4, 4.88, 2.75, 1.9, 2.75, 1.69, 5.37, 7.33, 6.06, 4.19,
1.6, 0.75, 6.63, 2.87, 3.77, 1.85, 1.69, 1.6, 4.85, 5.35,
2.65, 2.75, 2.83, 0.42, 4.88, 3.04, 9.44, 11.79, 4.79, 1.5,
3.52, 0.87, 1.71, 1.15, 1.02, 0.87, 3.35, 7.06, 4.19, 0.94,
0.63, 2.06, 4.62, 2.6, 1.29, 3.73, 4.25, 3.87, 4.23, 1.92,
6.15, 2.12, 4.83, 2.35, 2.29, 6.67, 1.38, 1.15, 1.54, 1.92,
1.75, 1.15, 0, 0, 2.96, 1.08, 0.17, 4.98, 3.5, 4.62, 1.65,
0.1, 2.92, 3.77, 1.65, 0, 1.69, 6.04, 3.88, 3.25, 2.44, 2.75,
1.63, 2.6, 3.04, 0.63, 2.06, 0.15, 0.63, 3.35, 1.15, 0.69,
2.5, 2.6, 0.96, 1.27, 3.6, 2.5, 3.77, 0.81, 0.96, 5.96, 1.12,
0.81, 0.85, 1.38, 4.1, 1.63, 1.69, 0.12, 5.62, 2.98, 3.44,
0.87, 3.17, 1.98, 2.92, 9.54, 0.06, 3.88, 0.81, 1.27, 0.46,
1.12, 2.13, 3.83, 8.83, 1.48, 7.23, 0.48, 1.58, 0.54, 3.12,
3.44, 0.54, 0.17, 3.6, 0.33, 0.81, 0.6, 0.37, 1.17, 2.6,
2.92, 1.81, 3.62, 2.98, 2.06, 4.35, 1.69, 0.37, 1.06, 2.23,
1.42, 0.73, 2.06, 1.38, 1.12, 2.19, 1.15, 0.6, 0.31, 3.83,
1.6, 3.98, 2.35, 13.9, 0.37, 1.85, 3.6, 2.19, 4.5, 0.42,
0.27, 4.23, 5.21, 4.04, 1.33, 5.06, 0, 10.35, 3.19, 2.33,
7.17, 0.52, 0.69, 4.04, 8.21, 7.44, 5.69, 3.5, 2.62, 7.42,
1.85, 4.02, 2.27, 16.15, 7.33, 1.42, 12.31, 3.04, 1.17, 3.17,
9.33, 4.71, 4.67, 4.46, 3.87, 0.21, 2.17, 6.73, 11.88, 2.98,
1.29, 15.87, 0.42, 1.6, 2.23, 1.21, 1.33, 2.81, 3.67, 3.13,
4.71, 6.21, 7.15, 1.44, 3.46, 3.04, 1.85, 1.37, 2.69, 3.71,
5.85, 1.12, 16.58, 2.9, 9.46, 4.58, 2.27, 5.15, 3.94, 2.38,
1, 4.52, 0.65, 1.87, 2.02, 0.15, 1.9, 16.31, 2.5, 4.08, 4.08,
5.21, 5.62, 3.62, 2.56, 1.63, 9.87, 0.63, 1.85, 3.19, 9.62,
3.71, 2.06, 4.79, 9.25, 5.96, 1.63, 2.27, 0.37, 2.9, 3.88,
4.08, 5.63, 5.94, 2.27, 3.38, 4.85, 2.4, 2.35, 0.52, 1.29,
3.52, 1.6, 4.77, 22.02, 3.94, 1.33, 1.33, 1.33, 14.63, 1.98,
6.12, 7.9, 1.5, 1.15, 5.85, 0.9, 2.17, 0.81, 2.17, 4.56,
2.23, 6.27, 10.58, 4.5, 7.96, 2.33, 6.25, 2.44, 3.02, 4.31,
6.58, 2.06, 3.5, 5.4, 0.69, 8, 1.71, 1.44, 0.85, 1.69, 7.54,
2.33, 1.37, 2.17, 2.92, 1.65, 1.69, 3.83, 3.35, 0.79, 3.4,
1.81, 0.81, 2.77, 3.12, 6.75, 1.6, 1.69, 2.54, 3.65, 3.65,
12.6, 3.29, 1.44, 1.65, 5.94, 6, 6.38, 1.48, 9.25, 1.21,
8.98, 2.35, 2.19, 2.71, 14.23, 1.69, 8.12, 23.46, 2.77, 1,
2.44, 1.27, 1.9, 6.63, 0.96, 0.87, 6.33, 1.21, 0.73, 5.9,
0.69, 1.81, 3.65, 4.46, 12, 6.21, 3.35, 1.02, 0.46, 0.21,
0.04, 6.04, 2.23, 1.42, 1.63, 1.58, 6.94, 5.35, 2.33, 1.92,
1.12, 8.98, 2.56, 0.87, 2.27, 1.08, 2.19, 10.67, 6.21, 0.38,
1.44, 0.04, 1, 1.21, 7.33, 0), row.names = c(NA,
-1432L), class = "data.frame")
Dput(Hours)
Days = c(8.5, 8.5, 8.5, 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9, 9, 9, 9, 9, 5,
10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 8.5, 8.5, 8.5, 8.5,
8.5, 8, 9.5, 9.5, 9.5, 9.5, 9.5, 3.5, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 3.5, 9.5, 9.5, 9.5, 9, 9.5, 8, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 8.5, 8.5, 8.5, 8.5, 8.5, 9, 9,
9, 9, 9, 10, 15, 15, 15, 15, 15, 15, 10, 10, 10, 10, 10,
10, 9, 9, 9, 9, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 6, 14, 14, 14,
14, 14, 14, 6, 12, 12, 12, 12, 12, 12, 6, 12, 12, 12, 12,
12, 12, 6, 12, 12, 12, 12, 12, 12, 9, 9, 9, 9, 9, 4, 9, 9,
9, 9, 9, 8, 9.5, 9, 9, 9, 9, 3, 9.5, 9.5, 9.5, 9.5, 9.5,
3.5, 10, 10, 10, 10.5, 10, 4, 11, 11, 12, 11, 12, 10, 10,
10, 10, 10, 6, 10.5, 10.5, 10.5, 10.5, 10.5, 9, 9, 9, 9,
9, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 4, 9.5, 9.5,
9.5, 9.5, 9.5, 9.75, 9.75, 9.75, 9.75, 9.75, 9, 9, 9, 9,
9, 9.25, 9.25, 9.25, 9.25, 9.25, 4, 10.25, 10.25, 10.25,
10.25, 10.25, 6, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 8.5, 8.5,
8.5, 8.5, 8.5, 9, 9, 9, 9, 9, 4, 8.5, 8.5, 8.5, 8.5, 8.5,
8.5, 8, 16, 16, 16, 16, 16, 12, 9, 9, 9, 9, 9, 9.5, 9.5,
9.5, 9.5, 9.5, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 10.5,
10.5, 10.5, 10.5, 10.5, 10, 11.5, 11.5, 11.5, 10.5, 10.5,
4, 9, 9, 9, 9, 9, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 3, 9.5, 9.5,
9.5, 9.5, 9.5, 3, 9.5, 9.5, 9.5, 9.5, 9.5, 9, 9, 9, 9, 9,
4, 10, 10, 10, 7.5, 10, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5,
9.5, 7.5, 9.5, 2.5, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 9.5,
9.5, 9.5, 9.5, 9.5, 3, 10.5, 10.5, 10.5, 10.5, 10.5, 9, 9,
9, 9, 9, 6, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5, 9.5, 9.5,
9.5, 4.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 9.5, 9.5, 9.5,
9.5, 9.5, 3, 9, 9, 9, 9, 9, 4, 10, 10, 10, 10, 10, 4, 9.75,
9.75, 9.75, 9.75, 9.75, 4, 9.75, 9.75, 9.75, 9.75, 9.75,
9.25, 9.25, 9.25, 4, 9.25, 9.5, 9.5, 9.5, 3.5, 9.5, 9.5,
9.5, 9.5, 9.5, 9.5, 9.75, 9.75, 9.75, 4.5, 9.75, 9, 9, 9,
9, 9, 4, 9.25, 9.25, 9.25, 9.25, 9.25, 2.5, 12, 10.5, 10.5,
10.5, 10.5, 9.75, 9.75, 9.75, 9.75, 9.75, 10, 10, 10, 10,
10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 6,
14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 12, 12, 12, 12, 12,
12, 6, 12, 12, 12, 12, 12, 12, 6, 14.5, 14.5, 14.5, 14.5,
14.5, 14.5, 6, 12, 12, 12, 12, 12, 12, 9.25, 9.25, 9.25,
9.25, 9.25, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 9, 9, 9, 9,
9, 9.5, 9.5, 9.5, 9.5, 9.5, 10, 10, 10, 10, 10, 6, 10.75,
10.75, 10.75, 10.75, 10.75, 10, 10.75, 10.75, 10.75, 10.75,
10.75, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 10, 10, 10, 10, 10,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 4, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 5,
9, 9, 9, 9, 9, 5, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 9, 9, 4, 9, 9, 9, 9, 9,
9, 9, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 4, 9, 9, 9, 9, 9, 6, 14.5, 14.5, 14.5, 14.5,
14.5, 14.5, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 14.5,
14.5, 14.5, 14.5, 14.5, 14.5, 6, 12, 12, 12, 12, 12, 12,
6, 12.5, 12.5, 12.5, 12.5, 12.5, 12, 6, 14, 14, 14, 14, 14,
14, 6, 12, 12, 12, 12, 12, 12, 6, 14.5, 14.5, 14.5, 14.5,
14.5, 14.5, 6, 4, 4, 4, 4, 4, 3, 9.75, 9.75, 9.75, 9.75,
9.75, 3.5, 9, 9, 9, 9, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5,
9.5, 9.5, 9.5, 9.75, 9.75, 9.75, 9.75, 9.75, 9, 9, 9, 9,
9, 9.5, 9.5, 9.5, 9.5, 9.5, 10, 10, 10, 10, 10, 4, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 11, 11,
11, 11, 11, 9.75, 9.75, 9.75, 9.75, 9.75, 10, 10, 10, 10,
10, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
10, 8, 9, 9, 9, 9, 9, 4, 9, 9, 9, 9, 9, 13.75, 14.5, 14.5,
14.5, 14.5, 14.5, 13.75, 4, 9.5, 9.5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15.5, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 10, 10, 10, 10, 10,
4, 10, 10, 10, 10, 10, 8, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 9,
9, 9, 9, 9, 8, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 9.5, 9.5, 9.5,
9.5, 9.5, 3, 9, 9, 9, 9, 9, 7, 4, 9.5, 9.5, 9.5, 9.5, 9.5,
8.5, 13, 12.5, 12.5, 12.5, 12.5, 12.5, 13, 9.5, 9.5, 9.5,
9.5, 9.5, 8, 9, 9, 9, 9, 9, 8.5, 10.5, 10.5, 10.5, 10.5,
10.5, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 10.5, 10.5, 10.5, 10.5,
10.5, 8, 9, 9, 9, 9, 9, 4, 10, 10, 10, 10, 10, 8, 10, 10,
10, 10, 10, 8, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 9.5, 9.5, 9.5,
9, 9.5, 4, 10, 10, 10, 10, 10, 8, 10, 11, 10, 10, 10, 10,
10, 10, 10, 10, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 10.5, 10.5, 10.5,
10.5, 10.5, 8, 10.25, 10.25, 10.25, 10.25, 10.25, 9.5, 9.5,
9.5, 9.5, 9.5, 10, 10, 10, 10, 10, 4, 9.5, 9.5, 9.5, 9, 9.5,
4, 10, 10, 10, 10, 10, 4, 10, 10, 10, 10, 10, 8.5, 9, 9,
9, 9, 9, 4, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 16,
16, 16, 16, 16, 15, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5,
6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 14.5, 14.5, 14.5,
14.5, 14.5, 14.5, 6, 13.5, 13.5, 13.5, 13.5, 13.5, 13.5,
6, 4, 4, 4, 4, 4, 3, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 9, 9, 9,
9, 9, 8.5, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 9, 9, 9, 9, 9, 4,
9.5, 9.5, 9.5, 9.5, 9.5, 4, 9, 9, 9, 9, 9, 4, 10.5, 10.5,
10.5, 10.5, 10.5, 8.5, 9.75, 9.75, 9.75, 9.75, 9.75, 4, 10,
10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9, 10, 10,
10, 10, 10, 8.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.25, 9.25, 9.25,
9.25, 9.25, 4, 9, 9, 9, 9, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 13,
14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 10, 10, 10, 10, 10, 13,
14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 10, 10, 10, 10, 10, 9,
10, 10, 10, 10, 10, 4, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 9.5,
9.5, 9.5, 9.5, 9.5, 3, 9.5, 9.5, 9.5, 9.5, 9.5, 8.25, 10,
10, 10, 10, 10, 4, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 9.5, 9.5,
9.5, 9.5, 9.5, 8.5, 9.75, 9.75, 9.75, 9.75, 9.75, 4, 9, 9,
9, 9, 9, 4, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 6, 14.5, 14.5, 14.5,
14.5, 14.5, 14.5, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5,
6, 12, 12, 12, 12, 12, 12, 6, 14.5, 14.5, 14.5, 14.5, 14.5,
14.5, 6, 14, 14, 14, 14, 14, 14, 6, 14.5, 14.5, 14.5, 14.5,
14.5, 14.5, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 9, 9,
9, 9, 9, 7, 6, 9.5, 9.5, 9.5, 10.5, 10.5, 8, 8.5, 8.5, 8.5,
8.5, 8.5, 8.5, 10, 10, 10, 10, 10, 9.5, 9.5, 9.5, 9.5, 9.5,
3, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 9, 9, 9, 9, 9, 8, 9.5, 9.25,
9.25, 9.25, 9.5, 8.5, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9,
4, 10, 10, 10, 10, 10, 8.5, 8.5, 8.5, 8.5, 8.5, 10, 10, 10,
10, 10, 9.5, 9.5, 9.5, 9.5, 9.5, 9, 9, 9, 9, 9, 8.5, 10,
10, 10, 10, 10, 8.5, 10.25, 10.25, 10.25, 10.25, 10.25, 4,
9, 9, 9, 9, 9, 5, 9.75, 9.75, 9.75, 9.75, 9.75, 4, 9, 9,
9, 9, 9, 8.5, 9, 9, 9, 9, 9, 8, 10, 10, 10, 10, 10, 9.5,
9.5, 9.5, 9.5, 9.5, 8.5, 9.75, 9.75, 9.75, 9.75, 9.75, 4,
8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 10, 10, 10, 10, 10, 9.5, 9.5,
9.5, 9.5, 9.5, 4, 10, 10, 10, 10, 10, 4, 9.5, 9.5, 9.5, 9.5,
9.5, 8, 10, 10, 10, 10, 10, 6, 12, 12, 12, 12, 12, 12, 6,
14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 12, 12, 12, 12, 12,
11, 6, 16, 16, 16, 16, 16, 15, 6, 12, 12, 12, 12, 12, 12,
6, 12, 12, 12, 12, 12, 11, 6, 16, 16, 16, 16, 16, 15, 10.25,
10.25, 10.25, 10.25, 10.25, 4, 10.5, 10.5, 9.5, 9.5, 9.5,
4, 10, 10, 10, 10, 10, 4, 9, 9, 9, 9, 9, 8, 9, 9, 9, 9, 9,
4, 8, 15.5, 15.5, 15.5, 15.5, 15.5, 14.5, 9.5, 9.5, 9.5,
9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 10, 10, 10, 10, 10, 9,
9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8.5,
9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 4.5, 10,
10, 10, 10, 10, 8.5, 9, 9, 9, 9, 9, 4, 10.5, 10.5, 10.5,
10.5, 10.5, 8.5, 8.5, 8.5, 8.5, 8.5, 8, 9, 9, 9, 9, 9, 8,
10.5, 10.5, 10.5, 12, 10.5, 10, 10.5, 10, 10.5, 10, 10, 10,
10, 10.5, 10, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 10, 10, 10, 10,
10, 10.5, 10.5, 10.5, 10.5, 10.5, 8, 9, 9, 9, 9, 9, 8, 10,
10, 10, 10, 10, 3.5, 10, 10, 10, 10, 10, 8, 10, 10, 10, 10,
10, 4, 10, 10, 10, 10, 10, 5, 9, 9, 9, 9, 9, 8.5, 9.5, 9.5,
9.5, 9.5, 9.5, 8, 10, 10, 10, 10, 10, 10.75, 10.75, 10.75,
11.75, 10.75, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 6, 14.5, 14.5,
14.5, 14.5, 14.5, 14.5, 6, 14.5, 14.5, 14.5, 14.5, 14.5,
14.5, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 12, 12, 12,
13, 13, 12, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 10.5,
10.5, 10.5, 10.5, 10.5, 8.5, 10, 10, 10, 10, 10, 4, 10.75,
9.75, 10, 9.75, 9.75, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 9.5, 9.5,
9.5, 9.5, 9.5, 8.5, 10.5, 10.5, 8.5, 10.5, 10.5, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 8.5, 10, 10, 10, 10, 10,
8.5, 11.5, 11.5, 11.5, 11.5, 11.5, 10, 10, 10, 10, 10, 8.5,
10, 10, 10, 10, 10, 4, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9,
8.5, 8.5, 8.5, 8.5, 8.5, 8.5, 10, 10, 10, 10, 10, 9, 9, 9,
8, 9, 9.5, 9.5, 9.5, 9.5, 9.5, 12, 13, 13, 13, 13, 13, 13,
10.5, 10.5, 10, 10.5, 10.5, 9, 9, 9, 9, 9, 4, 10, 10, 10,
10, 10, 8.5, 10, 10, 10, 10, 10, 8.5, 10, 10, 10, 10, 10,
3, 10, 10, 10, 10, 10, 4, 10.5, 10.5, 10.5, 11.5, 10.5, 10,
10, 10, 10, 10, 10, 10, 10.5, 10.5, 10, 8.5, 10.5, 10.5,
10.5, 10.5, 10.5, 4, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5,
6, 12, 12, 12, 12, 12, 12, 6, 14.5, 14.5, 14.5, 14.5, 14.5,
14.5, 6, 13, 13, 13, 13, 13, 13, 6, 14.5, 14.5, 14.5, 14.5,
14.5, 14.5, 9.75, 9.5, 9.75, 9.5, 9.75, 4, 11.25, 9.75, 9.75,
9.75, 9.75, 11.5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15,
15, 10, 10, 10, 10, 10, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 10.5,
10.5, 10.5, 10.5, 10.5, 8.5, 13.5, 14.5, 14.5, 14.5, 14.5,
14.5, 14.5, 10, 10, 10, 11, 10, 8.5, 8.5, 8.5, 8.5, 8.5,
8.5, 8.5, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 9, 9, 9, 9, 9, 4, 10,
10, 10, 10, 10, 10.5, 10.5, 10.5, 10, 10, 8.5, 9.5, 9.5,
9.5, 9.5, 9.5, 4, 10, 10, 10, 10, 10, 8.5, 9, 9, 9, 9, 9,
4, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 7, 13, 13, 13, 13, 13, 13,
10.5, 11, 10.5, 10.5, 10.5, 4, 7, 11, 11, 11, 11, 11, 9,
9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 9, 9, 9, 9, 9, 8.5, 11, 11,
11, 11, 11, 9, 7, 13, 13, 13, 13, 13, 13, 9.5, 9.5, 9.5,
9.5, 9.5, 8.5, 10, 10, 10, 10, 10, 9.5, 9.5, 9.5, 9.5, 9.5,
4, 9, 9, 9, 9, 9, 8.5, 9, 9, 9, 9, 9, 8.5, 9, 9, 9, 9, 9,
8.5, 9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 9.5, 9.5, 9.5, 9.5, 9.5,
8, 10, 10, 10, 10, 10, 8.5, 9, 9, 9, 9, 9, 8.5, 9.5, 9.5,
9.5, 9.5, 9.5, 4, 9, 9, 9, 9, 9, 4, 6, 13, 13, 13, 13, 13,
12, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 14.5, 14.5,
14.5, 14.5, 14.5, 14.5, 10, 10, 10, 10, 10, 9, 13, 14.5,
14.5, 14.5, 14.5, 14.5, 14.5, 10.5, 10.5, 10.5, 10.5, 10.5,
9.5, 9.5, 9.5, 9.5, 9.5, 8.5, 10, 10, 10, 10, 10, 3, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 4, 9.75, 9.75, 9.75,
9.75, 9.75, 3, 10, 10, 10, 10, 10, 8.5, 10, 10, 10, 10, 10,
8, 9, 9, 9, 9, 9, 4, 9.5, 9.5, 9.5, 9.5, 9.5, 8, 9, 9, 9,
9, 9, 4, 10, 10, 10, 10, 10, 4, 9, 9, 9, 9, 9, 8, 9.5, 9.5,
9.5, 9.5, 9.5, 4, 12, 12, 12, 12, 12, 12, 12, 9.5, 9.5, 9.5,
9.5, 9.5, 4, 10, 10, 10, 8, 10, 8, 10, 10, 10, 10, 10, 9,
9, 9, 9, 9, 8.5, 10.5, 10.5, 10.5, 10.5, 10.5, 4, 10.5, 10.5,
10.5, 10.5, 10.5, 10, 10, 10, 10, 10, 9.5, 9.5, 9.5, 9.5,
9.5, 4, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5,
8, 9, 9, 9, 9, 9, 8, 6, 12, 12, 12, 12, 12, 12, 6, 14.5,
14.5, 14.5, 14.5, 14.5, 14.5, 6, 12.5, 12.5, 12.5, 12.5,
12.5, 12, 6, 14.5, 14.5, 14.5, 14.5, 14.5, 14.5, 6, 14.5,
14.5, 14.5, 14.5, 14.5, 14.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9,
9, 9, 9, 9, 10, 10, 10, 10, 10, 3.5, 8.5, 8.5, 8.5, 8.5,
4, 9, 9, 9, 8.5, 9, 4, 9.5, 9.5, 9.5, 9.5, 9.5, 4, 9.5, 9.5,
8.5)), row.names = c(NA, -8658L), class = "data.frame")
Any help/guidance will be grateful
Many thanks

Maybe this tidyverse solution is close to what you want. But I am no sure where Hours variable comes. You can reshape your data to wide and then merge. Here the code, as days are present in both dataframes you can directly merge like this:
library(tidyverse)
#Code
#First reshape df2
merged <- df1 %>% select(StoreNumber,Online,Pressure) %>%
left_join(
df2 %>% pivot_wider(names_from = Day,values_from=Time),
by = c('StoreNumber'='BranchNumber'))
#Replace zeroes
merged <- merged %>% replace(is.na(.),0)
Output:
StoreNumber Online Pressure MON TUE WED
1 1 0.2 50 7.5 6 8.5
2 2 0.8 20 0.0 0 0.0
3 3 1.2 10 2.0 1 2.5
Some data used:
#Data 1
df1 <- structure(list(StoreNumber = 1:3, Online = c(0.2, 0.8, 1.2),
Pressure = c(50L, 20L, 10L), MON = c(0L, 0L, 0L), TUE = c(0L,
0L, 0L), WED = c(0L, 0L, 0L), SUN = c(0L, 0L, 0L)), class = "data.frame", row.names = c(NA,
-3L))
#Data 2
df2 <- structure(list(BranchNumber = c(1L, 1L, 1L, 3L, 3L, 3L), Day = c("MON",
"TUE", "WED", "MON", "TUE", "WED"), Time = c(7.5, 6, 8.5, 2,
1, 2.5)), class = "data.frame", row.names = c(NA, -6L))

Related

Why do quantile function in R gives unequal count of values in each group

I am trying to group a continuous value data into tertile. I am using the function quantile to do this. following is my code
dd$wbc_tert = with(dd,
cut(wbc,
vTert,
include.lowest = T,
labels = c("Low", "Medium", "High")))
Isn't it supposed to give equal count of values in each group? I am getting different count in the groups.
> dd %>% filter(wbc_tert == 'High') %>% select('wbc') %>% nrow()
[1] 143
> dd %>% filter(wbc_tert == 'Low') %>% select('wbc') %>% nrow()
[1] 148
> dd %>% filter(wbc_tert == 'Med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,
8.6, 8.5, 5.7, 8.6, 6, 5.1, 5.7, 8.2, 5.4, 6.9, 6.9, 8.3, 9.5,
5.4, 10.2, 8.8, 7.2, 4.8, 9.8, 4.6, 6.3, 5.8, 4.9, 12.7, 7.5,
10.6, 9.3, 5.5, 10.7, 6.2, 9.3, 8.3, 7.8, 8.05, 9.57, 6.62, 6.21,
5.34, 6.11, 10.37, 4.45, 5.55, 8.05, 8.31, 5.06, 6.05, 4.76,
9.09, 9.11, 9.04, 6.99, 6.33, 9.47, 6.48, 4.46, 9.44, 6.88, 7.09,
5.75, 10.89, 6.68, 3.64, 6.55, 8.69, 5.89, 9.05, 6.38, 11.62,
9.11, 9.22, 7.97, 9.64, 12.76, 8.39, 6.57, 8.1, 7.3, 10.1, 4.7,
6.4, 7.2, 5.5, 3.7, 5.1, 9.8, 7.6, 7.7, 6, 3.9, 6.8, 5.4, 5.4,
9.7, 9, 6, 7.3, 6.3, 5.8, 8.3, 7, 4.1, 11.2, 5, 7.6, 6.5, 4.8,
8, 10.1, 7.1, 7.4, 4.3, 4, 10.12, 4.3, 7.26, 8.84, 8.44, 8.44,
8.12, 6.5, 8.58, 8.55, 8.82, 4.53, 9.51, 4.93, 4.42, 4.69, 8.69,
5.77, 3.37, 6.58, 3.72, 3.09, 7.13, 8.11, 7.2, 12.18, 6.52, 7.91,
5.69, 8.24, 7.67, 5.69, 4.85, 7.03, 4.16, 3.57, 8.1, 4.61, 5.98,
5.13, 7.68, 5.47, 5.54, 4.59, 6, 11.62, 7.38, 7.06, 8.74, 8.02,
6.73, 7.19, 6.36, 4.86, 6.55, 8.4, 7.76, 4.73, 4.8, 5.73, 8.53,
4.6, 7.96, 9.48, 6.59, 5.75, 6.61, 6.49, 7.91, 6.92, 7.14, 6.24,
12.53, 7.03, 4.73, 8.05, 7.26, 4.07, 6.7, 5.7, 7.39, 5.2, 6.61,
6.8, 6.77, 5.65, 6.08, 7.24, 6.13, 7.92, 7.37, 7.99, 3.31, 9.72,
8.71, 8.35, 5.05, 8.15, 5.1, 5.4, 8.8, 4.9, 5, 7.43, 10.3, 6.3,
9.5, 6.9, 6.7, 5.4, 7.7, 8, 6.5, 5.6, 9.7)
Can someone please help what could be the reason
Here is an example that shows that quantiles are not necessarily symmetric in the number of values.
# Define some data
x <- 1:10
y <- rep(1:2, 10)
# Look at the quantiles
quantile(x)
#> 0% 25% 50% 75% 100%
#> 1.00 3.25 5.50 7.75 10.00
# Due to the added y we now have asymmetry in sizes
quantile(c(y,x))
#> 0% 25% 50% 75% 100%
#> 1.00 1.00 2.00 2.75 10.00
# Notice how the number of values below 50 % and 75 % changes.
## Without y we get roughly the same bin size
sum(x<quantile(x, .5))
#> [1] 5
sum(x<quantile(x, .75))
#> [1] 7
## But when we add y, there is a doubling of values despite we only increase
## the percentile with 25 %
sum(c(y,x)<quantile(c(y,x), .5))
#> [1] 11
sum(c(y,x)<quantile(c(y,x), .75))
#> [1] 22
Created on 2022-08-18 by the reprex package (v2.0.1)
There are 9 ways to compute the quantiles with function quantile, the default is type = 7.
Use findInterval instead of cut.
vTert <- quantile(dd$wbc, (0:3)/3, na.rm = TRUE)
dd$wbc_tert <- findInterval(dd$wbc, vTert, rightmost.closed = TRUE, all.inside = TRUE)
dd$wbc_tert <- factor(dd$wbc_tert, labels = c("Low", "Medium", "High"))
table(dd$wbc_tert, useNA = "always")
#>
#> Low Medium High <NA>
#> 143 143 144 1
Created on 2022-08-18 by the reprex package (v2.0.1)

Plotting Categorical Values Histogram in R

I have data from two instruments. One column is a categorical values- status of sensor (1 or 2 or 3), second column is reference value- numerical value. I want to plot a histogram of status of sensor (1 or 2 or 3) for different ranges of reference. For example: when the reference value is 1-5, I want to see a frequency distribution of sensor 1 status (1 or 2 or 3). Similarly for 6-10 of reference data and upto 95-100 of reference value, I want a frequency distributions of sensor status. Any help is appreciated. I am trying to figure out how good the sensor is with respect to the reference. Here is some sample data:
sample_data <-
structure(list(status = c(1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1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.6,
54.4, 54.2, 53.8, 53.8, 54.2, 54.4, 55, 54.4, 54.6, 56, 57.4,
54.6, 54.4, 54.6, 55.2, 55.4, 55.2, 54.2, 56, 52.2, 52.6, 53.2,
51, 47.6, 49.2, 49.4, 48.2, 49.2, 49.2, 52.4, 52.4, 53.8, 52.2,
49.2, 53.6, 55.2, 52.8, 53, 48.8, 51.2, 49.4, 49, 47.8, 47.4,
46.8, 50.4, 47.6, 47.2, 48.8, 48.8, 47.6, 47.8, 48.4, 48.2, 46.8,
45, 44.4, 43.4, 44.2, 45.8, 46.8, 47.4, 47.6, 45.4, 44.6, 44.6,
43.6, 44.4, 46.6, 39.8, 43.4, 42.2, 42.4, 40.4, 42.8, 44, 39.8,
41, 39.8, 38.4, 39.6, 40.2, 41, 40, 39.6, 38.6, 40.6, 40, 39.8,
38.6, 39, 38, 37.6, 37.6, 39.6, 37.6, 37.8, 38.8, 39.2, 38.2,
37.8, 35.8, 35.2, 36.2, 36.2, 37.4, 35.8, 35.6, 33.8, 35.2, 35.8,
35.2, 35.2, 35.6, 36.2, 36, 36.2, 36.2, 36, 34.4, 34.2, 34, 34,
34, 35, 34.2, 33.8, 31.2, 33.2, 32.4, 31.8, 32.4, 32.6, 31.8,
31.4, 31.2, 31.8, 30.8, 32.2, 30.8, 31.2, 29.4, 30.6, 30.2, 29.6,
29.8, 30.2, 30.2, 29.4, 30.2, 29.2, 29.8, 30, 30.4, 30.6, 29.8,
29.4, 29.4, 28.8, 28.8, 27.4, 29.4, 29, 28, 28.2, 29.4, 29.2,
28.6, 29.2, 26.8, 25.8, 25.4, 26.4, 25.8, 26, 27, 26, 27.6, 27.2,
27.6, 27.2, 25.8, 25.4, 25.6, 25.4, 26.4, 25.8, 25.2, 25.2, 24.8,
23.4, 24.4, 24, 24.6, 25, 25.2, 26.8, 23.2, 24, 24, 24.2, 23.8,
23.6, 24.6, 23.6, 23.6, 22.6, 23.8, 23.4, 21.4, 23, 21.8, 21.8,
22.6, 22.6, 22.6, 23.4, 23, 22, 24, 21.2, 21.4, 22.2, 22, 21.4,
22, 21.8, 21.6, 21, 21.6, 21.2, 21.6, 21.6, 21.4, 21.2, 21, 21.2,
21.2, 20.8, 21.2, 21.4, 20.6, 20, 20, 20.8, 21, 19.6, 19.2, 19.6,
20.2, 20.2, 20.4, 19.8, 19, 19, 18.8, 19.2, 19.4, 18.6, 18.2,
17.2, 17.8, 18.2, 17.8, 18, 17.4, 17, 16.8, 17.4, 17.8, 18.2,
17.6, 17.8, 17, 16.8, 17, 17.2, 17, 16.4, 17, 17.8, 15.6, 15.8,
17, 15.6, 17.2, 16.6, 16.2, 16.8, 17, 17, 16.8, 15.6, 16.4, 16.6,
15.4, 15.6, 15.4, 14.6, 14.8, 15.4, 14.6, 14.6, 15, 15.8, 15,
15.2, 15.2, 15.2, 14.6, 14.8, 15, 15.2, 14.4, 15, 15, 15, 15.2,
14, 13.8, 14.6, 14.8, 14, 14.2, 14.4, 14.4, 14.2, 14.2, 14.6,
14.4, 13.8, 13.6, 13, 13.6, 13.4, 13.6, 13, 14, 13.6, 12.4, 12.6,
13.6, 13.8, 12.8, 12.8, 12.8, 13.6, 13.2, 13, 13.2, 13.2, 12,
12.2, 11.6, 12.2, 11.8, 12, 12, 11.6, 12.2, 12.8, 14, 11.8, 11.6,
12.8, 11, 11, 11, 11.6, 12, 11.8, 11, 11.4, 11.8, 12, 11.8, 11.6,
11.6, 11.4, 11.2, 11.6, 11, 10.4, 11.2, 11, 10.4, 10, 9.8, 10.4,
11, 11.2, 11, 11.4, 10.8, 10.8, 11, 10.8, 10.4, 10.8, 9.8, 10.2,
10.4, 11.2, 10.6, 10, 9.6, 10.2, 9.6, 9.6, 9.8, 10.2, 10.4, 9.2,
9.8, 9.6, 9.6, 9.2, 9.2, 9.8, 8.6, 9.2, 9.4, 9.2, 9, 9, 9, 9,
9.4, 9.4, 9.4, 9.2, 9.2, 9.6, 8.4, 8.8, 8.6, 8.6, 8.8, 8.6, 8.8,
8.4, 8.8, 8.8,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3.4, 3.6, 3.6, 3.6, 3.6, 3.2, 3.4,
3.4, 3.4, 3.2, 3.6, 3.4, 3.2, 3.4, 3.4, 3.4, 3.2, 3.2, 3.2, 3.4,
3.2, 3.2, 3, 3.2, 3.4, 3.4, 3.2, 3.2, 3.2, 3.2, 3.2, 3, 3, 3.2,
3.2, 2.8, 3.2, 3.2, 3, 3, 2.8, 2.8, 3, 3, 3, 3, 3, 2.8, 3, 3,
2.8, 2.8, 2.8, 2.8, 2.8, 3, 2.8, 3, 2.6, 3.2, 2.8, 2.6, 2.8,
2.8, 2.8, 2.8, 2.6, 2.8, 2.8, 2.4, 2.6, 2.6, 2.6, 2.8, 2.6, 2.2,
2.4, 2.6, 2.4, 2.4, 2.6, 2.4, 2.4, 2.4, 2.4, 2.4, 2.6, 2.4, 2.4,
2.4, 2.4, 2.6, 2.4, 2.6, 2.4, 2.4, 2.4, 2.4, 2.2, 2.4, 2.4, 2.4,
2.4, 2.4, 2.4, 2.4, 2.4, 2.6, 2.2, 2.4, 2.2, 2.2, 2.2, 2.2, 2.4,
2.2, 2.2, 2.2, 2.2, 2.2, 2, 2.2, 2.2, 2.2, 2, 2.4, 2.4, 2.2,
2.2, 2.2, 2.4, 2.2, 2.2, 2.2, 2.2, 2, 2, 2.2, 2.2, 2.2, 2.2,
2.2)), row.names = 18388:19288, class = "data.frame")
First, create the bar chart:
barplot(table(sample_data$sensor4_calcstatus))
Now a table of frequencies:
tbl <- table(cut(sample_data$ref_conc, breaks=seq(0, 100, by=5)), sample_data$sensor4_calcstatus)
tbl
#
# 1 2 3
# (0,5] 281 0 0
# (5,10] 150 17 0
# (10,15] 8 92 0
# (15,20] 0 58 0
# (20,25] 0 36 20
# (25,30] 0 0 43
# (30,35] 2 0 30
# (35,40] 0 0 39
# (40,45] 1 0 18
# (45,50] 0 0 28
# (50,55] 1 1 43
# (55,60] 5 1 22
# (60,65] 0 0 0
# (65,70] 0 0 0
# (70,75] 0 0 0
# (75,80] 0 0 0
# (80,85] 0 0 0
# (85,90] 2 0 0
# (90,95] 0 0 0
# (95,100] 0 0 0
par(mfrow=c(3, 1))
for (i in 1:3) barplot(tbl[, i], space=0, main=paste("Group", i))
Notice that you have two ref_conc values greater than 100: 131.4 and 600.0.

Convert split data into dataframe in r

Please, can anyone explain to me how to put this split data (Fibre) into a dataframe in r. So that I can have two columns: Group and Observation.
Fibre
[[1]]
12.5, 5, 4.5, 6, 10.2, 9.6, 15.5, 12.2, 13, 17.5, 13, 14
[[2]]
11.5, 7, 4.5, 8, 13.2, 19.6, 13.5, 15.2, 13.5, 20,17
[[3]]
10.5, 6, 8.5, 8, 11.2, 14.6, 19.5, 15.9, 14.5, 21,12,15,17,18
[[4]]
9.5, 16, 9.5, 8.5, 13.5, 12.6, 11.5, 16.7, 14, 19.5
I used:
NewData <- as.data.frame(Fibre)

Match values in 2 dataframes, NA error

It is necessary to use the data presented here, for the sake of the problem.
I would like to match values from 2 dataframes. however some values are not "matched", and I cannot see why!
I will try to concisely explain my problem.
1) dataframe with theoretical values
#1.1) I have the following vector
Pos<-c(8.75, 9.3, 8.8, 9.6, 9.4, 11, NA, 13, 10.5, 12.31, 11.18, 13.06, 10.71, 12.5, 15.03, 15.26, 13.22, 15.25, 13.03, 15.28, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 9.2, NA, 9.6, NA, 10.93, NA, 11.19, NA, 10.86, 10.3, 9.4, 9.1, 9.1, 9.4, 9.7, 8.9, 9.86, 9.2, 9.2, NA, NA, NA, NA, NA, NA, NA, 10.9, NA, NA, 10.92, 10.69, 9.91, 10.01, NA, 10.66, NA, 10.38, NA, 11.4, 7.4, 7.3, 9, 9.6, NA, NA, 8, 9.3, NA, NA, 9.33, 9.9, 9.9, 11.2, 6.9, 7.3, 7, 8.7, 7.4, 8.6, 7.6, 9.24, 8.59, 8.6, 8.46, NA, 8.21, 9, 6.6, 8.5, 8.5, 10.2, 9.6, 9.55, NA, NA, 7.8, 9.6, NA, NA, 10.5, 11.4, 11.81, 9.7, NA, NA, 7.8, 8.9, NA, NA, NA, 12.29, NA, 11, NA, NA, NA, 11.11, NA, NA, 8.1, 8.1, 8.3, 10.2, NA, NA, 8.2, 11, NA, NA, NA, 8.7, NA, 8.9, NA, 11.3, NA, 12.2, NA, 12.5, 10.76, 14, 11.19, 15.4, NA, NA, 8.9, 10.9, NA, NA, 9.04, 9.74, 9.41, 9.43, 10.96, 10.93, 13.06, 10.31, 11.69, 8.66, 9.11, 8.87, 9.61, 8.99, 9.48, 9.58, 9.26, 9.29, 8.4, 8.5, 8.2, 8.3, 12.1, 8.7, 13.9, 8.8, 7.79, 10.45, 9.56, 9.66, 10.55, 11.76, 9.31, 12.36, 9.33, 10.71, 13.03, 12.36, 11.88, 11.94, 12.83, 13.51, 12.54, 14.29, 11.43, 11.19, 11.4, 9.9, 13.21, 11.1, 12.75, 12.03, 11.55, 10.3, 10.26, 10.31, 8.9, 8.8, 9.12, 10.35, 9.2, 9.3, 8.9, 7.7, 8.51, 8.2, 8.2, 8.54, 8.6, NA, 8, 8.5, 8.84, 8.22, 9.78, 7.8, 7.5, 7.7, 7.7, 9.68, 8.1, 8.21, 7.91, 8.11, 9.21, 9.01, 9.89, 8.2, 8.56, 10.19, 9.1, 9, 10.46, 8.7, 10.16, 8.9, 8.7, 9.6, 7.76, 7.76, 8.51, 10.26, 7.2, 11.71, 11.43, 11.24, 7.3, 9.13, 8.74, 8.81, 8.61, 8.63, 9.43, 8.93, 9.13, 9.33, 7.47, 7.21, 7.71, 8.28, 7.48, NA, 7.44, 8.81, 7.42, 7.25, 6.1, 8.74, 8.51, 6.7, 8.76, 6.2, 7.94, 8.51, 6.8, 13.03, 13.09, 12.9, 13.34, 13.07, 12.02, 12.94, 12, 12.61, 9.96, 8.79, 8.91, 9.2, 8.73, 8.61, 7.89, 8.17, 11.71, 8.99, 11.35, 10.36, 9.67, 8.86, 10.2, 11.17, 12.75, 12.49, 7.6, 9.62, 8.1, 9.93, 12.4, NA, NA, 8.3, 9.95, 7.4, 9.21, 9.34, 10.09, 7.9, 9.64, 7.6, 10.19, 12.65, 10.3, 10.3, 11, 11.66, 16, 11, 12.7, 11, 11.4, 11.49, 12.79, 16.65, NA, 11.75, 12.94, 13.3, 11.3, 9.86, 10.9, 12.08, 11, 9.99, 12.81, 12.36, NA, NA, 7.66, 6.5, 6.3, 6.4, 7, 7.1, 8.48, 6.8, 7.75, 12.97, 12.88, 12.49, 12.59, 12.83, 11.59, 8.9, 13.93, 13.35, 13.63, 14.64, 13.53, 13.64, 13.68, 13.38, 13.97, 12.98, 12.35, 12.89, 9.54, 9.3, 10.16, 10.71, 11.95, 12.03, 9.26, 10.15, 10.26, 6.7, 6.6, 7, 6.3, 7.76, 8.21, 7.7, 7.6, 13.49, 12.2, NA, 12.76, 12.78, 12.5, 13.57, 12.3, 12.84, 15.85, 11.26, 9.4, 11.16, 10.69, 11.43, 10.17, 10.51, 13.27, 11.39, 10.9, 10.54, NA, 10, 11.64, 10.6, 10.1, NA, 11.29, 7.61, 7.3, 7, 9.3, 13.33, 8.01, 8.16, 7.1, 9.91, 8.08, 11.33, 7.4, 10.39, 9, 11.5, 10.68, 8.53, 9.3, 11.19, 15.62, 11.02, 10.3, 9.7, 11.3, 10.5, 10.84, 13.86, 7.9, 7.6, 9.46, 7.9, 7.8, 9.33, 9.79, 7.7, 8.5, 8.3, 8.2, 8.1, 8.1, 10.2, 7.9, 8.3, 9.56, 9.34, 8.6, 9.6, 9.27, 8.1, 11.8, 9.74, 8.9, 8.3, 9.7, 7.6, 7.2, 9.21, 7.8, 7, 7.1, 8.1, 8.85, 9.4, 9.91, 9.44, 10.06, 8.6, 10.2, 10.55, NA, NA, 12.79, NA, NA, 9.75, 13.11, 14.54, NA, 14.36, 10.18, 14, 12.1, 15.26, NA, 10.99, 9.59, 10.9, 10.81, 9.3, 8.2, 8.75, 9.6, 8.9, 11.11, 11, 12, 10.9, 10.96, 8.99, 12.1, 11.76, 12.83, 11.1, 9.12, 8.54, 7.5, 9.01, 10.16, 11.71, 9.43, NA, 8.76, 13.07, 8.73, 8.86, 12.4, 7.9, 16, 11.75, 12.81, 7.1, 11.59, 13.38, 11.95, 7.76, 12.5, 11.43, 11.64, 13.33, 9, 9.7, 7.8, 10.2, 11.8, 7, 10.2, 14.54)
#1.2) Height, is the column to be filled
Pos.table<-data.frame(Pos=Pos,Height=NA)
2) dataframe with theoretical values
#2.1) the whole range of values that "Pos" can get
Source<- seq(0,17,0.01) #possible values that weight can get [0,17]
#2.2)height.0, the adjusted value of Height according to the Loop below
Table.match<- data.frame(Source=Source,Height.0=NA)
# loop for Source (real values)
for (i in 1:dim(Table.match)[1])
{
Table.match[i,"Height.0"] <- -57.5+5*(Table.match[i,"Source"])
}
2) Problem
The following Loop looks for respective matches.
for (i in 1:dim(Pos.table)[1])
{
H.i<-match(Pos.table[i,"Pos"], Table.match[,"Source"], nomatch = 0)
Pos.table[i,"Height"] <-ifelse(H.i,Table.match[H.i,"Height.0"],0)
# Rev.table[i,"Rev.Prot"]<-Rev.table[i,"Rev.Prot"]*Rev.table[i,"Yield"]
}
However, some values ares disregarded. for example, position 15 and 20 (among many others):
# both return NAs
match(15.03, Table.match[,"Source"])
match(15.28, Table.match[,"Source"])
Could you please advice me on how to overcome this problem?
I agree with Nicole that exact comparison between floating numbers should be avoided.
To solve that, I've just added a round() with 2 significant digits in the code:
for (i in 1:dim(Pos.table)[1])
{
H.i<-match(round(Pos.table[i,"Pos"],2), round(Table.match[,"Source"],2), nomatch = 0)
Pos.table[i,"Height"] <-ifelse(H.i,Table.match[H.i,"Height.0"],0)
# Rev.table[i,"Rev.Prot"]<-Rev.table[i,"Rev.Prot"]*Rev.table[i,"Yield"]
}
I guess this solves the problem.

leaflet R popup suddenly changed output?

I´m working on a leaflet map in r that visualizes data from a survey onto the map. You can get a look of how it looked over here: https://maglin.shinyapps.io/UM33/ . As you can see if you click on an area you get the name of thea area and the median score on the various questions in Swedish, for example this...
>! Område: Eds Glesbygd
Fler kultur­ och fritidsaktiviteter för äldre : 7.9
Fler kultur­ och fritidsaktiviteter för barn och ungdomar : 8.7
Förbättra äldreomsorgen i kommunen : 8.9
Fler ungdomsgårdar och fältassistenter : 9
Minska barngrupperna i förskolan : 9.9
But after some changes in the program I get this instead...
>!Område: 1:43
Bevara existerande större grönområden : c(5, 9.4, 9.6, 10.4, 8.7, 10.8, 8, 9.8, 7.3, 9.7, 12, 9, 10.1, 9.3, 9.4, 9.7, 8.5, 9.7, 10, 1, 8.4, 9.1, 10.2, 6.2, 8, 10.1, 11.5, 10.8, 9.7, 8.7, 10.3, 9.6, 10.6, 10.9, 10.9, 10, 10.7, 8, 9.4, 10.9, 6, 9.6, 14)
Anlägga parker i existerande stadsdelar : c(8, 8.1, 9.1, 9.4, 7.1, 9.6, 7.8, 9.4, 7.2, 7.4, 9, 8.2, 6.7, 8.4, 9, 9, 8.6, 8, 8, 3, 7.8, 7.8, 8, 5.2, 6.7, 8.1, 8.2, 8.9, 7.5, 7.3, 8.8, 7.7, 7.8, 7.5, 7.8, 10, 8.2, 5.7, 7.8, 7, 8, 8.2, 7)
Bygga bostäder nära grönområden : c(11, 7.7, 8.3, 6.9, 7.3, 6.6, 5.2, 7.6, 8.5, 7.5, 7.5, 7.4, 7.5, 8.7, 7.3, 11.3, 8.2, 8, 9, 13, 6.8, 6.7, 8, 9.2, 11, 7.2, 5.8, 7.5, 6.3, 8.3, 7.6, 8.1, 8.4, 9.1, 7.5, 13, 7.3, 11, 8.6, 5.9, 9, 7.3, 7)
Rusta upp befintliga parker : c(6, 9.4, 9.6, 10.7, 8.1, 9.9, 8.8, 8.8, 6.9, 9.5, 9, 9.1, 9.9, 8.3, 8.9, 11, 9.9, 9.7, 6, 12, 8.8, 9.4, 9.3, 9.5, 10, 9, 8.9, 9.6, 9.6, 8.5, 9.2, 8.5, 9.2, 9.3, 9, 14, 9.9, 9.7, 9.3, 10.3, 6, 9.7, 7)
Skapa bättre tillgänglighet till större grönområden : c(7, 8.1, 8.7, 9.2, 8.1, 9.1, 7.4, 8.5, 8.5, 8, 9.5, 7.2, 8.6, 7.6, 7.9, 8, 7, 8.7, 9, 13, 7.2, 7.3, 9, 6.2, 8.3, 8.5, 8.4, 9.1, 8.2, 7, 8.9, 8.2, 7.8, 7.8, 8, 13, 8.7, 9, 8.2, 8.4, 8, 8.3, 7)
The popup seems to show all the medians for every area instead of just the one you clicked on. This is an example of how the data looks when I save it inside an reactive variable...
Area X1a X1b X1c X1d X1e favorit
(fctr) (dbl) (dbl) (dbl) (dbl) (dbl) (chr)
1 Antuna /Älvsunda 5.0 8.0 11.0 6.0 7.0 X1c
2 Brunnby/Vik 9.4 8.1 7.7 9.4 8.1 X1a
3 Carlslund/Brunnby Park 9.6 9.1 8.3 9.6 8.7 X1a
4 Dragonvägen 10.4 9.4 6.9 10.7 9.2 X1d
5 Eds Glesbygd 8.7 7.1 7.3 8.1 8.1 X1a
And this is how the data looks when I print it out just before it gets feed into the addPolygons(popup) function...
>!"<Strong>Område: </strong> 1:43 <br><Strong> Bevara existerande större grönområden :</strong> c(5, 9.4, 9.6, 10.4, 8.7, 10.8, 8, 9.8, 7.3, 9.7, 12, 9, 10.1, 9.3, 9.4, 9.7, 8.5, 9.7, 10, 1, 8.4, 9.1, 10.2, 6.2, 8, 10.1, 11.5, 10.8, 9.7, 8.7, 10.3, 9.6, 10.6, 10.9, 10.9, 10, 10.7, 8, 9.4, 10.9, 6, 9.6, 14) <br><strong> Anlägga parker i existerande stadsdelar :</strong> c(8, 8.1, 9.1, 9.4, 7.1, 9.6, 7.8, 9.4, 7.2, 7.4, 9, 8.2, 6.7, 8.4, 9, 9, 8.6, 8, 8, 3, 7.8, 7.8, 8, 5.2, 6.7, 8.1, 8.2, 8.9, 7.5, 7.3, 8.8, 7.7, 7.8, 7.5, 7.8, 10, 8.2, 5.7, 7.8, 7, 8, 8.2, 7) <br><strong> Bygga bostäder nära grönområden :</strong> c(11, 7.7, 8.3, 6.9, 7.3, 6.6, 5.2, 7.6, 8.5, 7.5, 7.5, 7.4, 7.5, 8.7, 7.3, 11.3, 8.2, 8, 9, 13, 6.8, 6.7, 8, 9.2, 11, 7.2, 5.8, 7.5, 6.3, 8.3, 7.6, 8.1, 8.4, 9.1, 7.5, 13, 7.3, 11, 8.6, 5.9, 9, 7.3, 7) <br><strong> Rusta upp befintliga parker :</strong> c(6, 9.4, 9.6, 10.7, 8.1, 9.9, 8.8, 8.8, 6.9, 9.5, 9, 9.1, 9.9, 8.3, 8.9, 11, 9.9, 9.7, 6, 12, 8.8, 9.4, 9.3, 9.5, 10, 9, 8.9, 9.6, 9.6, 8.5, 9.2, 8.5, 9.2, 9.3, 9, 14, 9.9, 9.7, 9.3, 10.3, 6, 9.7, 7) <br><strong> Skapa bättre tillgänglighet till större grönområden :</strong> c(7, 8.1, 8.7, 9.2, 8.1, 9.1, 7.4, 8.5, 8.5, 8, 9.5, 7.2, 8.6, 7.6, 7.9, 8, 7, 8.7, 9, 13, 7.2, 7.3, 9, 6.2, 8.3, 8.5, 8.4, 9.1, 8.2, 7, 8.9, 8.2, 7.8, 7.8, 8, 13, 8.7, 9, 8.2, 8.4, 8, 8.3, 7)"
Has the dataset been turned into a factor or something? I can supply more code if needed, but I didn´t want to spam the OP with to much, The spoiler functions is messing with me.
EDIT1: So I have setup a project based on an old version that works and started looking for differences between the two projects. One difference so far is that there is a slight difference in the variable that is used to build the popup output...
In my current(faulty) project, this is what you get when you print out the variable
>print(var)
Source: local data frame [43 x 7]
Area X1a X1b X1c X1d X1e favorit
(fctr) (dbl) (dbl) (dbl) (dbl) (dbl) (chr)
1 Antuna /Älvsunda 5 8 11 6 7 X1c
2 Brunnby/Vik 9 8 8 9 8 X1a
3 Carlslund/Brunnby Park 10 9 8 10 9 X1a
4 Dragonvägen 10 9 7 11 9 X1d
5 Eds Glesbygd 9 7 7 8 8 X1a
.. ... ... ... ... ... ... ...
In the older but working version the variable looks like this...
>print(var)
Area X1a X1b X1c X1d X1e favorit
1 Antuna /Älvsunda 5 8 11 6 7 X1c
2 Brunnby/Vik 9 8 8 9 8 X1a
3 Carlslund/Brunnby Park 10 9 8 10 9 X1a
4 Dragonvägen 10 9 7 11 9 X1d
5 Eds Glesbygd 9 7 7 8 8 X1a
Have I accidentally changed a file/object type here that makes scrambles things up?
Edit2: I seem to have solved the problem by saving the dataset that (var) reads from in .csv format and then reading it in again, Any got a clue why that works?
Edit3: Seems the change happens when I call the plyr rename function, that seems to garble the output.

Resources