Re: [R] inverse table

2016-06-16 Thread Patrizio Frederic
uot; "A" > [3,] "b" "A" > [4,] "b" "A" > [5,] "c" "A" > [6,] "d" "A" > > - > David L Carlson > Department of Anthropology > Texas A University > Coll

[R] inverse table

2016-06-15 Thread Patrizio Frederic
thus how do I get raw data (object ab) from ddd? I've tried as.data.frame.table(ddd) which is not the answer I'm looking for. Thanks in advance, PF -- +--- | Patrizio Frederic, | http://morgana.unimore

Re: [R] While loop working with TRUE/FALSE?

2012-02-02 Thread Patrizio Frederic
://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. -- +--- | Patrizio Frederic, | http

Re: [R] Improve a browse through list items - Transform a loop to apply-able function.

2011-12-14 Thread Patrizio Frederic
. -- +--- | Patrizio Frederic, | http://www.economia.unimore.it/frederic_patrizio/ +--- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] R PLS package data format

2011-06-27 Thread Patrizio Frederic
-guide.html and provide commented, minimal, self-contained, reproducible code. -- +--- | Patrizio Frederic, | http://www.economia.unimore.it/frederic_patrizio

Re: [R] How to create a numeric data.frame

2011-06-13 Thread Patrizio Frederic
class(as.matrix(a)) # change class, and as.numeric(as.matrix(a)) # bingo, it works PF -- +--- | Patrizio Frederic, | http://www.economia.unimore.it/frederic_patrizio

Re: [R] How to create a numeric data.frame

2011-06-13 Thread Patrizio Frederic
-- +--- | Patrizio Frederic, | http://www.economia.unimore.it/frederic_patrizio/ +--- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] How to create a numeric data.frame

2011-06-13 Thread Patrizio Frederic
class(b) # which is now a numeric matrix best regards PF -- +--- | Patrizio Frederic, | http://www.economia.unimore.it/frederic_patrizio

[R] normal distribution and floating point traps (?): unexpected behavior

2011-03-29 Thread Patrizio Frederic
dear all, here's a couple of questions that puzzled me in these last hours: # issue 1 qnorm(1-10e-100)!=qnorm(10e-100) qnorm(1-1e-10) == -qnorm(1e-10) # turns on to be FALSE. Ok I'm not a computer scientist but, # but I had a look at the R inferno so I write: all.equal(qnorm(1-1e-10) ,

Re: [R] Finding non-normal distributions per row of data frame?

2011-02-04 Thread Patrizio Frederic
Hi Danny, it sounds to much easer than that. Try y - data.frame(matrix(rnorm(100),10)) nr - ncol(y) test - lapply(y, shapiro.test) sapply(test,function(x)c(x$statistic, x$p.value)) it should perform the required task. Cheers, P On Fri, Feb 4, 2011 at 4:52 AM, DB1984 dannyb...@gmail.com

Re: [R] best polynomial approximation

2010-05-18 Thread Patrizio Frederic
as usual I apologize for my fragmented English -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel:  +39 059 205 6727

[R] best polynomial approximation

2010-05-17 Thread Patrizio Frederic
for my fragmented English -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail

Re: [R] access objects in my environment

2010-05-13 Thread Patrizio Frederic
. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frede...@unimore.it

Re: [R] question about R

2010-05-11 Thread Patrizio Frederic
://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario

Re: [R] Replace NAs in a range of data frame columns

2009-12-12 Thread Patrizio Frederic
-guide.html and provide commented, minimal, self-contained, reproducible code. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel

[R] ReadItem: unknown type 136, perhaps written by later version of R

2009-06-08 Thread Patrizio Frederic
: Error in load(K:\\.RData) : ReadItem: unknown type 136, perhaps written by later version of R I've no idea of what type 136 is. Any hints? Thanks in advance, Patrizio -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department

Re: [R] data transformation using gamma

2009-05-07 Thread Patrizio Frederic
. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frede...@unimore.it

Re: [R] Reversing axis label order

2009-05-04 Thread Patrizio Frederic
http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via

Re: [R] political maps world maps in R, wrld_simpl

2009-04-07 Thread Patrizio Frederic
Roger, many thanks for your very useful suggestions. I've just produced some plot using xlim/ylim. I noticed I can only zoom in a square box. Is there any way to produce rectangular ones? Best Patrizio 2009/4/7 Roger Bivand roger.biv...@nhh.no: Patrizio Frederic frederic.patrizio at gmail.com

[R] political maps world maps in R, wrld_simpl

2009-04-06 Thread Patrizio Frederic
dear all, I'm a newbie in map tools. I was asking to perform an apparently very simple task. I have a list of countries (about fifty all over in the world) scored with a real positive value. Eg Country score Italy .56 UK .58 Korea .41 Mexico .63 ... I wish to plot geographical maps

Re: [R] Selecting all rows of factors which have at least one positive value?

2009-04-02 Thread Patrizio Frederic
or the exactly equivalent form: x[x$X1 %in% unique(x[x$X20,X1]), ] Patrizio 2009/4/2 Nutter, Benjamin nutt...@ccf.org: x - data.frame(matrix(c(rep(11,4),rep(12,3),rep(13,3),rep(0,3),1,rep(0,4),re p(1,2)),ncol=2)) id.keep - unique(subset(x,X20)$X1) x2 - subset(x,X1 %in% id.keep) x2

Re: [R] how to get all iterations if I meet NaN?

2009-03-27 Thread Patrizio Frederic
2009/3/27 huiming song huimi...@gmail.com: hi, everybody, please help me with this question: If I want to do iteration for 1000 times, however, for the 500th iteration, there is NaN appears. Then the iteration will stop. If I don't want the stop and want the all the 1000 iterations be done.

Re: [R] same value in column--delete

2009-03-26 Thread Patrizio Frederic
this works which.is.not.unique - apply(x,2,function(x)ifelse(length(unique(x))==1,F,T)) x[,which.is.not.unique] patrizio 2009/3/26 Duijvesteijn, Naomi naomi.duijveste...@ipg.nl:   Hi Readers,   I have a question.   I have a large dataset and want to throw away columns that have the same

Re: [R] Interpolate x from y

2009-03-25 Thread Patrizio Frederic
Greg, it seems an obvious behavior to me y=c(2,2,2,3,3,3,1) x=1:length(y) plot(x,y) lines(x,approxfun(x,y)(x)) # for every x it exists one only value of y plot(y,x) lines(sort(y),approxfun(y,x)(sort(y))) # for some y it exists more than one value of x! approxfun return a function. By definition

Re: [R] Converting a Matrix to a Vector

2009-03-25 Thread Patrizio Frederic
try also m - matrix( runif(5^2), nrow=5, dimnames = Names- list( c(A,B,C,D,E), c(O,P,Q,R,S) ) ) data.frame(expand.grid(Names[[1]],Names[[2]]),as.numeric(m)) data.frame(code=outer(Names[[1]],Names[[2]],paste,sep=.)[1:25],num=as.numeric(m)) Patrizio 2009/3/25 jim holtman jholt...@gmail.com:

Re: [R] multiple barplot

2009-03-18 Thread Patrizio Frederic
Hi Agus, try this two ones d-matrix(rpois(45,3),5,9) barplot(d,beside=T,col=rainbow(5),names=c(CRTL,LSB,ONEMKR, TWOMKR,BLUP,BLUPQ,BLUP1M,BLUP2M,GAS),las=2) barplot(d,beside=T,col=rainbow(5),names=c(CRTL,LSB,ONEMKR, TWOMKR,BLUP,BLUPQ,BLUP1M,BLUP2M,GAS),cex.names=.8) best Patrizio 2009/3/18

Re: [R] Way to rotate a histogram?

2009-03-17 Thread Patrizio Frederic
Jason, be carefully to the order of intensities (counts or densities): x=rnorm(1000) par(mfrow=c(2,2)) h=hist(x,breaks=bk-c(-5,-3,-2,-1,-.5,0,1,3,5)) barplot(rev(h$intensities),rev(bk[2:9]-bk[1:8]),space=0,horiz=T) # compare to axis(2) barplot(h$intensities,bk[2:9]-bk[1:8],space=0,horiz=T)

Re: [R] : record which entry in one file doesn't appear in a different file

2009-02-25 Thread Patrizio Frederic
hey Laura, I hope this help f1 = c(a,b,c) f2 = c(b,a,c,d) match(f2,f1) f3 = match(f2,f1,0) ?match cbind(f2,f3) cbind(f2,f30) f4 = ifelse(f30,yes,no) cbind(f2,f4) data.frame(f2,f4) Patrizio 2009/2/25 Laura Rodriguez Murillo laura.lmuri...@gmail.com: Hi dear list, If anybody could help me, it

Re: [R] Unadulterated plot

2009-02-19 Thread Patrizio Frederic
James, as I previously told you in my broken English, probably the function you're looking for is not filled.contour but image and contour The following code makes exactly what you ask for data(akima) akima akima.smooth - with(akima, interp(x, y, z, xo=seq(0,25, length=500),

Re: [R] Unadulterated plot

2009-02-18 Thread Patrizio Frederic
James, you're probably interested in image function rather than in filled.contour. Type ?image to see the syntax. Cheers, Patrizio 2009/2/18 James Nicolson jlnicol...@gmail.com: Hi, Thanks for your help. I have looked at the beginners documentation and while there are options to configure

Re: [R] several ifelse problems...

2009-02-16 Thread Patrizio Frederic
do you mean: f=function(x) 0*(abs(x-.5)=.3)-1*(abs(x-.5)=.4)+(10*x-2)*(x.1x.2)+(-10*x+8)*(x=.2x=.5) f(x) curve(f,0,1) hope it helps. Patrizio 2009/2/14 kathie kathryn.lord2...@gmail.com: Dear R users, From the code below, I try to compute y value. (In fact, y looks like a trapezoid)

Re: [R] extracting parts of words or extraxting letter to use in ifelse-func.

2009-02-13 Thread Patrizio Frederic
hey Joe, I had a quick look at your code. In this line: b2$PRRSvac - ifelse(b2$status==MS-X, PRRS-pos|b2$status==R�d SPF+Myc+Ap2+DK+Vac,1,0) some special characters are used. You must use only plain ascii characters Hope this help. Cheers, Patrizio 2009/2/13 joe1985 johan...@dsr.life.ku.dk:

Re: [R] multiple secondary axes

2009-01-14 Thread Patrizio Frederic
hey Kirsten, did type ?axis it may help. eg: plot(rnorm(100),axes=F) axis(1) axis(3,at=seq(0,50,length=3),labels=c(A,B,C)) axis(2) axis(4,at=seq(-2,2,length=10),labels=1:10) Best, Patrizio 2009/1/14 Kirsten Thonicke kirsten.thoni...@pik-potsdam.de: Dear R experts, I want to plot a line

Re: [R] repeated searching of no-missing values

2008-12-11 Thread Patrizio Frederic
dear Hadley and Bert, thank you very much for your suggestions. I asked one question and I learned 2 things: 1. Hadley, library(plyr) ddply(data, .(V1), colwise(cl)) that is exactly what I was searching for. 2. Bert, ?tapply says that the first argument is an **atomic** vector. A factor is

[R] repeated searching of no-missing values

2008-12-10 Thread Patrizio Frederic
? Thanks in advance, Patrizio +- | Patrizio Frederic, PhD | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205

[R] migrating data from s-plus to R

2008-09-19 Thread Patrizio Frederic
Dear all, is there any way to transform a .Data directory created in S-plus 6.1 for windows in a .RData file? Thanks in advance, Patrizio Frederic __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] contour lines in windows device but neither in pdf nor in postscript

2008-08-01 Thread Patrizio Frederic
status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) what's going wrong? Thanks in advance, Regards, Patrizio Frederic __ R-help

Re: [R] contour lines in windows device but neither in pdf nor in postscript

2008-08-01 Thread Patrizio Frederic
,d2,drawlabel=F) and everything works fine now. Thank you again, Patrizio 2008/8/1 Prof Brian Ripley [EMAIL PROTECTED]: What viewers are you using? Works for me (using ghostscript 4.61 and acroread 8.1.2) -- I even tried 2.7.1 (as well as R-patched). On Fri, 1 Aug 2008, Patrizio Frederic

Re: [R] tensor product of equi-spaced B-splines in the unit square

2008-07-31 Thread Patrizio Frederic
for studing a new topic). Any suggestion is welcome. Regards, Patrizio Frederic +- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena

Re: [R] Random number generation

2008-07-31 Thread Patrizio Frederic
?write.table could help PF 2008/7/31 Max [EMAIL PROTECTED]: Marc, this is very handy. My next question is, do you know a quick and easy way to transfer all of the output to a txt file? (or .xls)? Thanks, -Max Marc Schwartz explained on 07/31/2008 : on 07/31/2008 12:24 PM Max wrote:

Re: [R] What's the best way to operate R from within Excel?

2008-07-30 Thread Patrizio Frederic
have a look at http://sunsite.univie.ac.at/rcom/server/doc/RExcel.html regards, PF 2008/7/30 losemind [EMAIL PROTECTED]: Hi all, How do I operate R from within Excel? I mean, highlight a bunch of cells, and send to R, and do some statistics in R, and return back the numbers and do some

Re: [R] Howto Draw Bimodal Gamma Curve with User Supplied Parameters

2008-07-30 Thread Patrizio Frederic
can you write the bimodal gamma pdf? if so create your own pdf: dbigamma=function(x,alpha1,alpha2,beta1,beta2) { # ... the bimodal gamma pdf (I can't find it) } hist(x,probability=T) curve(dbigamma(x,alpha1,alpha2,beta1,beta2)) and look at the result regards, PF 2008/7/29 Gundala Viswanath

[R] tensor product of equi-spaced B-splines in the unit square

2008-07-29 Thread Patrizio Frederic
in advance, Patrizio Frederic +- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947

Re: [R] table questions

2008-07-29 Thread Patrizio Frederic
# is that what you want? table(cut(xy,seq(0,max(xy)+.4,by=.4))) # or this table(cut(xy,hist(xy)$breaks)) # not the same regards, PF +- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena

Re: [R] product of successive rows

2008-07-28 Thread Patrizio Frederic
this works too: n = 6 # number of rows m = 4 # number of coloumns nm = n*m mat = matrix(1:nm,n) # your matrix pf = function(Col){ ind = rep(1:(n/2),each=2) out = tapply(Col,ind,prod) out } # pf performs forall vecotr x: x[i]*x[i-1],

Re: [R] How to delete duplicate cases?

2008-07-24 Thread Patrizio Frederic
this works cno = c(rep(1342,times=3),rep(2568,times=2)) rank= c(.23,.14,.56,.15,.89) df1 = data.frame(cno,rank)[order(cno,rank),] cnou= unique(cno) ind = match(cno,cnou) where = tapply(rank,ind,length) where = cumsum(as.numeric(where)) df1[where,] regards, PF

Re: [R] mle2(): logarithm of negative pdfs

2008-07-23 Thread Patrizio Frederic
this is an off-topic, of course! by definition, pdf MUST BE POSITIVE and log function is defined ONLY for positive values. check your pdf code and find out the errors. regards Patrizio Frederic +- | Patrizio Frederic | Research associate

Re: [R] How to simulate heteroscedasticity (correlation)

2008-07-23 Thread Patrizio Frederic
)) abline(b0,b1,col=2) regards PF ps notice that in heteroscedasticity case the random vector (X,Y) is not a bivariate normal but it is: Y|X=x ~ normal(b0+b1 x; h(x)) ie every conditional Y is normal +- | Patrizio Frederic | Research associate

Re: [R] maximum likelihood method to fit a model

2008-07-23 Thread Patrizio Frederic
dear Silvia, quoting Venables WN and Ripley DB (1994) Modern Applied Statistics with S-plus, sringer, pag 185: Since explicit expressions for the maximum likelihood estimators are not usually available estimates MUST be calculate iteratively means that glm.fit performs MLE indirectly and

Re: [R] sequential sum of a vector...

2008-07-23 Thread Patrizio Frederic
try this colSums(matrix(x,8)) regards, PF +- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax

Re: [R] Convert list of lists -- data frame

2008-07-23 Thread Patrizio Frederic
try ?unlist it may help regards +- | Patrizio Frederic | Research associate in Statistics, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059

Re: [R] Troubles plotting lrm output in Design Library

2008-05-30 Thread Patrizio Frederic
2008/5/29 Frank E Harrell Jr [EMAIL PROTECTED]: Patrizio Frederic wrote: dear Harrell, thank you for quick reply and suggestions. I still have the problem: library(Design) x = rnorm(100) y = runif(100)(exp(x)/(1+exp(x))) y = 0*y+1*y d = datadist(x,y) options(datadist=d) fit

Re: [R] Troubles plotting lrm output in Design Library

2008-05-30 Thread Patrizio Frederic
is fixed. Now I know how .Options and options are related one each other. Sorry for wasting your time. Thank you for your help. Patrizio Frederic __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] Troubles plotting lrm output in Design Library

2008-05-29 Thread Patrizio Frederic
status major 2 minor 7.0 year 2008 month 04 day22 svn rev45424 language R version.string R version 2.7.0 (2008-04-22) thank you in advance, Patrizio Frederic - | Patrizio Frederic | Research

Re: [R] Troubles plotting lrm output in Design Library

2008-05-29 Thread Patrizio Frederic
. Patrizio Frederic version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.0 year 2008 month 04 day22 svn rev45424 language R version.string R version 2.7.0 (2008-04