问:
Why does the output of of a linear mixed model using lme4 show one level of a factor but not another?
I am using the lme4 package and running a linear mixed model but I am confused but the output and expect that I am encountering an error even though I do not get an error message.
The basic issue is when I fit a model like lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
and then look at the results using something like summary I see all the model fixed (and random) effects  as I would expect however the habitat effect is always displayed as habitatForest.  Like this:

```<code>Fixed effects:
                                                            Estimate Std. Error         df t value Pr(>|t|)
(Intercept)                                                996.63179    8.16633   31.22730 122.042  < 2e-16 ***
stimuliBHCO                                                 -3.57541    1.28877 8750.89273  -2.774 0.005544 **
stimuliCOHA                                                -10.17037    1.29546 8754.17156  -7.851 4.62e-15 ***
timeperiod                                                   0.19900    0.05516 8744.95307   3.608 0.000310 ***
scale(poly(distance.code, 3, raw = FALSE))1                 -3.87613    0.71431 8745.70773  -5.426 5.90e-08 ***
scale(poly(distance.code, 3, raw = FALSE))2                  2.65854    0.71463 8745.19353   3.720 0.000200 ***
scale(poly(distance.code, 3, raw = FALSE))3                  4.66340    0.72262 8745.67948   6.453 1.15e-10 ***
habitatForest                                              -68.82430   11.83009   29.95226  -5.818 2.34e-06 ***
wind.speed                                                  -0.35853    0.07631 8403.15191  -4.698 2.66e-06 ***
scale(poly(distance.code, 3, raw = FALSE))1:habitatForest    2.89860    1.03891 8745.46534   2.790 0.005282 **
scale(poly(distance.code, 3, raw = FALSE))2:habitatForest   -3.49758    1.03829 8745.11371  -3.369 0.000759 ***
scale(poly(distance.code, 3, raw = FALSE))3:habitatForest   -4.67300    1.03913 8745.30579  -4.497 6.98e-06 ***
---
</code>```

This is happening even though there are two levels of habitat (Forest and Grassland)
at first, I thought this might be because my model had an interaction term but it happens when I try a simpler model like lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)

Why would it say "habitatForest" and not just "habitat" or if it were going to include a factor by name why not say "habitatForest" and "habitatGrassland"?

A quick look at the expected output from this function here: https://rpubs.com/palday/mixed-interactions or here: https://ase.tufts.edu/bugs/guide/assets/mixed_model_guide.html (among others)
shows that the out put that I am getting is not what is expected or normal.
Other output I have seen simply have factors with two levels, like mine, as a single line (eg habitat).

Here is a portion of the data I am using. I used dput and subseting to produce this. I couldn't figure out how to make the data set smaller and still reproduce the error so I apologize if this is too large. The data set that it comes from is MUCH bigger! (also please let me know if I have used dput incorrectly.(Still new to R and stackoverflow)

```structure(list(location.code = structure(c(1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 4L, 4L, 4L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L,
1L, 1L, 1L, 2L, 2L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L,
4L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 3L, 3L, 3L,
4L, 4L, 4L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 4L, 4L, 4L,
3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 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L,
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L,
2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("Grassland",
"Forest"), class = "factor"), distance.code = c(0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L,
30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L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9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55,
55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65,
65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9), timeperiod = c(6L, 6L, 6L,
6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L,
17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L,
20L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L), Values = c(910.721895276374, 922.652711611841,
926.219785713456, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 992.059286431433,
1042.05240231832, 1018.99804250179, 911.976009884021, 918.215389274037,
931.037495260958, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 994.583211567691,
1006.58290843226, 1005.52479816571, 908.665064025178, 917.940176257067,
922.746174825048, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 982.154409713674,
1008.54477137219, 996.577798511801, 912.914857937818, 916.937508116615,
920.933077377339, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 983.866984633392,
1002.04551764872, 986.791628665069, 907.695668282537, 917.845214744473,
932.330755620455, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 1000.3672969178,
1021.78461788922, 1011.40975353271, 915.037273600535, 914.099859036178,
924.116937361394, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 974.273124973661,
1145.99211507205, 1013.58184367388, 913.467056616881, 920.213007520924,
919.794369158301, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 1015.24811721269,
1070.61183211249, 1016.57332551186, 910.196695694198, 923.403802532832,
905.400995326023, 1036.98011238981, 963.147077473505, 916.899569521736,
931.240844862156, 919.11781354823, 995.408916523572, 960.825305234446,
1026.22960551445, 1000.13773127026, 962.347584090332, 904.090295814044,
908.836747102913, 928.867625382891, 918.100799763641, 906.282906701285,
913.146312873635, 977.094140033575, 972.599778534534, 964.658406857446,
921.91272768213, 910.507770576621, 942.269786765654, 1014.34022271036,
1128.29327664605, 1043.1365958913, 919.185972424773, 925.486310755197,
908.769520270226, 1030.20866627018, 956.104935565803, 922.01947330213,
934.451182538208, 928.626906337293, 986.326936258622, 1003.40797963907,
1021.91264348048, 995.68658929192, 993.102343807935, 901.633626404701,
908.255562868123, 922.840049924103, 917.012733437446, 907.541530752433,
915.050696506642, 983.542956895186, 972.236377246083, 965.082329354352,
918.337944633569, 910.137012141557, 952.89462134025, 977.420371016686,
1154.17994731565, 1022.82998099991, 927.061613377597, 926.745527716988,
908.284054932259, 966.157586219165, 974.986841619676, 916.559494755925,
935.817296050643, 918.835719171662, 1023.62078549133, 1009.23121097376,
1005.81651905991, 981.715747809821, 953.127134375762, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 974.889830301362, 970.58615968713, 963.029605541189,
915.889893279581, 908.147726780027, 942.742415528349, 979.939535179807,
1153.51966568673, 1020.93502990084, 916.246150801212, 936.016759720656,
914.4488779132, 962.397352323664, 986.957848140285, 985.364195731404,
932.548910038465, 917.363220594089, 1085.89850605988, 1031.66330597084,
1005.64983154588, 991.988118229379, 975.384741587994, 902.60240793926,
907.989086075871, 923.287310593779, 912.878571722023, 904.107623756648,
905.563259817979, 991.530368160932, 975.190212414434, 965.951810135591,
915.334621878897, 910.857441830446, 936.093336975328, 972.074491630181,
1106.77459226532, 993.45400883741, 951.911391767329, 927.688604859773,
915.194279622847, 971.414103170297, 956.138106650696, 965.458656222347,
944.097918792458, 947.157460200658, 1029.14870726558, 992.151638322899,
954.129642526236, 981.48182339388, 968.10870393618, 906.941701681267,
917.956716926981, 923.05649603805, 934.459432014683, 922.801034508827,
920.724850575215, 981.478432929603, 1012.67364507927, 966.471299899978,
912.640460101352, 906.34455384334, 923.738349342148, 970.987788560016,
1210.42940542072, 975.753397539076, 911.747488522664, 928.34872697947,
910.852487444859, 982.304620375747, 1028.52794775628, 913.408967803895,
934.334726415048, 916.354017093653, 1036.08727658415, 974.408618327141,
1004.71633485176, 995.142763465394, 987.00017276687, 906.86826042139,
915.355833226192, 930.395950341189, 911.742114273539, 905.725754800821,
912.194776217353, 979.488696998854, 998.766511802223, 968.436523426865,
916.299279627464, 907.645161223541, 925.30056793674, 978.067851389738,
1142.91274685359, 1001.53234105611, 916.842758017232, 924.907983103717,
922.470305986631, 992.855613565408, 955.757560902304, 929.20232030375,
943.535934437766, 923.58180450271, 1035.68330820385, 962.09501965608,
1035.71434011945, 999.021624049638, 1037.74929152155, 904.65540329816,
907.898446182233, 915.586965865012, 912.540978342886, 904.648950841522,
910.146698786639, 970.655222414677, 969.045225438776, 961.588678057607,
922.252864714149, 904.866433981365, 921.496292021655, 971.871605044557,
1075.02261709497, 1018.63215987506, 925.837889075039, 937.313874872585,
919.393974179406, 984.865480173384, 998.38173566307, 923.591922218561,
935.764591123357, 914.144404904734, 1064.07484543951, 1009.55385037395,
1003.07982307794, 1019.96770677478, 1023.43370663799, 1075.23648079772,
918.40638740207, 930.381596850856, 911.431923384541, 908.158538518039,
913.917742396318, 972.975539521988, 969.261073622988, 966.900828461146,
912.922987528198, 906.204515258546, 917.349668426986, 965.167090686302,
1033.80724280751, 1019.96323854891, 923.466492256566, 923.247012056591,
911.896005256495, 983.55323734271, 987.195939413696, 948.013535459932,
946.283282150572, 946.996017019961, 1018.55920835599, 983.790383328001,
1044.1241515621, 1025.44806232873, 1013.07125415424, 936.438305947314,
914.845558304809, 919.627558974215, 912.08306092659, 905.506361055768,
925.863591354922, 980.84672626416, 1034.50509678374, 999.432501149952,
914.013428128551, 903.385280147577, 914.982720974316, 987.521728519027,
1026.27371444455, 1003.6659923071, 936.860089156893, 922.376363123921,
909.301601087255, 949.125313633903, 983.891808931205, 928.514242776379,
931.528375870523, 934.663002673557, 983.163630767407, 958.520107194186,
1028.60002280789, 1027.26325499148, 1026.49504978946, 904.375575893285,
912.523756638651, 919.179127414697, 913.641605762865, 905.043751380124,
918.017612913947, 966.955539088111, 1083.03489991906, 982.779995986195,
913.039005945342, 901.569366267589, 924.344189118069, 986.456388413752,
1053.70140237407, 1012.4655295529, 918.216939699045, 924.376017342816,
912.32335834515, 962.020663167786, 968.751653626515, 923.781426521514,
934.702280304594, 945.072040784087, 972.171048113648, 980.160384144599,
1029.12422797868, 1045.60159108586, 1069.71097019503, 904.989955563463,
911.137606736246, 913.282276988181, 911.62618760385, 904.022814213797,
917.471586361699, 969.239603596626, 1092.64417075988, 995.598256664543,
911.352468377778, 903.930535551161, 934.598647851096, 968.529282541217,
1014.22774561852, 992.123001836286, 955.008951781314, 928.638327604534,
930.057703919378, 979.117036821698, 961.435436233545, 927.430280788518,
933.188144311621, 938.849731346915, 975.793676023678, 984.576641002029,
953.148108722352, 1025.14511979605, 987.536969976085, 904.469118373204,
919.724696002539, 921.494112907094, 933.99081130992, 910.883621211755,
919.830805764804, 973.217375644616, 1097.82345512272, 955.321702833728,
914.950887550846, 907.869650845588, 930.21996042144, 988.365255219924,
1072.82537699421, 941.505101156388, 912.978755227237, 924.00211814663,
926.073413421038, 975.963524978988, 966.347030574186, 927.813889117707,
938.87057229942, 937.20592642584, 1049.77079831674, 993.369595475566,
941.988672609005, 1036.52896057029, 1025.79874961742, 909.778142305324,
926.05520033663, 930.593948095488, 927.731349235947, 909.012240248148,
918.177023640935, 965.119279536339, 1100.04708794994, 950.187396378294,
913.95540287581, 908.285198789598, 928.585928045517, 1009.11449170465,
1048.43494462072, 1070.81842375631, 919.615682872958, 927.180388372158,
911.229890874478, 979.675336133848, 975.987038362197, 936.015685237366,
944.935422587313, 934.084922337254, 1065.1158215132, 960.558846324124,
954.324007605299, 1036.19891812821, 1000.52619841385, 904.622130948163,
911.66456482634, 952.40730926852, 925.617846758624, 907.103270618455,
921.775155162068, 962.660086144894, 1089.5423829539, 976.343009650736,
917.002530477079, 905.207509685187, 920.30422426818, 985.37894037379,
1032.27384329955, 974.803996932782)), class = "data.frame", row.names = c(85L,
86L, 87L, 89L, 90L, 91L, 99L, 100L, 101L, 103L, 104L, 105L, 113L,
114L, 115L, 117L, 118L, 119L, 127L, 128L, 129L, 131L, 132L, 133L,
141L, 142L, 143L, 145L, 146L, 147L, 155L, 156L, 157L, 159L, 160L,
161L, 169L, 170L, 171L, 173L, 174L, 175L, 183L, 184L, 185L, 187L,
188L, 189L, 197L, 198L, 199L, 201L, 202L, 203L, 211L, 212L, 213L,
215L, 216L, 217L, 225L, 226L, 227L, 229L, 230L, 231L, 239L, 240L,
241L, 243L, 244L, 245L, 253L, 254L, 255L, 257L, 258L, 259L, 267L,
268L, 269L, 271L, 272L, 273L, 615L, 616L, 617L, 619L, 620L, 622L,
623L, 624L, 626L, 627L, 629L, 630L, 631L, 640L, 641L, 642L, 643L,
644L, 645L, 647L, 648L, 649L, 651L, 652L, 653L, 655L, 656L, 657L,
659L, 660L, 661L, 663L, 664L, 666L, 667L, 668L, 670L, 671L, 673L,
674L, 675L, 684L, 685L, 686L, 687L, 688L, 689L, 691L, 692L, 693L,
695L, 696L, 697L, 699L, 700L, 701L, 703L, 704L, 705L, 707L, 708L,
710L, 711L, 712L, 714L, 715L, 717L, 718L, 719L, 728L, 729L, 730L,
731L, 732L, 733L, 735L, 736L, 737L, 739L, 740L, 741L, 743L, 744L,
745L, 747L, 748L, 749L, 751L, 752L, 754L, 755L, 756L, 758L, 759L,
761L, 762L, 763L, 772L, 773L, 774L, 775L, 776L, 777L, 779L, 780L,
781L, 783L, 784L, 785L, 787L, 788L, 789L, 791L, 792L, 793L, 795L,
796L, 798L, 799L, 800L, 802L, 803L, 805L, 806L, 807L, 816L, 817L,
818L, 819L, 820L, 821L, 823L, 824L, 825L, 827L, 828L, 829L, 831L,
832L, 833L, 835L, 836L, 837L, 839L, 840L, 842L, 843L, 844L, 846L,
847L, 849L, 850L, 851L, 860L, 861L, 862L, 863L, 864L, 865L, 867L,
868L, 869L, 871L, 872L, 873L, 875L, 876L, 877L, 879L, 880L, 881L,
883L, 884L, 886L, 887L, 888L, 890L, 891L, 893L, 894L, 895L, 904L,
905L, 906L, 907L, 908L, 909L, 911L, 912L, 913L, 915L, 916L, 917L,
919L, 920L, 921L, 923L, 924L, 925L, 927L, 928L, 930L, 931L, 932L,
934L, 935L, 937L, 938L, 939L, 948L, 949L, 950L, 951L, 952L, 953L,
955L, 956L, 957L, 959L, 960L, 961L, 963L, 964L, 965L, 967L, 968L,
969L, 971L, 972L, 974L, 975L, 976L, 978L, 979L, 981L, 982L, 983L,
992L, 993L, 994L, 995L, 996L, 997L, 999L, 1000L, 1001L, 1003L,
1004L, 1005L, 1007L, 1008L, 1009L, 1011L, 1012L, 1013L, 1015L,
1016L, 1018L, 1019L, 1020L, 1022L, 1023L, 1025L, 1026L, 1027L,
1036L, 1037L, 1038L, 1039L, 1040L, 1041L, 1043L, 1044L, 1045L,
1047L, 1048L, 1049L, 1051L, 1052L, 1053L, 1055L, 1056L, 1057L,
1059L, 1060L, 1062L, 1063L, 1064L, 1066L, 1067L, 1069L, 1070L,
1071L, 1080L, 1081L, 1082L, 1083L, 1084L, 1085L, 1087L, 1088L,
1089L, 1091L, 1092L, 1093L, 1095L, 1096L, 1097L, 1099L, 1100L,
1101L, 1103L, 1104L, 1106L, 1107L, 1108L, 1110L, 1111L, 1113L,
1114L, 1115L, 1124L, 1125L, 1126L, 1127L, 1128L, 1129L, 1131L,
1132L, 1133L, 1135L, 1136L, 1137L, 1139L, 1140L, 1141L, 1143L,
1144L, 1145L, 1147L, 1148L, 1150L, 1151L, 1152L, 1154L, 1155L,
1157L, 1158L, 1159L, 1168L, 1169L, 1170L, 1171L, 1172L, 1173L,
1175L, 1176L, 1177L, 1179L, 1180L, 1181L, 1183L, 1184L, 1185L,
1187L, 1188L, 1189L, 1191L, 1192L, 1194L, 1195L, 1196L, 1198L,
1199L, 1201L, 1202L, 1203L, 1212L, 1213L, 1214L, 1215L, 1216L,
1217L, 1219L, 1220L, 1221L, 1223L, 1224L, 1225L, 1227L, 1228L,
1229L))
```
<p>Here is the code (I think) that would be needed to fit the model and see the summary after the above data is loaded:</p>
```library(lme4)
library(lmerTest)

fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
fit2 <- lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)

summary(fit1)
#or
summary(fit2)
```

I think this has to do with my data structure and the programming but if it is actually something to do with the stats I am happy to take this post down and re-post over at the stats stackexchange.

Thanks for any help!

答:
note: although your question is about the lmer() function, this answer also applies to lm() and other R functions that fit linear models.

The way that coefficient estimates from linear models in R are presented can be confusing. To understand what's going on, you need to understand how R fits linear models when the predictor is a factor variable.

Coefficients on factor variables in R linear models

Before we look at factor variables, let's look at the more straightforward situation where the predictor is continuous. In your example dataset, one of the predictors is wind speed (continuous variable). The estimated coefficient is about -0.35. It's easy to interpret this: averaged across the other predictors, for every increase of 1 km/h in wind speed, your response value is predicted to decrease by 0.35.

But what about if the predictor is a factor? A categorical variable cannot increase or decrease by 1. Instead it can take several discrete values. So what the lmer() or lm() function does by default is automatically code your factor variable as a set of so-called "dummy variables." Dummy variables are binary (they can take values of 0 or 1). If the factor variable has n levels, you need n-1 dummy variables to encode it. The reference level or control group acts like an intercept.

In the case of your habitat variable, there are only 2 levels so you have only 1 dummy variable which will be 0 if habitat is not Forest and 1 if it is Forest. Now we can interpret the coefficient estimate of -68.8: the average value of your response is expected to be 68.8 less in forest habitat relative to the reference level of grassland habitat. You don't need a second dummy variable for grassland because you only need to estimate the one coefficient to compare the two habitats.

If you had a third habitat, let's say wetland, there would be a second dummy variable that would be 0 if not wetland and 1 if wetland. The coefficient estimate there would be the expected difference between the value of the response variable in wetland habitat compared to grassland habitat. Grassland will be the reference level for all the coefficients.

Default setting of reference level

Now to directly address your question of why habitatForest is the coefficient name.

Because by default no reference level or control group is specified, the first one in the factor level ordering becomes the reference level to which all other levels are compared. Then the coefficients are named by appending the variable's name to the name of the level being compared to the reference level. Your factor is ordered with grassland first and forest second. So the coefficient is the effect of the habitat being forest habitat, compared to the reference level, which is grassland in this case. If you switched the habitat factor level ordering, Forest would be the reference level and you would get habitatGrassland as the coefficient instead. (Note that default factor level ordering is alphabetical, so without specifically ordering the factor levels as you seem to have done, Forest would be the reference level by default).

Incidentally, the two links you give in your question (guides to mixed models from Phillip Alday and Tufts) do in fact have the same kind of output as you are getting. For example in Alday's tutorial, the factor recipe has 3 levels: A, B, and C. There are two coefficients in the fixed effects summary, recipeB and recipeC, just as you would expect from dummy coding using A as reference level. You may be confusing the fixed effects summary with the ANOVA table presented elsewhere in his post. The ANOVA table does only have a single line for recipe which gives you the ratio of variance due to recipe (across all its levels) and the total variance. So that would only be one ratio regardless of how many levels recipe has.

Further reading

This is not the place for a full discussion of contrast coding in linear models in R. The dummy coding (which you may also see called one-hot encoding) I described here is just one way to do it. These resources may be helpful:

Documentation for the base R function contrasts()

description of different types of categorical variable coding in R from UCLA IDRE Stats

Marissa Barlaz' tutorial on R contrast coding

Body:
I am using the lme4 package and running a linear mixed model but I am confused but the output and expect that I am encountering an error even though I do not get an error message.
The basic issue is when I fit a model like lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
and then look at the results using something like summary I see all the model fixed (and random) effects  as I would expect however the habitat effect is always displayed as habitatForest.  Like this:

Fixed effects:
                                                            Estimate Std. Error         df t value Pr(>|t|)
(Intercept)                                                996.63179    8.16633   31.22730 122.042  < 2e-16 ***
stimuliBHCO                                                 -3.57541    1.28877 8750.89273  -2.774 0.005544 **
stimuliCOHA                                                -10.17037    1.29546 8754.17156  -7.851 4.62e-15 ***
timeperiod                                                   0.19900    0.05516 8744.95307   3.608 0.000310 ***
scale(poly(distance.code, 3, raw = FALSE))1                 -3.87613    0.71431 8745.70773  -5.426 5.90e-08 ***
scale(poly(distance.code, 3, raw = FALSE))2                  2.65854    0.71463 8745.19353   3.720 0.000200 ***
scale(poly(distance.code, 3, raw = FALSE))3                  4.66340    0.72262 8745.67948   6.453 1.15e-10 ***
habitatForest                                              -68.82430   11.83009   29.95226  -5.818 2.34e-06 ***
wind.speed                                                  -0.35853    0.07631 8403.15191  -4.698 2.66e-06 ***
scale(poly(distance.code, 3, raw = FALSE))1:habitatForest    2.89860    1.03891 8745.46534   2.790 0.005282 **
scale(poly(distance.code, 3, raw = FALSE))2:habitatForest   -3.49758    1.03829 8745.11371  -3.369 0.000759 ***
scale(poly(distance.code, 3, raw = FALSE))3:habitatForest   -4.67300    1.03913 8745.30579  -4.497 6.98e-06 ***
---

This is happening even though there are two levels of habitat (Forest and Grassland)
at first, I thought this might be because my model had an interaction term but it happens when I try a simpler model like lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)

Why would it say "habitatForest" and not just "habitat" or if it were going to include a factor by name why not say "habitatForest" and "habitatGrassland"?

A quick look at the expected output from this function here: https://rpubs.com/palday/mixed-interactions or here: https://ase.tufts.edu/bugs/guide/assets/mixed_model_guide.html (among others)
shows that the out put that I am getting is not what is expected or normal.
Other output I have seen simply have factors with two levels, like mine, as a single line (eg habitat).

Here is a portion of the data I am using. I used dput and subseting to produce this. I couldn't figure out how to make the data set smaller and still reproduce the error so I apologize if this is too large. The data set that it comes from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or"), distance.code = c(0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L,
30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L, 0L, 60L, 0L, 30L, 60L,
0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L, 60L, 0L, 30L,
60L), stimuli = structure(c(3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L,
2L, 2L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 3L,
3L, 3L, 2L, 2L, 2L, 3L, 3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, 55, 55,
55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9,
0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65,
65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.9, 0.9, 0.9, 65, 65, 65, 65, 65, 55, 55, 55, 50, 50,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9, 65,
65, 65, 65, 65, 55, 55, 55, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.9, 0.9, 0.9), timeperiod = c(6L, 6L, 6L,
6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 9L,
9L, 9L, 9L, 9L, 9L, 11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L,
17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L,
20L, 21L, 21L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 22L, 22L,
23L, 23L, 23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L,
15L, 15L, 15L, 15L, 15L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L,
19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L,
20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 20L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L, 21L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L,
23L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 24L,
24L, 24L, 24L, 24L, 24L, 24L), Values = c(910.721895276374, 922.652711611841,
926.219785713456, 1030.28919690464, 1121.98321368732, 992.741416151102,
910.878353926705, 920.201901019659, 922.134996121665, 992.059286431433,
1042.05240231832, 1018.99804250179, 911.976009884021, 918.215389274037,
931.037495260958, 981.032280455129, 983.700699744073, 989.716307418049,
911.476759038955, 918.554393750162, 920.391856289719, 994.583211567691,
1006.58290843226, 1005.52479816571, 908.665064025178, 917.940176257067,
922.746174825048, 986.419049170517, 1042.41789735969, 1082.89658057517,
916.02310296116, 918.254868924698, 931.01648294424, 982.154409713674,
1008.54477137219, 996.577798511801, 912.914857937818, 916.937508116615,
920.933077377339, 997.669828575817, 1007.44452218386, 1151.25894192961,
909.463528658898, 915.293665875472, 921.917039784441, 983.866984633392,
1002.04551764872, 986.791628665069, 907.695668282537, 917.845214744473,
932.330755620455, 972.609449456089, 1155.55960936774, 1083.40557091613,
909.903267624225, 914.846316952797, 921.279328283221, 1000.3672969178,
1021.78461788922, 1011.40975353271, 915.037273600535, 914.099859036178,
924.116937361394, 994.428182266452, 1123.09745015276, 1004.1485272116,
914.431649376896, 915.27037594587, 929.411251949862, 974.273124973661,
1145.99211507205, 1013.58184367388, 913.467056616881, 920.213007520924,
919.794369158301, 983.816025282468, 1103.11322201674, 974.792027063404,
910.532609655114, 917.616832229923, 923.462599912213, 1015.24811721269,
1070.61183211249, 1016.57332551186, 910.196695694198, 923.403802532832,
905.400995326023, 1036.98011238981, 963.147077473505, 916.899569521736,
931.240844862156, 919.11781354823, 995.408916523572, 960.825305234446,
1026.22960551445, 1000.13773127026, 962.347584090332, 904.090295814044,
908.836747102913, 928.867625382891, 918.100799763641, 906.282906701285,
913.146312873635, 977.094140033575, 972.599778534534, 964.658406857446,
921.91272768213, 910.507770576621, 942.269786765654, 1014.34022271036,
1128.29327664605, 1043.1365958913, 919.185972424773, 925.486310755197,
908.769520270226, 1030.20866627018, 956.104935565803, 922.01947330213,
934.451182538208, 928.626906337293, 986.326936258622, 1003.40797963907,
1021.91264348048, 995.68658929192, 993.102343807935, 901.633626404701,
908.255562868123, 922.840049924103, 917.012733437446, 907.541530752433,
915.050696506642, 983.542956895186, 972.236377246083, 965.082329354352,
918.337944633569, 910.137012141557, 952.89462134025, 977.420371016686,
1154.17994731565, 1022.82998099991, 927.061613377597, 926.745527716988,
908.284054932259, 966.157586219165, 974.986841619676, 916.559494755925,
935.817296050643, 918.835719171662, 1023.62078549133, 1009.23121097376,
1005.81651905991, 981.715747809821, 953.127134375762, 902.809201411559,
907.462229880533, 921.595454423298, 919.198277947855, 904.969515265664,
913.438353334218, 974.889830301362, 970.58615968713, 963.029605541189,
915.889893279581, 908.147726780027, 942.742415528349, 979.939535179807,
1153.51966568673, 1020.93502990084, 916.246150801212, 936.016759720656,
914.4488779132, 962.397352323664, 986.957848140285, 985.364195731404,
932.548910038465, 917.363220594089, 1085.89850605988, 1031.66330597084,
1005.64983154588, 991.988118229379, 975.384741587994, 902.60240793926,
907.989086075871, 923.287310593779, 912.878571722023, 904.107623756648,
905.563259817979, 991.530368160932, 975.190212414434, 965.951810135591,
915.334621878897, 910.857441830446, 936.093336975328, 972.074491630181,
1106.77459226532, 993.45400883741, 951.911391767329, 927.688604859773,
915.194279622847, 971.414103170297, 956.138106650696, 965.458656222347,
944.097918792458, 947.157460200658, 1029.14870726558, 992.151638322899,
954.129642526236, 981.48182339388, 968.10870393618, 906.941701681267,
917.956716926981, 923.05649603805, 934.459432014683, 922.801034508827,
920.724850575215, 981.478432929603, 1012.67364507927, 966.471299899978,
912.640460101352, 906.34455384334, 923.738349342148, 970.987788560016,
1210.42940542072, 975.753397539076, 911.747488522664, 928.34872697947,
910.852487444859, 982.304620375747, 1028.52794775628, 913.408967803895,
934.334726415048, 916.354017093653, 1036.08727658415, 974.408618327141,
1004.71633485176, 995.142763465394, 987.00017276687, 906.86826042139,
915.355833226192, 930.395950341189, 911.742114273539, 905.725754800821,
912.194776217353, 979.488696998854, 998.766511802223, 968.436523426865,
916.299279627464, 907.645161223541, 925.30056793674, 978.067851389738,
1142.91274685359, 1001.53234105611, 916.842758017232, 924.907983103717,
922.470305986631, 992.855613565408, 955.757560902304, 929.20232030375,
943.535934437766, 923.58180450271, 1035.68330820385, 962.09501965608,
1035.71434011945, 999.021624049638, 1037.74929152155, 904.65540329816,
907.898446182233, 915.586965865012, 912.540978342886, 904.648950841522,
910.146698786639, 970.655222414677, 969.045225438776, 961.588678057607,
922.252864714149, 904.866433981365, 921.496292021655, 971.871605044557,
1075.02261709497, 1018.63215987506, 925.837889075039, 937.313874872585,
919.393974179406, 984.865480173384, 998.38173566307, 923.591922218561,
935.764591123357, 914.144404904734, 1064.07484543951, 1009.55385037395,
1003.07982307794, 1019.96770677478, 1023.43370663799, 1075.23648079772,
918.40638740207, 930.381596850856, 911.431923384541, 908.158538518039,
913.917742396318, 972.975539521988, 969.261073622988, 966.900828461146,
912.922987528198, 906.204515258546, 917.349668426986, 965.167090686302,
1033.80724280751, 1019.96323854891, 923.466492256566, 923.247012056591,
911.896005256495, 983.55323734271, 987.195939413696, 948.013535459932,
946.283282150572, 946.996017019961, 1018.55920835599, 983.790383328001,
1044.1241515621, 1025.44806232873, 1013.07125415424, 936.438305947314,
914.845558304809, 919.627558974215, 912.08306092659, 905.506361055768,
925.863591354922, 980.84672626416, 1034.50509678374, 999.432501149952,
914.013428128551, 903.385280147577, 914.982720974316, 987.521728519027,
1026.27371444455, 1003.6659923071, 936.860089156893, 922.376363123921,
909.301601087255, 949.125313633903, 983.891808931205, 928.514242776379,
931.528375870523, 934.663002673557, 983.163630767407, 958.520107194186,
1028.60002280789, 1027.26325499148, 1026.49504978946, 904.375575893285,
912.523756638651, 919.179127414697, 913.641605762865, 905.043751380124,
918.017612913947, 966.955539088111, 1083.03489991906, 982.779995986195,
913.039005945342, 901.569366267589, 924.344189118069, 986.456388413752,
1053.70140237407, 1012.4655295529, 918.216939699045, 924.376017342816,
912.32335834515, 962.020663167786, 968.751653626515, 923.781426521514,
934.702280304594, 945.072040784087, 972.171048113648, 980.160384144599,
1029.12422797868, 1045.60159108586, 1069.71097019503, 904.989955563463,
911.137606736246, 913.282276988181, 911.62618760385, 904.022814213797,
917.471586361699, 969.239603596626, 1092.64417075988, 995.598256664543,
911.352468377778, 903.930535551161, 934.598647851096, 968.529282541217,
1014.22774561852, 992.123001836286, 955.008951781314, 928.638327604534,
930.057703919378, 979.117036821698, 961.435436233545, 927.430280788518,
933.188144311621, 938.849731346915, 975.793676023678, 984.576641002029,
953.148108722352, 1025.14511979605, 987.536969976085, 904.469118373204,
919.724696002539, 921.494112907094, 933.99081130992, 910.883621211755,
919.830805764804, 973.217375644616, 1097.82345512272, 955.321702833728,
914.950887550846, 907.869650845588, 930.21996042144, 988.365255219924,
1072.82537699421, 941.505101156388, 912.978755227237, 924.00211814663,
926.073413421038, 975.963524978988, 966.347030574186, 927.813889117707,
938.87057229942, 937.20592642584, 1049.77079831674, 993.369595475566,
941.988672609005, 1036.52896057029, 1025.79874961742, 909.778142305324,
926.05520033663, 930.593948095488, 927.731349235947, 909.012240248148,
918.177023640935, 965.119279536339, 1100.04708794994, 950.187396378294,
913.95540287581, 908.285198789598, 928.585928045517, 1009.11449170465,
1048.43494462072, 1070.81842375631, 919.615682872958, 927.180388372158,
911.229890874478, 979.675336133848, 975.987038362197, 936.015685237366,
944.935422587313, 934.084922337254, 1065.1158215132, 960.558846324124,
954.324007605299, 1036.19891812821, 1000.52619841385, 904.622130948163,
911.66456482634, 952.40730926852, 925.617846758624, 907.103270618455,
921.775155162068, 962.660086144894, 1089.5423829539, 976.343009650736,
917.002530477079, 905.207509685187, 920.30422426818, 985.37894037379,
1032.27384329955, 974.803996932782)), class = "data.frame", row.names = c(85L,
86L, 87L, 89L, 90L, 91L, 99L, 100L, 101L, 103L, 104L, 105L, 113L,
114L, 115L, 117L, 118L, 119L, 127L, 128L, 129L, 131L, 132L, 133L,
141L, 142L, 143L, 145L, 146L, 147L, 155L, 156L, 157L, 159L, 160L,
161L, 169L, 170L, 171L, 173L, 174L, 175L, 183L, 184L, 185L, 187L,
188L, 189L, 197L, 198L, 199L, 201L, 202L, 203L, 211L, 212L, 213L,
215L, 216L, 217L, 225L, 226L, 227L, 229L, 230L, 231L, 239L, 240L,
241L, 243L, 244L, 245L, 253L, 254L, 255L, 257L, 258L, 259L, 267L,
268L, 269L, 271L, 272L, 273L, 615L, 616L, 617L, 619L, 620L, 622L,
623L, 624L, 626L, 627L, 629L, 630L, 631L, 640L, 641L, 642L, 643L,
644L, 645L, 647L, 648L, 649L, 651L, 652L, 653L, 655L, 656L, 657L,
659L, 660L, 661L, 663L, 664L, 666L, 667L, 668L, 670L, 671L, 673L,
674L, 675L, 684L, 685L, 686L, 687L, 688L, 689L, 691L, 692L, 693L,
695L, 696L, 697L, 699L, 700L, 701L, 703L, 704L, 705L, 707L, 708L,
710L, 711L, 712L, 714L, 715L, 717L, 718L, 719L, 728L, 729L, 730L,
731L, 732L, 733L, 735L, 736L, 737L, 739L, 740L, 741L, 743L, 744L,
745L, 747L, 748L, 749L, 751L, 752L, 754L, 755L, 756L, 758L, 759L,
761L, 762L, 763L, 772L, 773L, 774L, 775L, 776L, 777L, 779L, 780L,
781L, 783L, 784L, 785L, 787L, 788L, 789L, 791L, 792L, 793L, 795L,
796L, 798L, 799L, 800L, 802L, 803L, 805L, 806L, 807L, 816L, 817L,
818L, 819L, 820L, 821L, 823L, 824L, 825L, 827L, 828L, 829L, 831L,
832L, 833L, 835L, 836L, 837L, 839L, 840L, 842L, 843L, 844L, 846L,
847L, 849L, 850L, 851L, 860L, 861L, 862L, 863L, 864L, 865L, 867L,
868L, 869L, 871L, 872L, 873L, 875L, 876L, 877L, 879L, 880L, 881L,
883L, 884L, 886L, 887L, 888L, 890L, 891L, 893L, 894L, 895L, 904L,
905L, 906L, 907L, 908L, 909L, 911L, 912L, 913L, 915L, 916L, 917L,
919L, 920L, 921L, 923L, 924L, 925L, 927L, 928L, 930L, 931L, 932L,
934L, 935L, 937L, 938L, 939L, 948L, 949L, 950L, 951L, 952L, 953L,
955L, 956L, 957L, 959L, 960L, 961L, 963L, 964L, 965L, 967L, 968L,
969L, 971L, 972L, 974L, 975L, 976L, 978L, 979L, 981L, 982L, 983L,
992L, 993L, 994L, 995L, 996L, 997L, 999L, 1000L, 1001L, 1003L,
1004L, 1005L, 1007L, 1008L, 1009L, 1011L, 1012L, 1013L, 1015L,
1016L, 1018L, 1019L, 1020L, 1022L, 1023L, 1025L, 1026L, 1027L,
1036L, 1037L, 1038L, 1039L, 1040L, 1041L, 1043L, 1044L, 1045L,
1047L, 1048L, 1049L, 1051L, 1052L, 1053L, 1055L, 1056L, 1057L,
1059L, 1060L, 1062L, 1063L, 1064L, 1066L, 1067L, 1069L, 1070L,
1071L, 1080L, 1081L, 1082L, 1083L, 1084L, 1085L, 1087L, 1088L,
1089L, 1091L, 1092L, 1093L, 1095L, 1096L, 1097L, 1099L, 1100L,
1101L, 1103L, 1104L, 1106L, 1107L, 1108L, 1110L, 1111L, 1113L,
1114L, 1115L, 1124L, 1125L, 1126L, 1127L, 1128L, 1129L, 1131L,
1132L, 1133L, 1135L, 1136L, 1137L, 1139L, 1140L, 1141L, 1143L,
1144L, 1145L, 1147L, 1148L, 1150L, 1151L, 1152L, 1154L, 1155L,
1157L, 1158L, 1159L, 1168L, 1169L, 1170L, 1171L, 1172L, 1173L,
1175L, 1176L, 1177L, 1179L, 1180L, 1181L, 1183L, 1184L, 1185L,
1187L, 1188L, 1189L, 1191L, 1192L, 1194L, 1195L, 1196L, 1198L,
1199L, 1201L, 1202L, 1203L, 1212L, 1213L, 1214L, 1215L, 1216L,
1217L, 1219L, 1220L, 1221L, 1223L, 1224L, 1225L, 1227L, 1228L,
1229L))

Here is the code (I think) that would be needed to fit the model and see the summary after the above data is loaded:

library(lme4)
library(lmerTest)

fit1 <- lmer(Values ~ stimuli + timeperiod + scale(poly(distance.code,3,raw=FALSE))*habitat + wind.speed + (1|location.code), data=df, REML=FALSE)
fit2 <- lmer(Values ~ stimuli + timeperiod + distance.code + habitat + wind.speed + (1|location.code), data=ex.df, REML=FALSE)

summary(fit1)
#or
summary(fit2)

I think this has to do with my data structure and the programming but if it is actually something to do with the stats I am happy to take this post down and re-post over at the stats stackexchange.

Thanks for any help!


来源: stackexchange

问:
python optional caching of function
What's the best way to cache a function in python with an optional caching parameter?

I've a function which performs a database request and does not take any arguments.
Most of the times it's okay if the function uses the cached result but sometimes I want to send a new database request.

from functools import lru_cache

@lru_cache
def my_database_request_function(use_cache: bool = False):

    if use_cache:
    # takes response from cache
    else:
    # makes database request

    return response

```

The implementation above won't work because the second time the functions gets called with the use_cache=False parameter it will not make a new request.

答:
```<code>from multipledispatch import dispatch
from functools import lru_cache

@dispatch(bool)
@lru_cache
def my_database_request_function(use_cache: bool):
    print('cached')

@dispatch()
def my_database_request_function():
    print('NOT cached')

my_database_request_function(True)
my_database_request_function(False)
my_database_request_function()
</code>```

Output:

```<code>cached
cached
NOT cached
</code>```

Using a module called multipledispatch, you can do function overloading where there are multiple functions of the same name and you specify the different parameters for each one. The bool here can change to anything you prefer.

ContentLicense: CC BY-SA 4.0

Title: python optional caching of function

Body:
What's the best way to cache a function in python with an optional caching parameter?

I've a function which performs a database request and does not take any arguments.
Most of the times it's okay if the function uses the cached result but sometimes I want to send a new database request.

from functools import lru_cache

@lru_cache
def my_database_request_function(use_cache: bool = False):

    if use_cache:
    # takes response from cache
    else:
    # makes database request

    return response

The implementation above won't work because the second time the functions gets called with the use_cache=False parameter it will not make a new request.

Body:
from multipledispatch import dispatch
from functools import lru_cache

@dispatch(bool)
@lru_cache
def my_database_request_function(use_cache: bool):
    print('cached')

@dispatch()
def my_database_request_function():
    print('NOT cached')

my_database_request_function(True)
my_database_request_function(False)
my_database_request_function()

Output:

cached
cached
NOT cached

Using a module called multipledispatch, you can do function overloading where there are multiple functions of the same name and you specify the different parameters for each one. The bool here can change to anything you prefer.


问:
Merge two lists into dynamic list in Python
I have a scenario where have lists List1 and List2 which has below values

List1 = [1,2,3]

List2 = [(11,22,33),(44,55,66),(77,88,99)]

Expected List3 = [(1,11,22,33),(2,44,55,66),(3,77,88,99)]

I need to populate this List3 in Python.Any help is appriciated.

i tried using multiple for loops but didnt work somehing like this

```<code>list = []
        for id in tIDs:
            tIDy = id["ID"]
            for row in PlanDf[["Owner","SP","rep"]].itertuples(index=False):
                list.append((tIDy ,tuple(row)[0],tuple(row)[1],tuple(row)[2]))
                break
</code>```

Body:
I have a scenario where have lists List1 and List2 which has below values

List1 = [1,2,3]

List2 = [(11,22,33),(44,55,66),(77,88,99)]

Expected List3 = [(1,11,22,33),(2,44,55,66),(3,77,88,99)]

I need to populate this List3 in Python.Any help is appriciated.

i tried using multiple for loops but didnt work somehing like this

list = []
        for id in tIDs:
            tIDy = id["ID"]
            for row in PlanDf[["Owner","SP","rep"]].itertuples(index=False):
                list.append((tIDy ,tuple(row)[0],tuple(row)[1],tuple(row)[2]))
                break

Body:
You could use a list comprehension like so:

List3 = [(i, *lst) for i, lst in zip(List1, List2)]

Output:

[(1, 11, 22, 33), (2, 44, 55, 66), (3, 77, 88, 99)]

Full test case:

List1 = [1,2,3]
List2 = [(11,22,33),(44,55,66),(77,88,99)]

List3 = [(i, *lst) for i, lst in zip(List1, List2)]

print(List3)


问:
How to delete contents excluding formula
Hereunder my vba code which "works" : each time the file is opened, the zones for input are re-initialised, but I have one cell which is a vertical ref to another and I would like to keep the formula in.

Is there a way to delete only the values but not the formulae ?
Many thanks for your tips :-)

```<code>Private Sub Workbook_Open()
MsgBox "Bonjour, Vous êtes bien sur le formulaire ECHANTILLONS à facturer ou à rembourser"
Call Effacercontenu
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim myRange As Range

Set myRange = Union(Range("C8"), Range("C10:C11"), Range("C13:C20"), Range("B25:D25"), Range("B33"), Range("B40"))
For Each cell In myRange
    If IsEmpty(cell.Value) = True Then
        Cancel = True
        MsgBox ("Vérifiez les cellules non remplies")
    End If
Next cell
ActiveWorkbook.Save
End Sub

Private Sub Effacercontenu()

Dim myRange As Range

With ActiveSheet.Range("C8,C10:C11,C13:C20,D19:D20,C25:D25,B33:H33,B40:H40").ClearContents
End With

End Sub
</code>```

答:
You could use Method SpecialCells

```<code>Sub ClearOnlyValues()
 Dim rngArea As Range

 'identify only numbers
 Set rngArea = Sheet1.Range("A1").SpecialCells(xlCellTypeConstants, 1)

 'look at immeadiate window
 Debug.Print rngArea.Address

 'clear it
 rngArea.ClearContents

End Sub
</code>```

Body:
Hereunder my vba code which "works" : each time the file is opened, the zones for input are re-initialised, but I have one cell which is a vertical ref to another and I would like to keep the formula in.

Is there a way to delete only the values but not the formulae ?
Many thanks for your tips :-)

Private Sub Workbook_Open()
MsgBox "Bonjour, Vous êtes bien sur le formulaire ECHANTILLONS à facturer ou à rembourser"
Call Effacercontenu
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim myRange As Range

Set myRange = Union(Range("C8"), Range("C10:C11"), Range("C13:C20"), Range("B25:D25"), Range("B33"), Range("B40"))
For Each cell In myRange
    If IsEmpty(cell.Value) = True Then
        Cancel = True
        MsgBox ("Vérifiez les cellules non remplies")
    End If
Next cell
ActiveWorkbook.Save
End Sub

Private Sub Effacercontenu()

Dim myRange As Range

With ActiveSheet.Range("C8,C10:C11,C13:C20,D19:D20,C25:D25,B33:H33,B40:H40").ClearContents
End With

End Sub

Body:
You could use Method SpecialCells

Sub ClearOnlyValues()
 Dim rngArea As Range

 'identify only numbers
 Set rngArea = Sheet1.Range("A1").SpecialCells(xlCellTypeConstants, 1)

 'look at immeadiate window
 Debug.Print rngArea.Address

 'clear it
 rngArea.ClearContents

End Sub


问:
How to define a dynamic block for advanced_filter
I want to define multiple filters for azurerm_eventgrid_event_subscription module

i tried by creating a dynamic block like below :

```<code>resource "azurerm_eventgrid_event_subscription" "subscription" {
  name                 = var.subscription_data["name"]
  scope                = var.subscription_data["scope"]
  expiration_time_utc  = var.subscription_data["expiration_time_utc"]
  included_event_types = var.included_event_types
  dynamic "advanced_filter" {
    for_each = var.advanced_filter
    content {
      dynamic "bool_equals" {
        for_each = try(var.advanced_filter.value.bool_equals, {})
        content {
          key   = "test"
          value = true
          # values = try(bool_equals.value.value_list, null)
        }
      }
    }
  }

variable "advanced_filter" {
  type = map(any)
  description = "Advanced filter maps"
}
</code>```

Terraform Doc : https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_event_subscription
But getting some error like this:

```<code>Error: Missing required argument

  on ../main.tf line 1, in resource "azurerm_eventgrid_event_subscription" "subscription":
   1: resource "azurerm_eventgrid_event_subscription" "subscription" {

"advanced_filter.0.number_not_in": one of
`advanced_filter.0.bool_equals,advanced_filter.0.is_not_null,advanced_filter.0.is_null_or_undefined,advanced_filter.0.number_greater_than,advanced_filter.0.number_greater_than_or_equals,advanced_filter.0.number_in,advanced_filter.0.number_in_range,advanced_filter.0.number_less_than,advanced_filter.0.number_less_than_or_equals,advanced_filter.0.number_not_in,advanced_filter.0.number_not_in_range,advanced_filter.0.string_begins_with,advanced_filter.0.string_contains,advanced_filter.0.string_ends_with,advanced_filter.0.string_in,advanced_filter.0.string_not_begins_with,advanced_filter.0.string_not_contains,advanced_filter.0.string_not_ends_with,advanced_filter.0.string_not_in`
must be specified

Error: Missing required argument

  on ../main.tf line 1, in resource "azurerm_eventgrid_event_subscription" "subscription":
   1: resource "azurerm_eventgrid_event_subscription" "subscription" {

"advanced_filter.0.string_in": one of
`advanced_filter.0.bool_equals,advanced_filter.0.is_not_null,advanced_filter.0.is_null_or_undefined,advanced_filter.0.number_greater_than,advanced_filter.0.number_greater_than_or_equals,advanced_filter.0.number_in,advanced_filter.0.number_in_range,advanced_filter.0.number_less_than,advanced_filter.0.number_less_than_or_equals,advanced_filter.0.number_not_in,advanced_filter.0.number_not_in_range,advanced_filter.0.string_begins_with,advanced_filter.0.string_contains,advanced_filter.0.string_ends_with,advanced_filter.0.string_in,advanced_filter.0.string_not_begins_with,advanced_filter.0.string_not_contains,advanced_filter.0.string_not_ends_with,advanced_filter.0.string_not_in`
must be specified
</code>```

答:
I Put multiple dynamic blocks 1 for advanced_filter and another for each filters and it got worked

```<code>    resource "azurerm_eventgrid_event_subscription" "subscription" {
      name                 = var.subscription_data["name"]
      scope                = var.subscription_data["scope"]
      expiration_time_utc  = var.subscription_data["expiration_time_utc"]
      included_event_types = var.included_event_types

      dynamic "advanced_filter" {
        for_each = length(try(var.advanced_filter[0], [])) != 0 ? [var.advanced_filter] : []
        content {
          dynamic "bool_equals" {
            for_each = [for filter in advanced_filter.value : [filter.bool_equals] if try(filter.bool_equals, null) != null]
            content {
              key   = bool_equals.value[0].key
              value = bool_equals.value[0].value
            }
          }

          dynamic "number_greater_than" {
            for_each = [for filter in advanced_filter.value : [filter.number_greater_than] if try(filter.number_greater_than, null) != null]
            content {
              key   = number_greater_than.value[0].key
              value = number_greater_than.value[0].value
            }
          }

          dynamic "number_greater_than_or_equals" {
            for_each = [for filter in advanced_filter.value : [filter.number_greater_than_or_equals] if try(filter.number_greater_than_or_equals, null) != null]
            content {
              key   = number_greater_than_or_equals.value[0].key
              value = number_greater_than_or_equals.value[0].value
            }
          }
}
    variable "advanced_filter" {
      description = "Advanced filter maps"
      type        = any
      default     = []
    }
</code>```

The terratest value should be like this:

```<code>advanced_filter = [
     {
       bool_equals = {
         key   = "test"
         value = true
      }
      },
    {
      number_not_in = {
        key    = "data.counter"
        values = [41, 0]
    } }
  ]
</code>```

Body:
I want to define multiple filters for azurerm_eventgrid_event_subscription module

i tried by creating a dynamic block like below :

resource "azurerm_eventgrid_event_subscription" "subscription" {
  name                 = var.subscription_data["name"]
  scope                = var.subscription_data["scope"]
  expiration_time_utc  = var.subscription_data["expiration_time_utc"]
  included_event_types = var.included_event_types
  dynamic "advanced_filter" {
    for_each = var.advanced_filter
    content {
      dynamic "bool_equals" {
        for_each = try(var.advanced_filter.value.bool_equals, {})
        content {
          key   = "test"
          value = true
          # values = try(bool_equals.value.value_list, null)
        }
      }
    }
  }

variable "advanced_filter" {
  type = map(any)
  description = "Advanced filter maps"
}

Terraform Doc : https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/eventgrid_event_subscription
But getting some error like this:

Error: Missing required argument

  on ../main.tf line 1, in resource "azurerm_eventgrid_event_subscription" "subscription":
   1: resource "azurerm_eventgrid_event_subscription" "subscription" {

"advanced_filter.0.number_not_in": one of
`advanced_filter.0.bool_equals,advanced_filter.0.is_not_null,advanced_filter.0.is_null_or_undefined,advanced_filter.0.number_greater_than,advanced_filter.0.number_greater_than_or_equals,advanced_filter.0.number_in,advanced_filter.0.number_in_range,advanced_filter.0.number_less_than,advanced_filter.0.number_less_than_or_equals,advanced_filter.0.number_not_in,advanced_filter.0.number_not_in_range,advanced_filter.0.string_begins_with,advanced_filter.0.string_contains,advanced_filter.0.string_ends_with,advanced_filter.0.string_in,advanced_filter.0.string_not_begins_with,advanced_filter.0.string_not_contains,advanced_filter.0.string_not_ends_with,advanced_filter.0.string_not_in`
must be specified

Error: Missing required argument

  on ../main.tf line 1, in resource "azurerm_eventgrid_event_subscription" "subscription":
   1: resource "azurerm_eventgrid_event_subscription" "subscription" {

"advanced_filter.0.string_in": one of
`advanced_filter.0.bool_equals,advanced_filter.0.is_not_null,advanced_filter.0.is_null_or_undefined,advanced_filter.0.number_greater_than,advanced_filter.0.number_greater_than_or_equals,advanced_filter.0.number_in,advanced_filter.0.number_in_range,advanced_filter.0.number_less_than,advanced_filter.0.number_less_than_or_equals,advanced_filter.0.number_not_in,advanced_filter.0.number_not_in_range,advanced_filter.0.string_begins_with,advanced_filter.0.string_contains,advanced_filter.0.string_ends_with,advanced_filter.0.string_in,advanced_filter.0.string_not_begins_with,advanced_filter.0.string_not_contains,advanced_filter.0.string_not_ends_with,advanced_filter.0.string_not_in`
must be specified

Body:
I Put multiple dynamic blocks 1 for advanced_filter and another for each filters and it got worked

    resource "azurerm_eventgrid_event_subscription" "subscription" {
      name                 = var.subscription_data["name"]
      scope                = var.subscription_data["scope"]
      expiration_time_utc  = var.subscription_data["expiration_time_utc"]
      included_event_types = var.included_event_types

      dynamic "advanced_filter" {
        for_each = length(try(var.advanced_filter[0], [])) != 0 ? [var.advanced_filter] : []
        content {
          dynamic "bool_equals" {
            for_each = [for filter in advanced_filter.value : [filter.bool_equals] if try(filter.bool_equals, null) != null]
            content {
              key   = bool_equals.value[0].key
              value = bool_equals.value[0].value
            }
          }

          dynamic "number_greater_than" {
            for_each = [for filter in advanced_filter.value : [filter.number_greater_than] if try(filter.number_greater_than, null) != null]
            content {
              key   = number_greater_than.value[0].key
              value = number_greater_than.value[0].value
            }
          }

          dynamic "number_greater_than_or_equals" {
            for_each = [for filter in advanced_filter.value : [filter.number_greater_than_or_equals] if try(filter.number_greater_than_or_equals, null) != null]
            content {
              key   = number_greater_than_or_equals.value[0].key
              value = number_greater_than_or_equals.value[0].value
            }
          }
}
    variable "advanced_filter" {
      description = "Advanced filter maps"
      type        = any
      default     = []
    }

The terratest value should be like this:

advanced_filter = [
     {
       bool_equals = {
         key   = "test"
         value = true
      }
      },
    {
      number_not_in = {
        key    = "data.counter"
        values = [41, 0]
    } }
  ]


问:
Why is adding attributes to an already instantiated object allowed?
I am studying python, and although I think I get the whole concept and notion of Python, today I stumbled upon a piece of code that I did not fully understand:

Say I have a class that is supposed to define Circles but lacks a body:

```<code>class Circle():
    pass
</code>```

Since I have not defined any attributes, how can I do this:

```<code>my_circle = Circle()
my_circle.radius = 12
</code>```

The weird part is that Python accepts the above statement. I don't understand why Python doesn't raise an undefined name error. I do understand that via dynamic typing I just bind variables to objects whenever I want, but shouldn't an attribute radius exist in the Circle class to allow me to do this?

EDIT: Lots of wonderful information in your answers! Thank you everyone for all those fantastic answers! It's a pity I only get to mark one as an answer.

答:
To add to Conchylicultor's answer, Python 3.10 added a new parameter to dataclass.

The slots parameter will create the __slots__ attribute in the class, preventing creation of new attributes outside of __init__, but allowing assignments to existing attributes.

If slots=True, assigning to an attribute that was not defined will throw an AttributeError.

Here is an example with slots and with frozen:

from dataclasses import dataclass

@dataclass
class Data:
    x:float=0
    y:float=0

@dataclass(frozen=True)
class DataFrozen:
    x:float=0
    y:float=0

@dataclass(slots=True)
class DataSlots:
    x:float=0
    y:float=0

p = Data(1,2)
p.x = 5 # ok
p.z = 8 # ok

p = DataFrozen(1,2)
p.x = 5 # FrozenInstanceError
p.z = 8 # FrozenInstanceError

p = DataSlots(1,2)
p.x = 5 # ok
p.z = 8 # AttributeError
```

ContentLicense: CC BY-SA 3.0

Body:
I am studying python, and although I think I get the whole concept and notion of Python, today I stumbled upon a piece of code that I did not fully understand:

Say I have a class that is supposed to define Circles but lacks a body:

class Circle():
    pass

Since I have not defined any attributes, how can I do this:

my_circle = Circle()
my_circle.radius = 12

The weird part is that Python accepts the above statement. I don't understand why Python doesn't raise an undefined name error. I do understand that via dynamic typing I just bind variables to objects whenever I want, but shouldn't an attribute radius exist in the Circle class to allow me to do this?

EDIT: Lots of wonderful information in your answers! Thank you everyone for all those fantastic answers! It's a pity I only get to mark one as an answer.


问:
Function to determine if it is possible to make the one string to be equal with the other
function to determine if it is possible to make the first input equal to the second input by either capitalizing or removing letters. Cannot interchange the positions of the letters.</p>

答:
const canReplace = (str1, str2) => {
  const letters1 = str1.split('')
  const letters2 = str2.split('')
  let lastIdx = -1

  for (let l2 of letters2) {
    const idx = letters1.findIndex(l1 => l2 === l1 || l2.toLowerCase() === l1)
    if (idx > lastIdx) {
      lastIdx = idx
    } else {
      return false
    }
  }

  return lastIdx !== -1

}

console.log(canReplace('abCde', 'BCD'))
console.log(canReplace('Abcdef', 'ACE'))
console.log(canReplace('ABCD', 'CBD'))
console.log(canReplace('ABC', 'AbC'))```


问:
prompt loads before anything else
hay if anybody understand why is prompt showing up even  before the console printing

i appreciate the help

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promptheadache</title>

```

答:
If you want to get the console before prompt you can add setTimeOut-setTimeout() is an asynchronous function.

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promptheadache</title>

```

Title: prompt loads before anything else

Body:
If you want to get the console before prompt you can add setTimeOut-setTimeout() is an asynchronous function.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promptheadache</title>
</head>

<body>
    <script>

        console.log('i should appear first on the console')
  setTimeout(() => {var promptInput = prompt('I\'m am here befor anything else')
},5000)

    </script>
</body>

</html>


Title: Create new column using tidy evaluation on the left and right of mutate in R

Body:
I know there are many questions regarding tidy evaluation in R. However, I couldn't figure out a solution to this seemingly easily problem.

I have this data.frame

structure(list(Date = c("25.02.2020", "26.02.2020", "27.02.2020",
"28.02.2020", "02.03.2020", "03.03.2020", "04.03.2020", "05.03.2020",
"06.03.2020", "09.03.2020", "10.03.2020", "11.03.2020", "12.03.2020",
"13.03.2020", "16.03.2020", "17.03.2020", "18.03.2020", "19.03.2020",
"20.03.2020", "23.03.2020", "24.03.2020", "25.03.2020", "26.03.2020",
"27.03.2020", "30.03.2020", "31.03.2020", "01.04.2020", "02.04.2020",
"03.04.2020", "06.04.2020"), change_AAPL_stocks = c("1", "0,95",
"0,93", "0,85", "0,94", "1,01", "0,99", "0,98", "0,94", "0,88",
"0,92", "0,92", "0,85", "0,88", "0,8", "0,82", "0,8", "0,82",
"0,82", "0,76", "0,79", "0,83", "0,82", "0,84", "0,83", "0,85",
"0,82", "0,8", "0,81", "0,83"), change_AMZN_stocks = c("1", "0,97",
"0,95", "0,9", "0,94", "0,97", "0,96", "0,95", "0,93", "0,88",
"0,92", "0,92", "0,85", "0,87", "0,81", "0,88", "0,86", "0,92",
"0,95", "0,9", "0,96", "0,95", "0,94", "0,95", "0,95", "0,97",
"0,95", "0,94", "0,94", "0,96")), row.names = c(NA, -30L), class = c("tbl_df",
"tbl", "data.frame"))

And I have these variables

date_col = "Date"
date_format = "%d.%m.%Y"
value_col = "change_AAPL_stocks"

And I'd like to write a function that can take arbitrary date_col and date_format values.

The code at the moment looks like this:

  df %>%
    select(date_col, value_col) %>%
    mutate(
      {{date_col}} := as.Date({date_col}, format=date_format)
    )

Which creates (overwrites) the column names Date. However, the as.Date(...) function does not work. I am not entirely sure what to do about that.

Body:
We can use .data to subset

library(dplyr)
df %>%
    select(all_of(date_col))%>%
    mutate(!! date_col := as.Date(.data[[date_col]], format = date_format))

-output

# A tibble: 30 × 1
   Date
   <date>
 1 2020-02-25
 2 2020-02-26
 3 2020-02-27
 4 2020-02-28
 5 2020-03-02
 6 2020-03-03
 7 2020-03-04
 8 2020-03-05
 9 2020-03-06
10 2020-03-09
# … with 20 more rows


问:
How to get messages sent by members in a group using the Telegram Bot API
How to receive messages sent by group members using Telegram Bot API, I'm using getUpdates to get messages but only getting command /command messages, the rest of the normal messages are not received by bot ok i want to receive all messages to check if the user sent message contains offensive words and delete it

答: A bot needs to be added as admin to a group chat to have access to all user messages.</p>


问:
How to determine a dependency graph solution is correct
I created a class that takes a directed graph, a vertex in that graph, and outputs an acceptable sequence of vertices to lead to that vertex.

e.g.

A->B

A->C

B->D

C->D

The two possible sequences for vertex D are:

A->B->C->D

A->C->B->D

Now, I need to design a test to determine if a solution my program gives is correct.

Any ideas?

答: You could use an algorithm based on Cyclomatic Complexity to calculate the number of paths that should be found, which would be a good sanity check - esp if you have a very big graph, getting exactly the right number of paths would be reassuring (though not obviously a guarantee that the paths themselves are correct!). It is broadly speaking the number of edges minus the number of nodes - you'll see the nuances on that wikipedia page. </p>


问:
How to add mean, and mode to ggplot histogram?
I need to add a mean line and the value of the mode for example to this kinds
of plots:

I use this for calculate the number of bins:

```<code>bw <- diff(range(cars$lenght)) / (2 * IQR(cars$lenght) / length(cars$lenght)^(1/3))
</code>```

And the plot:

```<code>ggplot(data=cars, aes(cars$lenght)) +
  geom_histogram(aes(y =..density..),
                 col="red",
                 binwidth = bw,
                 fill="green",
                 alpha=1) +
  geom_density(col=4) +
  labs(title='Lenght Plot', x='Lenght', y='Times')

cars$lenght
</code>```

168.8 168.8 171.2 176.6 176.6 177.3 192.7 192.7 192.7 178.2
  176.8 176.8 176.8 176.8 189.0 189.0 193.8 197.0 141.1 155.9
  158.8 157.3 157.3 157.3 157.3 157.3 157.3 157.3 174.6 173.2

Thanks in advance.

答:
Create a data.frame which has a value for each statistic you want to plot. This has the advantage of automatically creating a legend for each statistic.

```<code>cars$length <- cars$speed
bw <- diff(range(cars$length)) / (2 * IQR(cars$length) / length(cars$length)^(1/3))

sumstatz <- data.frame(whichstat = c("mean",
                                     "sd upr",
                                     "sd lwr"),
                       value     = c(mean(cars$length),
                                     mean(cars$length)+sd(cars$length),
                                     mean(cars$length)-sd(cars$length)))

ggplot(data=cars, aes(length)) +
  geom_histogram(aes(y =..density..),
                 col="black",
                 binwidth = bw) +
  geom_density(col="black") +
  geom_vline(data=sumstatz,aes(xintercept = value,
                               linetype = whichstat,
                               col = whichstat),size=1)+
  labs(title='Length Plot', x='Length', y='Count')
</code>```

Body:
I need to add a mean line and the value of the mode for example to this kinds
of plots:

I use this for calculate the number of bins:

bw <- diff(range(cars$lenght)) / (2 * IQR(cars$lenght) / length(cars$lenght)^(1/3))

And the plot:

ggplot(data=cars, aes(cars$lenght)) +
  geom_histogram(aes(y =..density..),
                 col="red",
                 binwidth = bw,
                 fill="green",
                 alpha=1) +
  geom_density(col=4) +
  labs(title='Lenght Plot', x='Lenght', y='Times')

cars$lenght

168.8 168.8 171.2 176.6 176.6 177.3 192.7 192.7 192.7 178.2
  176.8 176.8 176.8 176.8 189.0 189.0 193.8 197.0 141.1 155.9
  158.8 157.3 157.3 157.3 157.3 157.3 157.3 157.3 174.6 173.2

Thanks in advance.

Body:
Create a data.frame which has a value for each statistic you want to plot. This has the advantage of automatically creating a legend for each statistic.

cars$length <- cars$speed
bw <- diff(range(cars$length)) / (2 * IQR(cars$length) / length(cars$length)^(1/3))

sumstatz <- data.frame(whichstat = c("mean",
                                     "sd upr",
                                     "sd lwr"),
                       value     = c(mean(cars$length),
                                     mean(cars$length)+sd(cars$length),
                                     mean(cars$length)-sd(cars$length)))

ggplot(data=cars, aes(length)) +
  geom_histogram(aes(y =..density..),
                 col="black",
                 binwidth = bw) +
  geom_density(col="black") +
  geom_vline(data=sumstatz,aes(xintercept = value,
                               linetype = whichstat,
                               col = whichstat),size=1)+
  labs(title='Length Plot', x='Length', y='Count')


问:
Remove product title when product is "out of stock" on WooCommerce shop and archives pages
I am running an art gallery website using WooCommerce and the owner does not want to show the product name/title if the product has been sold/out of stock.

I have got this far with putting together a function, but it doesn't work. I wondered if anyone could give me any tips?

// Hides title on Sold products
add_filter( 'woocommerce_shop_loop_item_title', 'remove_name', 10, 2 );
function remove_name ( $product ) {
    if ( ! $product->is_in_stock()) {
        $title = '';
    }
    return $title;
}
```

答:
This does what you want but still allows access to the product page.</p>
```<code>add_action( 'woocommerce_shop_loop_item_title', function() {

    global $product;

    if ( ! $product->is_in_stock()) {
        remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 );
    }

}, 5 );

add_action( 'woocommerce_single_product_summary', function() {

    global $product;

    if ( ! $product->is_in_stock()) {
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
    }

}, 1);
</code>```

Body:
This does what you want but still allows access to the product page.

add_action( 'woocommerce_shop_loop_item_title', function() {

    global $product;

    if ( ! $product->is_in_stock()) {
        remove_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 );
    }

}, 5 );

add_action( 'woocommerce_single_product_summary', function() {

    global $product;

    if ( ! $product->is_in_stock()) {
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
    }

}, 1);


问:
How to refactor code using if condition in javascript?
i have code like below,

```<code>React.useMemo(() => {
    if (isInProgress && data && data.Run) {
        if (data.Run.partial === true) { //how can i rewrite this
            setIsRunPartial(true);
        }
        else {
            setIsRunPartial(false);
        }
    }

}, [data, isInProgress]);
</code>```

here the data.Run.partial can be undefined true or false. how can rewrite above code to look clean. i have to call setIsRunPartial to true if data.Run.partial is true and false if data.Run.partial is false.

how can rewrite above code. could someone help me with this. thanks.

答:
How about

```<code>React.useMemo(() => {
    if (isInProgress && data && data.Run && data.Run.partial) {
        setIsRunPartial(data.Run.partial);
    }

}, [data, isInProgress]);
</code>```

If you are using babel and open to adding the @babel/plugin-proposal-optional-chaining package, this can even become

```<code>React.useMemo(() => {
    if (isInProgress && data?.Run?.partial) {
        setIsRunPartial(data.Run.partial);
    }

}, [data, isInProgress]);
</code>```

Body:
i have code like below,

React.useMemo(() => {
    if (isInProgress && data && data.Run) {
        if (data.Run.partial === true) { //how can i rewrite this
            setIsRunPartial(true);
        }
        else {
            setIsRunPartial(false);
        }
    }

}, [data, isInProgress]);

here the data.Run.partial can be undefined true or false. how can rewrite above code to look clean. i have to call setIsRunPartial to true if data.Run.partial is true and false if data.Run.partial is false.

how can rewrite above code. could someone help me with this. thanks.

Body:
How about

React.useMemo(() => {
    if (isInProgress && data && data.Run && data.Run.partial) {
        setIsRunPartial(data.Run.partial);
    }

}, [data, isInProgress]);

If you are using babel and open to adding the @babel/plugin-proposal-optional-chaining package, this can even become

React.useMemo(() => {
    if (isInProgress && data?.Run?.partial) {
        setIsRunPartial(data.Run.partial);
    }

}, [data, isInProgress]);


问:
Firebase Authentication: auth/auth-domain-config-required
I'm getting auth-domain-config-required errors when using firebase.auth().signInWithPopup(provider).

I've tried with Google and Facebook. I've tested on my hosted site, and it works fine. You can test it live: Quiver Chat Demo

I suspect there's a problem with localhost:3333... does it not like my port? I can't add a port to the Authorized domains list, and adding it to my authDomain: config doesn't help either.

Here's my auth code, but as you can see from the screenshots below, I tried a bunch of different authDomain values.

```<code>  <script src="https://quiver-four.firebaseapp.com/__/firebase/4.6.2/firebase-app.js"></script>
  <script src="https://quiver-four.firebaseapp.com/__/firebase/4.6.2/firebase-auth.js"></script>
  <script>
    // Initialize Firebase
    var config = {
      apiKey: "AIzaSyCzNxnQ6WCJKejq6SBd7NqhVskxEOmDq_Y",
      authDomain: "quiver-four.firebaseapp.com",
      databaseURL: "https://quiver-four.firebaseio.com",
      projectId: "quiver-four",
      storageBucket: "quiver-four.appspot.com",
      messagingSenderId: "1082528354495"
    };
    firebase.initializeApp(config);
  </script>
</code>```

Attempting localhost:3333

Attempting localhost

Attempting quiver-four.firebaseapp.com

The domains are added

答:
I had the same problem and my solution was to have a file in the root firebase.js with all the connection configuration:</p>
```<code>// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import {getAuth} from 'firebase/auth'

import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
  apiKey: "xxxxxxx_xxx_R-xxx-CDxxxxcg",
  authDomain: "qxxxxxx-xxxx.firebaseapp.com",
  projectId: "xxxxxx-xxxxx",
  storageBucket: "xxxxxxx-xxxx.appspot.com",
  messagingSenderId: "xxxxxxx",
  appId: "1:xxxxxxx:wxb:xxxxxxxxxxxxxx",
  measurementId: "G-xxxxx"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);

export const db = getFirestore(app);
export const auth = getAuth(app);
</code>```

Body:
I'm getting auth-domain-config-required errors when using firebase.auth().signInWithPopup(provider).

I've tried with Google and Facebook. I've tested on my hosted site, and it works fine. You can test it live: Quiver Chat Demo

I suspect there's a problem with localhost:3333... does it not like my port? I can't add a port to the Authorized domains list, and adding it to my authDomain: config doesn't help either.

Here's my auth code, but as you can see from the screenshots below, I tried a bunch of different authDomain values.

Attempting localhost:3333

Attempting localhost

Attempting quiver-four.firebaseapp.com

The domains are added

Body:
I had the same problem and my solution was to have a file in the root firebase.js with all the connection configuration:

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import {getAuth} from 'firebase/auth'

import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
  apiKey: "xxxxxxx_xxx_R-xxx-CDxxxxcg",
  authDomain: "qxxxxxx-xxxx.firebaseapp.com",
  projectId: "xxxxxx-xxxxx",
  storageBucket: "xxxxxxx-xxxx.appspot.com",
  messagingSenderId: "xxxxxxx",
  appId: "1:xxxxxxx:wxb:xxxxxxxxxxxxxx",
  measurementId: "G-xxxxx"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);

export const db = getFirestore(app);
export const auth = getAuth(app);