当前位置:网站首页>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
边栏推荐
- [Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
- 8 websites that should be known for product development to enhance work experience
- 将opencv 图片转换为字节的方式
- Go language array operation
- 将新增和编辑的数据同步更新到列表
- CGC: contractual graph clustering for community detection and tracking
- MySQL —— 16、索引的数据结构
- Byte warehouse intern interview SQL questions
- No idle servers? Import OVF image to quickly experience smartx super fusion community version
- Synchronously update the newly added and edited data to the list
猜你喜欢
梳理網絡IP代理的幾大用途
风尚云网学习-h5的input:type属性的image属性
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
SSM框架系列——Junit单元测试优化day2-3
JMeter operation redis
Kubernetes 入門教程
Kubernets Getting started tutoriel
5 free audio material websites, recommended collection
Design of body fat detection system based on 51 single chip microcomputer (51 + OLED + hx711 + US100)
云原生KubeSphere部署Redis
随机推荐
Custom nail robot alarm
Read the data in Presto through sparksql and save it to Clickhouse
Servlet监听器&过滤器介绍
async void 导致程序崩溃
8 websites that should be known for product development to enhance work experience
SQL exercise question 1
Recovering data with MySQL binlog
CGC: contractual graph clustering for community detection and tracking
Remote access to raspberry pie at home (Part 1)
There is no need to crack the markdown editing tool typora
Ad20 supplementary note 3 - shortcut key + continuous update
SSM框架系列——Junit单元测试优化day2-3
Go iris framework implements multi service Demo: start (listen to port 8084) service 2 through the interface in service 1 (listen to port 8083)
Software testing weekly (issue 68): the best way to solve difficult problems is to wait and see the changes and push the boat with the current.
Fashion cloud learning - input attribute summary
leetcode-791. 自定义字符串排序
Record Alibaba cloud server mining program processing
Image attribute of input: type attribute of fashion cloud learning -h5
22. 括号生成
three.js文字模糊问题