[R] Reconstruct array dataset
jmburgos at u.washington.edu
Wed Nov 21 19:35:32 CET 2007
You can use the function scan() directly to read your file as a single
vector. Then, as Rob suggested, use the matrix function to give it the
dimensions you want.
Other option (perhaps less elegant) is to do something like this.
> This was my intention, but I'm not able to read it in as a vector (because i don't know the function, neither I can convert the read in table to a vector and then to matrix or directly.
> What did I miss or where do I have to look up?
> thanks alot
> -------- Original-Nachricht --------
>> Datum: Wed, 21 Nov 2007 14:17:41 -0000
>> Von: "Rob Robinson" <rob.robinson at bto.org>
>> An: "\'marcg\'" <mdgi at gmx.ch>
>> CC: r-help-bounces at r-project.org
>> Betreff: RE: [R] Reconstruct array dataset
>> Can you not read it into a single vector and then use as.matrix to shape
>> into a an appropriate sized matrix?
>> *** Wan==t to know about Britain's birds? Try www.bto.org/birdfacts ***
>> Dr Rob Robinson, Senior Population Biologist
>> British Trust for Ornithology, The Nunnery, Thetford, Norfolk, IP24 2PU
>> Ph: +44 (0)1842 750050 E: rob.robinson at bto.org
>> Fx: +44 (0)1842 750030 W: http://www.bto.org
>> ==== "How can anyone be enlightened, when truth is so poorly lit" =====
>>> -----Original Message-----
>>> From: r-help-bounces at r-project.org
>>> [mailto:] On Behalf Of marcg
>>> Sent: 21 November 2007 14:08
>>> To: r-help at stat.math.ethz.ch
>>> Subject: [R] Reconstruct array dataset
>>> Hi there
>>> I have an interesting problem:
>>> My csv file is of array dimensions [12,50], but it was saved
>>> the wrong way: there should be only 11 colums. What happens
>>> now if I read it into R is that the whole data set is shifted
>>> ( in the first row, the last column contains already the
>>> first value of the supposed second row and so on...)
>>> how can I tell R to switch after 11 read values to the next
>>> row, taking the value from column 12 as first in the new row
>>> (for row 3 the two second last of the upper row etc...)
>>> Thanks for suggestions
>>> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide
>>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help