Jarno Wolters
Jarno Wolters

Reputation: 3

Argument is of length zero in if statement using R

Does anyone know how I can solve this problem?

for (x in 1:nrow(homer1)-1) {if ((homer1$Start [x+1] +1) == homer1$End [x]) {homer1$annnot_prom <- paste(homer1$Detailed.Annotation, homer1$Nearest.PromoterID, sep="_") } else {homer1$annnot_prom <- homer1$Detailed.Annotation} }

Error in if ((homer1$Start[x + 1] + 1) == homer1$End[x]) { : 
  argument is of length zero

Upvotes: 0

Views: 1791

Answers (1)

Thomas
Thomas

Reputation: 44525

Add some brackets to your for loop:

for (x in 1:(nrow(homer1)-1))

Upvotes: 1

Related Questions