DS4PS / cpp-528-spr-2021

https://ds4ps.org/cpp-528-spr-2021/
0 stars 0 forks source link

Lab03- here::here() and storing graphing functions #25

Open gzbib opened 3 years ago

gzbib commented 3 years ago

Hello @cenuno ,

I was checking some functions that I can move from RMD to .R file, however, there were given only 2 functions ( jplot and compafe_dfs). Should we look for other functions to create on our own?

I tried creating the below functions but when I called them from my RMD file, nothing happened:

display1 <- function (){

  axis( side=1, at=seq( from=0, to=1000, by=100 ), 
        labels=paste0( "$", seq( from=0, to=1000, by=100 ), "k" ) )

  abline( v=seq(0,1000,100), lty=2, col="gray80" )

  text( 550, 4000, labels="Median Home \nValue in 1990", 
        col="darkslateblue", cex=1.8 ) 

}

display2<- function (){

  abline( v=seq(0,1000, 100 ), lty=2, col="gray80" )

  text( 550, 3500, labels="Median Home \nValue in 2000", 
        col="darkslateblue", cex=1.8 )

  axis( side=1, at=seq( from=0, to=1000, by=100 ), 
        labels=paste0( "$", seq( from=0, to=1000, by=100 ), "k" ) )  

}

I used the following here() function:

import:: here ("display1", .from = here:: here ("labs/wk03/utilities-lab03.R"), .character_only = TRUE)

import:: here ("display2", .from = here:: here ("labs/wk03/utilities-lab03.R"), .character_only = TRUE)

I am not sure what is the issue exactly because there is no error message.

Thanks a million.

cenuno commented 3 years ago

Hi Ghida,

This is a good question. I'm unsure if one can store R's base level graphing functions into a higher level function (such as your display1 function). I can look into this further and update you on my progress.

gzbib commented 3 years ago

Hello Sir,

It actually worked, after all, I missed calling the arguments in RMD at first.

I have another question regarding part 3 where I am trying to create my cartogram but I am not getting any display, although I tried to change the (xmin, xmax, ymin, ymax):

image

image

cenuno commented 3 years ago

The appearance of the legend makes me think this may just be an RStudio chunk issue. Is it possible for you to see the graph after knitting the RMD file?

gzbib commented 3 years ago

I wanted to test the knitting part but for some reason, I started getting a new error as below. I tried clearing the environment and re-run everything, but it is not working:

image

cenuno commented 3 years ago

Hi Ghida,

The error message is a bit verbose but it provides you the information you need to debug this error:

You're creating a data frame named df whose dimensions are not uniforn; said differently, one of the columns within this data frame has more elements than the other. Isolate which one that is, understand why, and then update the code.

Let me know how it goes!