Questions tagged [mutated]

77 questions
0
votes
2 answers

Double condition ifelse in combination with str_detect

I want to create another column which gives 1 if one of the words in the pattern is present in the column RoleName OR FulltextDescription, this is because it might be that the RoleName only says 'VP' while the FulltextDescription says that the…
Robbert
  • 93
  • 5
0
votes
1 answer

To apply mutate with an other line

I have a table and I would like to add a column that calculates the percentage compared to the previous line. You have to do as calculation takes the line 1 divided by line 2 and on the line 2, you indicate the result Example month <-…
0
votes
1 answer

I would like to create new columns for the original table in R

This is my current coding for data wrangling. crime_89 <- crime %>% filter(state_name %in% c("Georgia", "Pennsylvania", "West Virginia"), !is.na(rape_legacy)) %>% mutate(treat = case_when(year < 1989 ~ 0, TRUE ~ 1), …
SSW
  • 31
  • 3
0
votes
1 answer

Ifelse statement order with is.na using R Dplyr Mutate

I created some sample data below to help illustrate my question. library(dplyr) col1 = paste(rep('var',5),seq(1:5), sep = "") Value = c(1,1,0,NA,NA) p1 <- data.frame(col1,Value) > p1 col1 Value var1 1 var2 1 var3 0 var4 NA …
hwestblvd
  • 57
  • 1
  • 5
0
votes
1 answer

Including a body in useMutate using restful react

I am learning restful-react and trying to use the useMutate feature as a POST request but I need to include a payload. I see in the documentation there is the options to mock data to the console but Im not sure of how I can I actually include the…
CourtneyJ
  • 458
  • 6
  • 19
0
votes
2 answers

How to mutate a list of dataframes simultaneously in R

I am trying to mutate a dataframes which are part of a list of dataframe all at the same time in R Here are the functions I am running on the dataframe, this is able to mutate/group_by/summarise ebird_tod_1 <- ebird_split[[1]] %>% #ebird_split is…
0
votes
1 answer

Create new column depending on multiple other column character strings in R

I'm working on food consumption among mother-infant dyads and my data shows who is in proximity to my individual of interest when the eating behaviour is recorded. The data structure looks like this (very simplified): Individual Food…
Juliette
  • 41
  • 6
0
votes
0 answers

mutated function in several columns

I have a data frame like this one, with several rows for the same subject ID alcohol_1 alcohol_2 1 1 0 1 0 1 2 0 1 2 0 0 When I have "1" for the alcohol_1 and alcohol_2 columns, I would like to be…
lM__3
  • 85
  • 6
0
votes
1 answer

change in state does not re-renders the component

const [list, setList] = useState([]); useEffect(() => { const getData = async () => { let storeList = []; for (let i = 0; i<50; i++) { try { const token = await…
Ketul s
  • 55
  • 1
  • 8
0
votes
1 answer

R: Fill in NAs by multiple groups summing up lagges of two variables

I try to fill in the NA values of column N based on the lag of N and the lag of an additional column. The problem is that it fills in the second row, but not all of them. Here is my code. ```{r} library(tidyverse) library(zoo) # toy data ---- df <-…
Y_gr
  • 111
  • 5
0
votes
0 answers

How do I implicitly change an instance attribute by modifying another attribute of which it is comprised?

So I have a class and initiate the instances to have attributes as described: class Orders(): def __init__(self, country='USA', product='Shoes'): self.profile = 'https://website.com/user' self.token = 'leHAiOjE2Nz' …
0
votes
1 answer

How to create variables from unique rows in R

This is how my dataset looks: | hhid | food_code | consumed |.....| |----------|--------------|--------------|.....| | 479 | 01.1.1.1.0.3 | 0.66666667 |.....| | 479 | 01.1.1.2.1.3 | 0.00000000 |.....| | 480 |…
0
votes
1 answer

Mutate IF ELSE MULTIPLE COLUMNS

I have a file (df) with two columns (LAB and OID)... I would like to create a new variable on df file: column3(OID_new), using the information of Columns 1(LAB) and 2 (OID): LAB OID OID_new 12 NA 12 13 NA 13 14 NA …
0
votes
1 answer

How can I make this mutation into a function?

I have a bunch of variables, where I have these alternative text answers. Some of these alternative answers correspond to an answer in the multiple choice selection, so all I want to do is to recode these values back to the numerical format. I made…
Victor Nielsen
  • 443
  • 2
  • 14
0
votes
1 answer

Mutate with ifelse multiple conditions in R

I have dataframe like below monkey = data.frame(girl = 1:10, kn = NA, boy = 5) And i want to understand the following code meaning step by step monkey %>% mutate(t = ifelse(is.na(kn),.[,grepl('a',names(.))],ll)) Thank you everyone in advance for…
user16605750