reshape2

    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

    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