So I want to remove all cells that are blank within my dataset. So for example, if I had something like this, where the (..) represents blank numbers:-
1 10 .. 4
If your data.frame is named df
then:
df[df == ".."] <- NA
In order to get NA
s, then:
func<-function(i){
x<-as.numeric(as.character(df[,i][!is.na(df[,i])]))
xna<-as.numeric(as.character(df[,i][is.na(df[,i])]))
newx<-c(x,xna)
}
do.call(cbind,lapply(1:length(df[1,]),func))
> do.call(cbind,lapply(1:length(df[1,]),func))
[,1] [,2] [,3] [,4]
[1,] 1 10 10 4
[2,] 14 9 12 8
[3,] NA 8 NA 16