reshape2

    1热度

    1回答

    我目前正在使用正态分布运行模拟,它模拟事件之间的时间并基于给定数据的分析(与问题无关)。仿真创建这样的: SimProcess <- function(mu, sigma, T) { ctimes <- c() # Array of arrival times, initially empty t <- rnorm(1,mu, sqrt(sigma)) # Time of n

    0热度

    1回答

    我想将具有n行和n列的数据帧转换为单行,并添加了列名和行名称 例如,我想将下表转换为单行 Country Percentage United States 97.89% United Kingdom 0.65% Switzerland 0.50% Ireland 0.48% Singapore 0.45% Hong Kong

    0热度

    2回答

    我运行下面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

    1热度

    1回答

    有了这个代码标记点: week1 <- c(6,3,1,2,8,7,5,10,4,9) week2 <- c(3,2,1,4,9,10,5,8,6,7) dat <- data.frame(week1, week2) dat$team <- c("team a", "team b", "team c", "team d", "team e", "team f", "team g", "te

    1热度

    1回答

    我很想念这里。我看了很多例子,但无法弄清楚以下问题。 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

    1热度

    1回答

    问题 我有3辆车(分组变量),其中随时间变化的速度记录在以下数据集中。我想按组来转置这个数据帧。 数据 foo <- structure(list(file.ID2 = c("Cars_03", "Cars_03", "Cars_03", "Cars_03", "Cars_03", "Cars_03", "Cars_03", "Cars_03", "Cars_04", "Cars_04", "

    0热度

    1回答

    DATA 我有这样一个数据帧: id weigth temp_s1 temp_s2 1 50 2 7 2 51 3 8 3 52 4 9 4 53 5 10 5 54 6 11 我想要什么 我想获得这样的: id weigth temp value 1 50 temp_s1 2 1

    0热度

    1回答

    数据片段取自mlogit软件包(Game2),格式为长格式以模仿我的情况。其中CH是提供给平台等级,并享有一定是一个受访者 age hours platform ch own chid 1 33 2.00 GameBoy 6 0 1 2 33 2.00 GameCube 5 0 1 3 33 2.00 PC 4 1 1 4 33

    3热度

    3回答

    我的数据是这样的: mydata <- data.frame(id = c(1,1,1,2,2,3,3,3,3), subid = c(1,2,3,1,2,1,2,3,4), time = c(16, 18, 20, 10, 11, 7, 9, 10, 11)) id subid time 1 1 1 16 2 1 2 18 3 1 3 20

    -1热度

    2回答

    我的数据是这样的: 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