I’m loading a table like this:
mydata <- read.table("c:\\file.tab", header=TRUE, sep="\t", quote="\"")
I can calculate the percentage of blank entries in the COLUMN1_NAME column like so:
sum(mydata$COLUMN1_NAME == "")/nrow(mydata)
But I have a lot of columns. I’d like a way to loop throw and calculate this percentage for each column instead of copying and pasting the above line and manually changing the column name. I’m pretty new to R, so any help is appreciated.
Use the square brackets with a number rather than a name.
Etc.
See
?Extract. Also you could get the names programmatically and work with those, but it’s just an extra step: