当前位置:网站首页>melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
2022-04-23 12:58:00 【qq_52813185】
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
# examples from 'tidyr' package
library(tidyr)
library(reshape2)
stocks = data.frame(
time = as.Date('2009-01-01') + 0:9,
X = rnorm(10, 0, 1),
Y = rnorm(10, 0, 2),
Z = rnorm(10, 0, 4)
)
head(stocks)
stocksm = stocks %>%
melt(id.vars = "time", variable.name = "stock", value.name = "price")
head(stocksm)
table(stocksm$stock)
stocksm %>% dcast(time ~ stock)
stocksm %>% dcast(stock ~ time)
# dcast and melt are complements
df = data.frame(x = c("a", "b"), y = c(3, 4), z = c(5, 6))
df %>%
dcast(z ~ x, value.var = "y") %>%
melt(id.vars = "z", variable.name = "x", value.name = "y", na.rm = TRUE)
# }
版权声明
本文为[qq_52813185]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_52813185/article/details/124359319
边栏推荐
- Jupiter notebook installation
- Record a website for querying compatibility, string Replaceall() compatibility error
- SSM framework series - data source configuration day2-1
- The continuous construction of the Internet industry platform is not only able to collect traffic
- Go iris framework implements multi service Demo: start (listen to port 8084) service 2 through the interface in service 1 (listen to port 8083)
- 梳理网络IP代理的几大用途
- HQL statement tuning
- Aviation core technology sharing | overview of safety characteristics of acm32 MCU
- Van uploader upload picture implementation process, using native input to upload pictures
- Common problems of unity (1)
猜你喜欢
There is no need to crack the markdown editing tool typora
Kubernetes 入门教程
Jupiter notebook installation
SSM framework series - annotation development day2-2
No idle servers? Import OVF image to quickly experience smartx super fusion community version
98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
CGC: contractual graph clustering for community detection and tracking
Object. The disorder of key value array after keys
Van uploader upload picture implementation process, using native input to upload pictures
Read the data in Presto through sparksql and save it to Clickhouse
随机推荐
Read the data in Presto through sparksql and save it to Clickhouse
SSM framework series - annotation development day2-2
JDBC connection pool
How to click an object to play an animation
Go language: passing slices between functions
Summary of JVM knowledge points - continuously updated
Custom nail robot alarm
After the data of El table is updated, the data in the page is not updated this$ Forceupdate() has no effect
At instruction of nbiot
31. 下一个排列
Jupiter notebook installation
31. Next arrangement
Unlock openharmony technology day! The annual event is about to open!
box-sizing
软件测试周刊(第68期):解决棘手问题的最上乘方法是:静观其变,顺水推舟。
Process virtual address space partition
Go iris framework implements multi service Demo: start (listen to port 8084) service 2 through the interface in service 1 (listen to port 8083)
Luogu p5540 [balkanoi2011] timeismoney | minimum product spanning tree problem solution
如何实现点击一下物体播放一次动画
(1) Openjuterpyrab comparison scheme