Re: [R] how to extract from list

2012-10-16 Thread Muhammad Rahiz
. -- Muhammad Rahiz (za) +27 071 719 0104 (skype) muhammad.rahiz [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

[R] Correlating zero-truncated data

2012-03-07 Thread Muhammad Rahiz
Dear all, Does anyone know of a function in R which allows for correlation of zero-truncated timeseries such as x and y as illustrated below? x - rnorm(100) x[which(x0)] - 0 y - abs(rnorm(100)) Thanks -- Muhammad __ R-help@r-project.org mailing

Re: [R] Correlating zero-truncated data

2012-03-07 Thread Muhammad Rahiz
thanks petr. -- Muhammad On Wed, 7 Mar 2012, Petr Savicky wrote: On Wed, Mar 07, 2012 at 09:42:15AM +, Muhammad Rahiz wrote: Dear all, Does anyone know of a function in R which allows for correlation of zero-truncated timeseries such as x and y as illustrated below? x - rnorm(100) x

[R] execute array of functions

2012-02-14 Thread Muhammad Rahiz
Hi all, I'm trying to get the min and max of a sequence of number using a loop like the folllowing. Can anyone point me to why it doesn't work. Thanks. type- c(min,max) n - 1:10 for (a in 1:2){ print(type[a](n)) } -- Muhammad __

Re: [R] Title for a group of plots?

2011-11-10 Thread Muhammad Rahiz
Perhaps something like this? par(oma=c(0,0,2,0)) par(mar=c(1,1,1,1)) par(mfcol=c(3,1)) plot(rnorm(10)) mtext(title) plot(rnorm(10)) plot(rnorm(10)) -- Muhammad Rahiz On Thu, 10 Nov 2011, Kevin Burton wrote: I can get multiple plots on a page like: op - par(mfcol = c(3, 1)) What I

Re: [R] Significance of trend

2011-11-01 Thread Muhammad Rahiz
at 2:51 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Hi everyone, I'm trying to determine the significance of a trendline. From my internet search months ago, I came across the following post. I modified tim and dat for simiplicity. tim - 1:10 dat - c(0.17, 1.09 ,0.11, 0.82, 0.23, 0.38

[R] Significance of trend

2011-10-31 Thread Muhammad Rahiz
Hi everyone, I'm trying to determine the significance of a trendline. From my internet search months ago, I came across the following post. I modified tim and dat for simiplicity. tim - 1:10 dat - c(0.17, 1.09 ,0.11, 0.82, 0.23, 0.38 ,2.47 ,0.41 ,0.75, 1.44) fstat -

[R] ncdf - install error

2011-09-23 Thread Muhammad Rahiz
Dear all, I'm having issues with the installation of the ncdf package. It returns a non-zero exit status. Can anyone suggest what I should do next? FYI, I do not have problems installing other packages. Thanks. Muhammad * installing *source* package ‘ncdf’ ... checking for nc-config...

[R] Array

2011-06-18 Thread Muhammad Rahiz
Hi, Can someone advise why the followind did not produce the array, given the condition specified? s - 1 a1 - array(dim=c(1,4)) a2 - array(dim=c(2,4)) arr - ifelse(s==0,a1,a2) Thanks. Muhammad __ R-help@r-project.org mailing list

Re: [R] Array

2011-06-18 Thread Muhammad Rahiz
Understood now. Thanks Duncan. Muhammad On Sat, 18 Jun 2011, Duncan Murdoch wrote: On 11-06-18 10:45 AM, Muhammad Rahiz wrote: Hi, Can someone advise why the followind did not produce the array, given the condition specified? s- 1 a1- array(dim=c(1,4)) a2- array(dim=c(2,4)) arr- ifelse(s==0

[R] Polygon question

2011-06-16 Thread Muhammad Rahiz
Hi all, I have the following script which fills the values which are less than the mean of a given timeseries. If you look closely, the colored regions are out of line. Any suggestions how I can rectify this? Thanks Muhammad # - #rm(list=ls()) x - abs(rnorm(100)) tt - 1:100 m -

[R] Fit data to distribution

2011-06-03 Thread Muhammad Rahiz
(y),col=red) legend(topright,legend=c(x,y),col=c(black,red),lty=1,bty=n) x1 - fitdistr(x,gamma)$estimate # get scale and rate -- Muhammad Rahiz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] modify a data frame by values in the columns

2011-06-03 Thread Muhammad Rahiz
Hi Jason, This is one way; c1 - seq(2,20,2) c2 - seq(1,19,2) c3 - cbind(c1,c2) c3[,1][which(c3[,1]12)] - -1 c3[,2][which(c3[,2]10)] - -1 Muhammad On Fri, 3 Jun 2011, Jason024 wrote: I have a data frame like this: col1 col2 r1 21 r2 43 r3 65 r4 87 r5

Re: [R] Quick recode of -999 to NA in R

2011-03-30 Thread Muhammad Rahiz
Try using a loop like the following dat0 - read.table(time1.dat) id - c(e1dq, e1arcp, e1dev, s1prcp, s1nrcp,s1ints,a1gpar, a1pias, a1devt) for (a in 1:length(id)) { dat0[dat0$id[a]==-999.,as.character(id[a])] - NA } -- Muhammad Rahiz Researcher DPhil Candidate (Climate Systems

Re: [R] plotting multiple figures on one page

2011-03-17 Thread Muhammad Rahiz
Scarlet, If the mfrow is being overridden, perhaps the rimage package might be able to piece the individual plots... -- Muhammad Rahiz Researcher DPhil Candidate (Climate Systems Policy) School of Geography the Environment University of Oxford On Thu, 17 Mar 2011, scarlet wrote: Jim

[R] optimize

2011-01-03 Thread Muhammad Rahiz
Hi all, I'm trying to get the value of y when x=203 by using the intersect of three curves. The horizontal curve does not meet with the other two. How can I rectify the code below? Thanks Muhammad ts - 1:10 dd - 10:1 ts - seq(200,209,1) dd - c(NA,NA,NA,NA,1.87,1.83,1.86,NA,1.95,1.96)

Re: [R] optimize

2011-01-03 Thread Muhammad Rahiz
Josh's recommendation to use predict works. At the same time, I'll work on your suggestions, David. Thanks. Muhammad Rahiz Researcher DPhil Candidate (Climate Systems Policy) School of Geography the Environment University of Oxford On Mon, 3 Jan 2011, David Winsemius wrote: On Jan 3

Re: [R] nls optimize

2010-10-20 Thread Muhammad Rahiz
That works - Thanks Ravi. Muhammad Rahiz On Tue, 19 Oct 2010, Ravi Varadhan wrote: You can do this. dsm = c(800,600,NA,525,NA,450,400,NA,NA,NA,0) s3 = seq(0.05,1.05,0.1) plot(s3,dsm,col=blue,las=1,xlab=fraction,ylab=distance (km)) fc - function(x,a,b){a*exp(-b*x)} fm - nls(dsm~fc(s3,a,b

[R] nls optimize

2010-10-19 Thread Muhammad Rahiz
Hi all, I'm plotting to get the intersection value of three curves. Defining the x-axis as dsm, the following code works; dsm = c(800,600,NA,525,NA,450,400,NA,NA,NA,0) s3 = seq(0.05,1.05,0.1) plot(dsm,s3,col=blue,las=1,ylab=fraction,xlab=distance (km)) fc - function(x,a,b){a*exp(-b*x)} fm -

[R] Finding sets

2010-06-25 Thread Muhammad Rahiz
Hi all, I'd like to find how many sets of 1s there are in the following example; x - rep(c(1,2,1,3,5), each=5) I know that there are two sets of 1s, visually. Any function in R that allows me to automate the process? Thanks. Muhammad __

Re: [R] long command line cut in 2 parts

2010-05-13 Thread Muhammad Rahiz
Dear Arnaud, Wrap a pair of curly brackets around the command line and remove the + like the following; zz-{merge(transform(merge(value,allcon,all.y=T),SHORTDESCRIPTION=NULL, VALUE=NULL,PL=-VALUE*pl,quantity=NULL),PosB,all.x=T,sort=F )} Muhammad arnaud Gaboury wrote: Dear group, I have

[R] reading in file with different row length

2010-05-06 Thread Muhammad Rahiz
Hi all, I have a file, say, test.txt, which contains the following information. I'm trying to read in the file and specifying the missing values as NA so that each column has the same number of rows. I've tried all sorts of manipulation but to no avail. r1 r2 r3 1 3 2 3 3 2 3 4 2 3 5 2

Re: [R] reading in file with different row length

2010-05-06 Thread Muhammad Rahiz
, ... Then read.csv should handle it fine. On Thu, May 6, 2010 at 12:10 PM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk mailto:muhammad.ra...@ouce.ox.ac.uk wrote: Hi all, I have a file, say, test.txt, which contains the following information. I'm trying to read in the file and specifying

Re: [R] question about 'write.table'

2010-05-05 Thread Muhammad Rahiz
This could work out - c() for (a in 1:10){ out[a] - paste(loci,a,sep=) write.table(out[a],file=out[a],row.names=FALSE,col.names=FALSE)} Muhammad karena wrote: I have a question about the write.table I have 100 data.frames, loci1, loci2, loci3.,loci100. now, I want to

Re: [R] How to replace all NA values in a data.frame with another ( not 0) value

2010-05-04 Thread Muhammad Rahiz
000/000 returns NaN, which is no different than NA unless you want it as string i.e. 000/000 Muhammad Lanna Jin wrote: Try: x[which(is.na(x)),] - 000/000, where is x is your data frame - Lanna Jin lanna...@gmail.com 510-898-8525 __

Re: [R] How to replace all NA values in a data.frame with another ( not 0) value

2010-05-04 Thread Muhammad Rahiz
Hi Nevil, You can try a method like this x - c(rnorm(5),rep(NA,3),rnorm(5)) # sample data dat - data.frame(x,x) # make sample dataframe dat2 - as.matrix(dat) # conver to matrix y - which(is.na(dat)==TRUE) # get index of NA values dat2[y] -

Re: [R] Scree diagram,

2010-05-02 Thread Muhammad Rahiz
1) I believe you wanted a scree plot which shows the percentage of variance explained (y-axis) versus the principal components (x-axis). To do that, all you needs a simple plot(x,y) function where x = pc and y = variance. It is called a scree plot because the plot looks like a scree on the

Re: [R] adding year information to a scatter plot

2010-05-02 Thread Muhammad Rahiz
Hi Ozan, The {calibrate} package allows you to do that. install.packages(calibrate) library(calibrate) df=data.frame(year=c(2001,2002,2003),a=c(8,9,7),b=c(100,90,95)) df plot(b~a,data=df) textxy(df$a,df$b,df$year) Muhammad On 05/02/2010 08:25 PM, Ozan Bakis wrote: Hi R users, I would like

Re: [R] Intersection for two curves

2010-04-24 Thread Muhammad Rahiz
(0,120)) abline(v=in1$minimum,col=red,lty=2) abline(h=n,col=red,lty=2) Muhammad David Winsemius wrote: On Apr 23, 2010, at 8:06 PM, Muhammad Rahiz wrote: Thanks David Peter, The locator() works but not practical as I have to repeat the process many times. Does the code works

[R] Intersection for two curves

2010-04-23 Thread Muhammad Rahiz
Does anyone know of a method that I can get the intersection where the red and blue curves meet i.e. the value on the x-axis? x - 1:10 y - 10:1 plot(x,y) abline(lm(y~x),col=blue) abline(h=2.5,col=red) Muhammad __ R-help@r-project.org mailing list

Re: [R] Intersection for two curves

2010-04-23 Thread Muhammad Rahiz
PM, Peter Ehlers wrote: On 2010-04-23 11:46, David Winsemius wrote: On Apr 23, 2010, at 1:06 PM, Muhammad Rahiz wrote: Does anyone know of a method that I can get the intersection where the red and blue curves meet i.e. the value on the x-axis? x- 1:10 y- 10:1 plot(x,y) abline(lm(y~x

[R] using which to select range of values

2010-04-22 Thread Muhammad Rahiz
Hi all, I would like to get the array index for a range of values, say 0 x 1.5. I'm wondering if there is an alternative for the following which I've done x0 - rnorm(100) x1 - ifelse(x0 0 x0 1.5,t,f) x2 - which(x1==t,arr.ind=TRUE) x0[x2] Thanks. -- Muhammad

[R] Error in plotting non-linear regression

2010-04-22 Thread Muhammad Rahiz
Hello everyone, I'm trying to draw the non-linear regression curve to look at the distance decay relationship between distance and correlation values. But I'm not able to plot the curve as I'm struggling with the following error (parameters without starting value in 'data': x) and found no

Re: [R] simple question

2010-04-22 Thread Muhammad Rahiz
Hi Gabriele, This is one way but I'm sure that there is an optimal way of doing so... x - c(A,B,C,C,C,C,C,B,B) name - unique(x) # get unique characters freq - c() for (a in 1:length(name)){ freq[a] - sum(x==name[a])}# get frequency out - cbind(name,freq) Muhammad

Re: [R] Error in plotting non-linear regression

2010-04-22 Thread Muhammad Rahiz
It now works. Thanks both. Muhammad Peter Ehlers wrote: On 2010-04-22 11:09, Muhammad Rahiz wrote: Hello everyone, I'm trying to draw the non-linear regression curve to look at the distance decay relationship between distance and correlation values. But I'm not able to plot the curve

[R] array manipulation

2010-04-14 Thread Muhammad Rahiz
Hello listeRs, I'm trying to make a square radius around a given reference point. So given the following array, how can I manipulate it so that x0 - array(1,dim=c(5,5)) x0 1 1 1 1 1 1 1 1 1 1 1 1 *1* 1 1 1 1 1 1 1 1 1 1 1 1 becomes into 3 3 3 3 3 3 2 2 2 3 3 2 *1* 2 3 3 2 2 2 3 3 3 3 3 3

[R] plot area: secondary y-axis does not display well

2010-04-02 Thread Muhammad Rahiz
Dear useRs, I'm having a slight problem with plotting on 2 axes. While the following code works alright on screen, the saved output does not turn out as desired i.e. the secondary y-axis does not display fully. Just run the code and look at image output. Suggestions please... thanks,

Re: [R] Odp: plot area: secondary y-axis does not display well

2010-04-02 Thread Muhammad Rahiz
Thanks Ivan, Jim and Petr. The output turns out as desired after I've taken your suggestions. Muhammad __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] one way to write scripts in R

2010-03-29 Thread Muhammad Rahiz
I've been calling R from shell using the following (as example) ... #!/bin/bash for dir in $(ls *.txt); do R CMD BATCH script.R done Muhammad Tsjerk Wassenaar wrote: Hi, That seems quite neat. To make it a bit more flexible, and maybe do some argument acrobatics with bash, you could

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz
in the same file. HTH Jannis Muhammad Rahiz schrieb: Hello all, I'd like some advise on this. When I read my files, I pass the argument, skip=6, to skip 6 lines of header information. After performing the desired calculations, I have the output. Now I want to copy the 6 lines of skipped

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz
Yes, it works. Just wondering if the technique can be optimized... David Winsemius wrote: On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote: Dear Jannis, Thanks for the tip. It works but I'd like to improve on the way I did it. x - array(1:50,dim=c(10,10)) # data h1 - c(ncols

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz
290.00 -20.00 -20.00 5000.00 -.00 1 3 5 2 4 6 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY

[R] insert/copy skipped lines to output

2010-03-27 Thread Muhammad Rahiz
Hello all, I'd like some advise on this. When I read my files, I pass the argument, skip=6, to skip 6 lines of header information. After performing the desired calculations, I have the output. Now I want to copy the 6 lines of skipped information to the output. What I've been doing so far

Re: [R] Converting date format

2010-03-24 Thread Muhammad Rahiz
The following functions may help; strptime() ISOdate() Muhammad Hosack, Michael wrote: R community: Hello, I would to like to convert a character date variable from %m/%d/%Y to %m/%d/%y. Any advice would be greatly appreciated. I have tried functions for changing the formatting and

Re: [R] Summing with NA

2010-03-24 Thread Muhammad Rahiz
Slightly longer method, but works as well. z - c(-12,-9) e - c(-2,0) k - c(NA,NA) x - c(z,e,k) x1 - which(x!=NA,arr.ind=TRUE) # get elements which are not NA x2 - x[x1] sum(x2) [1] -23 -- Muhammad tj wrote: Hi all, May I request for your help if you have time and if you have an idea on

Re: [R] Create matrix with subset from unlist

2010-02-01 Thread Muhammad Rahiz
this the solution I gave?? On Fri, Jan 29, 2010 at 9:43 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk mailto:muhammad.ra...@ouce.ox.ac.uk wrote: Thanks David Dennis, I may have found something. Given that the object xx is the product of unlist(x), to create a 2x2 matrix

[R] Create matrix with subset from unlist

2010-01-29 Thread Muhammad Rahiz
Hello all, I'm trying to create a 2x2 matrix, 32 times after unlist() so that I can convert the list to matrix. I've looked through the R archive but couldn't find the answer. There is what I've done. f - system(ls *.txt, intern=TRUE) x - lapply(f, read.table) x [[1]] V1V2 1

Re: [R] Create matrix with subset from unlist

2010-01-29 Thread Muhammad Rahiz
Thanks David Dennis, I may have found something. Given that the object xx is the product of unlist(x), to create a 2x2 matrix with subsets, I could do, y - matrix(xx[c(1:4)], 2, 2). This returns, [,1] [,2] [1,] -27.3 14.4 [2,] 29.0 -38.1 If I do, y2 - matrix(xx[c(5:8)],2,2)

Re: [R] Create matrix with subset from unlist

2010-01-29 Thread Muhammad Rahiz
this right? Muhammad -- Muhammad Rahiz wrote: Thanks David Dennis, I may have found something. Given that the object xx is the product of unlist(x), to create a 2x2 matrix with subsets, I could do, y - matrix(xx[c(1:4)], 2, 2). This returns, [,1] [,2] [1,] -27.3 14.4 [2

[R] (list) object cannot be coerced to type 'double'

2010-01-26 Thread Muhammad Rahiz
Dear all, My script returns the following error: Error in storage.mode(test) - logical : (list) object cannot be coerced to type 'double' I've looked around and some suggest that it could be the way data have been imported. For my case, I don't think it is such. Rather I think it has to be

[R] Drought severity index: Excel to R

2010-01-16 Thread Muhammad Rahiz
. How do I make the data in Excel's Column C in R? Or in other words, how do I update the result of the conditional statements into the dummy file, d, which I created (which apparently didn't work). I hope my explanation makes sense. thanks. Muhammad -- Muhammad Rahiz | Doctoral Student

[R] Drought Severity Index (DSI)

2010-01-12 Thread Muhammad Rahiz
Does anyone have the code to calculate the drought severity index? -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford

Re: [R] Drought Severity Index (DSI)

2010-01-12 Thread Muhammad Rahiz
)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk Jim Lemon wrote: On 01/12/2010 07:21 PM, Muhammad Rahiz wrote: Does anyone have the code to calculate the drought severity index? Hi Muhammad, If you mean does anyone have the algorithm? it seems pretty hard to find. Even that old

Re: [R] Drought Severity Index (DSI)

2010-01-12 Thread Muhammad Rahiz
Thanks Steve! Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0

Re: [R] Increment in loop - OK

2010-01-07 Thread Muhammad Rahiz
This works. m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) out - list() for (i in 1:4){ t[[i]] - Reduce(+, x1[c(i:i+1)]) } Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School

Re: [R] Question on Reduce + rollmean

2010-01-07 Thread Muhammad Rahiz
)]) } Muhammad Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865

Re: [R] Question on Reduce + rollmean

2010-01-07 Thread Muhammad Rahiz
Yes, should be 1. out[[i]], instead of t[[i]]. 2. x1[c(i:(i+1))] # For this case, I was trying out the rolling sum. Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment

[R] Increment in loop

2010-01-06 Thread Muhammad Rahiz
[c(2:3)] x1[c(3:4)] where x1 = m - matrix(1:3,3,3) x1 - list(m, m+1, m+2, m+3, m+4) Thanks. Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford

Re: [R] Question on Reduce + rollmean

2010-01-04 Thread Muhammad Rahiz
Thanks Gabor, It works alright. But is there alternative ways to perform rollmean apart from permutating the data? Possibly combining the Reduce and rollmean functions? The easiest but traditional way is (x[[1]]+x[[2]]) / 2 (x[[2]]+x[[3]]) / 2 Muhammad Rahiz | Doctoral Student

[R] Question on Reduce + rollmean

2010-01-02 Thread Muhammad Rahiz
= (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY

Re: [R] Question on Reduce + rollmean

2010-01-02 Thread Muhammad Rahiz
]] ) / 2 ( x[[2]] + x[[3]] ) / 2 ... and so on. The desired output will return 2.5 2.5 2.5 3.5 3.5 3.5 4.5 4.5 4.5 5.5 5.5 5.5 6.5 6.5 6.5 7.5 7.5 7.5 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford

[R] select elements and transpose

2009-12-30 Thread Muhammad Rahiz
something like the following; 1 10 19 2 11 20 3 12 21 and so on.. Thanks.. -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre

Re: [R] To export results

2009-12-28 Thread Muhammad Rahiz
write.table(x2, filename.txt, col.name=FALSE, row.name=FALSE) # where x2 = variable you want to save Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University

[R] Scaling error

2009-12-27 Thread Muhammad Rahiz
data but not for my actual dataset. At the moment, I'm thinking of something in the lines of a for loop function i.e. for (i in ...){ statement... } Is there a syntax in the for loop that allows me to select the column/row in the file? Thanks. -- Muhammad Rahiz | Doctoral Student

[R] if else does not return right value

2009-12-26 Thread Muhammad Rahiz
and only the first element will be used The problem is solved if I use the ifelse function but I want to specify the code as following; if (/condition/) { /statement 1a statement 1b /} else { /statement 2a statement 2b /} Thanks. Muhammad -- Muhammad Rahiz | Doctoral Student in Regional

Re: [R] if else does not return right value

2009-12-26 Thread Muhammad Rahiz
(test.txt)) Original code; if (x 20){ y - x + 100 # statement 1a ... # statement 1b } else { y - x -100 # statement 2a ... # statement 2b } New code: n0 - x + 100 n1 - n0 + 0 m0 - x - 100 m1 - m0 - 0 ifelse(x 20, n1, m1) Muhammad Muhammad Rahiz | Doctoral Student in Regional Climate

Re: [R] Object of type 'closure' not subsettable

2009-12-21 Thread Muhammad Rahiz
the following, the error is gone but I'm not getting the output for each individual file I require d2 - f[[i]] - m The issue is, how do I make d2 subsettable? Thanks. Muhammad Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research

[R] Object of type 'closure' not subsettable - OK

2009-12-21 Thread Muhammad Rahiz
Thanks Petr, Barry David for your useful comments. Given d2[[i]] - f[[i]] - m The problem lies in how I define the object, d2[[i]], which I managed to resolve by d2 - list() -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling

[R] Problem with sequence in loop

2009-12-20 Thread Muhammad Rahiz
objects() list [1] 2006.01.txt.h 2006.02.txt.h 2006.12.txt.h The listed files are the last files in the sequence. Am I doing the loop correctly? -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School

[R] Recall: Problem with sequence in loop

2009-12-20 Thread Muhammad Rahiz
)) myfile1 - paste(strsplit(seq[[i]], \\.)[[1]][1], sum.txt, sep=.) write.table(mean, file=myfile1, row.names=FALSE, col.names=FALSE) } - Muhammad Rahiz wrote: Hi all, I've got a list of files from 1914 to 2000. For each file, I can call the read.table function as follows. file - read.table

[R] Object of type 'closure' not subsettable

2009-12-20 Thread Muhammad Rahiz
. for (j in 1:3) print (file[[j]]-mean) Thanks. Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks

Re: [R] Output multiple files

2009-12-08 Thread Muhammad Rahiz
Code works fine. Thanks! Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865

[R] Output multiple files

2009-12-07 Thread Muhammad Rahiz
. -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile

[R] Standard deviation for each element in a set of matrices

2009-12-04 Thread Muhammad Rahiz
cell in the file (I'm using gridded data). The desired output is Output 3 3 3 3 3 3 3 3 3 Thanks. Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography

[R] Arithmetic on multiple files

2009-12-02 Thread Muhammad Rahiz
Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865