[R] problem in reading GDX file

Berend Hasselman bhh at xs4all.nl
Tue May 21 15:09:20 CEST 2013


On 21-05-2013, at 13:16, shyam basnet <shyamabc2002 at yahoo.com> wrote:

> Dear R-Users,
>  
> While reading a GDX file from GAMS-software, the R-program does not read the string (text) observations. Instead, it assigns some numerical values to each text. Do you have some idea on how to read string observations?
>  
> Example in GDX file:
>  
> fid     out   year   value
> 1_2_3   RICE  1995   130.54
> 1_2_3   WHEAT 1996   115-40

Is the 115-40 correct?

> 1_2_4   RICE  1995   120.20
> 1_2_4   WHEAT 1996   115.40
>  
> But, the R-software reads the above data as:
>  
> fid        out     year     value
> 2721   10281   2155   130.54
> 2721   10284   2156   115-40
> 2726   10281   2155   120.20
> 2726   10284   2156   115.40
>  
> I want read the GDX file in as it is condition. 

You have not shown which function you have used to read in the file.
If you have used read.table or one of the alternatives:

?read.table

and look at argument stringsAsFactors: set it to FALSE. The strings have been treated as factors.

Berend



More information about the R-help mailing list