I have this data frame
atac.v1.pbmc.5k.possorted.bam.bam possorted.bam.bam
chr1.9941.10736 NA NA
13196 4348
chr1.10918.11476 NA NA
2624 658
chr1.20874.21591 NA NA
652 343
and I would like to remove the NAs and get this:
atac.v1.pbmc.5k.possorted.bam.bam possorted.bam.bam
chr1.9941.10736 13196 4348
chr1.10918.11476 2624 658
chr1.20874.21591 652 343
There are many questions about removing NAs, but I couldn't manage to use any of them to do this. I tried remove NAs and various code to remove white spaces, but wasn't able to.
For R a similar question was already asked here .
Thus when you want to solve it in R you can eg. use the following:
df = data.frame('name'=c('a',NA,'b',NA), 'val'=c(NaN, 1, NaN, 5))
library(dplyr)
na.omit(transform(df, name = lag(name)))
The df is only given to have a minimal running program.
Hi @RicS and @Robert Wilson, after I put dput(df) i get this
"", "s37d5.35353959.35354523", "", "s37d5.35354792.35354991",
"", "s37d5.35364108.35364390", "", "s37d5.35365154.35365375",
"", "s37d5.35371939.35372823", "", "s37d5.35373959.35374177",
"", "s37d5.35382938.35383151", "", "s37d5.35391117.35391934",
"", "s37d5.35391998.35392218", "", "s37d5.35411836.35412109",
"", "s37d5.35427424.35427818", "", "s37d5.35431087.35431415",
"", "s37d5.35431545.35431772", "", "s37d5.35449122.35449455",
"", "s37d5.35449665.35450121", "", "s37d5.35451782.35451987",
"", "s37d5.35453892.35454283", ""), c("atac.v1.pbmc.5k.possorted.bam.bam",
"possorted.bam.bam")))
I just copied and pasted some of it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.