Gpcols2rows: convert a file with columns to rows

Description Usage Arguments Value Author(s) See Also Examples

Description

Gpcols2rows converts a file with columns yyyy,m1,m2,m3,..., m12 to rows yyyy,m1 yyyy,m3 ... yyyy,m12 readable by gnuplot

Usage

1
2
Gpcols2rows(filename, newfile, filecolseparator=' ', fileheader = FALSE,
newfilerowseparator='\n\n')

Arguments

filename

file with columns yyyy,m1,m2,m3,...,m12

newfile

file with rows yyyy,m1 yyyy,m3 ... yyyy,m12

filecolseparator

string that separates the columns

fileheader

optional column header

newfilerowseparator

string that separates the rows

Value

none

Author(s)

Jose' Gama

See Also

Gpinit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Initialize the gnuplot handle
h1<-Gpinit()
#set gnuplot's additional search directories, to the extdata directory 
# from Rgnuplot (default)
Gpsetloadpath(h1)
#change gnuplot's working directory to be the same as 
#R's working directory (default)
Gpsetwd(h1)
## Not run: 
nordklim <- read.table(system.file('extdata/NordklimData.tab', package = 
"Rgnuplot"), stringsAsFactors=FALSE, header=TRUE)

NKmonths <- c('January','February','March','April','May','June','July','August',
'September','October','November','December')
#choose Helsinki (code 304) and country (code 'FIN') Precipitation (code 601)
nordklimHelsinkiPrecipitation <- nordklim[which((nordklim$NordklimNumber==304) &
(nordklim$CountryCode=='FIN') & (nordklim$ClimateElement==601)),c('FirstYear',
NKmonths)]
nordklimHelsinkiPrecipitation <- as.matrix(nordklimHelsinkiPrecipitation)
#save to a data file
Gpmatrixr2gnu(nordklimHelsinkiPrecipitation, 'NORDKLIM-Helsinki-prec.dat')

#convert the data file from 12 columns for the monthly data to 2 rows
Gpcols2rows('NORDKLIM-Helsinki-prec.dat','NORDKLIM-Helsinki-prec-columns.dat')

## End(Not run)
#close gnuplot handle
h1<-Gpclose(h1)

Rgnuplot documentation built on May 1, 2019, 9:17 p.m.