0

I have a dataset which contains multiple columns - around 30 but I would like to get the names column and years column if the years are bigger than 2000. I know how to do it if there would be both columns with numbers, but in my case one has names and the other numbers:

ys <- DF[DF$year<= DF$names, ] # this would work if both would contain numbers
counts <- table(names, year)
barplot(counts, main="Names by year",
        xlab="Years",ylab = "Names(count)", col=colorRampPalette(brewer.pal(name="Dark2", n = 8))(18),
        legend = rownames(counts))

And then as you can see above, I would like to use the result of that in the barplot.

Chris Ruehlemann
  • 20,321
  • 4
  • 12
  • 34
  • Welcome to SO ! Please provide a reproducible example fo your dataset by following this guide https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example, it will make easier to assist you. – dc37 Apr 17 '20 at 16:41
  • If you want to subset your dataframe on those rows where "the years are bigger than 2000" you can do it like that: `ys <- DF[DF$year > 2000, ]` – Chris Ruehlemann Apr 17 '20 at 17:13
  • @ChrisRuehlemann yea but how do I display only two columns than. Your example will display all columns which are around 30 –  Apr 17 '20 at 17:27
  • 1
    Sorry, without provision of any sample data I find it impossible to try and help – Chris Ruehlemann Apr 17 '20 at 17:32

0 Answers0