Open pearsonkm opened 5 years ago
To your first question, have you installed tmap in the past?
count_year should be getting created in the line with count(), so I'm not sure why that is an issue. if you create that variable earlier after creating Year does the code work?
You might try replacing the + with pipes:
https://community.rstudio.com/t/why-cant-ggplot2-use/4372/
It is sometimes easier to create your dataset first because some of the geoms don't play well with pipes.
pet_species <-
pet %>%
group_by( Species ) %>%
count( Year, name="count_year" )
ggplot( data=pet_species, ... )
@ejvanholm I installed tmap before running that line of code
Now, R is saying it is having trouble finding "Species"
@lecy Thanks, I will try that if it seems to be an issue!
That's one of the bigger complications with Markdown documents that I've always struggle to explain. When you're writing a Markdown, the working direction defaults to the file that the document is saved in. So you don't need to set your working directory if the data you're uploading is in the same folder that your Markdown is being written in to, but setwd() doesn't work. That's the easy solution.
Even though the folder that the document is saved in becomes your working directory, you can grab data from other folders. To move down a folder, you need to use a slash, and to move up a level you use two dots "..".
So for example, if I have three folders, let's say "Class", "Labs", "Lab 7", and I have my document saved in Labs I can move up to Class or down to Lab 7. read.csv("Lab 7/Data.csv")
read.csv("../Data.csv").
It definitely isn't my favorite feature of Markdown
@ejvanholm Ah, thank you! Okay, I worked it out.
Now, the column Species is unknown. Any ideas as to why that is?
If the data i loading I don't know why that would be an issue. The group_by() was initially done prior to count(), which might make the difference. If that doesn't work, check the names in the data set to make sure that everything is loading correctly.
I think now str_sub is the issue - R cannot find the function.
All the data set names are correct. Species matches Species.
Do I have to change the License.Issue.Date column to just include years?
If the issue is with str_sub, you need to make sure that the package stringr is loaded on your computer and active. Make sure you've run install.packages("stringr") and that library"stringr) is in the Markdown document.
The reason for that line of code is to change the dates from daily to annual figures. You can run the code with the daily data and see how the plot looks to you. Making a good, intelligible plot is what matters most.
@ejvanholm I have both of this commands installed. str_sub might be working now, but again I am having trouble with count(). I will email you my .Rmd if that's alright?
Hi all, I have a few errors related to Lab 7. The package tmap doesn't seem to be loading.
Second, the second visualization isn't loading because the object 'count_year' cannot be found. Am I supposed to define count_year?