title: Error: In if (file == "") file <- stdout() else if (is.character(file)) { : the condition has length > 1 and only the first element will be used
body: <p>I want to read a xlsx-file and write each row separately, as csv-files. My idea was to first select one row and save this one, then take the names that are are specified in one column apart and loop through this. How my code looks like:</p>
  
  <pre><code>## read xlsx-file
  
  dataset_allsheets &lt;- read_xlsx("U:/my_path/model/R/file.xlsx", 
                                         sheet = "TOTAL", 
                                         range = "B3:FJ398")
  
  ## take only the column where name is specified
  
  subset_countrynames &lt;- dataset_allsheets[,1]
  
  
  ## create loop
  for(i in subset_countrynames){
  
      country &lt;- i
  
  ## connect data from the specific country and save  as csv
  
  one_country &lt;- as.data.frame(dataset_allsheets[dataset_allsheets$Countryname==country,])
  
  write.csv2(one_country, file = paste("08052018",country,".csv"))
  
  }
  </code></pre>
  
  <p>When I run this it returns the following error:</p>
  
  <pre><code>Error in file(file, ifelse(append, "a", "w")) : 
    invalid 'description' argument
  In addition: Warning message:
  In if (file == "") file &lt;- stdout() else if (is.character(file)) { :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>When I give 'country' manually a name that exists in the dataframe it works and writes the csv perfectly. I also deleted all the NAs. So there seems to be a problem with the loop. Anyone that has an idea? </p>