[R-sig-eco] SPEI index

Bob O'Hara bohara at senckenberg.de
Tue Dec 23 10:05:58 CET 2014


On 12/23/2014 09:57 AM, ONKELINX, Thierry wrote:
> If the file is tab delimited then you need to use read.table(sep = "\t") instead of read.table(sep = ""). read.delim() is another option.
Or save the file as a .csv and use read.csv (this makes the reading in 
easier if you have things like spaces in the file).

Also, it's worth checking that you don't have a header row and then some 
empty rows. It's often worth opening up the .txt or .csv file as a text 
file (e.g. in Notepad) to see if there are any problems.

Oh, and the gdata package has a read.xls() function that is another 
alternative.

Bob

> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> Van: R-sig-ecology [mailto:r-sig-ecology-bounces at r-project.org] Namens Manuel Esteban Lucas Borja
> Verzonden: dinsdag 23 december 2014 9:13
> Aan: r-sig-ecology at r-project.org
> Onderwerp: [R-sig-eco] SPEI index
>
> Dear All,
>
> I am starting to use R software in order to calculate an aridity index (SPEI). I have installed the spei package and the library. Then, I have created a .xls file with year, month, Precip and Temp variables. The xls file has been exported to txt format (separated by tabulations). Then to try, the only output I have obtained can be see below. Could anyone of you please help me? If you want, I can send you the txt file.
>
> All the best,
>
> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
> 1 NA NA NA NA NA NA NA NA NA NA NA NA
> 2 NA NA NA NA NA NA NA NA NA NA NA NA
>
> Script:
> library(SPEI)
> SPEI <- read.table("/Users/PALAN.txt", header=TRUE, sep="")
> str(SPEI)
> PET <- thornthwaite(SPEI$Tm,40.00000)
> spei(SPEI$PREC-PET,1)
>
> ---
> Manuel Esteban Lucas Borja
> Universidad de Castilla La Mancha
> Escuela T�cnica Superior de Ingenieros Agr�nomos y de Montes
> Departamento de Ciencia y Tecnolog�a Agroforestal y Gen�tica
> Campus Universitario s/n,
> C.P. 02071, Albacete (Spain)
> T�lf.; 967599200 ext. 2818
> Mail: ManuelEsteban.Lucas at uclm.es
> Web:http://www.uclm.es/profesorado/manuelestebanlucas/
>
>
>          [[alternative HTML version deleted]]
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> Disclaimer Bezoek onze website / Visit our website<https://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


-- 
Bob O'Hara

Biodiversity and Climate Research Centre
Senckenberganlage 25
D-60325 Frankfurt am Main,
Germany

Tel: +49 69 7542 1863
Mobile: +49 1515 888 5440
WWW:   http://www.bik-f.de/root/index.php?page_id=219
Blog: http://blogs.nature.com/boboh
Journal of Negative Results - EEB: www.jnr-eeb.org



More information about the R-sig-ecology mailing list