I have responses where I solicited rankings of issues and the response I have for each individual look like this: structure(list(Rank = "Shifting angler preferences and behaviors;Increasing effort and fishing power;R3 (Recruitment, Retention, and Reactivation);Economic impacts;Climate change;"), row.names = c(NA, -1L), class = "data.frame") I am trying to create a column that gives the numeric… Read More Creating a col that adds a numeric value based on the order of a character string in R
for dataframe below, df <- data.frame(id = c(rep(101, 4), rep(202, 3)), status = c("a","b","c","d", "a", "b", "c"), wt = c(100,200,100,105, 20,22,25), ht = c(5.3,5.2,5,5.1, 4.3,4.2,4.1)) df id status wt ht 1 101 a 100 5.3 2 101 b 200 5.2 3 101 c 100 5.0 4 101 d 105 5.1 5 202 a 20 4.3… Read More How to insert rows in specific indices of dataframe containing sum of few rows above only in R pipe dplyr
I’ve been tasked with returning only rows with unique IDs but returning a row for every ID in SQL. How would I go about this? Logic: For primary row, select where JOB_INDICATOR = ‘P’. If there are multiple rows, then use the record where PRIM_ROLE_IND = ‘Y’. If there are still multiple then select the… Read More How do I conditionally select a unique value in SQL?
I have two columns Project ID and Project Number in my dataframe hpds_all_clean with NAs in them, and I’m trying to replace all NAs occurrences with "Undisclosed Project ID" and "Undisclosed Project Number". Here are some of my attempts which have the same error: target of assignment expands to non-language object Using gsub(): hpds_all_clean %>%… Read More Replace all occurrences of columns in a data frame