I have created a function in R
, which accepts a string in it and outputs the pattern For example, for string, "abcabcabc"
, it outputs "abc"
, but if I have the string, "abcdefghi" / Code>, then this output,
""
Now, when running this function containing 1000 rows on the dataframe
, I get the output, but the output dataframe contains several rows
""
How can I remove it as a product? The output data frame is of the following:
1 2 abc 2 3 bc 3 4 t 4 5 "" 5 3 UI
Therefore, I want to 4 And in the form of 5 to remove the row with the value in the first two columns. Thanks!
is not an empty string NULL
(try is Null ("")
). What you're seeing is one factor level ""
(nothing between the quotes) You can extract the rows of the data.The data by searching this string.
xy [! Xy $ col% in% "", # I added! In order to actually select the inverse,
as an advertisement or if it is appropriate, you can redefining the level (xy)
at any other factor level Can merge.
This is an example
set.seed (357) xy & lt; - data.frame (first = C ("a", "a", "b", "b", "b", "", "", "", "", "d", "d") Second = Rainif (10)) xy [! Xy $ first% in% "", #) You can select multiple values (see below) Xy [! Xy $ first == "", # option, only one value # bonus xy [! You can select Xy $ %% c% ("a", ""),]
No comments:
Post a Comment