Concatenating two text columns in dplyr

前端 未结 4 1659
渐次进展
渐次进展 2021-01-04 07:01

My data look like this:

round <- c(rep(\"A\", 3), rep(\"B\", 3))
experiment <- rep(c(\"V1\", \"V2\", \"V3\"), 2)
results <- rnorm(mean = 10, n = 6)
         


        
4条回答
  •  Happy的楠姐
    2021-01-04 07:31

    This should do the trick if you are looking for a new variable

    library(tidyverse)
    
    round <- c(rep("A", 3), rep("B", 3))
    experiment <- rep(c("V1", "V2", "V3"), 2)
    results <- rnorm(mean = 10, n = 6)
    
    df <- data.frame(round, experiment, results)
    df
    
    df <- df %>% mutate(
      name = paste(round, experiment, sep = "_")
    )
    

提交回复
热议问题