2
I have table I have a column that is a data set I need to separate this data and unify the "standard columns".
I’ve managed to separate the contents of the column by staying this way:
nrow temp area sep1 sep2 sep3 sep4 sep5 sep6
1 x x x x x x NA NA
2 x x x x x x x NA
3 x x x x NA NA NA NA
100000 x x x x x x x x
But I still need to do this:
nrow temp area sep1
1 x x x
2 x x x
3 x x x
100000 x x x
nrow temp area sep2
1 x x x
2 x x x
3 x x x
100000 x x x
nrow temp area sep3
1 x x x
2 x x x
3 x x NA
100000 x x x
nrow temp area sep4
1 x x x
2 x x x
3 x x NA
100000 x x x
nrow temp area sep5
1 x x NA
2 x x x
3 x x NA
100000 x x x
nrow temp area sep6
1 x x NA
2 x x NA
3 x x NA
100000 x x x
For this I tried to separate the columns and join with a loop of repetition, but I cannot finish the code, below what I tried to do:
file_split = data.frame(colsplit(file_unic$UNIR, pattern=";", names=paste0("sep", 1:34)))### separar coluna
for(i in 1:ncol(file_split)){
uniao = cbind(file,sep) # juntar uma coluna previamente separada ao conjunto de dados
}
However, I would still need to place one block below the other. How can I finish this?
i tried to do this for my data, but gave the following error Warning message: Attributes are not identical Across Measure variables; they will be Dropped @Marcosbanik
– Joyce Maia
Not if allowed in this forum, but I can make my full code and file available in Dropbox?
– Joyce Maia
would be better to change my example. For example, I’m suspicious that the contents of sep1, sep2, sep3 are just letters like 'a, b, c' or NA. if so, try using df[3:8] <- lapply(df[3:8], factor, levels=Letters). 3:8 is the range with the number of columns containing the seps. Check this reply from SOEN https://stackoverflow.com/a/25689246, I think it can help you.
– Marcos Banik
I was able to solve the problem with your comment, I made a modification. I read the file with fread and used colClasses = "Character". Leaving everything as the same class your model worked. Thank you very much =)
– Joyce Maia