How to split two rows in multiples row in R
1
0
Entering edit mode
2.2 years ago
joaovmio • 0

I have a dataset like this (1st) and I want to turn him into this format (2st)!

1st

2st

row dataset split R col • 1.1k views
ADD COMMENT
2
Entering edit mode

See the pivot_longer function from the tidyr package. https://tidyr.tidyverse.org/reference/pivot_longer.html

ADD REPLY
0
Entering edit mode

Where are you getting the values for column1 in the output df from?

ADD REPLY
0
Entering edit mode

sorry for the lack of information, but basically there are several files (each with the name in column 1) that I joined in a file only through "list.files()". the second image I made manually by excel, but this is not good, because later I will have many more files to join and format in a dataframe.

I started my first contact with bioinformatics in biology graduation, so I have no experience

ADD REPLY
0
Entering edit mode

Please show us your full code, starting from the list.files() command.

ADD REPLY
1
Entering edit mode
2.2 years ago
Asaf 10k

What you are looking for is probably:

 b <- matrix(a, ncol=8, byrow = TRUE)

Then rename column names and transform to data.frame if you wish.

ADD COMMENT

Login before adding your answer.

Traffic: 2333 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6