Page 1 of 1

Long to Wide

Posted: 20 Aug 2024, 08:04
by gabriellesod
Dear Professors,

I have an issue with transforming my data from the long to the wide format. Below is the code that I have written so far, but the last line where I try to do the actual tranformation does not seem to work.

settings <- list(
alternative_column = "Alt",
alternative_specific_attributes = c("strg_no", "strg_1", "strg_10", "strg_24", "peer_low", "peer_med", "peer_high", "es_yes", "es_no", "invcost"),
choice_column = "choice",
ID_column = "Record",
observation_column = "Q"
)

SOLAR_PV <- apollo_longToWide(SOLAR_PV_BASE, longToWide_settings = settings)


I was wondering if you could help me with what I am doing wrong?

Best regards,
Gabrielle Söderberg

Re: Long to Wide

Posted: 31 Aug 2024, 11:42
by stephanehess
Gabrielle

can you be more specific, please? Do you get an error message?

Stephane

Re: Long to Wide

Posted: 09 Sep 2024, 14:10
by gabriellesod
Hello again,

I receive the following error message after running the line of code:


> settings <- list(
+ alternative_column = "Alt",
+ alternative_specific_attributes = c("strg_no", "strg_1", "strg_10", "strg_24", "peer_low", "peer_med", "peer_high", "es_yes", "es_no", "invcost"),
+ choice_column = "choice",
+ ID_column = "Record",
+ observation_column = "Q"
+ )
> SOLAR_PV <- apollo_longToWide(DUMMY_CODED_EXPERIMENT, longToWide_settings = settings)
Error: object 'DUMMY_CODED_EXPERIMENT' not found
> SOLAR_PV <- apollo_longToWide(SOLAR_PV_BASE, longToWide_settings = settings)
Error in `x[r, vars, drop = drop]`:
! Can't subset rows with `r`.
✖ Logical subscript `r` must be size 1 or 48240, not 0.
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: Unknown or uninitialised column: `alt`.
2: Unknown or uninitialised column: `alt`.
3: Unknown or uninitialised column: `alt`.
4: Unknown or uninitialised column: `alt`.
5: Unknown or uninitialised column: `alt`.

Best,
Gabrielle

Re: Long to Wide

Posted: 09 Sep 2024, 20:32
by stephanehess
Gabrielle

difficult to know without trying this myself. Are you able to share the data and code with me outside the forum?

Stephane