How to create empty columns when selecting columns from a data frame by using NA indexes?

Viewed 1659

here is what I mean:

indexes=c(1,NA,4)

Now if I do the following I will obviously get an error because of the NA:

mpg[,indexes]

So for the NA index I need an empty column, in other words I want to see:

manufacturer  unknown   year
     audi        ""     1999
     audi        ""     1999
     ...         ...     ...
1 Answers
Related