I would like to leave the data.frame without repeated elements used this code:

Asked

Viewed 38 times

-2

f<- c("Juca", "Sam", "Ze", "Anta", "Buddy", "Irma")
f<- sample(f, 3, FALSE)
a<- c("Juca", "Silas", "Ze", "Ziraldo", "bar", "Ramister", "Luizinho")
a<- sample(a, 3, FALSE)

b <- c("Mario", "Eneas", "Rita", "bar", "laplace", "Ramister")
b <- sample(b, 3, FALSE)

c<- c("Tadeu", "Mario", "Eneas", "Rita", "bar", "Alvim", "Zeca")
c<- sample(c, 3, FALSE)
d<- c("Tadeu", "Mario", "He_man", "Rita", "bar", "laplace", "Luizinho")
d<- sample(d, 3, FALSE)
e<- c("João", "Sam", "José", "Tadeu", "bar", "laplace", "Luizinho")
e<- sample(e, 3, FALSE)
g<- c("Tadeu", "Mario", "Eneas", "Rita", "bar", "laplace", "Luizinho")
g <- sample(g, 3, FALSE)
h<- c("Tadeu", "Irma", "Bogos", "Espiao", "Julios", "Luizinho")
h<- sample(h, 3, FALSE)
library("magrittr")
data.frame(f) %>% 
  data.frame(a) %>% 
  data.frame(b) %>% 
  data.frame(c) %>% 
  data.frame (d) %>% 
  data.frame(e) %>% 
  data.frame(g) %>% 
  data.frame(h)

escala <- (data.frame(f) %>% 
              data.frame(a) %>% 
              data.frame(b) %>% 
              data.frame(c) %>% 
              data.frame (d) %>% 
              data.frame(e) %>% 
              data.frame(g) %>% 
              data.frame(h))   
escala

escala<- escala[!duplicated(escala), ]
escala
  • Detail plus your problem, @Lincoln.

  • this is the output, I would like to delete repetitions on the lines ; f a b c d e g h 1 Buddy Silas Rita Alvim bar Rita Espiao 2 Sam bar bar bar Luizinho Tadeu Aplace Luizinho 3 Juca Juca Eneas Zeca Rita José Eneas Tadeu >

  • Edit the question with these details (and more than you think is necessary to get a good answer).

  • This answers your question? Eliminating Double Lines from a Data.Frame

1 answer

0

It is not necessary to repeat the calls to sample, once is enough. As for the final result, it is not clear which format is intended, this code data.frame only with one column and no repetitions.

f <- c("Juca", "Sam", "Ze", "Anta", "Buddy", "Irma")
a <- c("Juca", "Silas", "Ze", "Ziraldo", "bar", "Ramister", "Luizinho")
b <- c("Mario", "Eneas", "Rita", "bar", "laplace", "Ramister")
c <- c("Tadeu", "Mario", "Eneas", "Rita", "bar", "Alvim", "Zeca")
d <- c("Tadeu", "Mario", "He_man", "Rita", "bar", "laplace", "Luizinho")
e <- c("João", "Sam", "José", "Tadeu", "bar", "laplace", "Luizinho")
g <- c("Tadeu", "Mario", "Eneas", "Rita", "bar", "laplace", "Luizinho")
h <- c("Tadeu", "Irma", "Bogos", "Espiao", "Julios", "Luizinho")

vetores <- ls(pattern = '^[[:alpha:]]$')


set.seed(2020)
escala <- lapply(mget(vetores), sample, size = 3)
escala <- do.call(cbind.data.frame, escala)
names(escala) <- LETTERS[seq.int(ncol(escala))]
escala
#         A     B     C        D        E     F        G        H
#1  Ziraldo Mario Alvim    Mario      Sam Buddy  laplace Luizinho
#2 Luizinho   bar Tadeu Luizinho     José  Anta Luizinho   Espiao
#3     Juca Eneas   bar      bar Luizinho   Sam     Rita     Irma
  • I need a DF with 3 rows and 8 columns where no names are repeated in the rows, it is a working scale ( the names are 8 sets F, A, B .... H if you can help me... f a b c d e g h 1 Anta Ziraldo Mario Zeca bar João Laplace Bogos 2 Juca bar Rita bar Rita Tadeu Tadeu Luizinho 3 Sam Silas bar Tadeu Mario bar Luizinho Tadeu

  • @Lincolnlinhares Done, see if this is what you want.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.