I have a data set which is read into a dataframe as characters. The characters have numerical portions, and some include a "/T". For example:
df <- data.frame(col1 = c("237.7", "191.8", "95.4/T", "48.1"),
col2 = c("234.3", "766.4/T", "167.6/T", "401.6"))
> df
col1 col2
1 237.7 234.3
2 191.8 766.4/T
3 95.4/T 167.6/T
4 48.1 401.6
What command can I use to identify the rows and columns in the dataframe which contain data with "/T"? The following will clearly not work:
which(df == "/T", arr.ind = TRUE)
Also, I want to extract only the numerical portion of the data from the entire dataframe, or remove all "/T". My actual example has far more columns and rows than the example I provide above. I have seen the following examples in Stack Overflow:
Extracting decimal numbers from a string
Extracting numeric portion from a character in the Data Frame
The above links provide solutions to vectors or a column of the data frame. How can I generalize these solutions to go systemically throughout the entire dataframe?
Thanks.