当前位置:网站首页>Melt reshape decast long data short data length conversion data cleaning row column conversion
Melt reshape decast long data short data length conversion data cleaning row column conversion
2022-04-23 13:01:00 【qq_ fifty-two million eight hundred and thirteen thousand one h】
melt reshape decast Long data short data Long short conversion Data cleaning Transformation of ranks
# 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_ fifty-two million eight hundred and thirteen thousand one h]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231258305842.html
边栏推荐
- Object.keys后key值数组乱序的问题
- 将新增和编辑的数据同步更新到列表
- 梳理网络IP代理的几大用途
- 精度、速度完美平衡,最新图像分割SOTA模型重磅发布!!!
- Ad20 supplementary note 3 - shortcut key + continuous update
- Utils of various date conversion
- Kubernetes 入门教程
- 4.22学习记录(你一天只做了水题是吗)
- Teach you to quickly develop a werewolf killing wechat applet (with source code)
- Introduction to servlet listener & filter
猜你喜欢
SSM framework series - JUnit unit test optimization day2-3
About the 'enum' enumeration type and structure.
SSL certificate refund instructions
22. Bracket generation
4. DRF permission & access frequency & filtering & sorting
The quill editor image zooms, multiple rich text boxes are used on one page, and the quill editor upload image address is the server address
Homomorphic encryption technology learning
Install nngraph
SSM框架系列——Junit单元测试优化day2-3
如何实现点击一下物体播放一次动画
随机推荐
Learning materials
精度、速度完美平衡,最新图像分割SOTA模型重磅发布!!!
Translation of attention in natural language processing
【蓝桥杯】4月17日省赛刷题训练(前3道题)
Free and open source intelligent charging pile SaaS cloud platform of Internet of things
Kubernets Getting started tutoriel
Community version Alibaba MQ ordinary message sending subscription demo
Date time type in database
Use source insight to view and edit source code
Start mqbroker CMD failure resolution
Go language mapping operation
Read the data in Presto through sparksql and save it to Clickhouse
PC starts multiple wechat at one time
在线计算过往日期天数,计算活了多少天
melt reshape decast 长数据短数据 长短转化 数据清洗 行列转化
SSL certificate refund instructions
Navicat远程连接数据库 出现 1130- Host xxx is not allowed to connect to this MySQL server错误
Deploying MySQL in cloud native kubesphere
Use Proteus to simulate STM32 ultrasonic srf04 ranging! Code+Proteus
安装nngraph