Q:

R Colnames and Colsums converting logical to numeric

Please check my sample code below where i created a dataframe with some NA values. My colnames(test)[colSums(is.na(test))>0]will give me the names of columns that has NA values. My question is when i subset the column names I should give a number or logical value for subsetting but i noticed that my colSums give me two outputs one is logical and another one is the names of columns itself. How does colnames takes only the logical part of my colSums??
test <- data.frame(matrix(rnorm(50), nrow = 5, ncol = 10))
colnames(test) <-c("xOne", "xtwo", "x3",    "x4","x5","xsix","x7","x8","xnine","x10")
test$x5[3:4] <-NA
colnames(test)[colSums(is.na(test))>0]

Here is the output of colSums(is.na(test))>0
xOne  xtwo    x3    x4    x5  xsix    x7    x8 xnine   x10 
FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE

A:

The first line is is the names attribute showing which named column corresponds to each result
> attributes(colSums(is.na(test))>0)
$names
 [1] "xOne"  "xtwo"  "x3"    "x4"    "x5"    "xsix"  "x7"    "x8"    "xnine" "x10"  

