Are you just trying to collect GO terms associated with each ENSIPUG ID into a single row?
#Your data
df <- read.table(text = "ENSIPUG00000001371 ;GO:0008236
ENSIPUG00000001371 ;GO:0008233
ENSIPUG00000001371 ;GO:0070011
ENSIPUG00000001371 ;GO:0016787
ENSIPUG00000001371 ;GO:0017171
ENSIPUG00000001371 ;GO:0140096
ENSIPUG00000001374 ;GO:0005515
ENSIPUG00000001374 ;GO:0003674
ENSIPUG00000001374 ;GO:0005488
ENSIPUG00000001375 ;GO:0008152
ENSIPUG00000001375 ;GO:0008150
ENSIPUG00000001375 ;GO:0016758", sep = ",")
#Libraries we need.
library(magrittr)
library(stringr)
library(dplyr)
#Putting the ENSI identifiers and GO terms in their
#own columns.
df %<>%
rowwise() %>%
mutate(V2 = unlist(str_split(V1, " ;"))[2],
V1 = unlist(str_split(V1, " ;"))[1])
#Collecting each ENSI identifier's set of GO terms into
#a single row.
df %<>%
group_by(V1) %>%
mutate(V2 = paste0(V2, collapse = "; ")) %>%
ungroup() %>%
distinct(V1, .keep_all = TRUE)
#Taking a glance at the output.
df
# # A tibble: 3 × 2
# V1 V2
# <chr> <chr>
# 1 ENSIPUG00000001371 GO:0008236; GO:0008233; GO:0070011; GO:0016787; GO:0017171; GO:0140096
# 2 ENSIPUG00000001374 GO:0005515; GO:0003674; GO:0005488
# 3 ENSIPUG00000001375 GO:0008152; GO:0008150; GO:0016758
#Write to file.
#File's saved as "newformat.csv" to whatever location getwd()
#indicates.
write.table(df, file = "newformat.csv", quote = TRUE, sep = ",")
you don't need to load the data in R just for that. Try this:
if you want it in R, try one of these:
input: