[英]R - change factor to variable
我確實有一個關於我的數據格式的問題,但在這里的任何帖子中都沒有找到。
目前,我有一個如下所示的數據框:
> bymonth
month n_positive n_negative
1 April 563 587
2 August 186 240
3 December 671 581
4 February 2026 1827
5 January 1227 1115
6 July 63 57
7 June 360 336
8 March 430 378
9 May 422 481
10 November 1017 947
11 October 617 694
12 September 601 434
我想創建一個以月份名稱作為變量的時間序列。 看起來像這樣的東西:
> bymonth
sentiment January February March April ...
1 n_positive 1227 2026 430 563 ...
2 n_negative 1115 1827 378 587 ...
我怎樣才能做到這一點? 任何幫助將不勝感激!
您只想轉置您的數據?
t(bymonth)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.