Closed Tilmon closed 4 months ago
@Tilmon
It looks like your co2
dataset lacks the expected column isic_4digit
. Are you using the correct data?
Here I remove it and get the same error:
devtools::load_all()
#> ℹ Loading tiltIndicator
companies <- example_companies()
products <- example_products()
products$isic_4digit <- NULL
emissions_profile(companies, products)
#> Error in `check_matches_name()` at tiltIndicator/R/pad_column.R:2:3:
#> ! The data lacks a column matching the pattern 'isic_4digit'.
#> ℹ Are you using the correct data?
Created on 2024-02-15 with reprex v2.1.0
@maurolepore as you can see in the script I shared, I didn't use any external data. Isn't the co2
dataset in the package as toyData?
CORRECTION @maurolepore
Apologies, me stupid. The only "problem" is that on this page, the function is specified the following way
emissions_profile(companies, co2, low_threshold = 1/3, high_threshold = 2/3)
while further below on the same page or on the homepage of the article, it's specified the following way
both <- emissions_profile(companies, products)
I.e., the only "issue" is that in one case the toyData are given the name products
, in the other co2
. Yesterday night, my brain was apparently not able to identify this anymore and I thought that it's two different functions that use different data :) But probably still good to align naming conventions within the same article?
cc' @AnneSchoenauer
it happens :-)
I've spent countless nights debugging code that I then fixed in my head while showering the following morning.
It happens less often since I got in the habit of writing reprexes. Writing a reproducible example is a systematic approach to solving problems with a strong focus on the minimal elements required to comuniicate the problem. 90% of the reprexes are never shared because the system is so powerful that people end up finding their own bugs.
A reprex is so important that if you try to open a new issue in tidyverse packages you'll get a pre-populated message asking you to share a reprex:
https://github.com/tidyverse/dplyr/issues/new
Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on <https://stackoverflow.com/> or <https://community.rstudio.com/>.
Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading <https://www.tidyverse.org/help/#reprex>.
---
Brief description of the problem
```r
# insert reprex here
Note we have a ds-incubator series about reprex -- but probably the overview is enough: https://youtu.be/erv1yJaNID8?si=NTxiImvqPn567KEt
Actually reprex is so easy to use that even that video might be an overkill, so you may want to first have a look directly at the examples here: https://reprex.tidyverse.org/
Hi @maurolepore ,
running the function
emissions_profile
of tiltIndicator, I encountered an unexpected error, please see screenshot below. Pls also find my R Script here: https://drive.google.com/file/d/1AE-8E6OY22g2CuWnMfNofaI2NOKDcyzf/view?usp=sharing Not an urgent issue because the following functions work but still good to solve as it's our user-facing work.WORKS:
DOESN'T WORK![Image](https://github.com/2DegreesInvesting/tiltIndicator/assets/88719608/138b8c5a-7d9a-4b1c-bc87-43efffc4dbbc)
I wonder if it's the case because I use the dataset names from the main page of the article, i.e.
companies
andproducts
instead ofco2
. But in that case it would be good to align the wording.cc' @AnneSchoenauer