In stack.data.frame(data) : non-vector columns will be ignored

I need to stack my data, but I need my factors to remain in my dataset. Instead, R lists the name of the value where the factor should be, and I do not know how to correct it. Any help is greatly appreciated.

R-Package:
package utils

Dataset
2021HelicopterPlanWithResponseData.pdf (44.0 KB)

R-code
stacked.data = stack(data)
names(stacked.data) = c("hangtTime", "Wing.Length")

Output:
In stack.data.frame(data) : non-vector columns will be ignored

hang.time Wing.Length
2.80 hang.time.in.seconds
2.70 hang.time.in.seconds
2.63 hang.time.in.seconds
2.82 hang.time.in.seconds

Please provide your data via sharing the output of

dput(data)

Also please share with us what package/library you load which contains the stack function you are wishing to use.

I have supplied the information you requested. Unfortunately, my dataset was smaller than the output you asked for; since there are strict rules on posting, I decided my data set would be better.

I find what you have presented here to be confusing, but I will make an honest attempt to engage.

Is your issue that you have 4 columns, and you wish to have 2 ?
that you have winglength twice and hang time in seconds also twice , and you would rather have them once each in a longer frame, than the wider frame you seem to be saying that you have?

as a sidenote, I don't see anything that looks like a factor per say. unless perhaps you have decided to encode Wing.Length as a factor rather than as a numeric ?

No, if you had looked at the upload rather than having me post the dataset they were in two columns. Wing. Length is a repeating factor of 4, 4.5, 5, 5.5, and 6. They are in two long columns in my data set. However, still need to stack it.

ok, are you clear on what 'stacking is ' ?
I think it would be best if you described the resulting dataset that you want to end up with. Then perhaps there can be an attempt to achieve that....
if your data already is long then perhaps you are trying to make it wide ? that would be unstack if anything...
However I think stack and unstack have requirements vis the data balance , so probably tidyverse functions like pivot_wider (/pivot_longer) would be more flexible and appropriate for you.

Did you look at the output and the problem I need addressed? It changes Wing.Length completely and yes I need the data stacked. In order to complete the Wilcox.test, Dunn test, Krustal test. Wing.Length needs to remain a factor.

Sorry for not helping you. I will pass.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.