Entering edit mode
2.8 years ago
logbio
▴
30
I have dataframe like below
child = data.frame(girl = 1:10, kn = NA, boy = 5)
And i want to understand the following code meaning step by step for these dataframe
df3 %>% mutate(t = ifelse(is.na(kk), select(., matches('a')) %>%pull, ll))
Thank you for helping
This question makes no sense. There is no connection between that data.frame and its colnames and the tidy chunk below. What is "a"? There is no kk in
child
, is it kn, and what isll
? Please invest some effort and put together a proper question.I am new to bioinformatics That's why I'm looking for help too.
There is some communication gap then - either your advisor gave you an incomplete/wrong problem or you're missing something when you share this with us.
For this code to work, the df3 must have columns, kk, ll, and any column with an
"a"
letter in it, for example"bay"
.The meaning step-by-step:
ifelse(is.na(kk),
- check if kk is NAselect(., matches('a')) %>% pull
take the value from column with a column name that has"a"
in it., ll))
if the value is not NA, then use the values fromll
column.mutate(t =
finally assign the value from ifelse into new column tThank you for helping
How is this related to bioinformatics and not a simple R question?
Actually my advisor was given as starting content for R
That makes this plain old R, not really bioinformatics. Please search StackOverflow and read dplyr manual pages.