You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and helper functions; related to #1@bselden and @JWMorley you might want to be aware of how I did this, and how it differs slightly from the video I link in Issue #1. Basically what I changed is something I already pointed out in the video: I wrote a function to avoid introducing inconsistencies.
# Function to see if the corrected version of a bad spp name
140
+
# already exists in a data set; if it does,
141
+
# then the wrong version is overwritten with the content
142
+
check.and.set<-function(wrong, corrected){
143
+
check<-spp.key[,corrected%in%spp]
144
+
if(check){
145
+
# if the corrected name already exists,
146
+
# make sure to have all the rows with the wrong name match up with the corrected rows,
147
+
# that way if we make any changes, both sets get updated
148
+
# For example, if a name XX is wrong, and Xx is the corrected name,
149
+
# say that we are going to set the trophic level of Xx to 42,
150
+
# but the current entry is 40. If we were to say 'change all rows
151
+
# with name XX to have a TL to 42, and also switch the bad XX name to the good Xx name',
152
+
# then we would have some rows with TL of 42 (the ones that originally had the bad name), and
153
+
# some rows with TL of 40 (the ones that originally had the corrected name).
154
+
# Thus, we have to get the names and other content to match before changing anything.
155
+
# Bottom line is that we need to be sure that all things are consistent, and that this requires
156
+
# more care when we are switching the 'spp' of an entry to a 'spp' that is already there.
157
+
#
158
+
# stopifnot(all(sapply(spp.key[spp==corrected], function(x)length(unique(x[!is.na(x)]))<=1))) # this check is to ensure that the contents of the corrected data set do not contain conflicts (NA's aside, which may or may not be a good idea)
0 commit comments