I repeat I am new to R and did not figure out just yet all the idiosyncrasy of R. I do not know where I am missing the simple point here.
I try to plot a histogram with ggplot and do not manage to label my x axis properly and to get rid of the NA values I have (see small data set provided): http://ubuntuone.com/7iL1UG0YxHpKs0kXN8uQhC (8,2 KB)
sex <- factor(rawdata$Sesso)
ggplot(rawdata, aes(x=sex)) + geom_histogram() + xlab("") + ylab("Number of Persons") + ggtitle("Gender of Persons") + scale_x_discrete(breaks=c("1", "2", NA),labels=c("Male", "Female", "NA"))
I get either this:
or that:
This is what I tried so far to address that issue:
sex <- sex[complete.cases(sex),]
ggplot(na.omit(rawdata), aes(x=sex)) + geom_histogram() + xlab("") + ylab("Number of Persons") + ggtitle("Gender of Persons")
ggplot(rawdata[!is.na(rawdata$Sesso),], aes(x=rawdata$Sesso)) + geom_histogram() + xlab("") + ylab("Number of Persons") + ggtitle("Gender of Persons")
sex <- factor(rawdata$Sesso,exclude=NULL)
But to no avail!