Hi - I am new to Rstudio and I just wanted some help in using the concatenate function. I have a file with 450 female weights and 450 male weight samples. Now I want to create a combined list so that I can access the female and male weights together. I tried writing the concatenate function, but I keep getting errors and I cannot move forward. I wanted to see how to correctly write out the concatenate function.
To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
Hi, I have written below the first 5 pieces of data,
Male Female
95 72
46 64
66 59
67 45
101 81
The table aims to show the weights of different males and females. I want to create a combined list of the data for males and females, and I was told you do this using the concatenate function.
It would be useful for others facing a similar issue if you share the actual coding solution to your problem.
Also, by using c() function over Male and Female you would be losing information about the sex, I think it would be better to reshape your dataset to a long format keeping all information, see this example:
library(tidyverse)
weights <- data.frame(
Male = c(95, 46, 66, 67, 101),
Female = c(72, 64, 59, 45, 81)
)
weights %>%
gather(sex, weight)
#> sex weight
#> 1 Male 95
#> 2 Male 46
#> 3 Male 66
#> 4 Male 67
#> 5 Male 101
#> 6 Female 72
#> 7 Female 64
#> 8 Female 59
#> 9 Female 45
#> 10 Female 81
Created on 2019-11-30 by the reprex package (v0.3.0.9000)
This would enable you to perform comparisons more easily, for example