我很想念这里。我看了很多例子,但无法弄清楚以下问题。 df1 <- data.frame(
Rep = factor(rep(1:3, each = 4, times = 2)),
Gen = rep(paste0("T", 1:4), times = 6),
Env = rep(paste0("Loc", 1:2), each = 12),
Y = rnor
我的数据是这样的: data.frame(name=c("city","village"),code=c(10322,10321),plz=c(7041,7043),plz1=c(7044,7044),plz2=c(7043,NA))
什么是列plz1和列plz2转换为PLZ最聪明的办法: name code plz
city 10322 7041
city 10322 7044
我目前正在使用正态分布运行模拟,它模拟事件之间的时间并基于给定数据的分析(与问题无关)。仿真创建这样的: SimProcess <- function(mu, sigma, T) {
ctimes <- c() # Array of arrival times, initially empty
t <- rnorm(1,mu, sqrt(sigma)) # Time of n
我想将具有n行和n列的数据帧转换为单行,并添加了列名和行名称 例如,我想将下表转换为单行 Country Percentage
United States 97.89%
United Kingdom 0.65%
Switzerland 0.50%
Ireland 0.48%
Singapore 0.45%
Hong Kong
我运行下面R码Rstudio,目的是宽的数据帧(称为“合并”)转换成一个漫长的。 > merged
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2017 (A) 5980 5341 5890 5596 5753 5470 5589 5545 5749 5938 5844 5356
2017 (P) 5762 5275 5733