title: Organizing data from physics experiments for ggplot2
body: <p>I am currently trying to use ggplot2 to visualize results from simple current-voltage experiments. I managed to achieve good results for one set of data of course.</p>
  
  <p>However, I have a number of current-voltage datasets, which I input in R recursively to get the following organisation (see minimal code) :</p>
  
  <pre><code>data.frame(cbind(batch(string list), sample(string list), dataset(data.frame list)))
  </code></pre>
  
  <p>Edit : My data are stored in text files names batchname_samplenumber.txt, with voltage and current columns. The code I use to import them is :</p>
  
  <pre><code>require(plyr)
  require(ggplot2)
  
  #VARIABLES
  regex &lt;- "([[:alnum:]_]+).([[:alpha:]]+)"
  regex2 &lt;- "G5_([[:alnum:]]+)_([[:alnum:]]+).([[:alpha:]]+)"
  
  #FUNCTIONS
  getJ &lt;- function(list, k) llply(list, function(i) llply(i, function(i, indix) getElement(i,indix), indix = k))
  
  #FILES
  files &lt;- list.files("Data/",full.names= T)
  
  #NAMES FOR FILES
  paths &lt;- llply(llply(files, basename),function(i) regmatches(i,regexec(regex,i)))
  paths2 &lt;- llply(llply(files, basename),function(i) regmatches(i,regexec(regex2,i)))
  names &lt;- llply(llply(getJ(paths, 2)),unlist)
  batches &lt;- llply(llply(getJ(paths2, 2)),unlist)
  samples &lt;- llply(llply(getJ(paths2, 3)),unlist)
  
  #SETS OF DATA, NAMED
  sets &lt;- llply(files,function(i) read.table(i,skip = 0, header = F))
  names(sets) &lt;- names
  for (i in as.list(names)) names(sets[[i]]) &lt;- c("voltage","current")
  
  df&lt;-data.frame(cbind(batches,samples,sets))    
  </code></pre>
  
  <p>And a minimal data can be generated via :</p>
  
  <pre><code>require(plyr)
  
  batch &lt;- list("A","A","B","B")
  sample &lt;- list(1,2,1,2)
  set &lt;- list(data.frame(voltage = runif(10), current = runif(10)),data.frame(voltage = runif(10), current = runif(10)),data.frame(voltage = runif(10), current = runif(10)),data.frame(voltage = runif(10), current = runif(10)))
  
  df&lt;-data.frame(cbind(batch,sample,set))
  </code></pre>
  
  <p>My question is : is it possible to use the data as is to plot using a code similar to the following (which does not work) ?</p>
  
  <pre><code>ggplot(data, aes(x = dataset$current, y = dataset$voltage, colour = sample)) + facet_wrap(~batch)
  </code></pre>
  
  <p>The more general version would be : is ggplot2 able of handeling raw physical data, as opposed to discrete statistical data (like diamonds, cars) ?</p>