Skip to main content

All Questions

Tagged with
0 votes
3 answers
45 views

If ... else : the condition has length > 1

I am trying to classify variants according to their type (polymorphisms, insertion or deletion). Here is a snippet of my input : A T G C T AG C T TT C AT CC Here is the dput output, if you need ...
user25420086's user avatar
0 votes
1 answer
42 views

Recoding of item files with if-loop in R [closed]

I´m a uni student who recently started learning to use statistical analysis code with R. Unfortunately I´m not the best yet, and my prof. isn´t really willing to help. Which is why I´m hoping that ...
Alina Dzaferovic's user avatar
2 votes
2 answers
38 views

How do I use an error as input for to if clause (in R)

This workflow will either produce a value or an error. I want that, in the event of an error, will perform an arbitrary code (it could print a message to the console, create an objet). a <- 1 b <...
BMLopes's user avatar
  • 586
0 votes
3 answers
66 views

nested ifelse in R with "condition has length > 1" warning

I have the below data frame and would like to impose some rules to generate new values: column_1<-c("B","B","B","B","A","A","A",...
Bubbles's user avatar
  • 565
0 votes
1 answer
31 views

Multi-Column Conditional Highlighting with KableExtra and ifelse statement

Solution Below Original Question: I am attempting to highlight the text of a KableExtra table to indicate where group observations increase or decrease by year. However, I am receiving an error about ...
Shaq's user avatar
  • 1
0 votes
2 answers
47 views

use group_by function with if/then/else condition

I have a dateframe like this one with variables corresponding to death on inclusion and variables corresponding to death on follow-up visits: Id death_inclusion date_death_inc follow-up ...
lM__3's user avatar
  • 91
1 vote
2 answers
56 views

Calculate Beginning and Ending Balances Using R

I am trying to follow a process where I make a contribution to an investment every period, that investment grows or shrinks over time and then I have an ending balance. The next period I take that ...
JohnS's user avatar
  • 21
0 votes
1 answer
62 views

issue with mutate and if's in R 4.4.0 [duplicate]

I updated R to it's new version 4.4.0 and I'm finding errors which I didn't had for example, this used to work: temp <- data.frame("a"=c(1,2),"b"=c(3,4),"c"=0) temp &...
Mikael's user avatar
  • 131
2 votes
2 answers
78 views

How can I convert R tibble character variable (with both characters and integers) to integer type with integers and NA_integer_?

I have a set of data frames with a variable age. In some data frames, age is numeric type (containing integer age values, and -1 and 99 as missing values). In others, it is character type (containing ...
sesnelson's user avatar
0 votes
2 answers
43 views

How to reassign values based on grouping and dates (R)

I have a dataframe that looks like the following: grp1 <- c('A','A','A','A','A','A', 'B','B','B','B','B','B', 'C','C','C','C','C','C') grp2 <- c('PQ2','PQ2','PQ2','PQ2','PQ2',...
user2813606's user avatar
0 votes
1 answer
67 views

R Setting up an if statement inside a for loop

I am extremely new to learning coding so please be patient with me. I have a list made up of two data frames and I need to add a value into a new column col3 based on another column col1. I apologize ...
Lazzie's user avatar
  • 1
2 votes
2 answers
63 views

for loop and if else [closed]

df_test2 <- data.frame(test1=c("in", "out"), test2=c(1:2)) > df_test2 test1 test2 1 in 1 2 out 2 for (i in df_test2$test1) { for (j in df_test2$test2) { ...
Bubbles's user avatar
  • 565
2 votes
4 answers
81 views

How to apply multiple conditions when using %in%?

I have this example where I wish to create the column m where if x1 or x2 or x3 = "A" or "B" then m = 1, otherwise m = 0 df <- data.frame(x1 = LETTERS[1:10], x2 = LETTERS[2:11], ...
An116's user avatar
  • 903
0 votes
1 answer
27 views

ggplot - Using ifelse inside aes with geom_line gives unlogic result

I am trying to create a chart with two data dependent line formats: the "x opp"-data (high values) with a solid line, and the "x ned"-data (low values) with a longdashed line. ...
Martin Liungman's user avatar
1 vote
4 answers
49 views

R - assigning value to a new variable based on the results of the ifelse function

I have some agarose gel band migration data and I would like to automatize the process in terms of assigning values from control lanes to the treatemnt lanes. The data that I get out of the band ...
BioNewb's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
306