Re: [R] plotting on a reverse log scale

2005-07-07 Thread Sundar Dorai-Raj
Michael Friendly wrote: Thanks to all who replied, particularly Duncan Murdoch, whose solution I adopted. It thought it might be of interest to some to see the results and compare these ways of representing the distribution of historical events over time. The events are the items I

Re: [R] plotting on a reverse log scale

2005-07-07 Thread Sundar Dorai-Raj
Michael Friendly wrote: Thanks to all who replied, particularly Duncan Murdoch, whose solution I adopted. It thought it might be of interest to some to see the results and compare these ways of representing the distribution of historical events over time. The events are the items I

Re: [R] Main Title for multiple charts

2005-07-07 Thread Sundar Dorai-Raj
Laura Holt wrote: Hi R ! I have the following set up: par(mfrow=c(2,2)) curve(dexp,from=0,to=5) hist(z1,main=Size 5) hist(z2,main=Size 15) hist(z3,main=Size 30) I would like to put a title at the very top of the page that ties the theme of all the charts together. How would

Re: [R] removing factor level represented by less than x rows

2005-07-08 Thread Sundar Dorai-Raj
Mikkel Grum wrote: In a number of different situations I'm trying to remove factor levels that are represented by less than a certain number of rows, e.g. if I had the dataset aa below and wanted to remove the species that are represented in less than 2 rows: data(iris) aa -

Re: [R] Finding indices of NA values in a data frame

2005-07-08 Thread Sundar Dorai-Raj
Ken Termiso wrote: Hi all, I've got a data frame with NA values scattered throughout. I would like to find the rows which contain an NA. Trying to find the indices of the NAs with grep() doesn't work (apparently you can't convert NA to NA character value, even with as.character()) so I

[R] building packages on Windows

2005-07-11 Thread Sundar Dorai-Raj
Hi, all, I just recently upgraded my computer though I'm using the same OS (XP). But now I'm having difficulty building packages and I cannot seem to solve the problem. I'm using R-2.1.1pat on Windows XP. Here is what I tried: D:\Users\sundard\slib\sundar\RR CMD CHECK sundar * checking for

Re: [R] building packages on Windows

2005-07-11 Thread Sundar Dorai-Raj
Duncan Murdoch wrote: On 7/11/2005 3:21 PM, Sundar Dorai-Raj wrote: Hi, all, I just recently upgraded my computer though I'm using the same OS (XP). But now I'm having difficulty building packages and I cannot seem to solve the problem. I'm using R-2.1.1pat on Windows XP. Here is what

Re: [R] Determining response variable in a formula

2005-07-12 Thread Sundar Dorai-Raj
David Kane wrote: I have a formula from which I want to deduce the name of the response variable. One way of doing so is as follows: my.form - as.formula(y ~ x + z) all.vars(my.form)[1] [1] y Is there a better way and/or preferrred method of determining y from my.form than this

Re: [R] getting panel.loess to use updated version of loess.smooth

2005-07-12 Thread Sundar Dorai-Raj
Benjamin Tyner wrote: I'm updating the loess routines to allow for, among other things, arbitrary local polynomial degree and number of predictors. For now, I've given the updated package its own namespace. The trouble is, panel.loess still calls the original code in package:stats instead

Re: [R] 3d scatter plot

2005-07-15 Thread Sundar Dorai-Raj
Eric Hu wrote: Hi, I ran into a dilemma trying to plot the following data in a 3d scatter fashion. My data are not always increasing as persp() expects. For now I use scatterplot3d to get points in a 3d scatter plot. I wonder if I have any way to plot the surfaces. Thanks! Eric

Re: [R] extracting row means from a list

2005-07-19 Thread Sundar Dorai-Raj
Andy Bunn wrote: Hello: I'm reading in a series of text files (100 files that are each 2000 rows by 6 columns). I wish to combine the columns (6) of each file (100) and get the row mean. I'd like to end up with a data.frame of 2000 rows by 6 columns. foo - list() for(i in 1:10){ #

Re: [R] deriv - accessing numeric output listed under gradient attribute

2005-07-19 Thread Sundar Dorai-Raj
Jay Rotella wrote: Hi, I am interested in using the numeric output from the gradient attribute of deriv's output in subsequent analyses. But, I have so far been unable to determine how to do so. I will use the example from the deriv help to illustrate. ## function with defaulted

Re: [R] Regression lines for differently-sized groups on the same plot

2005-07-19 Thread Sundar Dorai-Raj
Laura M Marx wrote: Hi there, I've looked through the very helpful advice about adding fitted lines to plots in the r-help archive, and can't find a post where someone has offered a solution for my specific problem. I need to plot logistic regression fits from three differently-sized

Re: [R] R graphics

2005-07-21 Thread Sundar Dorai-Raj
Sam Baxter wrote: Hi I am trying to set up 16 graphs on one graphics page in R. I have used the mfrow=c(4,4) command. However I get a lot of white space between each graph. Does anyone know how I can reduce this? Thanks Sam Two options: 1. play around with the `mar' parameter

Re: [R] A Question About Inverse Gamma

2005-07-21 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] wrote: Hi R users, I am having a little problem finding the the solution to this problem in R: 1. I need to generate normal distribution of sample size 30, mean = 50, sd = 5. 2. From the statistics obtained in step 1, I need to generate the Inverse Gamma

Re: [R] order of panels in xyplot

2005-07-25 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] wrote: I'm having trouble with the order of the panels using xyplot. I had used this bit of code before and received the desired plot (the code was not identical, but very similar; perhaps more importantly I was working with an older version of R) . Now the panels

Re: [R] Returning positions of a vector

2005-07-27 Thread Sundar Dorai-Raj
Mike Jones wrote: Hi, I'd like to return the rows of sampled values of a vector. Can't figure out how to do it. For example: I start with [3, 1, 7, 4, 10] that have position [1,2,3,4,5]. I sample [10,1,4] and I want to return [5,2,4]. I'm sure there's a simple way to do that but

Re: [R] using integrate with optimize nested in the integration

2005-07-28 Thread Sundar Dorai-Raj
Gregory Gentlemen wrote: Hi guys im having a problem getting R to numerically integrate for some function, say f(bhat)*optimize(G(bhat)), over bhat. Where id like to integrate this over some finite range, so that here as we integrate over bhat optimize would return a different optimum.

Re: [R] using integrate with optimize nested in the integration

2005-07-28 Thread Sundar Dorai-Raj
Again, not a good example, since f is linear in n so the max will always be at 15. Try this: f - function(x, n) -(x - 2.5 * n)^2 # max is at 2.5*n g - function(n) { o - vector(numeric, length(n)) for(i in seq(along = n)) o[i] - optimize(f, c(0, 15), maximum = TRUE, n =

Re: [R] xyplot auto.key issue

2005-07-31 Thread Sundar Dorai-Raj
Hi, Mike, Mike Lawrence wrote: Hi Deepayan, Thanks for the reply, but when I enter the type = b code into the auto.key (see below) command I get the following message: Error in valid.pch(x$pch) : zero-length 'pch' Any suggestions? Why not just ignore auto.key and use key?

Re: [R] prcomp eigenvalues

2005-08-02 Thread Sundar Dorai-Raj
Rebecca Young wrote: Hello, Can you get eigenvalues in addition to eigevectors using prcomp? If so how? I am unable to use princomp due to small sample sizes. Thank you in advance for your help! Rebecca Young Hi, Rebecca, From ?prcomp: The calculation is done by a singular

Re: [R] filter data set unique, duplicate..

2005-08-03 Thread Sundar Dorai-Raj
Hi, Anders/Dimitris, Dimitris Rizopoulos wrote: maybe you could consider something like this: dat - data.frame(x = c(1, 2, 2, 3, 3, 4), y1 = c(1, 1, 2, 1, 7, 8), y2 = c(NA, NA, NA, 5, 5, 4), y3 = c(3, 11, NA, 16, 2, 1)) #

Re: [R] passing variable to formula environment

2005-08-03 Thread Sundar Dorai-Raj
Eric Archer wrote: List gurus, I'm trying to code a Gompertz growth curve function as part of a larger project and have run across a problem due to my ignorance of environments. Some sample data and the function are as follows: growth - data.frame(age = c(1.92, 3, 5.83, 3.17, 15.5,

Re: [R] help regarding loops in R

2005-08-03 Thread Sundar Dorai-Raj
Rangesh Kunnavakkam wrote: I have a large vector of around 12597 elements and I wish to calculate p-value for each element using a formula of something like: p-value= 1- exp^(kexp^(-labda)) I was wondering someone could give some ideas how to implement for each

Re: [R] optim

2005-08-04 Thread Sundar Dorai-Raj
nwew wrote: Dear R-helpers, The function optim implements algorithms that I would like to use. I have function implemented in R, which given the parameters of which minimization is to take place returns a scalar as well as the gradient. Unfortunately optim requires two function

Re: [R] additional graphical parameters in contour function

2005-08-04 Thread Sundar Dorai-Raj
Abdou ALI wrote: Do you know why additional graphical parameters (like type,pch, ...) do not work in the R contour fonction. For example the command 'contour(..., type=o,pch=16)' gives nothing, just simple contour lines. Please, can you explain why you think it does make sense here? The

Re: [R] interpolation function in R

2005-08-04 Thread Sundar Dorai-Raj
吴 昊 wrote: Hi does R provide some interpolation fucntions? thank __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] use of NA's

2005-08-05 Thread Sundar Dorai-Raj
tom wright wrote: Can someone please explain why this works: d-c(0,2,3,2,0,3,4,0,0,0,0,0) d.mat-matrix(data=d,nrow=4,ncol=3,byrow=TRUE) for(i in 1:length(d.mat[1,])){ + d.mat[,i][d.mat[,i]==0]-mean(d.mat[,i][d.mat[,i]0]) + } Whereas: d-c(0,2,3,2,0,3,4,0,0,0,0,0)

Re: [R] R: cbind

2005-08-08 Thread Sundar Dorai-Raj
Clark Allan wrote: hi all are we able to combine column vectors of different lengths such that the result appears in matrix form? e.g. a=1 b=1:3 d=1:4 then z=CBIND(a,b,d) 1 1 1 2 2 3 3 4 i stil want the following! z[,1]=1 z[,2]=1:3 z[,3]=1:5 i made

Re: [R] predict nbinomial glm

2005-08-16 Thread Sundar Dorai-Raj
Katharina, I agree with Prof. Ripley's assessment. But, perhaps one thing you may have overlooked is that subset.data.frame does not remove unused levels. So, subset_of_dataframe = subset(data_frame, (b 80 c 190)) levels(subset_of_dataframe$d) [1] q r s t table(subset_of_dataframe$d)

Re: [R] Classifying values in vector

2005-08-17 Thread Sundar Dorai-Raj
mark salsburg wrote: I have a vector of size 217 called A. the values of A are not sorted and range from 0 to 1 (normalized) I am having difficulty writing a program to create a new vector B where if A's value is 0 A =0.333 then B is 0 if A's value is 0.333 A =0.666 then B is 1 if

Re: [R] Classifying values in vector

2005-08-17 Thread Sundar Dorai-Raj
mark salsburg wrote: I have a vector of size 217 called A. the values of A are not sorted and range from 0 to 1 (normalized) I am having difficulty writing a program to create a new vector B where if A's value is 0 A =0.333 then B is 0 if A's value is 0.333 A =0.666 then B is 1 if

Re: [R] do glm with two data sets

2005-08-17 Thread Sundar Dorai-Raj
Hu, Ying (NIH/NCI) wrote: I have two data sets: File1.txt: Name id1 id2 id3 ... N10 1 0 ... N20 1 1 ... N31 1 -1... ... File2.txt: Group id1 id2 id3 ... G1 1.22 1.34 2.44 ... G2 2.33

Re: [R] do glm with two data sets

2005-08-18 Thread Sundar Dorai-Raj
PROTECTED] Sent: Wednesday, August 17, 2005 7:01 PM To: Sundar Dorai-Raj Cc: Hu, Ying (NIH/NCI); r-help@stat.math.ethz.ch Subject: Re: [R] do glm with two data sets On Wed, 2005-08-17 at 17:22 -0500, Sundar Dorai-Raj wrote: Hu, Ying (NIH/NCI) wrote: I have two data sets: File1.txt: Name id1

Re: [R] do glm with two data sets

2005-08-18 Thread Sundar Dorai-Raj
: Thursday, August 18, 2005 11:00 AM To: Hu, Ying (NIH/NCI) Cc: Sundar Dorai-Raj; r-help@stat.math.ethz.ch Subject: RE: [R] do glm with two data sets On Thu, 2005-08-18 at 10:38 -0400, Hu, Ying (NIH/NCI) wrote: Thanks for your help. # read the two data sets e - as.matrix(read.table(file1.txt

Re: [R] problem with repeated formal arguments and ...

2005-08-18 Thread Sundar Dorai-Raj
Ross Boylan wrote: I want to add an argument if it is not present. Following the Green Book, p. 337: test - function(x, ...){ dots - list(...) if (!hasArg(from)) from - 0 else from - dots$from curve(x, from=from, ...) } test(sin) test(sin, from=4) Error in

Re: [R] problem with repeated formal arguments and ...

2005-08-18 Thread Sundar Dorai-Raj
Sundar Dorai-Raj wrote: Ross Boylan wrote: I want to add an argument if it is not present. Following the Green Book, p. 337: test - function(x, ...){ dots - list(...) if (!hasArg(from)) from - 0 else from - dots$from curve(x, from=from, ...) } test(sin) test(sin, from=4

Re: [R] Converting characters to numbers in data frames

2005-08-25 Thread Sundar Dorai-Raj
Anon. wrote: I'm sure I'm missing something obvious here, but I can't find the solution (including in the FAQ etc.). I have a vector of names of variables like this: NRes.x.y. where x and y are numbers. I want to extract these numbers as numbers to use elsewhere. I can extract the

Re: [R] tiing an array to a data frame

2005-08-29 Thread Sundar Dorai-Raj
?rbind --sundar Mag. Ferri Leberl wrote: Dear colleagues! I am afraid this is an easy question but as a pitty I did not find out on my own, so please be patient with my question: If I have a data frame X and an array Y. Which is the command to make Y become an additional row of X?

Re: [R] user defined panel function

2005-08-29 Thread Sundar Dorai-Raj
Martin Henry H. Stevens wrote: Mac OS 10.3.9 R framework v. 2.1.1 I am attempting to put a fitted curve into each panel of a lattice graph, but am failing to do so. I have tried writing a very sophisticated function to do so. The function seems to work when used with plot(), but does

Re: [R] Spacing and margins in lattice...

2005-09-01 Thread Sundar Dorai-Raj
Jamieson Cobleigh wrote: Similar to my last question, I want to tighten up the spacing and margins in a plot I am doing with lattice. Here are the commands I'm using: data - data.frame(x=c(1:3, 1:3), y=c(1:3, 1:3*2), cat=c(foo,foo,foo,bar, bar,bar)) xyplot(panel=panel.superpose, y~x,

Re: [R] Lattice key seems to ignore the key list

2005-09-07 Thread Sundar Dorai-Raj
Patrick Connolly wrote: I've never had this problem before and can't see what could be different from other times I've used keys with lattice. It appears that auto.key is being taken as TRUE when I specify a key list. The list I specify seems to be ignored. Where can I place a

Re: [R] solving a system of nonlinear equations

2005-09-07 Thread Sundar Dorai-Raj
Olshansky,Moshe wrote: What is the classic R function for solving a (possibly over determined) system of non-linear equations? Thank you! Moshe Olshansky e-mail: [EMAIL PROTECTED] I'm not sure what your definition of 'classic' is, but there are several options in

Re: [R] set differences

2005-09-12 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] wrote: Can anyone tell me how to do set differences in R? e.g., if I have a vector a-c(1,2,3,4,5) and another vector b-c(2,5), how can I do something like a/b = (1,3,4)? Thanks! a[!a %in% b] *or* setdiff(a, b) --sundar

Re: [R] Collineariy Diagnostics

2005-09-13 Thread Sundar Dorai-Raj
Antoine de Bary wrote: Hi, and thanks for your help in order to do collinearity analysis I downloaded the perturb package. I run a lm (regression) and on that the ³calldiag² commad to get condition numbers but i get the following message: the variable XY with modus ³numeric² was not found

Re: [R] if() command

2005-09-13 Thread Sundar Dorai-Raj
Carlos Maurício Cardeal Mendes wrote: Hi everyone ! Could you please help me with this problem ? I´ve trying to write a code that assign to a variable the content from another, but all I´ve got is a message error. For example: if (age =10) {group == 1} else if (age 10 age = 20)

Re: [R] where is eda library (Prof. Ripley's Exploratory Data Analysis Library)

2005-09-13 Thread Sundar Dorai-Raj
Three things: 1. Please do not hit the reply button to an unrelated topic and change the subject. As the signature tells you, PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html; 2. You are looking for the eda *package* and not a *library*. 3. Since eda is not on

Re: [R] what OS

2005-09-13 Thread Sundar Dorai-Raj
Omar Lakkis wrote: How can I determine whT OS I am running under? if WINDOWS do this if LINUX do that Hi, Omar, Look at version$os. # windows version$os [1] mingw32 # linux version$os [1] linux-gnu HTH, --sundar __

Re: [R] if() command

2005-09-14 Thread Sundar Dorai-Raj
if is not vectorised and age is a vector. Try the following test: if(c(TRUE, FALSE)) TRUE else FALSE You really need to use ifelse. ifelse(c(TRUE, FALSE), TRUE, FALSE) As others have suggested, you might want to look at ?cut. --sundar Carlos Mauricio Cardeal Mendes wrote: Ok Petr, I run

Re: [R] Integrate functions with loops

2005-09-16 Thread Sundar Dorai-Raj
A.Brennan wrote: Hi i am having a problem with the 'integrate' function the function i want to integrate has the form sum(vector^x) i have defined the function with a for loop first - integrandtotest - function(x) {a-rep(0,len=2) for (i in 1:2) {a[i]-t[i]^x}

Re: [R] Possible bug in lmer nested analysis with factors

2005-09-16 Thread Sundar Dorai-Raj
My guess is he wants this: c1 - factor(c) d1 - factor(d) m - lmer(a ~ b + (1|c1:d1)+(1|c1)) which assumes d1 is nested within c1. Take a look at Section 3 in the MlmSoftRev vignette: library(mlmRev) vignette(MlmSoftRev) HTH, --sundar Doran, Harold wrote: I think you might have confused lme

Re: [R] trimmed mean in R seems to round the trimming fraction

2005-09-18 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] wrote: subject: trimmed mean in R seems to round the trimming fraction to [EMAIL PROTECTED] Consider the following example of 10 numbers. 10% trimmed mean is correct but you can see that the result is the same for many trimming fractions till 0.20! For example

Re: [R] How to exclude a level from a factor

2005-09-20 Thread Sundar Dorai-Raj
Qiong Yang wrote: Hi, I could not use 'exlcude=' option in factor() to exclude a level from a existing factor. x is a factor: x [1] a b c Levels: a b c factor(x,exclude=c) [1] a b c Levels: a b c Warning message: NAs introduced by coercion However, c is not coded as

Re: [R] [R-pkgs] Reshape package: new version 0.5

2005-09-23 Thread Sundar Dorai-Raj
Randall R Schulz wrote: Hadley, On Thursday 22 September 2005 16:36, hadley wickham wrote: Reshape version 0.5 === Reshape is an R package for flexibly restructuring and aggregating data. It's very much pivot table inspired, and it (hopefully) makes it very easy to view

Re: [R] histogram - one bin for all values larger than a certain value

2005-09-26 Thread Sundar Dorai-Raj
Florian Defregger wrote: Dear all, I wonder if I can put together a histogram where one bin contains all the values that are larger than a certain specified value. Example: I have values ranging from 0 to 40 and I want 10 bins from 0 to 10, i.e. for the intervals [0,1), [1,2) , ...,

Re: [R] arima.sim bug?

2005-10-02 Thread Sundar Dorai-Raj
Kemp S E (Comp) wrote: Hi, I am using the arima.sim function to generate some AR time series. However, the function does not seem to produce exactly the same time series when I specify the innov parameter. For example r - rnorm(300) x - arima.sim(300,

Re: [R] returning a modified fix()-ed dataframe

2005-10-07 Thread Sundar Dorai-Raj
Adrian DUSA wrote: Dear all, In order to ease the transition from SPSS to R for some of my colleagues, I am trying to create a function which would show the variables and their labels (if those exist), using function label in package Hmisc. A toy example would be this: my.data -

Re: [R] returning a modified fix()-ed dataframe

2005-10-07 Thread Sundar Dorai-Raj
Adrian DUSA wrote: On Friday 07 October 2005 20:55, Sundar Dorai-Raj wrote: Adrian DUSA wrote: [...snip...] Hi, Adrian, You need to assign fix(dataf) to something: my.data - data.frame(age=c(24,35,28), gender=c(Male, Female, Male)) require(Hmisc) label(my.data$age) - Respondent's age

Re: [R] How to get the remaining vector after sampling a subset?

2005-10-09 Thread Sundar Dorai-Raj
Xiao Shi wrote: Hi , I have a vector,for example, x=rnorm(100) Then i rendom choose 20 of them. chosen=sample(x,20). And i want to get the remain values in x. Is there a quick way to go? Thanks in advance. [[alternative HTML version deleted]] How about: x - rnorm(100) y -

Re: [R] Reading # in file with read.csv

2005-10-11 Thread Sundar Dorai-Raj
Michel Friesenhahn wrote: I'm using read.csv to read in a csv file containing '#' characters. For example, say I'm reading the following file (test.csv): var1,var2,var3 a,b,c d,e#,f g,h,i It outputs: read.csv(Raw Data\\test.csv) var1 var2 var3 1abc 2de

Re: [R] Need help write a function

2005-10-11 Thread Sundar Dorai-Raj
Jan Sabee wrote: Dear all, I am still learning R with write a small function for my self. I was wondering if someone can help me to write a R function formula below: Z_k (x) = \sum_{i=0}^{i=k} \binom{n}{i} (m-1)^i Thanks a million in advance, Sincerely, Jan Sabee (This smells like a

Re: [R] How to get aspect ratio as output from from plot()

2005-10-11 Thread Sundar Dorai-Raj
Waichler, Scott R wrote: Is there a way to get the aspect ratio as output from a plot() call or something similar in the base graphics system? I would like to note vertical exaggeration on an elevation profile. Thanks, Scott Waichler Pacific Northwest National Laboratory [EMAIL

Re: [R] problems with levelplot and contourplot

2005-10-11 Thread Sundar Dorai-Raj
Tom Lenaerts wrote: Hello, Using the following code i want to make a level or contourplot of some data that I produced library(grid);library(lattice); No need to explicitly load grid. This is done when attaching lattice. Also, you do not need any ; at the end of any lines. mydata

Re: [R] problems with levelplot and contourplot

2005-10-11 Thread Sundar Dorai-Raj
://www.tomlenaerts.tk/ Postdoc Researcher @ IRIDIA-Universite Libre de Bruxelles-Belgium Guest Professor @ DINF-Vrije Uiversiteit Brussel-Belgium On 11 Oct 2005, at 22:26, Sundar Dorai-Raj wrote: Tom Lenaerts wrote: Hello, Using the following code i want to make a level

Re: [R] functions available for use with aggregate?

2005-10-12 Thread Sundar Dorai-Raj
t c wrote: What are the functions available for use with “aggregate”? Where can a reference to them be found? Since aggregate is a S3 generic, you can use methods(aggregate) to see what objects have an aggregate method. For me, I have the following: methods(aggregate) [1]

Re: [R] shell scripts in R

2005-10-13 Thread Sundar Dorai-Raj
Benedykt P. Barszcz wrote: Dnia czwartek, 13 października 2005 23:25, Andrew Robinson napisał: Marco, use the system command. ?system I hope that this helps, system(ls, intern = FALSE, ignore.stderr = TRUE) Error in as.character(args[[i]]) : cannot coerce to vector In fact it

Re: [R] Sweave and multipage lattice

2006-07-19 Thread Sundar Dorai-Raj
Dieter Menne wrote: Dear R-Listeners, as the Sweave faq says: http://www.ci.tuwien.ac.at/~leisch/Sweave/FAQ.html creating several figures from one figure chunk does not work, and for standard graphics, a workaround is given. Now I have a multipage trellis plot with an a-priori

Re: [R] Wrap a loop inside a function

2006-07-19 Thread Sundar Dorai-Raj
Doran, Harold wrote: I need to wrap a loop inside a function and am having a small bit of difficulty getting the results I need. Below is a replicable example. # define functions pcm - function(theta,d,score){ exp(rowSums(outer(theta,d[1:score],'-')))/

Re: [R] throwaway() function

2006-07-20 Thread Sundar Dorai-Raj
John Wiedenhoeft wrote: Dear all, I apologize if this is a FAQ (seems a bit like one, but I didn't find anything). I'm looking for an easy way to cut one value out of a vector and shorten the vector accordingly. Something like: x - c(1, 1, 0, 6, 2) throwaway(x[3]) which will return

Re: [R] intersect of list elements

2006-07-21 Thread Sundar Dorai-Raj
Georg Otto wrote: Hi, i have a list of several vectors, for example: vectorlist $vector.a.1 [1] a b c $vector.a.2 [1] a b d $vector.b.1 [1] e f g I can use intersect to find elements that appear in $vector.a.1 and $vector.a.2: intersect(vectorlist[[1]],

Re: [R] scatter plot with axes drawn on the same scale

2006-07-28 Thread Sundar Dorai-Raj
Try: plot(x, y, asp = 1) --sundar bogdan romocea wrote: Dear useRs, I'd like to produce some scatter plots where N units on the X axis are equal to N units on the Y axis (as measured with a ruler, on screen or paper). This approach x - sample(10:200,40) ; y - sample(20:100,40)

Re: [R] Sweave error in example code

2006-07-31 Thread Sundar Dorai-Raj
LL wrote: Hi.. I am running R version 2.3.1 on a Windows XP machine with the latest Miktex 2.5 installed. I get no errors from R when running the Sweave example, testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils) However, when I tex the resulting .tex file (after

[R] deleting a directory

2006-08-01 Thread Sundar Dorai-Raj
Hi, all, I'm looking a utility for removing a directory from within R. Currently, I'm using: foo - function(...) { mydir - tempdir() dir.create(mydir, showWarnings = FALSE, recursive = TRUE) on.exit(system(sprintf(rm -rf %s, mydir))) ## do some stuff in mydir invisible() }

Re: [R] deleting a directory

2006-08-01 Thread Sundar Dorai-Raj
Please ignore. I forgot ?unlink had a recursive argument. Thanks. --sundar Sundar Dorai-Raj wrote: Hi, all, I'm looking a utility for removing a directory from within R. Currently, I'm using: foo - function(...) { mydir - tempdir() dir.create(mydir, showWarnings = FALSE

Re: [R] Doubt about Student t distribution simulation

2006-08-04 Thread Sundar Dorai-Raj
Hi, Jose/John, Here's an example to help Jose and highlights John's advice. Also includes set.seed which should be included in all simulations posted to R-help. set.seed(42) mu - 10 sigma - 5 n - 3 nsim - 1 m - matrix(rnorm(n * nsim, mu, sigma), nsim, n) t - apply(m, 1, function(x)

Re: [R] fitting truncated normal distribution

2006-08-16 Thread Sundar Dorai-Raj
[EMAIL PROTECTED] wrote: Hello, I am a new user of R and found the function dtnorm() in the package msm. My problem now is, that it is not possible for me to get the mean and sd out of a sample when I want a left-truncated normal distribution starting at 0. fitdistr(x,dtnorm,

Re: [R] fitting truncated normal distribution

2006-08-16 Thread Sundar Dorai-Raj
Sorry, didn't notice that you *did* mention dtnorm is part of msm. Ignore that part of the advice... --sundar Sundar Dorai-Raj wrote: [EMAIL PROTECTED] wrote: Hello, I am a new user of R and found the function dtnorm() in the package msm. My problem now is, that it is not possible for me

Re: [R] fitting truncated normal distribution

2006-08-17 Thread Sundar Dorai-Raj
in advance markus Sorry, didn't notice that you *did* mention dtnorm is part of msm. Ignore that part of the advice... --sundar Sundar Dorai-Raj wrote: [EMAIL PROTECTED] wrote: Hello, I am a new user of R and found the function dtnorm() in the package msm. My problem now

Re: [R] fitting truncated normal distribution

2006-08-18 Thread Sundar Dorai-Raj
, there is a way fitdistr can also compute difficult data. Best regards, markus -Original Message- From: Sundar Dorai-Raj [mailto:[EMAIL PROTECTED] Sent: Donnerstag, 17. August 2006 16:47 To: Schweitzer, Markus Cc: r-help@stat.math.ethz.ch Subject: Re: [R] fitting truncated normal

Re: [R] generating an expression for a formula automatically

2006-08-24 Thread Sundar Dorai-Raj
Maria Montez wrote: Hi! I would like to be able to create formulas automatically. For example, I want to be able to create a function that takes on two values: resp and x, and then creates the proper formula to regress resp on x. My code: fit.main - function(resp,x) { form -

Re: [R] Extracting column name in apply/lapply

2006-08-28 Thread Sundar Dorai-Raj
Nick Desilsky wrote: Hi, any good trick to get the column names for title() aside from running lapply on the column indexes? Thanks Nick. apply(X[,numCols],2,function(x){ nunqs - length(unique(x)) nnans - sum(is.na(x)) info -

Re: [R] legend problems in lattice

2006-09-07 Thread Sundar Dorai-Raj
Ernst O Ahlberg Helgee wrote: Hi! Im sorry to bother you but I cant fix this. I use the lattice function levelplot and I want the colorkey at the bottom, how do I get it there? I have tried changing colorkey.space and changing in legend but I cant get it right, plz help btw I'd like to

Re: [R] exactly representable numbers

2006-09-11 Thread Sundar Dorai-Raj
Robin Hankin said the following on 9/11/2006 3:52 AM: Hi Given a real number x, I want to know how accurately R can represent numbers near x. In particular, I want to know the infinum of exactly representable numbers greater than x, and the supremum of exactly representable

Re: [R] levels of factor when subsetting the factor

2006-09-12 Thread Sundar Dorai-Raj
Yes. I do this periodically: dat.new - dat[1:6, ] dat.new[] - lapply(dat.new, function(x) if(is.factor(x)) factor(x) else x) HTH, --sundar Afshartous, David said the following on 9/12/2006 11:00 AM: thanks to all for the quick replies! if the factor is part of a

Re: [R] Basic help needed: group bunch of lines in a list (matrix)

2006-09-12 Thread Sundar Dorai-Raj
Emmanuel Levy said the following on 9/12/2006 3:50 PM: Hello, I'd like to group the lines of a matrix so that: A 1.0 200 A 3.0 800 A 2.0 200 B 0.5 20 B 0.9 50 C 5.0 70 Would give: A 2.0 400 B 0.7 35 C 5.0 70 So all lines corresponding to a letter (level), become a single line

Re: [R] S in cor.test(..., method=spearman)

2006-09-13 Thread Sundar Dorai-Raj
Dietrich Trenkler said the following on 9/13/2006 9:44 AM: Dear HelpeRs, I have some data: ice - structure(c(0.386, 0.374, 0.393, 0.425, 0.406, 0.344, 0.327, 0.288, 0.269, 0.256, 0.286, 0.298, 0.329, 0.318, 0.381, 0.381, 0.47, 0.443, 0.386, 0.342, 0.319, 0.307, 0.284, 0.326,

Re: [R] converting strings to expressions

2006-09-14 Thread Sundar Dorai-Raj
Deepayan Sarkar said the following on 9/14/2006 2:31 PM: Hi, consider this: -- estr - c(2^4, alpha[1]) eexp - expression(2^4, alpha[1]) ## Is it possible to get 'eexp' starting from 'estr'? The closest I could ## get was: do.call(expression, lapply(estr, as.name))

Re: [R] dotplot, dropping unused levels of 'y'

2006-09-15 Thread Sundar Dorai-Raj
Benjamin Tyner said the following on 9/15/2006 2:36 PM: In dotplot, what's the best way to suppress the unused levels of 'y' on a per-panel basis? This is useful for the case that 'y' is a factor taking perhaps thousands of levels, but for a given panel, only a handfull of these levels

Re: [R] Add percentage to pie (was (no subject))

2006-09-18 Thread Sundar Dorai-Raj
ERICK YEGON said the following on 9/18/2006 8:22 AM: Hi Gurus, i have a small problem with working with graphs on R. Say i have data say bull-c(34,23,7,4) and i assign names to the elements in the brackets if i do Pie(bull) i get a pie chart of bull togtjer with the names. Question. How

Re: [R] acos(0.5) == pi/3 FALSE

2006-09-18 Thread Sundar Dorai-Raj
Iñaki Murillo Arcos said the following on 9/18/2006 12:31 PM: Hello, I don't know if the result of acos(0.5) == pi/3 is a bug or not. It looks strange to me. Inaki Murillo __ R-help@stat.math.ethz.ch mailing list

Re: [R] Matrix from a vector?

2006-09-21 Thread Sundar Dorai-Raj
kone said the following on 9/21/2006 2:30 PM: Hi, Is there some function, which generates this kind of n x n -matrix from a vector? rhset [1] 1792 256 13312 512 1024 2048 8192 4096 m=matrix(nrow=length(rhset),ncol=length(rhset)) for(i in 1:length(rhset)) +

Re: [R] Double integral

2006-09-22 Thread Sundar Dorai-Raj
Caio Lucidius Naberezny Azevedo said the following on 9/22/2006 4:40 PM: Hi all, I need to solve double integrals with no closed solution. Calling x and y the two variables we have x ~ Normal(y*v,1) and y ~Half-Normal(0,1). In fact, given a joint funcion g(x,y), I need evaluate the

Re: [R] Print and supressing printing in function

2006-09-24 Thread Sundar Dorai-Raj
Marc Schwartz said the following on 9/24/2006 1:56 PM: On Sun, 2006-09-24 at 11:31 -0700, Jonathan Greenberg wrote: Another newbie question for you all: In a function, say I have: countme - function() { for(i in 1:10) { i } } How do I get R to print i as it runs (e.g. By calling

Re: [R] Single Precision (4 byte) floats with readBin

2006-09-27 Thread Sundar Dorai-Raj
Peter Lauren said the following on 9/27/2006 3:11 PM: I would like to use readBin to read a binary data file. Most of the data is 4-byte floating point but, for some reason, only double precision appears to be offered. I tried fVariable=readBin(iFile,what=single()); and got 35.87879

Re: [R] safe prediction from lm

2006-09-28 Thread Sundar Dorai-Raj
Spencer Jones said the following on 9/28/2006 10:44 AM: I am fitting a regression model with a bs term and then making predictions based on the model. According to some info on the internet at http://www.stat.auckland.ac.nz/~yee/smartpred/DummiesGuide.txt there are some problems with using

Re: [R] xyplot

2006-10-05 Thread Sundar Dorai-Raj
Osman Al-Radi said the following on 10/5/2006 3:43 PM: Hi, for the data below: time-c(rep(1:10,5)) y-time+rnorm(50,5,2) subject-c(rep('a',10),rep('b',10),rep('c',10),rep('d',10),rep('e',10)) group-c(rep('A',30),rep('B',20)) df-data.frame(subject,group,time,y) I'd like to produce a

Re: [R] adding error bars to lattice plots

2006-10-12 Thread Sundar Dorai-Raj
Daniel E. Bunker said the following on 10/12/2006 11:48 AM: Dear R users, About a year ago Deepayan offered a suggestion to incorporate error bars into a dotplot using the singer data as an example http://finzi.psych.upenn.edu/R/Rhelp02a/archive/63875.html. When I try to utilize this

Re: [R] R not responding for nested glm model

2006-10-12 Thread Sundar Dorai-Raj
Yuval Sapir said the following on 10/12/2006 1:08 PM: Hi, I'm trying to perform a glm model on count data (poisson distribution of the errors) where data are nested. glmmodel-glm(y~x/z,poisson) x and z are factors, z nested within x, y is count data. In that point the R just stuck and not

Re: [R] nontabular logistic regression

2006-10-13 Thread Sundar Dorai-Raj
Jeffrey Stratford said the following on 10/13/2006 9:28 AM: Hi. I'm attempting to fit a logistic/binomial model so I can determine the influence of landscape on the probability that a box gets used by a bird. I've looked at a few sources (MASS text, Dalgaard, Fox and google) and the

Re: [R] Reading SAS data into R

2004-08-27 Thread Sundar Dorai-Raj
Søren Højsgaard wrote: Dear all, One of my students (whom I am trying to convince to use R) wants to get a fairly large SAS dataset into R (about 150mB). An obvious and simple thing she tried was to write the dataset as a .csv-file and then read that into R, but that takes forever (or something

  1   2   3   4   5   6   >