how to keep colnames when reshaping?
up vote
0
down vote
favorite
I reshaped a dataset from wide to long, but I'd like to keep column names instead of column numbers. Is there a way of doing this without having to write out all the column names? I need columns 5 to 38, as seen in the code below. My code is:
cc_hear_reshaped <- reshape(cc_hear, varying = c(5:38),
v.names = "Hearing",
timevar = "Org",
times = c(5:38),
new.row.names = 1:1000,
direction = "long")
Any help appreciated. Thank you so much!
EM
r reshape
add a comment |
up vote
0
down vote
favorite
I reshaped a dataset from wide to long, but I'd like to keep column names instead of column numbers. Is there a way of doing this without having to write out all the column names? I need columns 5 to 38, as seen in the code below. My code is:
cc_hear_reshaped <- reshape(cc_hear, varying = c(5:38),
v.names = "Hearing",
timevar = "Org",
times = c(5:38),
new.row.names = 1:1000,
direction = "long")
Any help appreciated. Thank you so much!
EM
r reshape
1
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not usestr()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?
– Tung
Nov 11 at 1:37
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I reshaped a dataset from wide to long, but I'd like to keep column names instead of column numbers. Is there a way of doing this without having to write out all the column names? I need columns 5 to 38, as seen in the code below. My code is:
cc_hear_reshaped <- reshape(cc_hear, varying = c(5:38),
v.names = "Hearing",
timevar = "Org",
times = c(5:38),
new.row.names = 1:1000,
direction = "long")
Any help appreciated. Thank you so much!
EM
r reshape
I reshaped a dataset from wide to long, but I'd like to keep column names instead of column numbers. Is there a way of doing this without having to write out all the column names? I need columns 5 to 38, as seen in the code below. My code is:
cc_hear_reshaped <- reshape(cc_hear, varying = c(5:38),
v.names = "Hearing",
timevar = "Org",
times = c(5:38),
new.row.names = 1:1000,
direction = "long")
Any help appreciated. Thank you so much!
EM
r reshape
r reshape
edited Nov 11 at 1:15
Harro Cyranka
916513
916513
asked Nov 10 at 18:10
ex_machina
11
11
1
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not usestr()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?
– Tung
Nov 11 at 1:37
add a comment |
1
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not usestr()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?
– Tung
Nov 11 at 1:37
1
1
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use
str()
, head()
or screenshot)? You can use the reprex
and datapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?– Tung
Nov 11 at 1:37
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use
str()
, head()
or screenshot)? You can use the reprex
and datapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?– Tung
Nov 11 at 1:37
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241958%2fhow-to-keep-colnames-when-reshaping%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use
str()
,head()
or screenshot)? You can use thereprex
anddatapasta
packages to assist you with that. See also Help me Help you & How to make a great R reproducible example?– Tung
Nov 11 at 1:37