1

   position price              model                url  
      <int> <chr>              <chr>                <chr>
 1        1 "\nab 1.699,00 €\~ "\nGROUND CONTROL\n" NA   
 2        2 "\nab 1.999,00 €\~ "\nROOT MILLER\n"    NA   
 3        3 "\nab 3.099,00 €\~ "\nPIKES PEAK\n"     NA   
 4        4 "\n"               "\nTHE BRUCE\n"      NA   
 5        5 "\n"               "\nCOUNT SOLO\n"     NA   
 6        6 "\nab 1.849,00 €\~ "\nPSYCHO PATH\n"    NA   
 7        7 "\nab 2.599,00 €\~ "\nTHRILL HILL\n"    NA   
 8        8 "\nab 2.899,00 €\~ "\nTHRILL HILL TRAI~ NA   
 9        9 "\nab 2.149,00 €\~ "\nSOUL FIRE\n"      NA   
 

this is a 33x4 tibble I created. I would like to get rid of the whole row without price info e.g. 4th 5th rows(they do not have the data bc the product is not for sale). I thought of the filter or subset function with condition nchar(...)!=0 but I am having trouble indicating that column. Can you help me?

Phil
  • 7,287
  • 3
  • 36
  • 66
hased
  • 63
  • 7

1 Answers1

1

We can use a comparison operator to check whether the 'price' column is not equal to string "\n" to subset the rows

df2 <- subset(df1, price != "\n")

nchar will not be 0 when there is \n

nchar("\n")
#[1] 1
akrun
  • 874,273
  • 37
  • 540
  • 662