xlsx - Excel data organized in multiple nested rows, can R read it? -


please see picture. i've started using r, , know how/that can read files excel, can read formatted this?

http://www.flickr.com/photos/68814612@n05/8632809494/

(my apologies, upload not working me)

elaborating on of what's in comments:

if load file excel, can save fixed-width or comma-delimited text file. either should easy read r.

the following may obvious already.

(first, question: sure can't data in format has 1 set of data per line? possible file you're getting generated different file format more conducive loading data r?)

whether should start rearranging data in r or instead manipulate raw text depends on comes naturally (or people have around can help). me, personally, rearrange text file outside of r before loading r. that's what's easiest me. perl great language purpose, unix shell scripts if that's accessible you, or using powerful editor such vim or emacs. if have no preference, i'd suggest perl. if have significant programming experience, you'll able learn need. on other hand, you're loading r, maybe better process data there.

for example, execute loop goes text file line line , this:

while (still have lines read) {   read first header line vector if first time through loop    otherwise, read , throw away   read data line 1 vector   read second header line vector if first time    otherwise, read , throw away   read data line 2 vector   read third header line vector if first time    otherwise, read , throw away   read data line 3 vector   if first time through, concatenate header vectors; store next row     in (a file, matrix, dataframe, etc.)   concatenate data vectors you've been saving, , store next row in same thing }  write out whole 2d data structure 

or if headers never change, embed them literally script before loop, , throw them out no matter what. make code cleaner. or read first few lines of file separately headers, , have separate script read data , add file headers in it. (the headers useful in r, suggest preserving them @ top of text file.)


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -