[問題] dplyr流程下如何匯出data.frame

看板R_Language作者 (understand?)時間1年前 (2022/06/30 12:55), 1年前編輯推噓1(101)
留言2則, 2人參與, 1年前最新討論串1/1
[問題類型]: 程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來) [軟體熟悉度]: 入門(寫過其他程式,只是對語法不熟悉) [問題敘述]: 我有一組數據(IDW_table) ,我想處理分組計算後,另存成一個data.frame 但目前結果只能顯示在console,無法另存起來,不知道哪裡寫錯了,請給個指教 下列是我的資料格式 (範例檔https://reurl.cc/0pMROo) yearmon actual predicted 202101 11.3 10.626 202101 11.3 10.805 202102 11.2 10.78 202103 11.1 10.727 [程式範例]: library(dplyr) x <- data.frame(stringsAsFactors = F) IDW_table%>% select(yearmon,actual,predicted)%>% group_by(yearmon) %>% summarise( RMSE = sqrt(1/length(actual)*sum((actual-predicted)^2)) )%>% as.data.frame()%>% rbind.data.frame(x) 我自己嘗試成功了 但這好像不能刪文,所以我就把成功的部份寫出來,獻醜 x <- IDW_table%>% select(yearmon,actual,predicted)%>% group_by(yearmon) %>% summarise( RMSE = sqrt(1/length(actual)*sum((actual-predicted)^2)) )%>% as.data.frame() [環境敘述]: 請提供 sessionInfo() 的輸出結果 R version 4.1.3 Patched (2022-03-10 r81883) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22000) other attached packages: [1] dplyr_1.0.9 [關鍵字]: 選擇性,也許未來有用 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.247.190.248 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1656564943.A.181.html

06/30 13:09, 1年前 , 1F
我好像自己解決了
06/30 13:09, 1F
※ 編輯: studioA (27.247.190.248 臺灣), 06/30/2022 13:12:52

06/30 18:17, 1年前 , 2F
哈哈 恭喜解決!自己解決超有成就感的XD
06/30 18:17, 2F
文章代碼(AID): #1YlIpF61 (R_Language)
文章代碼(AID): #1YlIpF61 (R_Language)