4
I would like to perform a filter on R. I have a database with 5 variables and more than 5000 lines. One of my variables is "room", in which I have 29 room (ex:Sala1,sala2...).
I would like to perform a filter, to filter all the information that it contains in my database for a particular room, and then export this information in a csv file.
I even made a program, but it is not storing right in a csv file. I would like someone to give me a tip for better my code and/or help me solve this storage problem. Below follows my code.
dados=read.csv("C:/teste/dados.csv", sep=";",header=TRUE)
nome=dados$nome
perfil=dados$perfil
sala=dados$sala
forum=dados$forum
mensagem=dados$mensagem
BD=data.frame(nome,perfil,sala,forum,mensagem)
x2=subset(nome,sala=="(T2/14/EI) D01 - Diversidade e Cultura Inclusiva")
x3=subset(perfil,sala=="(T2/14/EI) D01 - Diversidade e Cultura Inclusiva")
x6=subset(sala,sala=="(T2/14/EI) D01 - Diversidade e Cultura Inclusiva")
x7=subset(forum,sala=="(T2/14/EI) D01 - Diversidade e Cultura Inclusiva")
x10=subset(mensagem,sala=="(T2/14/EI) D01 - Diversidade e Cultura Inclusiva")
dados1=paste(x2,x3,x6,x7,x10,sep=";")
cat("nome;perfil;sala;forum;mensagem", dados1, file="arquivo.csv", sep="\n",header=T)
What is the current code behavior?
– JJoao
So Jjoao he is even performing the filtering properly, but when I ask to store in a csv file, he is storing everything "messy".
– user20273
What code are you using to generate . csv? Is your data.frame when you write . csv correct? I recommend using the command: write.csv(seuDataFrame, file = "seusDados.csv") to generate . csv from a dataframe
– Icaro Bombonato
I’m using this: data1=Paste(x2,X3,X6,X7,X10,Sep=";") cat("name;profile;room;forum;message", data1, file="file.csv", Sep=" n",header=T). I didn’t know that command, I’ll try to use
– user20273
It is worth taking a look at this question also on ways to filter a data.frame: http://answall.com/questions/17439/como-filterr-um-data-frame/17479#17479
– Carlos Cinelli