I have a dataframe which contains value of log2fold change but it contains inf and NA values i searched all over stack-exchange tried their solution but most of them seems not working few of them works but its not giving me the desired output ,need help it should't be that difficult i suppose .
my data frame
GENE_NAME `HSC_VS_CMP` `HSC_VS_GMP``HSC_VS_Monocytes`
ACTL6A -0.20084399 0.297430 -0.350876000
ACTR8 -0.2925280 -0.158551 1.10747
AICDA inf NA inf
ANP32B -0.6549 -0.615725 -0.35858
I get error like this " default method not implemented for type 'list' "
So please suggest me how to remove all the inf and NA from the data frame
What have you tried (with code)? Presuming you just want to remove the rows, it's a simple (A) apply(d, 1, function(x) anyis.na(x) || is.infinite(x))) and then (B) subsetting accordingly.
Alternative without using
apply
:Note: either way, you may need to take special care of the GENE_NAME column. I suspect your are having trouble with that in your attempts so far (but as mentioned by Devon, please show us the code).
You can't
is.infinite()
dataframes, which is probably what resulted in the originally reported error.You are right! (didn't do enough testing...) Find this a bit inconsistent since
is.na()
works fine. Further searching points to this SO post where a viable solution is to implementis.infinite.data.frame
method, e.g.:what is the way to do it ?the way you suggested ,I know there are multiple ways but since Im learning and the at the same time I have to use them in the data sets so i have to just read and see which one is working.
So can you show me how do i remove NA ,inf and 0 if any from my data frame in a concise code
I can take out the GENE_NAME column and apply the same
I tried this
}
What is the desired output?
well I want to replace inf and NA with 0 .