UM-R-for-EnvSci-Registered-Student / General-Discussion

Public repo for general discussion about the course and assignments
1 stars 0 forks source link

Saving a GT Table in Results Folder #20

Open madelinestanley opened 3 years ago

madelinestanley commented 3 years ago

I have created a GT summary table for the week 11 homework assignment, but I am having trouble saving the table into the results folder. I have tried using the gtsave() function, but I also want to integrate here() so I can direct it to a particular folder.

Any advice on how to do this?

Thanks!

peperg commented 3 years ago

@madelinestanley,

There is a previous issue that provides a solution to use gtsave() to save as a .pdf.

If your problem is more with the implementation using here(), would you be able to push the code as you have it now and i can take a look?

madelinestanley commented 3 years ago

Hi Pepe,

I have pushed the Rmd to the repo. I did follow the gt save as described before, but am unable to make it work.

I also am having trouble with developing the plot. It says that my x value is non-numeric, but is a year. I was curious how I can set a year as factor when working in multiple tibbles? I tried to do a mutate in lines 116 onward before creating the mutate(plot) code, by doing mutate(year=as.factor(data$year)) or something along these lines, but it is not working. Any advice on this as well?

madelinestanley commented 3 years ago

So for anyone else having this problem, I was able to fix my gtsave problem by installing the webshot package and then installing another function within that as requested in the console. That then allowed me to save my gt table in my results folder as a pdf/png.

However, Pepe, my other question my ggplot remains.

Thanks

peperg commented 3 years ago

Awesome on the saving the table front. Let me take a look on the other thing.

madelinestanley commented 3 years ago

@peperg I will re-push my current code to github so you have the most up to date version.

peperg commented 3 years ago

@madelinestanley, ok, your assessment was correct. Your years are still considered as a character variable, that is why it cannot properly plot them in a continuous scale. This is because they came from a step in which we extracted them from a string. Numbers are characters too, if you don't specify that they are numbers and they came from a character string, they are still a character string. You will need to transform them to numeric. I recommend yo do this early in the code, before any of the modelling steps as well.

Also, as a side note print() doesn't seem to like gt objects. You can just write the object name alone and it does the same as the print() function, and... it works with gt objects!

Pepe

madelinestanley commented 3 years ago

Hi Pepe,

Great thank you. I was trying to set them as numeric later on. I will try doing earlier and hopefully that helps my problem. I will let you know if I have any further questions.

Madeline