[R-sig-eco] Re : Display or save very long matrix

Sarah Goslee sarah.goslee at gmail.com
Thu Sep 22 12:56:37 CEST 2011


Excerpted from below, because all else is irrelevant:
>write.table("C:\\Users\\Documents\\DISC D\\ Mat1.txt",sep=" ")

You need to tell R *what* to write to a file, not just the file name.
Please read ?write.table and also try
write.table(Mat1, "C:\\Users\\Documents\\DISC D\\ Mat1.txt",sep=" ")

Sarah

On Thu, Sep 22, 2011 at 6:23 AM, momadou sow <momadou at yahoo.fr> wrote:
> Hi,
> Thank Sarah and David for your help.
> for David Galbraith
> For the moment, I did not use any text editor, I want to save all my matrix
> in a file which can be (.txt) or another.
>    Sorry Sarah I missed a code line, also I tried write.table but I have not
> a saved file in my folder.
> RasterToColonne transforms raster to Colum.  Here, the complete code used:
>
>>library(raster)
>>adresse<-"C:\\Users\\Documents\\DISC D\\Images282"
>>RasterToColonne <- function(AdresseRaster){ # to transform raster to Colum
>>a <- raster(adresse)
>>CentreRaster <- rasterToPoints(a)
>>PixelColonne <- as.data.frame(CentreRaster)
>>PixelColonne <- cbind(PixelColonne,coordonnee =
>> paste(PixelColonne[,1],PixelColonne[,2],sep=" "))
>>colnames(PixelColonne) <-
>> c("Longitude","Latitude","ValeurPixel","Coordonnees")
>>return(PixelColonne)
>>}
>>Mat1 <- RasterToColonne(adresse)
>>write.table("C:\\Users\\Documents\\DISC D\\ Mat1.txt",sep=" ")
> Thank you for your help
> De : Sarah Goslee <sarah.goslee at gmail.com>
> À : momadou sow <momadou at yahoo.fr>
> Cc : "R-sig-ecology at r-project.org" <R-sig-ecology at r-project.org>
> Envoyé le : Jeudi 22 Septembre 2011 0h16
> Objet : Re: [R-sig-eco] Display or save very long matrix
>
> Hi,
>
> I'm not sure why you want to display a matrix of that size to the screen,
> but
> why not use write.table() to save it to a file?
>
>>Mat1 <- RasterToColonne(adresse)
>
> If that isn't enough, then we might need to know what the function
> RasterToColonne() does. Or is that the function that you only included
> half of in your email?
>
> Sarah
>
> On Wed, Sep 21, 2011 at 5:06 PM, momadou sow <momadou at yahoo.fr> wrote:
>> Hi,
>>
>> I extract the coordinates and pixel values on my image. Thus I want to
>> display all my matrix and save it in a (. txt) file.
>> I used this code:
>>
>>>library(raster)
>>>adresse<-"C:\\Users\\Documents\\DISC D\\\Images282"
>>>a <- raster(adresse)
>>>CentreRaster <- rasterToPoints(a)
>>>PixelColonne <- as.data.frame(CentreRaster)
>>>PixelColonne <- cbind(PixelColonne,coordonnee =
>> paste(PixelColonne[,1],PixelColonne[,2],sep=" "))
>>>colnames(PixelColonne) <-
>> c("Longitude","Latitude","ValeurPixel","Coordonnees")
>>>return(PixelColonne)
>>>}
>>>Mat1 <- RasterToColonne(adresse)
>>>Mat1[1:5168101,]  # number of rows = 5168101
>>
>> In the result, I have not all the matrix. Only a part of the matrix
>> appears.
>> How can I save the entire matrix to a file (. txt)?
>>
>> Thank you in advance
>> Momadou
>>
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-sig-ecology mailing list