Re: [R] FW: Combined grouped and stacked bargraph

2012-04-26 Thread Nicola Van Wilgen
Dear John and R-list Thank you for your comment. Here are my data in the dput format: cs.not.log.bp - ( structure(c(168, 69, 16, 69, 41, 6, 148, 6, 5, 4, 7, 4, 4, 2, 7, 2, 4, 2, 4, 2, 1, 0, 2, 0), .Dim = c(4L, 6L), .Dimnames = list( c(IUCN.Terrestrial, IUCN.Marine, National.CS.Terrestrial,

Re: [R] Basic matrix manipulation problem

2012-04-26 Thread Hans Thompson
Thanks Rui and Jeff, I thought that transposing the matrix would let me plot it the way I thought it would but it did not. How can I take: matrix e: AAB BAB CCD DCD x 1.75 2.25 3.25 3.75 y 6.25 6.75 7.25 7.75 and treat the x and y rows as the x and y axis values and plot

Re: [R] [pROC] roc.test returns NA p-value...

2012-04-26 Thread O
Dear Uwe: Many thanks for your prompt feedback. You were right about the data. I don't understand why but one map wasn't perfect (i.e., it didn't include count information for each value). If this happens the map seems alright using GIS programs because you can still produce pretty maps based

[R] Obtaining translated, rotated and scaled matrics in procrustes analysis

2012-04-26 Thread ali_protocol
Hi all, I wondered how I can get the translated, rotated and scaledmatrix in a procrustes analysis. This does not help: ## library (vegan) #defining the target matrix: a= cbind (c (1,2,3,4), c( 10,12,14,16)) #defining the matrix to be rotated: b= a; b[,2]=

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Wet Bell Diver
In addition: the object MyNumberIs *is* created, but inside the environment attached to the function as you evaluate it. And this environment is gone when the function is done. (there is more to it, but this is basically how it works). This is what Michael refers to in his answer. So, when

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Patrick Burns
I suspect you are trying to find your way into Circle 6 of 'The R Inferno' but haven't yet got in. http://www.burns-stat.com/pages/Tutor/R_inferno.pdf Pat On 26/04/2012 03:06, michaelyb wrote: Hello, I am trying to understand why the FUNCTION used in several codes, won't create the object

[R] variable dispersion in glm models

2012-04-26 Thread Chris Rh
Hello, I am currently working with the betareg package, which allows the fitting of a variable dispersion beta regression model (Simas et al. 2010, Computational Statistics Data Analysis). I was wondering whether there is any package in R that allows me to fit variable dispersion parameters in

[R] write to M, using row and columns taken from A and B, with values from C

2012-04-26 Thread Amen
I want to write to M, using row and columns taken from A and B, with values from C. C is a lot longer than A and B, so only the first 67420 elements of C are used in my loop.So how can I improve it to take then the next 67420 and write it to new file and so on till the 248th 67420. Many thanks

Re: [R] variable dispersion in glm models

2012-04-26 Thread Vito Muggeo (UniPa)
there are at least two alternatives 1) package dglm for Double generalized linear models or probably better 2)package gamlss for Generalized Additive Models for Location Scale and Shape. Here you can use alternative, sometimes more appropriate, families and also you can include additive

Re: [R] comparison of bivariate normal distributions

2012-04-26 Thread Petr Savicky
On Wed, Apr 25, 2012 at 08:43:34PM +, Fabian Roger wrote: sorry for cross-posting Dear all, I have tow (several) bivariate distributions with a known mean and variance-covariance structure (hence a known density function) that I would like to compare in order to get an intersect

Re: [R] RODBC Error Code 202 on Mac OS X 10.6

2012-04-26 Thread julia . jacobson
I thought that maybe installing the RODBC package from source might fix the problem: install.packages(RODBC,type=source) but to no success. RODBC still gives the same warning with the same error code and very little information to tackle the problem. On Apr 25, 2012, at 10:03 AM,

[R] redefining [ (subset) for array

2012-04-26 Thread ghostwheel
Hi, I'm having a hard time redefining the subset operation for arrays. The aim is to be able to call a[dim2=1:5] instead of having to write a[,1:5,,,] (assuming dimnames(a)[2]=-dim2). I already wrote a function that does this (see bottom). But I just can't figure out how to redefine [.array. I

Re: [R] How to delete rows from dataframe that sum to zero

2012-04-26 Thread ghostwheel
Here's an example a=data.frame( sample(0:1,20,rep=T), sample(0:1,20,rep=T) ) # make 2 random columns of length 20. a.no0 = a[ rowSums(a)!=0, ] -- View this message in context: http://r.789695.n4.nabble.com/How-to-delete-rows-from-dataframe-that-sum-to-zero-tp4589289p4589308.html Sent from the

Re: [R] Intercept between two lines

2012-04-26 Thread ghostwheel
You could also use polyroot. Do x0=Re( polyroot( c(100,-0.5) - c(150,-1) ) ) In your code. -- View this message in context: http://r.789695.n4.nabble.com/Intercept-between-two-lines-tp4587343p4589349.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Basic matrix manipulation problem

2012-04-26 Thread Jessica Streicher
M [,1] [,2] [,3] [,4] x 1.75 2.25 3.25 3.75 y 6.25 6.75 7.25 7.75 plot(t(M)) Does just fine for me oO then again, as you write it, you actually have a data frame there.. so.. D AAB BAB CCD DCD x 1.75 2.25 3.25 3.75 y 6.25 6.75 7.25 7.75 plot(t(D)) Does just fine for me as well oO

Re: [R] How to plot graph with different scale (y axis) on same graph?

2012-04-26 Thread ghostwheel
You ask two questions. First, how to put points with a different y-axis on the plot. One possibility s like this: plot(1:10) plot.window(xlim=c(1,10),ylim=c(1,100)) points( seq(1,10,length=100), 100:1, col=2 ) axis(4,col.axis=2,col=2) The command plot.window is the one that changes the

Re: [R] On the Design of the R Language

2012-04-26 Thread Ramon Diaz-Uriarte
On Wed, 25 Apr 2012 20:57:31 +0200,peter dalgaard pda...@gmail.com wrote: On Apr 25, 2012, at 20:19 , Marc Schwartz wrote: I have not read it yet, but the acknowledgements at the end of the paper note that: 1. It was supported by an NSF grant. 2. At least two members of R Core

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Dwaipayan Dasgupta
Hi , Thanks again for helping me out. Here is the code I am using Ad_1 - subset(Attrition_data_1,Attrition_ind==1) Ad_0 - subset(Attrition_data_1,Attrition_ind==0) s1-sample(1:dim(Ad_0)[1],0.8*dim(Ad_0)[1])# 80% of the non-attrites s2-sample(1:dim(Ad_1)[1],0.8*dim(Ad_1)[1])# 80% of attritees s3-

[R] How to plot graph with different scale (y axis) on same graph?

2012-04-26 Thread Manish Gupta
Hi, I have my data in below format. position var1var2 2 .1 10 3 .29 89 12.56 100 425 .341234 6546 .12 21

Re: [R] Intercept between two lines

2012-04-26 Thread pannigh
Thank you Jorge, this did get me started and who else might be interested in the topic, a possible code could be something like: # Define the functions f1 - function(x) 100-0.5*x f2 - function(x) 150- x # Plot the functions par (xaxs=i, yaxs=i) plot( 1,

[R] How to delete rows from dataframe that sum to zero

2012-04-26 Thread Emily O'Connor
Hello, I am trying to figure out how to delete all rows which sum to zero from a dataframe. I do not have a column with the sum of each column yet, so perhaps that would need to be done first? Thank you for any help anyone can offer with this. Emily PS sorry if this question has already been

Re: [R] R-help Digest, Vol 110, Issue 28

2012-04-26 Thread Richard Valliant
I will be out of the office Apr 26-27, 2012 with limited or no email access. For immediate help, please call the JPSM main number, 301-314-7911. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] How to plot graph with different scale (y axis) on same graph?

2012-04-26 Thread Jim Lemon
On 04/26/2012 08:02 PM, Manish Gupta wrote: Hi, I have my data in below format. position var1var2 2 .1 10 3 .29 89 12.56 100 425 .34

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Frank Harrell
You can run simulations to find out how large N must be so that split sample validation yields sufficient precision to be trustworthy, in other words, that different random splits provide the same estimate of model accuracy to within some small tolerance. You will be surprised how large N must be

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Jessica Streicher
Be reminded that s1 and s2 are only the indexes on AD_0 and AD_1 of the data which you want to keep. therefore traindata - rbind(s1,s2) will not work. you need to take data from AD_0 and AD_0 for that, similarly with what you did with s3 and s4. Am 26.04.2012 um 12:56 schrieb Dwaipayan

Re: [R] repeat matrix rows as a whole

2012-04-26 Thread Petr PIKAL
Hi what about rbind(a,a) [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 Regards Petr a - matrix(1:8, 2, 4, byrow=TRUE) a [,1] [,2] [,3] [,4] [1,]1234 [2,]5678

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Dwaipayan Dasgupta
Hi, I am sorry, could you tell me exactly how. I understand I am troubling you but im trying to learn R since the last two weeks and haven’t been able to come to terms with the suble nuances. Thanks again, doy From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On

[R] Modifying values into XML with R

2012-04-26 Thread Bastien.Ferland-Raymond
Dear R gurus, I use R all the time at work, so one day a problem managing my personal arise data made me think: Why not use R, it does everything!. Anyway, my goal is to use R to manage my personal music library, and more precisely my playcounts. I have two XML files, one from Winamp and the

Re: [R] repeat matrix rows as a whole

2012-04-26 Thread Jessica Streicher
a - matrix(1:8, 2, 4, byrow=TRUE) b-t(a) r-rep(b,5) # can insert anything for 5 matrix(r,ncol=dim(a)[2],byrow=T) [,1] [,2] [,3] [,4] [1,]1234 [2,]5678 [3,]1234 [4,]5678 [5,]1234 [6,]5678

Re: [R] Splitting data into test and train (80:20) kepping attributes similar

2012-04-26 Thread Jessica Streicher
Ad_1 - subset(Attrition_data_1,Attrition_ind==1) Ad_0 - subset(Attrition_data_1,Attrition_ind==0) s1-sample(1:dim(Ad_0)[1],0.8*dim(Ad_0)[1])# 80% of the non-attrites s2-sample(1:dim(Ad_1)[1],0.8*dim(Ad_1)[1])# 80% of attritees s3- Ad_0 [-s1,] summary(s3) s4- Ad_1 [-s2,] summary(s4) s5-

[R] Help Graph edit distance in R

2012-04-26 Thread d . destefano
Hi there, I'm working on a very specific topic related to graph theory. In particular I'd like to compare two graphs by a general dissimilarity function in graph domain, named graph edit distance (GED). Do you know if there exists a package or a script in R implementing algorithm to 

[R] converting class verbatim to string

2012-04-26 Thread arunkumar1111
Hi I have a variable in verbatim and want to search a pattern . but i'm not able to convert it into string. is there anyway that i can search directly from verbatim - Thanks in Advance Arun -- View this message in context:

[R] PLM package PGGLS strange behavior

2012-04-26 Thread Ruben de Bliek
When using the PLM package (version 1.2-8), I encounter the probem that calling the FGLS estimator evokes strange behavior, when choosing the random effects model. After calling the PGGLS function to estimate FGLS, PLM gives me a warning, stating that the random model has been replaced with the

Re: [R] Proper apply function for matrices embedded in lists

2012-04-26 Thread Uwe Ligges
On 26.04.2012 01:18, Bcampbell99 wrote: Hi: I have a small problem that I'm not quite sure how to figure out. I've generated some randomized (permutated) data which consists of nrows=3 by ncols=165 (see below) per element (3 x 165 = 495 sub-elements). [,1] [,2] [,3] [,4] [,5] [,6]

Re: [R] Dataset maximum size?

2012-04-26 Thread Uwe Ligges
We do not know anything about the data, but given those are floting point numbers or integers there sould not be a problem with 4500 times 3. Uwe Ligges On 26.04.2012 05:15, Rich Lane wrote: Hi all, I have an interesting project coming up, but the datasets are way bigger than

Re: [R] converting class verbatim to string

2012-04-26 Thread Berend Hasselman
On 26-04-2012, at 14:23, arunkumar wrote: Hi I have a variable in verbatim and want to search a pattern . but i'm not able to convert it into string. is there anyway that i can search directly from verbatim This is utterly incomprehensible. Please provide a reproducible example.

Re: [R] write to M, using row and columns taken from A and B, with values from C

2012-04-26 Thread David Winsemius
On Apr 26, 2012, at 4:25 AM, Amen wrote: I want to write to M, using row and columns taken from A and B, with values from C. C is a lot longer than A and B, so only the first 67420 elements of C are used in my loop.So how can I improve it to take then the next 67420 and write it to new

[R] Correlated random effects: comparison unconditional vs. conditional GLMMs

2012-04-26 Thread Eiko Fried
In a GLMM, one compares the conditional model including covariates with the unconditional model to see whether the conditional model fits the data better. (1) For my unconditional model, a different random effects term fits better (independent random effects) than for my conditional model

[R] Heatmap fidelity

2012-04-26 Thread Steven Wolf
I'm having a problem when using heatmap. Even though the diagonal of my matrix is all the same value, the diagonal of my heatmap is not all the same color. Any suggestions? Here is some reproducible code: # # Get data nba -

[R] confidence envelope for pair correlation

2012-04-26 Thread Lucie V
Dear R users, I was just wondering if anyone would be able to advice me on how to create a confidence envelope on the graph when plotting a pair correlation function (or mark correlation function). Is the command qqenvl() or envl.plot() what I need or is it something completely

[R] nearest positive semidefinit toeplitz matrix

2012-04-26 Thread juliane0212
hHllo, I'm looking for an algroithm to transform an existing toeplitz matrix (autocorrelation matrix) to the nearest positive semidefinite toeplitz matrix. I merely found an algorithm to transform an correlation matrix via the function nearcor() based on the algorithm of Higham. But as I

Re: [R] understanding the FUNCTION function

2012-04-26 Thread michaelyb
Peter, your solution is actually very interesting. I have never seen or heard of before. I will look into it. Meanwhile, look at this example instead: fac-function(x){a-1 for(i in 1:x){ a-a*i print(a)}} The result is : fac(5) [1] 1 [1] 2 [1] 6

[R] How to find 5 closest number from matrix having attributes?

2012-04-26 Thread sagarnikam123
i found one clue in our forum, but it can give position for whole matrix, n-read.table(file.choose(),header=T) y-n[,c(1,2,3)] my.number=1.12270420185886 z-abs(y-my.number)==min(abs(y-my.number)) which(z) [1] 19 i have uploaded file,which

[R] looking for an add-in for daily data analysis

2012-04-26 Thread and_mue
Hi all I am looking for an add-in. I am currently working on something and I use daily data of closing stock prices. As not all companies are traded daily (e.g. on monday, then on thursday etc) at the stock exchange, there is satistically a problem. There are some papers which explain the

Re: [R] Heatmap fidelity

2012-04-26 Thread Duncan Murdoch
On 26/04/2012 9:01 AM, Steven Wolf wrote: I'm having a problem when using heatmap. Even though the diagonal of my matrix is all the same value, the diagonal of my heatmap is not all the same color. Any suggestions? heatmap() rescales the matrix by default. Use heatmap(abs(psim),

[R] Aggregate function for comparison stats

2012-04-26 Thread Neil Davis
Hi, I have a data.frame which contains timeseries from several different locations, which I want to compare against each other for example calculating RMSE, or normalized mean bias of each location against the others. An example of this is the cor function where I can put in a data.frame and

[R] print table on plot

2012-04-26 Thread statquant2
Hello, I would like to be able to plot an array on a plot, something like: |arg1 | arg2 | arg3 val1| 0.9| 1.1| 2.4 val2| 0.33 | 0.23 | -1.4 val3| hello| stop | test I know Rwave is good to report but don't want to use it. ? Is there a package that allow quick and dirty plot of

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Ista Zahn
On Thu, Apr 26, 2012 at 8:56 AM, michaelyb cel81009...@gmail.com wrote: Peter, your solution is actually very interesting. I have never seen or heard of before. I will look into it. Meanwhile, look at this example instead: fac-function(x){a-1                 for(i in 1:x){                

Re: [R] Heatmap fidelity

2012-04-26 Thread Steven Wolf
Thanks! -Steve -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Thursday, April 26, 2012 9:28 AM To: Steven Wolf Cc: r-help@r-project.org Subject: Re: [R] Heatmap fidelity On 26/04/2012 9:01 AM, Steven Wolf wrote: I'm having a problem when using heatmap.

Re: [R] Add attributes to igraph vector by name, not index

2012-04-26 Thread Gábor Csárdi
Hi, you can iterate over the vertices, but it'll be probably slow. The best solution is to create the graph directly from the data frame(s) containing all structure and attribute data. See the graph.data.frame() function for this. Btw. it might be worth to post your igraph related questions to

Re: [R] How to plot graph with different scale (y axis) on same graph?

2012-04-26 Thread David Winsemius
On Apr 26, 2012, at 7:31 AM, Jim Lemon wrote: On 04/26/2012 08:02 PM, Manish Gupta wrote: Hi, I have my data in below format. position var1var2 2 .1 10 3 .29 89 12.56

Re: [R] Aggregate function for comparison stats

2012-04-26 Thread David Winsemius
On Apr 26, 2012, at 9:29 AM, Neil Davis wrote: Hi, I have a data.frame which contains timeseries from several different locations, which I want to compare against each other for example calculating RMSE, or normalized mean bias of each location against the others. An example of this is

Re: [R] looking for an add-in for daily data analysis

2012-04-26 Thread R. Michael Weylandt
Perhaps PerformanceAnalytics and the CAPM.* functions. Michael On Thu, Apr 26, 2012 at 8:46 AM, and_mue and_muel...@bluewin.ch wrote: Hi all I am looking for an add-in. I am currently working on something and I use daily data of closing stock prices. As not all companies are traded daily

[R] Sweave: Avoiding recompilation of figures

2012-04-26 Thread julia . jacobson
Hello everybody out there using Sweave, There are some complicated SQL queries and laborous calculations against large data included as R code chunks using Sweave in my LaTeX document. These code chunks create graphs that do not change most of the time, but they are of course recompiled every

Re: [R] understanding the FUNCTION function

2012-04-26 Thread William Dunlap
Did you read ?'-' as Peter suggested? Better yet, do not read ?'-' and do not use -. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ista Zahn Sent: Thursday, April

Re: [R] take data from a file to another according to their correlation coefficient

2012-04-26 Thread jeff6868
Hello Rui, For the write.table, it's OK! And for the second one (for the 2nd best correlation) seems to work great! You're too strong ^^ I have to check a bit more to be sure, but it seems to do it! If you come in the Alps, it will be more liqueurs such as Chartreuse or Génépi (from mountain

Re: [R] Sweave: Avoiding recompilation of figures

2012-04-26 Thread Rainer Schuermann
The easiest way probably is to put the code that takes so long to execute, in a separate file, such as graph1.Rnw, and get it into your master file via SweaveInput( graph1.Rnw ). Once you are happy with your graph1, you can comment this line out and only compile the stuff that keeps changing.

[R] Using if and else in a data frame

2012-04-26 Thread pannigh
Dear list, I get the ifelse function to work on a data frame but don't know how to do something similar (only more conditions) with the combination of if and else like in the example: A - c(a,a,b,b,c,c) B - c(rep(2,6)) dat - data.frame(A,B) dat$C - if(AB$A==a) {AB$B^2} else

[R] kernlab kpca code

2012-04-26 Thread Jessica Streicher
Hi! how do i get to the source code of kpca or even better predict.kpca(which it tells me doesn't exist but should) ? (And if anyone has too much time: Now if i got that right, the @pcv attribute consists of the principal components, and for kpca, these are defined as projections of some

Re: [R] Sweave: Avoiding recompilation of figures

2012-04-26 Thread Yihui Xie
I guess there is not a steep learning curve if you want to use cache in knitr or cacheSweave -- just use the chunk option cache=TRUE and you are all set. heavy-chunk, cache=TRUE= # time-consuming computation here @ Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web:

Re: [R] kernlab kpca code

2012-04-26 Thread Steve Lianoglou
Hi Jessica, On Thu, Apr 26, 2012 at 11:59 AM, Jessica Streicher j.streic...@micromata.de wrote: Hi! how do i get to the source code of kpca or even better predict.kpca(which it tells me doesn't exist but should) ? Probably you have to do kernlab:::predict.kpca from your R workspace, but why

Re: [R] Using if and else in a data frame

2012-04-26 Thread Rui Barradas
Hello, Your example code has a bug, there's no fata.frame called 'AB'. It's corrected below. pannigh wrote Dear list, I get the ifelse function to work on a data frame but don't know how to do something similar (only more conditions) with the combination of if and else like in the

[R] Use scores from factor analysis and missing values factanal(), napredict(), na.omit()

2012-04-26 Thread Simon Kiss
Dear all, I have a series of variables that looks roughly like the sample data below and I'm trying to conduct a factor analysis. I've omitted cases with missing values for the factor analysis, but now I'd like to use the scores on each component as new variables in the *original* data set for

Re: [R] print table on plot

2012-04-26 Thread David Winsemius
On Apr 26, 2012, at 9:26 AM, statquant2 wrote: Hello, I would like to be able to plot an array on a plot, something like: |arg1 | arg2 | arg3 val1| 0.9| 1.1| 2.4 val2| 0.33 | 0.23 | -1.4 val3| hello| stop | test I know Rwave is good to report but don't want to use it. ? Is

[R] Using the R predict function to forecast a model fit with auto.arima function

2012-04-26 Thread PaulJr
Hello R users, Hope everyone is doing great. I have a dataset that is in .csv format and consists of two columns: one named Period (which contains dates in the format _mm) and goes from 1995_10 to 2007_09 and the second column named pcumsdry which is a volumetric measure and has been

Re: [R] kernlab kpca code

2012-04-26 Thread Jessica Streicher
Thanks a lot, totally forgot cran there. Hm.. so they're multiplying some specifically computed Kernelmatrix with the pcv's.. interesting.. too tired to check the math there, guess i'll just accept its possible and go to sleep. Am 26.04.2012 um 18:10 schrieb Steve Lianoglou: Hi Jessica,

[R] nnet formular for reproduce the expect output

2012-04-26 Thread poorlyeric
Dear All, I am recently working on neural network using nnet package. The network has 4 hidden layers and 1 output layer, the target output 1 or 0. The model I use is as follows: nn-nnet(target~f1+f2+f3+f4+f5+f6+f7+f8+f9+f10,data=train,size=4,linout=FALSE,decay=0.025,maxit=800) It works well

Re: [R] calculate correlation effect size using contrast analysis for an omnibus Chi-square test statistic

2012-04-26 Thread Michael Dewey
At 00:55 26/04/2012, Steven Orzack wrote: I am looking for an R package with which one can calculate an effect size for a set of contrasts given an omnibus chi-square test statistic (more than 1 degree of freedom). Is there such a package? Presumably, it would implement the procedure (or

Re: [R] Positioning main title

2012-04-26 Thread Greg Snow
You could also use the grconvertX function to convert from the middle of the plotting region (from='npc') to user coordinates (to='user'), or many other combinations. On Wed, Apr 25, 2012 at 5:53 AM, Ramon Ovelar ramon.ove...@gmail.com wrote: Many many thanks for the tip and for authoring this

Re: [R] random effects in library mgcv

2012-04-26 Thread Simon Wood
On 25/04/12 14:02, Mabille, Geraldine wrote: Hi, I am working with gam models in the mgcv library. My response variable (Y) is binary (0/1), and my dataset contains repeated measures over 110 individuals (same number of 0/1 within a given individual: e.g. 345-zero and 345-one for individual A,

Re: [R] understanding the FUNCTION function

2012-04-26 Thread michaelyb
Any solution for that type of problem? I did read the ?-, and seems very similar to the assign function, if I am not mistaken -- View this message in context: http://r.789695.n4.nabble.com/Using-FUNCTION-to-create-usable-objects-tp4588681p4590445.html Sent from the R help mailing list

Re: [R] print table on plot

2012-04-26 Thread statquant2
Hello, ok for xtable, but how will I print the latex code generated in a plot ? Cheers -- View this message in context: http://r.789695.n4.nabble.com/print-table-on-plot-tp4589804p4590407.html Sent from the R help mailing list archive at Nabble.com.

[R] ErrError in f(x, ...) : object 'g.' not found

2012-04-26 Thread Guaramy
Hi , R is a new language for me so sorry in advance if this error is to basic for posting. I have tried the R manual and search online for quite a few, if anyone could help i would be very thankful. Here is my code. kappa = 1.1 theta = 0.1 sigma = 0.4 rho = -0.6 v0 = 0.2 r = 0.05 T = 0.5 s0 = 1

[R] Problem with constrOptim when hitting boundary

2012-04-26 Thread Elizabeth Purdom
Hello, I am using constrOptim to maximize a likelihood function (the values of my parameter vector must be between zero and one and must sum up to =1). I am getting the error 'initial value in 'vmmin' is not finite'. I've tracked it down to a problem in the function 'R' defined within the

Re: [R] Use of optim to fit two curves at the same time ?

2012-04-26 Thread Greg Snow
The phrase does not work is not very helpful, it can mean quit a few things including: * Your computer exploded. * No explosion, but smoke is pouring out the back and microsoft's NoSmoke utility is not compatible with your power supply. * The computer stopped working. * The computer sits around

Re: [R] understanding the FUNCTION function

2012-04-26 Thread R. Michael Weylandt
Yes, don't do it. I know this can seem appealing if you're coming from another language, but playing fast and loose with globals, non-local effects, and superassignment is almost-never a good idea. Michael On Thu, Apr 26, 2012 at 1:32 PM, michaelyb cel81009...@gmail.com wrote: Any solution for

Re: [R] ErrError in f(x, ...) : object 'g.' not found

2012-04-26 Thread Sarah Goslee
Just what it says: You define g but refer to a variable g. in the next line. Just get rid of the typo. Sarah On Thu, Apr 26, 2012 at 1:43 PM, Guaramy guar...@hotmail.com wrote: Hi , R is a new language for me so sorry in advance if this error is to basic for posting. I have tried the R

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Ista Zahn
On Thu, Apr 26, 2012 at 1:32 PM, michaelyb cel81009...@gmail.com wrote: Any solution for that type of problem? Solution for what type of problem? I did read the ?-, and seems very similar to the assign function, if I am not mistaken Bottom line: don't use - until you know what you are

Re: [R] understanding the FUNCTION function

2012-04-26 Thread michaelyb
Ista, Since you seem to know your stuff very well, how would you get 120 out of a function that gives you the factorial of 5, without using factorial(5)? Meanwhile, look at this example instead: fac-function(x){a-1 for(i in 1:x){ a-a*i

Re: [R] understanding the FUNCTION function

2012-04-26 Thread R. Michael Weylandt
Simply return it like a function is supposed to: fac - function(x, loud = TRUE){ a - 1 for(i in seq_len(x)) { # seq_len is faster and more robust a - a * i if(loud) print(a) } return(a) } fac3 - fac(3) print(fac3) # As desired Michael On Thu, Apr 26, 2012 at

Re: [R] understanding the FUNCTION function

2012-04-26 Thread David Winsemius
On Apr 26, 2012, at 2:16 PM, michaelyb wrote: Ista, Since you seem to know your stuff very well, how would you get 120 out of a function that gives you the factorial of 5, without using factorial(5)? Meanwhile, look at this example instead: fac-function(x){a-1 for(i in

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Sarah Goslee
In R, the preferred method is to assign the result to a new object: fac - function(x) { a-1 for(i in 1:x){ a-a*i print(a) } a # need to explicitly state what the function should return } myresult - fac(5) myresult Sarah On Thu, Apr 26, 2012 at 2:16 PM, michaelyb

Re: [R] recommended way to group function calls in Sweave

2012-04-26 Thread Liviu Andronic
Dear Rainer On Wed, Apr 25, 2012 at 5:34 PM, Rainer Schuermann rainer.schuerm...@gmx.net wrote: chunk_name_1,eval=FALSE,echo=FALSE= I like the 'eval=FALSE' trick. SweaveInput( setup.Rnw ) and from here, I can suse the named chunks almost like function calls, as you you describe below.

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Jeff Newmiller
the solution is to write functions that return the data you want changed, and let the caller of the function decide where to put the answer. If you want to return multiple answers, collect them in a vector or list and return that.

Re: [R] Selecting columns whose names contain mutated except when they also contain non or un

2012-04-26 Thread Greg Snow
Sorry I took so long getting back to this, but the paying job needs to take priority. The regular expression (?!un)(?!non)muta looks for a string that matches muta then looks at the characters immediately before it to see if they match either un or non in which case it makes it a not match.

Re: [R] understanding the FUNCTION function

2012-04-26 Thread Rui Barradas
Hello, gives you 120, but you cannot access it after the end of execution. Because you're just printing the final value of 'a', not returning it. fac - function(x){ a - 1 for(i in 1:x) a - a*i a } The return value must be the last instruction in a function. Then, if

Re: [R] Accessing a list

2012-04-26 Thread Greg Snow
The latest version of fortunes (from R-forge, not sure about CRAN) have fortunes up to number 317 which is from just a couple of days ago (and 312 is the quoted one from February). For some reason some of the instances of R on my computer stop at 291, others go up to 317 (running a new instance

Re: [R] Use of optim to fit two curves at the same time ?

2012-04-26 Thread Arnaud Mosnier
Nice, thank you ! I particularly appreciated the list of possible explanations for it does not work ! :-) Arnaud Le 26 avril 2012 13:49, Greg Snow 538...@gmail.com a écrit : The phrase does not work is not very helpful, it can mean quit a few things including: * Your computer exploded. *

[R] creating a package?

2012-04-26 Thread Jose Bustos Melo
Dear R users.   I'm trying to know how to create a function. I have developed a big code that use a file and makes many process and then creates a table that is exported as txt. The point is to make something like a function.  I need to make it easy for others, so they can run it. This has a

[R] problem with break command

2012-04-26 Thread cassie jones
Hello R-users, I am having a problem with the 'break' command in R. I am wondering if anyone can help me out with this. My program is similar to the following. a=rep(NA,5) a[1]=0 for(i in 2:5) { a[i]=a[i-1]+runif(1,0,3) if(a[i]5) { i=2 break } } What exactly I am

Re: [R] Use of optim to fit two curves at the same time ?

2012-04-26 Thread Marc Schwartz
On Apr 26, 2012, at 12:49 PM, Greg Snow wrote: The phrase does not work is not very helpful, it can mean quit a few things including: * Your computer exploded. * No explosion, but smoke is pouring out the back and microsoft's NoSmoke utility is not compatible with your power supply. *

[R] Merge function - Return NON matches

2012-04-26 Thread RHelpPlease
Hi there, I wish to merge a common variable between a list and a data.frame return rows via the data.frame where there is NO match. Here are some details: The list, where the variable/col.name = CLAIM_NO CLAIM_NO 20 83 1440 4439 7002 ... dim(hrc78_clm_no) [1] 66781 The data.frame, where

Re: [R] problem with break command

2012-04-26 Thread Berend Hasselman
On 26-04-2012, at 21:30, cassie jones wrote: Hello R-users, I am having a problem with the 'break' command in R. I am wondering if anyone can help me out with this. My program is similar to the following. a=rep(NA,5) a[1]=0 for(i in 2:5) { a[i]=a[i-1]+runif(1,0,3) if(a[i]5)

Re: [R] Merge function - Return NON matches

2012-04-26 Thread Steve Lianoglou
Hi, To increase the chances of you getting help on this one, please give example data (a small data.frame, a small list) that you are trying to do this on, and also show the desired output. Whip these variables up in your R workspace and paste the output of `dput` for each into your follow up

Re: [R] problem with break command

2012-04-26 Thread cassie jones
Thanks Berend, you are right. The break command would not work here. But the while loop is taking time to generate the desired. On Thu, Apr 26, 2012 at 2:39 PM, Berend Hasselman b...@xs4all.nl wrote: On 26-04-2012, at 21:30, cassie jones wrote: Hello R-users, I am having a problem with

Re: [R] understanding the FUNCTION function

2012-04-26 Thread michaelyb
David - My question to you may sound (actually, it really is) silly, but please do take your time to answer it. What is the difference between: fac-function(x){a-1 for (i in 1:x){ a-a*i }a} and: fac-function(x){a-1 for (i

Re: [R] problem with break command

2012-04-26 Thread Petr Savicky
On Thu, Apr 26, 2012 at 02:30:09PM -0500, cassie jones wrote: Hello R-users, I am having a problem with the 'break' command in R. I am wondering if anyone can help me out with this. My program is similar to the following. a=rep(NA,5) a[1]=0 for(i in 2:5) { a[i]=a[i-1]+runif(1,0,3)

Re: [R] Merge function - Return NON matches

2012-04-26 Thread RHelpPlease
Hi Steve, Thanks for replying. Here's a small piece of the data.frame: bestPartAreadmin[1:5,1:6] DESY_SORT_KEY PRVDR_NUM CLM_THRU_DT CLAIM_NO NCH_NEAR_LINE_REC_IDEN_CD NCH_CLM_TYPE_CD 1 10193 290003 20090323 20

[R] Subsetting dataframe with missing values

2012-04-26 Thread Luciano La Sala
Dear R-community, I am using R (V 2.14.1) on Windows 7. I have a dataset which consists of 19 variables for 91 individuals or rows. Two of my variables are Age (adult/chick, with no NA values) and Sex (0 for females/1 for females, with quite a few NA values). The sex of many adult birds is

Re: [R] understanding the FUNCTION function

2012-04-26 Thread David Winsemius
On Apr 26, 2012, at 3:40 PM, michaelyb wrote: David - My question to you may sound (actually, it really is) silly, but please do take your time to answer it. What is the difference between: fac-function(x){a-1 for (i in 1:x){ a-a*i }a} and:

  1   2   >