[R] Multiple Imputation / Non Parametric Models / Combining Results
Dear R-Users, The following question is more of general nature than a merely technical one. Nevertheless I hope someone get me some answers. I have been using the mice package to perform the multiple imputations. So far, everything works fine with the standard regressions analysis. However, I am wondering, if it is theoretically correct to perform nonparametric models (GAM, spline smoothing etc.) with multiple imputed datasets. If yes, how can I combine the results in order to show the uncertainty? In the research field of real estate economics, the problem of missing data is often ignored respectively unmentioned. However, GAM, spline smoothing etc. become increasingly popular. In my research, I would like to use multiple imputed datasets and GAM, but I am unsure how present single results. Again I want to apologize that this is a rather theoretical statistical question than a technical question on R. Thanks in advance for any hints and advices. Simon Simon P. Kempf Dipl.-Kfm. MScRE Immobilienökonom (ebs) Wissenschaftlicher Assistent Büro: IREBS Immobilienakademie c/o ebs Immobilienakademie GmbH Berliner Str. 26a 13507 Berlin Privat: Dunckerstraße 60 10439 Berlin Mobil: 0176 7002 6687 Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about apply function
Dear R-Users, For example i have a data matrix with five samples and three variables. DATA - matrix(c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),nrow=5,ncol=3,byrow=TRUE) colnames (DATA) - c(V1,V2,V3) rownames (DATA) - c(S1,S2,S3,S4,S5) I want to normalize all samples to same sum of variables: NormFun - function (i) {(i*(1/sum(i)))} Dnorm - apply(DATA,1,NormFun) Why I am getting tranposed matrix Dnorm? And with my experimental data (with 32k variables) i am getting a slighty different results from: apply(DATA,1,NormFun) apply(t(DATA),2,NormFun) Thankyou, Andris Jankevics __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about apply function
in this case you may use something like the following: DATA - matrix(1:5, 5, 3) dimnames(DATA) - list(c(S1,S2,S3,S4,S5), c(V1,V2,V3)) # DATA / rowSums(DATA) DATA / rep(colSums(DATA), each = nrow(DATA)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Andris Jankevics [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, December 08, 2006 9:36 AM Subject: [R] question about apply function Dear R-Users, For example i have a data matrix with five samples and three variables. DATA - matrix(c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),nrow=5,ncol=3,byrow=TRUE) colnames (DATA) - c(V1,V2,V3) rownames (DATA) - c(S1,S2,S3,S4,S5) I want to normalize all samples to same sum of variables: NormFun - function (i) {(i*(1/sum(i)))} Dnorm - apply(DATA,1,NormFun) Why I am getting tranposed matrix Dnorm? And with my experimental data (with 32k variables) i am getting a slighty different results from: apply(DATA,1,NormFun) apply(t(DATA),2,NormFun) Thankyou, Andris Jankevics __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] filled.contour and NA's
On 11/29/06, antonio rodriguez [EMAIL PROTECTED] wrote: Hi, I'm trying to do a filled.contour plot where some points are labelled as NA. How do I could plot this kind of graphics, so NA points are coloured black, keeping the levels of remaining points. NA's values represent land points (meaningless), and what I want to plot is the levels of a variable over the sea. Hi Antonio, I haven't seen a reply to your question yet, so I'll make a try. I'm having the same issue myself. What I've ended up doing is replacing NA's with a big negative value, define levels as one color for negative values, and a regular scale above. This gives a fairly good separation between what areas contain data, and what doesn't. To make NA's black, I suppose one would have to define your own colour.palette, but I haven't looked into it. Hope this helps, and let me know if you've found a better solution! Best, Gustaf Rydevik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lattice: defining an own function using args for formula and groups
x.fun - function( formula, data ) dotplot( formula, data ) x.grp - function( formula, groups, data ) dotplot( formula, groups, data ) data( barley ) x.fun( variety ~ yield | site, data=barley ) # no problem dotplot( variety ~ yield | site, groups=year, data=barley ) # no problem x.grp( variety ~ yield | site, groups=year, data=barley ) object year not found # that's my error, so I do: x.grp( variety ~ yield | site, groups=barley$year, data=barley ) Error in eval(expr, envir, enclos) : numeric 'envir' arg not of length one traceback() 9: eval(substitute(groups), data, environment(formula)) 8: bwplot.formula(x = formula, data = c(2, 2, 2, 2, 2, 2, 2, 2, ... Why it is a problem calling x.grp() and no problem calling x.fun() ? What could I do to get work x.grp() ? Thanks - Wolfram __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Aggregate?
Hi All, I think i'm failing to undersatnd how aggregate() is supposed to work. example: test1-sample(c(0,1),100,replace=T) test2-sample(letters,100,replace=T) aggregate(test1,list(test2),sum) Error in data.frame(w, lapply(y, unlist, use.names = FALSE)) : arguments imply differing number of rows: 26, 0 I thought this would give me a list containing the number of ones that belong to each letter. What am I doing wrong? Thanks in advance, Gustaf -- email:[EMAIL PROTECTED] tel: +46(0)703051451 address: Kantorsgatan 50:190 75424 Uppsala Sweden __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : formula format for parameter estimation
see nlm or optim Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. - Message d'origine De : Wayne Delport [EMAIL PROTECTED] À : r-help@stat.math.ethz.ch Envoyé le : Vendredi, 8 Décembre 2006, 8h27mn 44s Objet : [R] formula format for parameter estimation Hello, I am trying to input the following formula into R for parameter estimation. I don't quite have the just of formula syntax. I understand simple basic regression (y ~ x), but how do I do the ff: y = ( b0*x )/(x + b1), where b0 and b1 are parameters that need to be solved. Any help/suggestions for a newbie would be much appreciated. thanks ./w Wayne Delport Molecular Ecology and Evolution Programme Department of Genetics University of Pretoria Pretoria 0002 South Africa Percy FitzPatrick Institute of African Ornithology University of Cape Town Rondebosch Cape Town 7701 South Africa 640K ought to be enough for anybody Bill Gates, 1981 I love deadlines, I love the whooshing noise they make as they go by. Douglas Adams __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ___ interface révolutionnaire. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to plot two variables in the same qqnorm-plot?
Dear all, I have two variables called c2 and c3 and want to plot these variables in the same qqnorm-plot with two different symbols or colors to distinguish them so I can easily compare the variables aginst each other. How can I do in R? I only manage to do two separated qqnorn-plots. Thanks for your help, All the best, Jenny c2= -0.1545775144 -0.0601161235 -0.1454710903 0.1893182564 -0.0470586789 -0.0740945381 -0.0041386301 0.0889232833 -0.0418779055 -0.0184595989 -0.1116784460 0.5286719173 -0.0714560939 -0.1160750488 0.2479689612 -0.0255424336 -0.1802256606 -0.1436590798 0.2091955894 -0.0408695231 -0.0097490458 0.4674886420 0.1310178029 0.2518403775 c3= -0.1696564482 -0.1126714841 -0.1460504793 0.1674967485 -0.0181011669 -0.0671367425 0.3261235871 0.0125372613 -0.0970306822 0.0066345879 -0.0438274488 0.8376670819 -0.1195411677 -0.0735540655 0.2999832105 -0.0133914650 -0.1020235781 -0.0929364933 0.1909337727 -0.0198168723 0.0544515704 0.5744399944 0.5022208978 -0.1494894501 - Stava rätt! Stava lätt! Yahoo! Mails stavkontroll tar hand om tryckfelen och mycket mer! Få den på http://se.mail.yahoo.com [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregate?
It does that for me without errors ... (R 2.3.1 on Mac OSX 10.4.8) Best, Ingmar From: Gustaf Rydevik [EMAIL PROTECTED] Date: Fri, 8 Dec 2006 12:58:01 +0300 To: r-help@stat.math.ethz.ch Subject: [R] Aggregate? Hi All, I think i'm failing to undersatnd how aggregate() is supposed to work. example: test1-sample(c(0,1),100,replace=T) test2-sample(letters,100,replace=T) aggregate(test1,list(test2),sum) Error in data.frame(w, lapply(y, unlist, use.names = FALSE)) : arguments imply differing number of rows: 26, 0 I thought this would give me a list containing the number of ones that belong to each letter. What am I doing wrong? Thanks in advance, Gustaf -- email:[EMAIL PROTECTED] tel: +46(0)703051451 address: Kantorsgatan 50:190 75424 Uppsala Sweden __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to plot two variables in the same qqnorm-plot?
try this: z1 - rnorm(100) z2 - rt(100, 3) ## q1 - qqnorm(z1, plot.it = FALSE) q2 - qqnorm(z2, plot.it = FALSE) plot(range(q1$x, q2$x), range(q1$y, q2$y), type = n) points(q1) points(q2, col = red, pch = 3) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Jenny persson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, December 08, 2006 11:30 AM Subject: [R] How to plot two variables in the same qqnorm-plot? Dear all, I have two variables called c2 and c3 and want to plot these variables in the same qqnorm-plot with two different symbols or colors to distinguish them so I can easily compare the variables aginst each other. How can I do in R? I only manage to do two separated qqnorn-plots. Thanks for your help, All the best, Jenny c2= -0.1545775144 -0.0601161235 -0.1454710903 0.1893182564 -0.0470586789 -0.0740945381 -0.0041386301 0.0889232833 -0.0418779055 -0.0184595989 -0.1116784460 0.5286719173 -0.0714560939 -0.1160750488 0.2479689612 -0.0255424336 -0.1802256606 -0.1436590798 0.2091955894 -0.0408695231 -0.0097490458 0.4674886420 0.1310178029 0.2518403775 c3= -0.1696564482 -0.1126714841 -0.1460504793 0.1674967485 -0.0181011669 -0.0671367425 0.3261235871 0.0125372613 -0.0970306822 0.0066345879 -0.0438274488 0.8376670819 -0.1195411677 -0.0735540655 0.2999832105 -0.0133914650 -0.1020235781 -0.0929364933 0.1909337727 -0.0198168723 0.0544515704 0.5744399944 0.5022208978 -0.1494894501 - Stava rätt! Stava lätt! Yahoo! Mails stavkontroll tar hand om tryckfelen och mycket mer! Få den på http://se.mail.yahoo.com [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] MAXIMIZATION WITH CONSTRAINTS
Dear R users, I’m a graduate students and in my master thesis I must obtain the values of the parameters x_i which maximize this Multinomial log–likelihood function log(n!)-sum_{i=1]^4 log(n_i!)+sum_ {i=1}^4 n_i log(x_i) under the following constraints: a) sum_i x_i=1, x_i=0, b) x_1=x_2+x_3+x_4 c)x_2=x_3+x_4 I have been using the “ConstrOptim” R-function with the instructions I report below, and I have tried to implement them with different values of “n”. BUT I have encountered 2 problems: 1) the result of the maximization is the same of the minimization, i.e. the maximum value of the function is equal to the minimum (TOO OFTEN) 2) a lot of times the algorithm returns errors such as “value out of range in 'gammafn'” In both cases 1) 2) I don’t know where is the problem, which is my mistake. Can you help me?! Do you know another way to solve my problem of maximization under constraints? THANKS! My R instructions n=c(10,20,3,5) n1=n[1] n2=n [2] n3=n[3] n4=n[4] logfr=function(x) { ##function to maximize x1= x [1] x2= x[2] x3= x[3] x4= x[4] log(factorial(sum(n)))-sum(log (factorial(n)))+sum(n*log(x)) } grr.log - function(x) { ## Gradient of 'log fr' x1=x[1] x2=x[2] x3=x[3] x4=x[4] return(n/x) } par.start= c(.1999,.15,.4,.25) constr.coeff = rbind(diag(1,4,4),c(-1,1,1,1),c (0,-1,1,1),c(-1,-1,-1,-1), c(1,1,1,1)) constr.tn= c(0,0,0,0,0,0,-1,. 999) min= constrOptim(par.start, logfr, grr.log, ui=constr.coeff, ci=constr.tn) max=constrOptim(par.start, logfr, grr.log, ui=constr. coeff, ci=constr.tn, control=list(fnscale=-1)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice: defining an own function using args for formula and groups
Don't know of a more straight forward way but this works. It constructs a new call to bwplot from the one to x.grp2 and evaluates it in the parent environment: library(lattice) x.grp2 - function(x, groups, data) { cl - match.call() cl[[1]] - as.name(bwplot) eval.parent(cl) } x.grp2( variety ~ yield | site, year, barley ) On 12/8/06, Wolfram Fischer [EMAIL PROTECTED] wrote: x.fun - function( formula, data ) dotplot( formula, data ) x.grp - function( formula, groups, data ) dotplot( formula, groups, data ) data( barley ) x.fun( variety ~ yield | site, data=barley ) # no problem dotplot( variety ~ yield | site, groups=year, data=barley ) # no problem x.grp( variety ~ yield | site, groups=year, data=barley ) object year not found # that's my error, so I do: x.grp( variety ~ yield | site, groups=barley$year, data=barley ) Error in eval(expr, envir, enclos) : numeric 'envir' arg not of length one traceback() 9: eval(substitute(groups), data, environment(formula)) 8: bwplot.formula(x = formula, data = c(2, 2, 2, 2, 2, 2, 2, 2, ... Why it is a problem calling x.grp() and no problem calling x.fun() ? What could I do to get work x.grp() ? Thanks - Wolfram __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fmincon equivalent in R
Dear all R users, I am wondering if there are any function for Constraint optimization in R. Especially i am looking for a R - equivalent of fmincon function in MATLAB. Thanks and regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] A smal fitting problem...
Dear R-helpers, I'm for sure not familiar with R, but it seem like a nice sofware tool, so I've decided to try using it. Here is my problem I just can't figure out: I'd like to do least square fit of a straight horizontal (a = 0) line y = ax + b through some data points x = (3,4,5,6,7,8) y = (0.62, 0.99, 0.83, 0.69, 0.76, 0.82) How would i find b? All the best, Ked [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Aggregate?
Hi look to your workspace by ls(). I bet there is some mismatch in variables as your example works for me without any error. You probably redefined sum function. test1-sample(c(0,1),100,replace=T) test2-sample(letters,100,replace=T) aggregate(test1,list(test2),sum) Group.1 x 1b 1 2c 3 3d 1 4e 4 sum-5 aggregate(test1,list(test2),sum) Error in FUN(X[[1]], ...) : argument INDEX is missing, with no default HTH Petr On 8 Dec 2006 at 12:58, Gustaf Rydevik wrote: Date sent: Fri, 8 Dec 2006 12:58:01 +0300 From: Gustaf Rydevik [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Aggregate? Hi All, I think i'm failing to undersatnd how aggregate() is supposed to work. example: test1-sample(c(0,1),100,replace=T) test2-sample(letters,100,replace=T) aggregate(test1,list(test2),sum) Error in data.frame(w, lapply(y, unlist, use.names = FALSE)) : arguments imply differing number of rows: 26, 0 I thought this would give me a list containing the number of ones that belong to each letter. What am I doing wrong? Thanks in advance, Gustaf -- email:[EMAIL PROTECTED] tel: +46(0)703051451 address: Kantorsgatan 50:190 75424 Uppsala Sweden __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] missing factor levels in a lattice barchart panel cause unexpected failure
Hi all - I'm trying to generate lattice barchart graphs with missing values, and came across the following: This does not run. I would expect it to: library(lattice) D = data.frame(X=1, Y=factor(letters[2], letters[1:2])) barchart(~ X, D, groups=Y) Error in grid.Call.graphics(L_rect, x$x, x$y, x$width, x$height, resolveHJust(x$just, : invalid line type which is simply solved by changing the factor levels: D$Y = factor(D$Y) barchart(~ X, D, groups=Y) or by filling factor levels from the bottom: D = data.frame(X=1, Y=factor(letters[1], letters[1:2])) barchart(~ X, D, groups=Y) However, the failure is important, because it causes the following to fail, no matter how Y is levelled E = data.frame(X=c(1,2,3,4), Y=factor(letters[c(1,2,1,2)], letters [1:2]), Z=factor(c(F,F,G,H))); barchart(~ X | Z, E, groups=Y) Which is an example of a comparison over multiple tests Z for different parameter Y where some Y are missing. alternative version: E = data.frame(X=c(1,2,3,4), Y=letters[c(1,2,1,2)], Z=letters[c (7,7,8,9)]); barchart(~ X | Z, E, groups=Y) I have updated to 2.4.0 and lattice 0.14-16 and the problem still exists. -Alex Brown __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] svm plot question
Aimin: 1) Please do not spam the r-help list---one request per issue (and two private mails to the code author) really suffice. Not all contributors to the R-project are on-line 24/24, and have time to provide immediate answers. 2) The error occurs because plot.svm() currently does not set valid defaults for categorical dimensions you are conditioning on for your 2D-plot (in your example: 'P' and 'Aa') which certainly is a bug. I will commit a fix for the next release of e1071. For the time being, you will have to explicitly specify the levels of 'P' and 'Aa': plot(m.svm,p5.new,As~Cur, slice = list(P = factor(821p, levels = levels(P)), Aa = factor(ALA, levels = levels(Aa (Note that the defaults for the slice argument are completely arbitrary anyway). Thanks for pointing this out, David Aimin Yan wrote: I have a question about svm in R I run the following code, all other is ok, but plot(m.svm,p5.new,As~Cur) is not ok Do you know why? install.packages(e1071) library(e1071) library(MASS) p5 - read.csv(http://www.public.iastate.edu/~aiminy/data/p_5_2.csv;) p5.new-subset(p5,select=-Ms) p5.new$Y-factor(p5.new$Y) levels(p5.new$Y) - list(Out=c(1), In=c(0)) attach(p5.new) m.svm-svm(Y~P+Aa+As+Cur,data=p5.new) summary(m.svm) plot(m.svm,p5.new,As~Cur) Here is output: install.packages(e1071) --- Please select a CRAN mirror for use in this session --- trying URL 'http://rh-mirror.linux.iastate.edu/CRAN/bin/windows/contrib/2.4/e1071_1.5-16.zip' Content type 'application/zip' length 592258 bytes opened URL downloaded 578Kb package 'e1071' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\aiminy\Local Settings\Temp\RtmpY0B2qb\downloaded_packages updating HTML package descriptions library(e1071) Loading required package: class library(MASS) p5 - read.csv(http://www.public.iastate.edu/~aiminy/data/p_5_2.csv;) p5.new-subset(p5,select=-Ms) p5.new$Y-factor(p5.new$Y) levels(p5.new$Y) - list(Out=c(1), In=c(0)) attach(p5.new) m.svm-svm(Y~P+Aa+As+Cur,data=p5.new) summary(m.svm) Call: svm(formula = Y ~ P + Aa + As + Cur, data = p5.new) Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.04 Number of Support Vectors: 758 ( 382 376 ) Number of Classes: 2 Levels: Out In plot(m.svm,p5.new,As~Cur) Error in scale(newdata[, object$scaled, drop = FALSE], center = object$x.scale$scaled:center, : (subscript) logical subscript too long -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Tel: +43-1-313 36 4393 Fax: +43-1-313 36 90 4393 HP: http://wi.wu-wien.ac.at/~meyer/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A smal fitting problem...
If you really want to fit a horizontal line then the best estimate (meaning least squares) for b is mean(y), regardless of the actual x values, which becomes clear if you look at your design matrix / regressor matrix . In general least squares regression could be done with lsfit(). In your case the design matrix (X matrix) is a simple vector of ones. Kåre Edvardsen schrieb: Dear R-helpers, I'm for sure not familiar with R, but it seem like a nice sofware tool, so I've decided to try using it. Here is my problem I just can't figure out: I'd like to do least square fit of a straight horizontal (a = 0) line y = ax + b through some data points x = (3,4,5,6,7,8) y = (0.62, 0.99, 0.83, 0.69, 0.76, 0.82) How would i find b? All the best, Ked [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot.svm
Try debug(e1071:::plot.svm) and then re-run your plot command, stepping through one line at a time and see where it fails. Andy From: Aimin Yan where is plot.svm method? I just find plot(svm, data, formula) method Aimin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A smal fitting problem...
b = mean(y) On 08/12/06, Kåre Edvardsen [EMAIL PROTECTED] wrote: Dear R-helpers, I'm for sure not familiar with R, but it seem like a nice sofware tool, so I've decided to try using it. Here is my problem I just can't figure out: I'd like to do least square fit of a straight horizontal (a = 0) line y = ax + b through some data points x = (3,4,5,6,7,8) y = (0.62, 0.99, 0.83, 0.69, 0.76, 0.82) How would i find b? All the best, Ked [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simulation in R - Part 2
Hi from write.csv help page: x the object to be written, preferably a matrix or data frame. If not, it is attempted to coerce x to a data frame. So array is not a kind of object which can be saved as you want without some complication. Basically it is a plain vector with dim attributes and write.csv do its best to coerce it to data frame, but here you definitely need to do the transformation on your own. You either shall use list and then transfer it to data frame by do.call(rbind, the.list) # or something similar or try to reshape your array e.g. by using melt and cast from reshape package to the form suitable for data frame transformation. HTH Petr On 7 Dec 2006 at 22:33, Alexander Geisler wrote: Date sent: Thu, 07 Dec 2006 22:33:05 +0100 From: Alexander Geisler [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Simulation in R - Part 2 Hello! So, the simulation works (drawing 100 samples and then calculate the model for each sample). Here is the code: --snip-- # sample size n=200 ergebnisse200 - rep(0, each=100) stichproben200 - vector(âślistâť, 100) default200 - rep(0, each=100) for (i in seq(1:100)) { n - dim(daten)[1] ix - sample(n,200) samp_i - daten[ix,] # draw samples y - sum(samp_i$y) # number of defaults stichproben200[[i]] - samp_i # saving the samples default200[i] - y # saving the number of defaults # Modell berechnen: posterior_i - MCMClogit(y ~ fbl.ind + fekq3 + febitda4 + fuvs + fkru + fzd + fur3, data=samp_i, b0=prior, B0=precision, tune=0.5) # calculation ergebnisse200[i] - summary(posterior_i) # saving the results } # write out the solutions into an excel-file write.csv2(ergebnisse200, ergebnisse.csv) --snip-- My solution has the following form: http://img296.imageshack.us/my.php?image=ergebnissewa0.jpg write.csv2 makes the right thing, but in the excel-file, if I open the csv-file in excel, several objects are next to each other (I'm missing the line break after each object of the array); look at http://img67.imageshack.us/my.php?image=ergebnisseexcelbg7.jpg The problem is that there is an error message by importing the csv in excel, because there are to many columns needed to import the 100 objects. So, my question: Is it possible to write the 100 objects of the array among each other. Like as it can be seen in R (http://img296.imageshack.us/my.php?image=ergebnissewa0.jpg)? Another way is to produce 50 samples in a first turn and then produce 50 samples again in another turn, but this can not be a clean solution (and surely not the only one). Hopefully you can help me and this is the last question for my simulation. Thanks for your efforts Alex -- Alexander Geisler * Kaltenbach 151 * A-6272 Kaltenbach email: [EMAIL PROTECTED] | [EMAIL PROTECTED] phone: +43 650 / 811 61 90 | skpye: al1405ex __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fmincon equivalent in R
Arun Kumar Saha arun.kumar.saha at gmail.com writes: Dear all R users, I am wondering if there are any function for Constraint optimization in R. Especially i am looking for a R - equivalent of fmincon function in MATLAB. Thanks and regards, Arun Unfortunately, the built-in functions in R only handle box constraints (independent inequality constraints on each parameter), via method L-BFGS-B in optim() or via nlminb(), or linear inequality constraints via constrOptim(). You might try doing an RSiteSearch() for Lagrange multiplier -- that will provide potential solutions to your problem, but you'll very much have to roll your own. (If any R-helpers out there would like to correct me or provide pointers to examples of Lagrange multiplier implementations in R, that would be great ...) Ben Bolker __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Remove from a string
Hi all! I have lots of functions called in the following pattern 'NameOfFunctionNumber' where the name always stays the same and the number varies from 1 to 98. Another function which I run in advance returns the number of the function which has to be called next. Now I want to combine 'NameOfFunction' with the 'Number' returned so that i can call the desired function. I do this by: x-c(NameOfFunction,Number) z-paste(x,collapse=) z which returns NameOfFunctionNumber My Problem is that R doesn't recognise this as the name of my function because of the at the beginning and the end. Is there a way of getting rid of those? Or does anybody know another way of solving this problem? Thanks a lot for your help! Cheers, Katharina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove from a string
Try using 'get' to return the object specified as a character string: f1-function()1 f2 - function()2 z - 'f2' z [1] f2 get(z)() [1] 2 On 12/8/06, Katharina Vedovelli [EMAIL PROTECTED] wrote: Hi all! I have lots of functions called in the following pattern 'NameOfFunctionNumber' where the name always stays the same and the number varies from 1 to 98. Another function which I run in advance returns the number of the function which has to be called next. Now I want to combine 'NameOfFunction' with the 'Number' returned so that i can call the desired function. I do this by: x-c(NameOfFunction,Number) z-paste(x,collapse=) z which returns NameOfFunctionNumber My Problem is that R doesn't recognise this as the name of my function because of the at the beginning and the end. Is there a way of getting rid of those? Or does anybody know another way of solving this problem? Thanks a lot for your help! Cheers, Katharina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dyn.load and function calls without 'PACKAGE' argument
I'm writing a package that interfaces to the FAME database, via a library of compiled C routines accessible through a Linux .so file. My .onLoad() function loads the .so like this: dyn.load(/opt/fame/timeiq/lib/linux_x86/libjchli.so, local = F) and after that I also load my own fame.so via library.dynam(fame, package = fame) The code in fame.so uses functions found in libjchli.so, making the 'local = F' argument in dyn.load() necessary. But since Fame symbols are found in libjchli.so, which is NOT part of my package, I can't, for example, do this: .C(cfmfin, status = integer(1), PACKAGE = fame) since the PACKAGE argument tells R to look only in fame.so for symbols. Instead, I have to do it without specifying 'PACKAGE', i.e., .C(cfmfin, status = integer(1)) This works, but 'R CMD check' complains: Foreign function calls without 'PACKAGE' argument: followed by a list of the functions called from libjchli.so. Is there a way to make R CMD check happy here? Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove from a string
If I understand what you need, Number=2 x - paste(NameOfFunction,as.character(Number),sep=) x [1] NameOfFunction2 And you can use do.call(x, ...) to get your function. Hope it helps, Scionforbai __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re : A smal fitting problem...
May be you are also not familiar with statistic. the solution of min \sum_{i=1}^{n} (y_{i}-b)^{2} is the mean. So the solution is b-mean(y) Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. - Message d'origine De : Kåre Edvardsen [EMAIL PROTECTED] À : R-help r-help@stat.math.ethz.ch Envoyé le : Vendredi, 8 Décembre 2006, 13h20mn 10s Objet : [R] A smal fitting problem... Dear R-helpers, I'm for sure not familiar with R, but it seem like a nice sofware tool, so I've decided to try using it. Here is my problem I just can't figure out: I'd like to do least square fit of a straight horizontal (a = 0) line y = ax + b through some data points x = (3,4,5,6,7,8) y = (0.62, 0.99, 0.83, 0.69, 0.76, 0.82) How would i find b? All the best, Ked [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ___ Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internaut [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove from a string
try this: f1 - function(x) x + 1 f2 - function(x) x + 2 f3 - function(x) x + 3 ### FunNam - f1 eval(call(FunNam, x = 1:5)) FunNam - f2 eval(call(FunNam, x = 1:5)) FunNam - f3 eval(call(FunNam, x = 1:5)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Katharina Vedovelli [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, December 08, 2006 2:57 PM Subject: [R] Remove from a string Hi all! I have lots of functions called in the following pattern 'NameOfFunctionNumber' where the name always stays the same and the number varies from 1 to 98. Another function which I run in advance returns the number of the function which has to be called next. Now I want to combine 'NameOfFunction' with the 'Number' returned so that i can call the desired function. I do this by: x-c(NameOfFunction,Number) z-paste(x,collapse=) z which returns NameOfFunctionNumber My Problem is that R doesn't recognise this as the name of my function because of the at the beginning and the end. Is there a way of getting rid of those? Or does anybody know another way of solving this problem? Thanks a lot for your help! Cheers, Katharina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove from a string
On Fri, 2006-12-08 at 14:57 +0100, Katharina Vedovelli wrote: Hi all! I have lots of functions called in the following pattern 'NameOfFunctionNumber' where the name always stays the same and the number varies from 1 to 98. Another function which I run in advance returns the number of the function which has to be called next. Now I want to combine 'NameOfFunction' with the 'Number' returned so that i can call the desired function. I do this by: x-c(NameOfFunction,Number) z-paste(x,collapse=) z which returns NameOfFunctionNumber My Problem is that R doesn't recognise this as the name of my function because of the at the beginning and the end. Is there a way of getting rid of those? Or does anybody know another way of solving this problem? Thanks a lot for your help! Cheers, Katharina It is not entirely clear what your ultimate goal is, thus there may be a (much) better approach than calling functions in this manner. What do the functions actually do and does the output vary based upon some attribute (ie. the class) of the argument such that using R's typical function dispatch method would be more suitable. However, to address the specific question, at least two options: NameOfFunction21 - function(x) x^2 eval(call(paste(NameOfFunction, 21, sep = ), 21)) [1] 441 do.call(paste(NameOfFunction, 21, sep = ), list(21)) [1] 441 In both cases, the result is to evaluate the function call, with 21 as the argument. See ?call, ?eval and ?do.call for more information. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] JOB: R/S programmers at Mango Solutions (UK)
Hello, Due to the continued growth of Mango Solutions, we are now inviting applications for the following positions: * Senior R/S Programmer: http://www.mango-solutions.com/company/jobuk13.html * R/S Programmer: http://www.mango-solutions.com/company/jobuk14.html To view all available positions at Mango Solutions, visit the Careers page at http://www.mango-solutions.com/company/careers.html Kind regards, Romain. *mangosolutions* data analysis that delivers -- Mango Solutions Tel +44 1249 467 467 Fax +44 1249 467 468 Mob +44 7813 526 123 data analysis that delivers __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A smal fitting problem...
On Dec 8, 2006, at 7:42 AM, David Barron wrote: b = mean(y) On 08/12/06, Kåre Edvardsen [EMAIL PROTECTED] wrote: Dear R-helpers, I'm for sure not familiar with R, but it seem like a nice sofware tool, so I've decided to try using it. Here is my problem I just can't figure out: I'd like to do least square fit of a straight horizontal (a = 0) line y = ax + b through some data points x = (3,4,5,6,7,8) y = (0.62, 0.99, 0.83, 0.69, 0.76, 0.82) How would i find b? And in the context of linear models: x - 3:8 y - c(0.62, 0.99, 0.83, 0.69, 0.76, 0.82) lm(y ~ 1) _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave and warning messages
How does one tell Sweave() to include analysis warning messages in the verbatim output? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Hallo.
Dr. PETER MALUBA/CHRIS NISSEN ASSOCIATES SOLICITORS ADVOCATES GABORONE. BOTSWANA. Hallo, Mein Name ist Dr. Peter Maluba, bin ein 50 jähriger Anwalt aus Gaborone, Botswana. Einer meiner 15 Jährigen Klienten ,ein Deutscher Namens Gunter Haymann, welcher über 18 Jahre für eine Diamanten Bergbaufirma ( Debsawna Diamond Company pty Limited) gearbeitet hat, ist leider im November 2003 in einem Autounfall verunglückt. Herr. Hayman ist an den Folgen seiner Verletzungen im Krankenhaus von Borswana verstorben.Aus seiner Tätigkeit als Bergbauunternehmer und Contractor ist ein ansehnliches Vermögen angewachsen und betrug bei seinem Ableben rund 8.5 Mio $. Während der Jahre unserer Zusammenarbeit hat sich ein grosses Vertrauen zu mir gebildet und nach seinem Tode konnte ich sogar seine Prokuristin anstellen. Todtraurig hat sich bis zum heutigen Tag kein Verwandter oder Angehöriger gemeldet um das Vermögen zu übernehmen. Bei uns in Botswana besteht ein Gesetz , dass Vermögen welche nicht innert 3 Jahren in Anspruch genommen werden an die Regierungskasse übergehen. Dies möchte ich mit allen Mitteln verhindern. Aus diesem Grund habe mich bemüht über eine Security Company und einem Sperrkonto (Safe Deposit Box) das Vermögen zu sichern damit es nicht an die Regierung zurückfällt. Ich suche ferner aus diesem Grund, einen europäischen Partner mit welchem ich einen Vertrag abschliessen kann und über ihn (Firma,Name,Adresse,Tel,Fax etc,) diese Geldtransaktion abwickeln zu können. Dieser Partner würde für seine Dienste mit 20% Provision belohnt. Gerne würde ich von ihnen erfahren ob sie an so einem Projekt interessiert wären? ich werde mich auf eine Rückantwort freuen. [EMAIL PROTECTED] Herzlichen Dank, ich würde mich über ihre Koorperation freuen. mfg, Dr. Peter Maluba. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove from a string
The best approach is probably to load all of your functions into a list: myfunctions - list() myfunctions[[1]] - NameOfFunction1 myfunctions[[2]] - NameOfFunction2 ... Or myfunctions - list() for (i in 1:98){ + myfunctions[[i]] - get( paste('NameOfFunction',i,sep='') ) + } Then you can run the function like: myfunctions[[Number]](data, ...) You could use 'get' directly, but the list of functions is probably cleaner. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Katharina Vedovelli Sent: Friday, December 08, 2006 6:57 AM To: r-help@stat.math.ethz.ch Subject: [R] Remove from a string Hi all! I have lots of functions called in the following pattern 'NameOfFunctionNumber' where the name always stays the same and the number varies from 1 to 98. Another function which I run in advance returns the number of the function which has to be called next. Now I want to combine 'NameOfFunction' with the 'Number' returned so that i can call the desired function. I do this by: x-c(NameOfFunction,Number) z-paste(x,collapse=) z which returns NameOfFunctionNumber My Problem is that R doesn't recognise this as the name of my function because of the at the beginning and the end. Is there a way of getting rid of those? Or does anybody know another way of solving this problem? Thanks a lot for your help! Cheers, Katharina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to create data.frame with dynamic count of values
Hello R-Group I found how to fill the data.frame - http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html N1 - rnorm(4) N2 - rnorm(4) N3 - rnorm(4) N4 - rnorm(4) X1 - LETTERS[1:4] ### nams - c(paste(N, 1:4, sep = ), X1) dat - data.frame(lapply(nams, get)) names(dat) - nams dat But I need also to create a dynamic count of numeric vectors items = 15 VarSize -10 N1 - rep(0,VarSize) N2 - rep(0,VarSize) N3 - rep(0,VarSize) N4 - rep(0,VarSize) N5 - rep(0,VarSize) ... N15- rep(0,VarSize) # 15 items Thank you in advance Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove from a string
I second Marc's comments below, but for amusement, another alternative to the (undesirable) eval(call()) construction is: foo-function(x)x^2 get(foo)(1:5) [1] 1 4 9 16 25 I believe this is equally undesirable, however, and as Marc said, making your function a function of two arguments or something similar would be the better approach. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marc Schwartz Sent: Friday, December 08, 2006 6:14 AM To: Katharina Vedovelli Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Remove from a string On Fri, 2006-12-08 at 14:57 +0100, Katharina Vedovelli wrote: Hi all! I have lots of functions called in the following pattern 'NameOfFunctionNumber' where the name always stays the same and the number varies from 1 to 98. Another function which I run in advance returns the number of the function which has to be called next. Now I want to combine 'NameOfFunction' with the 'Number' returned so that i can call the desired function. I do this by: x-c(NameOfFunction,Number) z-paste(x,collapse=) z which returns NameOfFunctionNumber My Problem is that R doesn't recognise this as the name of my function because of the at the beginning and the end. Is there a way of getting rid of those? Or does anybody know another way of solving this problem? Thanks a lot for your help! Cheers, Katharina It is not entirely clear what your ultimate goal is, thus there may be a (much) better approach than calling functions in this manner. What do the functions actually do and does the output vary based upon some attribute (ie. the class) of the argument such that using R's typical function dispatch method would be more suitable. However, to address the specific question, at least two options: NameOfFunction21 - function(x) x^2 eval(call(paste(NameOfFunction, 21, sep = ), 21)) [1] 441 do.call(paste(NameOfFunction, 21, sep = ), list(21)) [1] 441 In both cases, the result is to evaluate the function call, with 21 as the argument. See ?call, ?eval and ?do.call for more information. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dynamic panel data estimation
Hello every one, is there an R package that can handle dynamic panel data model aviablable ? thank you for help chen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MAXIMIZATION WITH CONSTRAINTS
On Fri, 8 Dec 2006, [EMAIL PROTECTED] wrote: Dear R users, I??m a graduate students and in my master thesis I must obtain the values of the parameters x_i which maximize this Multinomial log??likelihood function log(n!)-sum_{i=1]^4 log(n_i!)+sum_ {i=1}^4 n_i log(x_i) under the following constraints: a) sum_i x_i=1, x_i=0, b) x_1=x_2+x_3+x_4 c)x_2=x_3+x_4 I have been using the ??ConstrOptim?? R-function with the instructions I report below, and I have tried to implement them with different values of ??n??. BUT I have encountered 2 problems: The problem is that the first constraint is not an inequality but an equality. Writing it as two inequalities results in the feasible region for the optimization being a very narrow slice of four-dimensional space, which makes the optimization difficult. There are at least two ways to fix the problem. The first is to note that the loglikelihood is monotone in each x, so that sum_i x_i =1 is sufficient when maximizing. The second is to reparametrize in terms of three parameters. Minimization is more challenging, because the loglikelihood does not have a minimum. It is negative infinite when any x_i is zero and the corresponding n is non-zero. -thomas My R instructions n=c(10,20,3,5) n1=n[1] n2=n [2] n3=n[3] n4=n[4] logfr=function(x) { ##function to maximize x1= x [1] x2= x[2] x3= x[3] x4= x[4] log(factorial(sum(n)))-sum(log (factorial(n)))+sum(n*log(x)) } grr.log - function(x) { ## Gradient of 'log fr' x1=x[1] x2=x[2] x3=x[3] x4=x[4] return(n/x) } par.start= c(.1999,.15,.4,.25) constr.coeff = rbind(diag(1,4,4),c(-1,1,1,1),c (0,-1,1,1),c(-1,-1,-1,-1), c(1,1,1,1)) constr.tn= c(0,0,0,0,0,0,-1,. 999) min= constrOptim(par.start, logfr, grr.log, ui=constr.coeff, ci=constr.tn) max=constrOptim(par.start, logfr, grr.log, ui=constr. coeff, ci=constr.tn, control=list(fnscale=-1)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Solve non linear system of equations
Hello, how do Ito solve a non linear system of equations in R? -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Constraint Optimization problem.
Dear all R users, I have a optimization problem like this: f(x,y) is a function with two variables, x, and y. Variable x is unbounded but y lies between [-10, 10]. I want to minimize f(x,y) subject to a constraint x + y 5. Can anyone tell me which R function should I use. I already gone through ?constrOptim. But here I cannot specify lower and upper bounds for x, and y. However if I use ?optim function then I can not specify the constraint. can anyone give me any clue? any help will be highly appreciated. Thanks and regards, Arun [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] filled.contour and NA's
Hi Gustaf I'm having the same issue myself. What I've ended up doing is replacing NA's with a big negative value, define levels as one color for negative values, and a regular scale above. How to define 'levels' as one color for negative values and a regular scale above? I don't know how the syntax within the filled.contour function shoul be. BR Antonio This gives a fairly good separation between what areas contain data, and what doesn't. To make NA's black, I suppose one would have to define your own colour.palette, but I haven't looked into it. Hope this helps, and let me know if you've found a better solution! Best, Gustaf Rydevik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to create data.frame with dynamic count of values
I don't understand what you're asking for. But if your goal is to create N1 through N15 in order to use them to fill a data frame, then it can be much simpler: items - 15 VarSize - 10 tmp - matrix(0,nrow=VarSize,ncol=items) tmp - data.frame(tmp) names(tmp) - paste('N',seq(items),sep='') ## of course, this next only works if VarSize = length(letters) tmp$X1 - letters[1:VarSize] You could instead start with tmp - matrix( rnorm(VarSize*items) , nrow=VarSize , ncol=items) -Don At 5:17 PM +0100 12/8/06, Knut Krueger wrote: Hello R-Group I found how to fill the data.frame - http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html N1 - rnorm(4) N2 - rnorm(4) N3 - rnorm(4) N4 - rnorm(4) X1 - LETTERS[1:4] ### nams - c(paste(N, 1:4, sep = ), X1) dat - data.frame(lapply(nams, get)) names(dat) - nams dat But I need also to create a dynamic count of numeric vectors items = 15 VarSize -10 N1 - rep(0,VarSize) N2 - rep(0,VarSize) N3 - rep(0,VarSize) N4 - rep(0,VarSize) N5 - rep(0,VarSize) ... N15- rep(0,VarSize) # 15 items Thank you in advance Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Paste function and backslash
Dear useRs, calls and results below: paste(\ \n) [1] \n *but* paste(\ \N) [1] N Question: Is that by design? If so, how can I obtain simple LaTeX-type: [1] \N version platform i386-pc-linux-gnu arch i386 os linux-gnu system i386, linux-gnu status major 2 minor 4.0 year 2006 month 10 day03 svn rev39566 language R version.string R version 2.4.0 (2006-10-03) -- Szymon Wlazlowski __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] svm plot question
thanks, I did get this plot. Before I have this problem, I did get a plot by my code. However after I change a little my code. it doesn't work. It is pity not saving my original code. Now the question is the plot I get using your code is different from what I got before. Moreover I did remember I use plot(m.svm,p5.new,As~Cur) Do you know why? Thanks, Aimin At 06:32 AM 12/8/2006, David Meyer wrote: Aimin: 1) Please do not spam the r-help list---one request per issue (and two private mails to the code author) really suffice. Not all contributors to the R-project are on-line 24/24, and have time to provide immediate answers. 2) The error occurs because plot.svm() currently does not set valid defaults for categorical dimensions you are conditioning on for your 2D-plot (in your example: 'P' and 'Aa') which certainly is a bug. I will commit a fix for the next release of e1071. For the time being, you will have to explicitly specify the levels of 'P' and 'Aa': plot(m.svm,p5.new,As~Cur, slice = list(P = factor(821p, levels = levels(P)), Aa = factor(ALA, levels = levels(Aa (Note that the defaults for the slice argument are completely arbitrary anyway). Thanks for pointing this out, David Aimin Yan wrote: I have a question about svm in R I run the following code, all other is ok, but plot(m.svm,p5.new,As~Cur) is not ok Do you know why? install.packages(e1071) library(e1071) library(MASS) p5 - read.csv(http://www.public.iastate.edu/~aiminy/data/p_5_2.csv;) p5.new-subset(p5,select=-Ms) p5.new$Y-factor(p5.new$Y) levels(p5.new$Y) - list(Out=c(1), In=c(0)) attach(p5.new) m.svm-svm(Y~P+Aa+As+Cur,data=p5.new) summary(m.svm) plot(m.svm,p5.new,As~Cur) Here is output: install.packages(e1071) --- Please select a CRAN mirror for use in this session --- trying URL 'http://rh-mirror.linux.iastate.edu/CRAN/bin/windows/contrib/2.4/e1071_1.5-16.zip' Content type 'application/zip' length 592258 bytes opened URL downloaded 578Kb package 'e1071' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\aiminy\Local Settings\Temp\RtmpY0B2qb\downloaded_packages updating HTML package descriptions library(e1071) Loading required package: class library(MASS) p5 - read.csv(http://www.public.iastate.edu/~aiminy/data/p_5_2.csv;) p5.new-subset(p5,select=-Ms) p5.new$Y-factor(p5.new$Y) levels(p5.new$Y) - list(Out=c(1), In=c(0)) attach(p5.new) m.svm-svm(Y~P+Aa+As+Cur,data=p5.new) summary(m.svm) Call: svm(formula = Y ~ P + Aa + As + Cur, data = p5.new) Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.04 Number of Support Vectors: 758 ( 382 376 ) Number of Classes: 2 Levels: Out In plot(m.svm,p5.new,As~Cur) Error in scale(newdata[, object$scaled, drop = FALSE], center = object$x.scale$scaled:center, : (subscript) logical subscript too long -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Tel: +43-1-313 36 4393 Fax: +43-1-313 36 90 4393 HP: http://wi.wu-wien.ac.at/~meyer/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Paste function and backslash
On Fri, 8 Dec 2006, Szymon Wlazlowski wrote: Dear useRs, calls and results below: paste(\ \n) [1] \n *but* paste(\ \N) [1] N Question: Is that by design? If so, how can I obtain simple LaTeX-type: [1] \N FAQ 7.37: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-backslash-behave-strangely-inside-strings_003f version platform i386-pc-linux-gnu arch i386 os linux-gnu system i386, linux-gnu status major 2 minor 4.0 year 2006 month 10 day03 svn rev39566 language R version.string R version 2.4.0 (2006-10-03) -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to create data.frame with dynamic count of values
Hello R-Group I found how to fill the data.frame - http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html N1 - rnorm(4) N2 - rnorm(4) N3 - rnorm(4) N4 - rnorm(4) X1 - LETTERS[1:4] ### nams - c(paste(N, 1:4, sep = ), X1) dat - data.frame(lapply(nams, get)) names(dat) - nams dat But I need also to create a dynamic count of numeric vectors items = 15 VarSize -10 N1 - rep(0,VarSize) N2 - rep(0,VarSize) N3 - rep(0,VarSize) N4 - rep(0,VarSize) N5 - rep(0,VarSize) ... N15- rep(0,VarSize) # 15 items Thank you in advance Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] any way to make the code more efficient ?
The code bekow works so this is why I didn't include the data to reproduce it. The loops about 500 times and each time, a zoo object with 1400 rows and 4 columns gets created. ( the rows represent minutes so each file is one day worth of data). Inside the loop, I keep rbinding the newly created zoo object to the current zoo object so that it gets bigger and bigger over time. Eventually, the new zoo object, fullaggfxdata, containing all the days of data is created. I was just wondering if there is a more efficient way of doing this. I do know the number of times the loop will be done at the beginning so maybe creating the a matrix or data frame at the beginning and putting the daily ones in something like that would Make it be faster. But, the proboem with this is I eventually do need a zoo object. I ask this question because at around the 250 mark of the loop, things start to slow down significiantly and I think I remember reading somewhere that doing an rbind of something to itself is not a good idea. Thanks. #=== === start-1 for (filecounter in (1:length(datafilenames))) { print(paste(File Counter = , filecounter)) datafile= paste(datadir,/,datafilenames[filecounter],sep=) aggfxdata-clnaggcompcurrencyfile(fxfile=datafile,aggminutes=aggminutes, fillholes=1) logbidask-log(aggfxdata[,bidask]) aggfxdata-cbind(aggfxdata,logbidask) if ( start == 1 ) { fullaggfxdata-aggfxdata start-0 } else { fullaggfxdata-rbind(fullaggfxdata,aggfxdata) } } #=== == This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question for if else
I have a data set like this I want to assign outward to Y if sc 90 and assign inward to Y if sc=90. then cbind(p1982,Y) to get like these p aa as ms cur sc Y 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 inward 2 154l_aa THR 15.86 28.32 0.2563560 103.67100inward 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 outward 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930outward 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 inward 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980outward does anyone know how to these? Aimin head(p1982) p aa as mscursc 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 2 154l_aa THR 15.86 28.32 0.2563560 103.67100 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any way to make the code more efficient ?
Using rbind almost always slows things down significantly. You should define the objects aggfxdata and fullaggfxdata before the loop and then assign appropriate values to the corresponding rows and/or columns. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Friday, December 08, 2006 4:17 PM To: r-help@stat.math.ethz.ch Subject: [R] any way to make the code more efficient ? The code bekow works so this is why I didn't include the data to reproduce it. The loops about 500 times and each time, a zoo object with 1400 rows and 4 columns gets created. ( the rows represent minutes so each file is one day worth of data). Inside the loop, I keep rbinding the newly created zoo object to the current zoo object so that it gets bigger and bigger over time. Eventually, the new zoo object, fullaggfxdata, containing all the days of data is created. I was just wondering if there is a more efficient way of doing this. I do know the number of times the loop will be done at the beginning so maybe creating the a matrix or data frame at the beginning and putting the daily ones in something like that would Make it be faster. But, the proboem with this is I eventually do need a zoo object. I ask this question because at around the 250 mark of the loop, things start to slow down significiantly and I think I remember reading somewhere that doing an rbind of something to itself is not a good idea. Thanks. #=== === start-1 for (filecounter in (1:length(datafilenames))) { print(paste(File Counter = , filecounter)) datafile= paste(datadir,/,datafilenames[filecounter],sep=) aggfxdata-clnaggcompcurrencyfile(fxfile=datafile,aggminutes=aggminutes, fillholes=1) logbidask-log(aggfxdata[,bidask]) aggfxdata-cbind(aggfxdata,logbidask) if ( start == 1 ) { fullaggfxdata-aggfxdata start-0 } else { fullaggfxdata-rbind(fullaggfxdata,aggfxdata) } } #=== == This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any way to make the code more efficient ?
ravi : I appreciate your help but could you be a little more specific about what you mean ? I can just stack aggfxdata below the current full one ( the rbind works out the ordrering by date because it's a zoo object ) so it's not a question of where to put the new one. It's a question of how to avoid rbind ? I apologize because I don't think I understand what you are saying. Or maybe it's not possible to avoid rbind ? Thanks. -Original Message- From: Ravi Varadhan [mailto:[EMAIL PROTECTED] Sent: Friday, December 08, 2006 5:21 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: RE: [R] any way to make the code more efficient ? Using rbind almost always slows things down significantly. You should define the objects aggfxdata and fullaggfxdata before the loop and then assign appropriate values to the corresponding rows and/or columns. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Friday, December 08, 2006 4:17 PM To: r-help@stat.math.ethz.ch Subject: [R] any way to make the code more efficient ? The code bekow works so this is why I didn't include the data to reproduce it. The loops about 500 times and each time, a zoo object with 1400 rows and 4 columns gets created. ( the rows represent minutes so each file is one day worth of data). Inside the loop, I keep rbinding the newly created zoo object to the current zoo object so that it gets bigger and bigger over time. Eventually, the new zoo object, fullaggfxdata, containing all the days of data is created. I was just wondering if there is a more efficient way of doing this. I do know the number of times the loop will be done at the beginning so maybe creating the a matrix or data frame at the beginning and putting the daily ones in something like that would Make it be faster. But, the proboem with this is I eventually do need a zoo object. I ask this question because at around the 250 mark of the loop, things start to slow down significiantly and I think I remember reading somewhere that doing an rbind of something to itself is not a good idea. Thanks. #=== === start-1 for (filecounter in (1:length(datafilenames))) { print(paste(File Counter = , filecounter)) datafile= paste(datadir,/,datafilenames[filecounter],sep=) aggfxdata-clnaggcompcurrencyfile(fxfile=datafile,aggminutes=aggminutes, fillholes=1) logbidask-log(aggfxdata[,bidask]) aggfxdata-cbind(aggfxdata,logbidask) if ( start == 1 ) { fullaggfxdata-aggfxdata start-0 } else { fullaggfxdata-rbind(fullaggfxdata,aggfxdata) } } #=== == This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
I have a data set like this: if I want to less than 20 obs from this data set. How can I do these? str(p1982) 'data.frame': 465979 obs. of 6 variables: $ p : Factor w/ 1982 levels 154l_aa,1A0P_aa,..: 1 1 1 1 1 1 1 1 1 1 ... $ aa : Factor w/ 19 levels ALA,ARG,ASN,..: 2 16 4 5 18 3 19 3 2 9 ... $ as : num 152.0 15.9 65.1 57.2 28.9 ... $ ms : num 108.8 28.3 59.2 49.9 31.8 ... $ cur: num -0.1020 0.2564 0.0312 -0.0550 0.0526 ... $ sc : num 92.10 103.67 7.27 72.98 96.12 ... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
p1982[sample(nrow(p1982),20),] On 12/8/06, Aimin Yan [EMAIL PROTECTED] wrote: I have a data set like this: if I want to less than 20 obs from this data set. How can I do these? str(p1982) 'data.frame': 465979 obs. of 6 variables: $ p : Factor w/ 1982 levels 154l_aa,1A0P_aa,..: 1 1 1 1 1 1 1 1 1 1 ... $ aa : Factor w/ 19 levels ALA,ARG,ASN,..: 2 16 4 5 18 3 19 3 2 9 ... $ as : num 152.0 15.9 65.1 57.2 28.9 ... $ ms : num 108.8 28.3 59.2 49.9 31.8 ... $ cur: num -0.1020 0.2564 0.0312 -0.0550 0.0526 ... $ sc : num 92.10 103.67 7.27 72.98 96.12 ... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any way to make the code more efficient ?
Save your intermediate results as a list of matrices. Then rbind them all at once using do.call. It looks like this will save 23 seconds (see below), if you are running on a PC like mine (AMD 2GHz, WinXP ). But I wonder, if 23 a mere seconds is all you save is this really worth worrying about?? Maybe you are losing time elsewhere. If so, you need to profile this run and/or track memory usage. amat - NULL mat.1400.by.4 - matrix(1:(1400*4),nc=4) system.time(for (i in 1:500) amat - rbind(amat, mat.1400.by.4 )) [1] 20.05 1.53 23.24NANA list.of.matrices - rep( list( mat.1400.by.4 ) , 500 ) system.time( amat2 - do.call(rbind, list.of.matrices ) ) [1] 0.08 0.00 0.08 NA NA all.equal(amat,amat2) [1] TRUE On Fri, 8 Dec 2006, Leeds, Mark (IED) wrote: The code bekow works so this is why I didn't include the data to reproduce it. The loops about 500 times and each time, a zoo object with 1400 rows and 4 columns gets created. ( the rows represent minutes so each file is one day worth of data). Inside the loop, I keep rbinding the newly created zoo object to the current zoo object so that it gets bigger and bigger over time. Eventually, the new zoo object, fullaggfxdata, containing all the days of data is created. I was just wondering if there is a more efficient way of doing this. I do know the number of times the loop will be done at the beginning so maybe creating the a matrix or data frame at the beginning and putting the daily ones in something like that would Make it be faster. But, the proboem with this is I eventually do need a zoo object. I ask this question because at around the 250 mark of the loop, things start to slow down significiantly and I think I remember reading somewhere that doing an rbind of something to itself is not a good idea. Thanks. #=== === start-1 for (filecounter in (1:length(datafilenames))) { print(paste(File Counter = , filecounter)) datafile= paste(datadir,/,datafilenames[filecounter],sep=) aggfxdata-clnaggcompcurrencyfile(fxfile=datafile,aggminutes=aggminutes, fillholes=1) logbidask-log(aggfxdata[,bidask]) aggfxdata-cbind(aggfxdata,logbidask) if ( start == 1 ) { fullaggfxdata-aggfxdata start-0 } else { fullaggfxdata-rbind(fullaggfxdata,aggfxdata) } } #=== == This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any way to make the code more efficient ?
I don't know about efficiency, but at least for readability, you may want to do the following: 1. Indent your code. 2. Create a list of appropriate length, and populate the list with objects you're creating in the loop. 3. After the loop, use do.call(rbind, list). HTH, Andy From: Leeds, Mark (IED) ravi : I appreciate your help but could you be a little more specific about what you mean ? I can just stack aggfxdata below the current full one ( the rbind works out the ordrering by date because it's a zoo object ) so it's not a question of where to put the new one. It's a question of how to avoid rbind ? I apologize because I don't think I understand what you are saying. Or maybe it's not possible to avoid rbind ? Thanks. -Original Message- From: Ravi Varadhan [mailto:[EMAIL PROTECTED] Sent: Friday, December 08, 2006 5:21 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: RE: [R] any way to make the code more efficient ? Using rbind almost always slows things down significantly. You should define the objects aggfxdata and fullaggfxdata before the loop and then assign appropriate values to the corresponding rows and/or columns. Ravi. -- -- --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -- -- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Friday, December 08, 2006 4:17 PM To: r-help@stat.math.ethz.ch Subject: [R] any way to make the code more efficient ? The code bekow works so this is why I didn't include the data to reproduce it. The loops about 500 times and each time, a zoo object with 1400 rows and 4 columns gets created. ( the rows represent minutes so each file is one day worth of data). Inside the loop, I keep rbinding the newly created zoo object to the current zoo object so that it gets bigger and bigger over time. Eventually, the new zoo object, fullaggfxdata, containing all the days of data is created. I was just wondering if there is a more efficient way of doing this. I do know the number of times the loop will be done at the beginning so maybe creating the a matrix or data frame at the beginning and putting the daily ones in something like that would Make it be faster. But, the proboem with this is I eventually do need a zoo object. I ask this question because at around the 250 mark of the loop, things start to slow down significiantly and I think I remember reading somewhere that doing an rbind of something to itself is not a good idea. Thanks. #= == === start-1 for (filecounter in (1:length(datafilenames))) { print(paste(File Counter = , filecounter)) datafile= paste(datadir,/,datafilenames[filecounter],sep=) aggfxdata-clnaggcompcurrencyfile(fxfile=datafile,aggminutes=a ggminutes, fillholes=1) logbidask-log(aggfxdata[,bidask]) aggfxdata-cbind(aggfxdata,logbidask) if ( start == 1 ) { fullaggfxdata-aggfxdata start-0 } else { fullaggfxdata-rbind(fullaggfxdata,aggfxdata) } } #= == == This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question for if else
If p1982 is a data.frame: p1982$Y - ifelse(p1982$sc90, 'inward', 'outward') If it is a matrix p1982 - cbind(p1982, Y=ifelse(p1982[,'sc']90, 'inward', 'outward')) On 12/8/06, Aimin Yan [EMAIL PROTECTED] wrote: I have a data set like this I want to assign outward to Y if sc 90 and assign inward to Y if sc=90. then cbind(p1982,Y) to get like these p aa as ms cur sc Y 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 inward 2 154l_aa THR 15.86 28.32 0.2563560 103.67100inward 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 outward 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930outward 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 inward 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980outward does anyone know how to these? Aimin head(p1982) p aa as mscursc 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 2 154l_aa THR 15.86 28.32 0.2563560 103.67100 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question for if else
Hopefully it is a dataframe or else you matrix will be converted to character; forgot that when I sent it. On 12/8/06, jim holtman [EMAIL PROTECTED] wrote: If p1982 is a data.frame: p1982$Y - ifelse(p1982$sc90, 'inward', 'outward') If it is a matrix p1982 - cbind(p1982, Y=ifelse(p1982[,'sc']90, 'inward', 'outward')) On 12/8/06, Aimin Yan [EMAIL PROTECTED] wrote: I have a data set like this I want to assign outward to Y if sc 90 and assign inward to Y if sc=90. then cbind(p1982,Y) to get like these p aa as ms cur sc Y 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 inward 2 154l_aa THR 15.86 28.32 0.2563560 103.67100inward 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 outward 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930outward 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 inward 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980outward does anyone know how to these? Aimin head(p1982) p aa as mscursc 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 2 154l_aa THR 15.86 28.32 0.2563560 103.67100 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to create data.frame with dynamic count of values
Consider using a list: N - list() for (i in 1:15) N[[paste(N, i, sep='')]] - numeric(10) N $N1 [1] 0 0 0 0 0 0 0 0 0 0 $N2 [1] 0 0 0 0 0 0 0 0 0 0 $N3 [1] 0 0 0 0 0 0 0 0 0 0 $N4 [1] 0 0 0 0 0 0 0 0 0 0 $N5 [1] 0 0 0 0 0 0 0 0 0 0 $N6 [1] 0 0 0 0 0 0 0 0 0 0 $N7 [1] 0 0 0 0 0 0 0 0 0 0 $N8 [1] 0 0 0 0 0 0 0 0 0 0 $N9 [1] 0 0 0 0 0 0 0 0 0 0 $N10 [1] 0 0 0 0 0 0 0 0 0 0 $N11 [1] 0 0 0 0 0 0 0 0 0 0 $N12 [1] 0 0 0 0 0 0 0 0 0 0 $N13 [1] 0 0 0 0 0 0 0 0 0 0 $N14 [1] 0 0 0 0 0 0 0 0 0 0 $N15 [1] 0 0 0 0 0 0 0 0 0 0 # access a specific element of the list N$N10 [1] 0 0 0 0 0 0 0 0 0 0 On 12/8/06, Knut Krueger [EMAIL PROTECTED] wrote: Hello R-Group I found how to fill the data.frame - http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70843.html N1 - rnorm(4) N2 - rnorm(4) N3 - rnorm(4) N4 - rnorm(4) X1 - LETTERS[1:4] ### nams - c(paste(N, 1:4, sep = ), X1) dat - data.frame(lapply(nams, get)) names(dat) - nams dat But I need also to create a dynamic count of numeric vectors items = 15 VarSize -10 N1 - rep(0,VarSize) N2 - rep(0,VarSize) N3 - rep(0,VarSize) N4 - rep(0,VarSize) N5 - rep(0,VarSize) ... N15- rep(0,VarSize) # 15 items Thank you in advance Knut __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] trouble with cloud output to bmp when in loop
I have some data that I need to view in various 3-D clouds. To better see the cloud structure on a 2-D screen I would like to output a bunch of bmp files with clouds at slightly different angles, then run them through an external program to animate them. But I'm having trouble getting cloud() from the lattice package to output to bmp files. Oddly, this is only a problem when outputting multiple files in a loop. WORKS FINE: bmp(d:/test2.bmp); cloud(z~x+y); dev.off() ALSO WORKS: bmp(d:/test01.bmp); cloud(z~x+y); dev.off(); bmp(d:/test02.bmp); cloud(z~x+y); dev.off(); DOES NOT WORK (produces blank bitmaps): for(i in 1:3) {bmp(d:/test2.bmp); cloud(z~x+y); dev.off()} Is this a bug? Is there a way to make this work? (working in MS Windows XP x64 with R 2.4.0) Thanks! --- Eric B. Peterson Vegetation Ecologist Nevada Natural Heritage Program [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with cloud output to bmp when in loop
This is FAQ Q7.22 On Fri, 8 Dec 2006, Eric Peterson wrote: I have some data that I need to view in various 3-D clouds. To better see the cloud structure on a 2-D screen I would like to output a bunch of bmp files with clouds at slightly different angles, then run them through an external program to animate them. But I'm having trouble getting cloud() from the lattice package to output to bmp files. Oddly, this is only a problem when outputting multiple files in a loop. WORKS FINE: bmp(d:/test2.bmp); cloud(z~x+y); dev.off() ALSO WORKS: bmp(d:/test01.bmp); cloud(z~x+y); dev.off(); bmp(d:/test02.bmp); cloud(z~x+y); dev.off(); DOES NOT WORK (produces blank bitmaps): for(i in 1:3) {bmp(d:/test2.bmp); cloud(z~x+y); dev.off()} Is this a bug? Is there a way to make this work? (working in MS Windows XP x64 with R 2.4.0) Thanks! --- Eric B. Peterson Vegetation Ecologist Nevada Natural Heritage Program [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Please do take note here. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any way to make the code more efficient ?
Something like this may be reasonably efficient. I create a length-500 list of 1400*4 matrices of uniform random numbers. Farrar numArrays - 500 # number of arrays arrDim1 - 1400 # array num. rows arrDim2 - 4 # array num. cols arrList - list(numArrays, mode=list) # reserve space for(i in 1:numArrays) arrList[[i]] - matrix( + runif(arrDim1*arrDim2), + arrDim1,arrDim2 ) Leeds, Mark (IED) [EMAIL PROTECTED] wrote: ravi : I appreciate your help but could you be a little more specific about what you mean ? I can just stack aggfxdata below the current full one ( the rbind works out the ordrering by date because it's a zoo object ) so it's not a question of where to put the new one. It's a question of how to avoid rbind ? I apologize because I don't think I understand what you are saying. Or maybe it's not possible to avoid rbind ? Thanks. -Original Message- From: Ravi Varadhan [mailto:[EMAIL PROTECTED] Sent: Friday, December 08, 2006 5:21 PM To: Leeds, Mark (IED); r-help@stat.math.ethz.ch Subject: RE: [R] any way to make the code more efficient ? Using rbind almost always slows things down significantly. You should define the objects aggfxdata and fullaggfxdata before the loop and then assign appropriate values to the corresponding rows and/or columns. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED) Sent: Friday, December 08, 2006 4:17 PM To: r-help@stat.math.ethz.ch Subject: [R] any way to make the code more efficient ? The code bekow works so this is why I didn't include the data to reproduce it. The loops about 500 times and each time, a zoo object with 1400 rows and 4 columns gets created. ( the rows represent minutes so each file is one day worth of data). Inside the loop, I keep rbinding the newly created zoo object to the current zoo object so that it gets bigger and bigger over time. Eventually, the new zoo object, fullaggfxdata, containing all the days of data is created. I was just wondering if there is a more efficient way of doing this. I do know the number of times the loop will be done at the beginning so maybe creating the a matrix or data frame at the beginning and putting the daily ones in something like that would Make it be faster. But, the proboem with this is I eventually do need a zoo object. I ask this question because at around the 250 mark of the loop, things start to slow down significiantly and I think I remember reading somewhere that doing an rbind of something to itself is not a good idea. Thanks. #=== === start-1 for (filecounter in (1:length(datafilenames))) { print(paste(File Counter = , filecounter)) datafile= paste(datadir,/,datafilenames[filecounter],sep=) aggfxdata-clnaggcompcurrencyfile(fxfile=datafile,aggminutes=aggminutes, fillholes=1) logbidask-log(aggfxdata[,bidask]) aggfxdata-cbind(aggfxdata,logbidask) if ( start == 1 ) { fullaggfxdata-aggfxdata start-0 } else { fullaggfxdata-rbind(fullaggfxdata,aggfxdata) } } #=== == This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Run Sample R (Linux)
Hi, all How do I run sample R (Linux). I open R, find a prompt an now what? Thanks Nuno Vale [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with cloud output to bmp when in loop
On 12/8/06, Eric Peterson [EMAIL PROTECTED] wrote: I have some data that I need to view in various 3-D clouds. To better see the cloud structure on a 2-D screen I would like to output a bunch of bmp files with clouds at slightly different angles, then run them through an external program to animate them. But I'm having trouble getting cloud() from the lattice package to output to bmp files. Oddly, this is only a problem when outputting multiple files in a loop. WORKS FINE: bmp(d:/test2.bmp); cloud(z~x+y); dev.off() ALSO WORKS: bmp(d:/test01.bmp); cloud(z~x+y); dev.off(); bmp(d:/test02.bmp); cloud(z~x+y); dev.off(); DOES NOT WORK (produces blank bitmaps): for(i in 1:3) {bmp(d:/test2.bmp); cloud(z~x+y); dev.off()} Is this a bug? No, but it's a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem of Running Simulations for Monte Carlo Spatial Segregation Test using Spatialkernel Package
Hello, When I used spseg function in the spatialkernel package to run Monte Carlo spatial segregation test, R would not let me run more than 50 simulations. That is, I tried to run the following code, sp - spseg(pts, bin, hcv, opt=3, ntest=1000, poly=polyb) where pts was a 116*2 matrix containing lat/long; bin was a vector containing categorical types with length of 116; hcv was the selected bandwidth; polyb was a 4*2 matrix which would form a rectangle. But R immediately gave an error message cannot locate vector of size. I used gc() but it would not help. I could only make it work when ntest=50 or less. Any suggestion is appreciated. Wei Zhang __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to identify structural breaks in GARCH?
hi all, I am trying to find some break points in GARCH model. Is there any function for it? any suggestion is appreciated! Thanks Rick Cheap talk? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simulation with R
An apparatus exists whereby a collection of balls is displaced to the top of a stack by suction. A top level (Level 1) each ball is shifted 1 unit to the left or 1 unit to the right at random with equal probability. The ball then drops down to level 2. At Level 2, each ball is again shifted 1 unit to the left or 1 unit to the right at random. The process continues for 15 levels and the balls are collected at the bottom for a short time until being collected by suction to the top. Can we do a simulation of the process using R with 100 balls, and plot the frequency distribution of the position of the balls at the bottom with respect to the entry position? thx in advance ej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.