1

context: 10 files. csv, each file contains an date frame with 5 columns: name, date of birth, sex, attitude, and result. On each line there is a name, date of birth, sex, attitude, and result.

problem: each attitude has a result. each attitude was exported on one line. soon, there are several lines for each registered attitude.

goal: to extract from each of the files, individuals who possess the set of attitudes recorded with their results.

ext {
atlist <- as.list(x1, x2, x3, x4, x5, x6, x7, x8)
library(dplyr)
setwd("~/")
files_list <- list.files(x, full.names=TRUE)
dat <- data.frame()
fim <-  data.frame()
for (i in 1:10) {                                
    dat <- (read.csv(files_list[i]))
    dat <- dat %>% filter(attitude == "atlist")
    fim <- rbind(fim, dat)
  }
  fim
}

I'm struggling with this for some time. Can someone help me ?

jogo
  • 12,469
  • 11
  • 37
  • 42
Henrique
  • 146
  • 7
  • 4
    Can you add a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – Frank Nov 20 '15 at 17:50

1 Answers1

1

I'm not exactly sure what you're asking because it's not clear what x1, x2, x3, etc. are, but if each of those represents the attitudes that you would like filtered, perhaps you would like to do the following:

atlist <- c(x1, x2, x3, x4, x5, x6, x7, x8)
setwd("~/")
files_list <- list.files(full.names=TRUE)
fim <-  NULL
for (i in 1:10) {                                
    dat <- (read.csv(files_list[i]))
    dat <- dat[dat$attitude %in% atlist,]
    fim <- rbind(fim, dat)
}
Sam Dickson
  • 5,082
  • 1
  • 27
  • 45