[R] width and alignment of Latex table columns
Dear all, I'm using xtable package in order to produce Latex table. There is a way to specify not only the alignment but also the width of table colums?? Thanks for your attention. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] restricted model estimation
Dear all, I would like to know how to estimate in R a restricted model. The model would be: y=beta*X1+(1-beta)*X2 so the sum of coefficients must be one. I wonder if there is an option in the lm function that allows to specify that restriction or any other solutions to get the expected results. Thanks for your attention! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem with tick graph
Dear all, I'm having problems with the tick of my graph. I'mpcombining lines and barplot. For my I'm using the function axis combined with the function pretty to have more efficient tick, but all my tick (for example, 300 as my max tick and -100 as my min tick) are not printed on my graph. So I would like to have for the left axis the seq from 0 to 100 (with 0 and 100 printed on my graph) and for the right axis the seq from -100 to 300 (with -100 and 300 printed on my graph) Someone Knows how to get it??? The code and data are: grafico<-{ pdf(file=file, paper="special",width=30, height=20) par(bg="white",font=3,font.axis=3,las=1,cex.axis=2.2, mar=c(8,6,8,8)+8) barplot(Imp$TassoV, width=10,space=c(0,0.1),legend.text = FALSE,beside=TRUE, border="grey40", main="",col="midnightblue",cex.main=2.4, axes = FALSE, axisnames =FALSE) lab=as.character(pretty(Imp$TassoV)) axis(side=4,at=pretty(Imp$TassoV),labels=lab,cex.axis=2.4) par(new=T) chart.TimeSeries(Imp$ValueA, type="l", lwd=8, main="", ylab="", xlab="", date. format="%y", col="red3",major.ticks="years",minor.ticks=TRUE, grid.color="grey50", grid. lty="dotted", cex.axis=2.4,yaxis=FALSE) axis(2,at=c(pretty(Imp$ValueA))) legend("topleft",c("Livelli mln $ (sc. sx)","Tasso di var. (sc.dx)"),col=c ("red3", "midnightblue"),bty="n",lwd=4,cex=2.4) } dev.off() ValueA ValueA_L TassoV 1995-12-1688.06557 NA NA 1996-12-1688.34237 88.06557 0.3143044 1997-12-1657.86447 88.34237 -34.4997529 1998-12-16 50.19389 57.86447 -13.2561039 1999-12-16 23.06846 50.19389 -54.0412943 2000-12-16 45.79965 23.06846 98.5379304 2001-12-16 22.35262 45.79965 -51.1947722 2002-12-16 66.89223 22.35262 199.2589371 2003-12-1689.24867 66.89223 33.4215852 2004-12-1677.16459 89.24867 -13.5397854 2005-12-16 51.23656 77.16459 -33.6009462 2006-12-16 49.51073 51.23656 -3.3683450 2007-12-16 90.39337 49.51073 82.5732837 2008-12-16 38.84831 90.39337 -57.0230554 2009-12-16 14.70859 38.84831 -62.1384086 2010-12-16 55.23819 14.70859 275.5505995 Thanks for your attention __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] map
Hi!I'm trying to plot the italian map with provincial administration but I don't find the right database and packages to do so.Does anyone help me and tell me how to do???Thanks for your attention [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] try to generate graph for each element of my list
Dear all, I have the following problem. I have a List of time series dataframe.I'm trying to produce specific graph for each element of my list. The code is: This is my list: Lista_import<-lapply(Lista_import, function(x){ x2<-subset(x, select=c("ANNO","DICHIARANTE","PARTNER", "quota")) x2<-cast(x2, ANNO+DICHIARANTE~PARTNER) x2<- as.xts(as.matrix(as.timeSeries(x2))) return(x2)}) each list have the following shape: $AUS $DEU and data inside...I'm not showing you the content cause I think is not relevant For the GRaph the code is c<-lapply(Lista_import,function(x){ for(i in names(Lista_import)){ legenda <- read.csv ("/home/fturrini/Tessile/01_Dati_complementari/Legenda_paese.csv",header=TRUE) leg <- data.frame(ISO3=colnames(x),inutile=1) legenda <- merge(legenda,leg, by="ISO3", all.y=TRUE) png(paste("/home/Tessile/Output/Gra/MaxM/QuoteEXperPaese_",i,".png"), width=1661,height=828) graph <-{par(bg="grey97", font=3,font.axis=3,bty="l",las=1, mar=c(8,6,4,2), xpd=FALSE) yrange<-c(min(x,na.rm=TRUE), 1.05*max(x,na.rm=TRUE)) colori <- c("Blue","Aquamarine1", "Firebrick3", "Chocolate4", "BlueViolet", "Yellow3") chart.TimeSeries(x, type="l",lwd=5, ylab="", xlab="", main="", date.format="% Y", ylim=yrange, col=colori, cex.axis=1.6, major.ticks="years", minor.ticks=FALSE, grid.color="gray50", grid.lty="dotted") legend("topleft",as.character(legenda$PAESE),bty="n",cex=1.7,lwd=5, ncol=2, col=colori, horiz=F) mtext("Fonte: Unctad, Pctas", side=1,line=5,adj=1,cex=1.8,col="grey20") mtext(p, side=1,line=5,adj=0,cex=1.5,col="grey10")}} dev.off() rm(grafico) }) The results is that I get the same graph for each element of my list. Someone knows how to get one graph for each element of my list pasting the names' list element in the .png file?? Thanks for your attention! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] NA problem
Dear R list I have a problem with NA, which should be a string, but R seems that it doesn't recognize it. What I do is first give the format command to my data frame: format.data.frame(mydata,big.mark=" ") so I give a blank as thousand separator. All my records in my data frame become strings, so instead of having NA I have "NA". I try to convert "NA" in ".",but it seems that R doesn't recognize "NA". Someone knows why and how to treats those "NA"?? Thanks for your attention __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ifelse statement
Dear list, I have a question I'm trying to use the following command in R, but it gives me an error message.The command is: data<-ddply(data,c("year","name"), transform, check1=ifelse(check1==1 & check2==1, 1,NULL)) so in my data frame I already have the check1 variable, if the conditions (check1==1 & check2==1) is respected, check has to have 1 as value, whereas if it is not I want that variable to maintain its value. Anyone knows, how to do this, by doing this for name and year?? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problems with unique
Hi everyone, I have a question concerning the unique function. I'm using it with two different data frame,which are similar in structure, but as in one case unique works properly in the other doesn't work and I don't understand why. Someone knows why sometimes unique doesn't do things properly?? Thanks for your attention __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pagebreak in xtable and columns'width
Dear list, I'm using the Sweave function in order to get some report. Here one chunk: <>= report<-lapply(repor, function(x) { (print(xtable(data.frame(x[1:2,]), align="|l|rrr|"),floating=FALSE,tabular. environment="longtable",include.colnames=FALSE,size="\\small")) (print(xtable(data.frame(x[3:nrow(x),]),align="l|rrr"),floating=FALSE,tabular. environment="longtable",include.colnames=FALSE,add.to.row=list(pos=list (1,12,23,43), command=c("\\hline\\multicolumn{1}{l|}{\\textbf{Stato Patrimoniale Attivo}}","\\multicolumn{1}{l|}{\\textbf{Stato Patrimoniale Passivo}}","\\multicolumn{1}{l|}{\\textbf{Conto Economico}} ","\\multicolumn{1}{l|}{\\textbf{Indicatori di Bilancio}}")),size=" \\small",NA.string="."))}) I would like to Know if somewhere in xtable I can put the command \pagebreak . The object repor over I pass the lapply function and after the xtable function has more or less 200 tables. So at the end of each table, the new table would have to start at a new page. I tried to put \pagebreak in "command" but it doesent work.Any suggestions??? Moreover someone knows how to set the width of each column? Thanks for your attention __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] for loop
Dear list, I'm trying to run the following for loop: I have two list, the first one is $'5684' CFISCALE"5684" RAGSOCB"Brembo" $'4532' CFISCALE"4532" RAGSOCB"Stella" which is this one in terms of dput: dput(kk) structure(list(`5684` = structure(c("5684", "Brembo", "5684", "Brembo", "5684", "Brembo"), .Dim = 2:3, .Dimnames = list( c("CFISCALE", "RAGSOCB"), c("1", "3", "2"))), `4532` = structure(c("450155", "Stella"), .Names = c("CFISCALE", "RAGSOCB" ))), .Names = c("5684", "4532")) The second one is: $'5684' ANNO1986 1987 1988 var1 45 2387 $'4532' ANNO1986 var1 35 In terms of dput: dput(kk1) structure(list(`5684` = structure(c("1986", "45", "1987", " 23", "1988", "87"), .Dim = 2:3, .Dimnames = list(c("ANNO", "var1"), c("1", "3", "2"))), `4532` = structure(c("1986", "35" ), .Names = c("ANNO", "var1"))), .Names = c("5684", "4532" )) This is my loop: mate: function(x,y){ for (i in x){ for (i in y){ ifelse(names(x)==names(y),print(xtable(i)) & print(xtable(l)),NULL)}}} This is the error message I get: Errore in print(xtable(i)) & print(xtable(l)) : operations are possible only for numeric, logical or complex types Anyone KNows How to solve it??? Moreover there is a way to use the structure of the first list object for the second one? I mean: turn $'4532' ANNO1986 var1 35 into: $'4532' ANNO1986 1987 1988 var1 35NA NA Thanks a lot for your attention! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] set the structure before xtable
Dear list, I would like to know if there is a package in R which is able to set the structure of the element of a list or dataframe in order to use xtable's options without problems. I will do an example to be more clear: if I have a list like this with the following element: $ind1 year1year2year3 p4534 56 q1945 76 r 90 5 10 $ind2 year2 p6 q24 r76 when I use xtable (library(xtable)),I cannot use the options align cause I have two table with different number of columns. So I'm looking for (I havent found anything useful yet) something that allows me to set the structure of each element of the list or a dataframe before passing it through xtable, in order to get something like this: $ind1 year1year2year3 p4534 56 q1945 76 r 90 5 10 $ind2 year1 year2 year3 p NA 6 NA q NA 24 NA r NA 76 NA Thanks for your attention!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] print.xtable suppress my row.names
Dear list, someone knows why the print.xtable doesnt print row.names? I dident do anything with the options.may depends on the size of my table??? This is my code: \documentclass[a4paper]{article} \title{SCHEMA DI BILANCIO PER SINGOLE AZIENDE} \begin{document} \maketitle \hline <>= library(xtable) library(plyr) rep=Bilanci rep$SPA<-as.numeric(NA) rep$SPP<-as.numeric(NA) rep$CE<-as.numeric(NA) rep$IN<-as.numeric(NA) rep$VA<-as.numeric(NA) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,PROD=EC01+EC02+EC03) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,VP=rev(rev(PROD)*c(rev(PROD ^ (-1)),0)[-1])) rep$CTOT<-Bilanci$AA01+Bilanci$AA03+Bilanci$AA04 rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,CIRCOL=c(NA,rev(rev(AA03)*0. 5+c(rev(AA03)*0.5,NA)[-1])[-1])+c(NA,rev(rev(AA04)*0.5+c(rev(AA04)*0.5,NA)[-1]) [-1])+c(NA,rev(rev(AL04)*0.5+c(rev(AL04)*0.5,NA)[-1])[-1])) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IE01=(EC04-EC05)/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IE02=EC06/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IE03=EC07/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IE07=(EC11A+EC11C)/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,MOL=100+IE07-IE01-IE02-IE03) rep$IR<-as.numeric(NA) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,ROI=((PROD-EC04+EC05-EC06- EC07+EC11C+EC11A-EC08)*c(NA,(rev(rev(CTOT)*0.5+c(rev(CTOT)*0.5,NA)[-1])^(-1)) [-1])*100)) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,RNC=((EC12)*c(NA,(rev(rev (CTOT)*0.5+c(rev(CTOT)*0.5,NA)[-1])^(-1))[-1])*100)) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,EBIT=ROI+RNC) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,RF=((EC10-EC09)*c(NA,(rev(rev (CTOT)*0.5+c(rev(CTOT)*0.5,NA)[-1])^(-1))[-1])*100)) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,ROE=((EC14)*c(NA,(rev(rev (AL01)*0.5+c(rev(AL01)*0.5,NA)[-1])^(-1))[-1])*100)) rep$CC<-as.numeric(NA) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IC01=(CIRCOL/PROD)*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IC02=c(NA,rev(rev(AA03)*0.5+c (rev(AA03)*0.5,NA)[-1])[-1])/PROD*365) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IC03=c(NA,rev(rev(AA04)*0.5+c (rev(AA04)*0.5,NA)[-1])[-1])/EC01*365) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IC04=c(NA,rev(rev(AL04)*0.5+c (rev(AL04)*0.5,NA)[-1])[-1])/(EC04+EC06)*365) rep$ES<-as.numeric(NA) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IF04=(EC14+EC08)/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN03=c(NA,rev(rev(AA01)*0.5+c (rev(AA01)*0.5,NA)[-1])[-1])/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN04=c(NA,rev(rev(CTOT)*0.5+c (rev(CTOT)*0.5,NA)[-1])[-1])/PROD*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN05=AA02/AA07*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN07=AL01/AL06*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN08=AL05/AL06*100) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN09=IN08/IN07) rep<-ddply(rep,c("CFISCALE","RAGSOCB"),transform,IN10=((EC09)*c(NA,(rev(rev (AL05)*0.5+c(rev(AL05)*0.5,NA)[-1])^(-1))[-1])*100)) rep1=subset(rep,select=c(RAGSOCB,CFISCALE,ANNO,SPA,AA01,AA01I,AA01M,AA02,AA02B, AA02L,AA03,AA04,AA05,AA06,AA07,SPP,AL01,AL02,AL03,AL04,AL04A,AL04B,AL05,AL05B, AL05L,AL99,AL06,CE,EC01,EC02,EC03,EC04,EC05,EC06,EC07,EC08,EC08A,EC08B,EC09, EC10,EC11,EC11A,EC11C,EC12,EC13,EC14,EC15,EC16,IN,VA,PROD,CTOT,CIRCOL,MOL,IR, ROI,RNC,EBIT,RF,ROE,CC,IC01,IC02,IC03,IC04,ES,IF04,IN03,IN04,IN05,IN07,IN08, IN09,IN10)) mynames<-names(rep1) mynames[mynames=="SPA"]<-"STATO_PATRIMONIALE_ATTIVO" mynames[mynames=="AA01"]<-"Immobilizzazioni_tecniche_nette" mynames[mynames=="AA01I"]<-"Immobilizzazioni_imm_nette" mynames[mynames=="AA01M"]<-"Immobilizzazioni_mat_nette" mynames[mynames=="AA02"]<-"Partecipazioni e crediti fin" mynames[mynames=="AA02B"]<-"Attivita fin a breve" mynames[mynames=="AA02L"]<-"Immobilizzazioni finan" mynames[mynames=="AA03"]<-"Magazzino" mynames[mynames=="AA04"]<-"Crediti commerciali" mynames[mynames=="AA05"]<-"Liquidita" mynames[mynames=="AA06"]<-"Altre attivita" mynames[mynames=="AA07"]<-"Tot attivita" mynames[mynames=="SPP"]<-"STATO PATRIMONIALE PASSIVO" mynames[mynames=="AL01"]<-"Capitale netto" mynames[mynames=="AL02"]<-"Fondo tfr" mynames[mynames=="AL03"]<-"Altri fondi" mynames[mynames=="AL04"]<-"Debiti commerciali" mynames[mynames=="AL04A"]<-"Anticipi di clienti" mynames[mynames=="AL04B"]<-"Debiti vs fornitori" mynames[mynames=="AL05"]<-"Debiti fin tot" mynames[mynames=="AL05B"]<-"Debiti fin a breve" mynames[mynames=="AL05L"]<-"Debiti fin a medio lungo" mynames[mynames=="AL99"]<-"Altre passivita" mynames[mynames=="AL06"]<-"Tot passivita" mynames[mynames=="CE"]<-"CONTO ECONOMICO" mynames[mynames=="EC01"]<-"Ricavi netti" mynames[mynames=="EC02"]<-"Produzione int capitalizzate" mynames[mynames=="EC03"]<-"Variazione scorte prod finiti" mynames[mynames=="EC04"]<-"Acquisti" mynames[mynames=="EC05"]<-"Variazioni scorte mat prime" mynames[mynames=="EC06"]<-"Costi per servizi god beni terz
[R] split with list
Dear List I would like to ask you something concenting a better print of the R output: I have a bit data frame which has the following structure: CFISCALE RAGSOCBANNO VAR1VAR2. 9853312 astra 2005 6 45 9853312 astra 2006 78 45 9853312 astra 2007 55 76 9653421 geox 2005 35 89 9653421 geox 200624 33 9653421 geox 2007 54 55 The first thing I did is to split my data frame for CFISCALE. The result is that R has transformed my data frame into a list. The second step was to transpose each element of my list. repo=split(rep,rep$CFISCALE) repor=lapply(repo,function(x){ t(x)}) When I print my list the format is the following $9853312 1 2 3 CFISCALE"9853312" "9853312" "9853312" RAGSOCB"astra" "astra""astra" ANNO "2005""2006" "2007" VAR1 6 78 55 VAR2 4545 76 There is a way to remove the first row I mean 1, 2 , 3 and to have just one CFISCALE and RAGSOCB??? For the second problem I tried to use unique but it seems that it doesnt work for list. So what I would like to get is: $9853312 CFISCALE"9853312" RAGSOCB"astra" ANNO "2005""2006" "2007" VAR1 6 78 55 VAR2 4545 76 This is because I next run xtable on my list in order to get a table in Latex, which I woud like to be in a nice format. Thanks a lot for your attention! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave function
Dear list, I'm trying to generate a latex Document in which there are a lot of tables. I'm using the Sweave function in the package utils, but I'm having a lot of problems with the format. This is my code: \documentclass[a4paper]{amsbook} \title{Schema di bilancio} \begin{document} \maketitle <>= report=Bilanci mynames<-names(report) mynames[mynames=="AA01"]<-"Immobilizzazioni tecniche nette" mynames[mynames=="AA01I"]<-"Immobilizzazioni imm. nette" mynames[mynames=="AA01M"]<-"Immobilizzazioni mat. nette" mynames[mynames=="AA02"]<-"Partecipazioni e crediti fin." mynames[mynames=="AA02B"]<-"Attivita' fin. a breve" mynames[mynames=="AA02L"]<-"Immobilizzazioni finan." mynames[mynames=="AA03"]<-"Magazzino" mynames[mynames=="AA04"]<-"Crediti commerciali" mynames[mynames=="AA05"]<-"Liquidita'" mynames[mynames=="AA06"]<-"Altre attivita'" mynames[mynames=="AA07"]<-"Tot attivita'" mynames[mynames=="AL01"]<-"Capitale netto" mynames[mynames=="AL02"]<-"Fondo tfr" mynames[mynames=="AL03"]<-"Altri fondi" mynames[mynames=="AL04"]<-"Debiti commerciali" mynames[mynames=="AL04A"]<-"Anticipi di clienti" mynames[mynames=="AL04B"]<-"Debiti vs fornitori" mynames[mynames=="AL05"]<-"Debiti fin. tot." mynames[mynames=="AL05B"]<-"Debiti fin. a breve" mynames[mynames=="AL05L"]<-"Debiti fin. a medio/lungo" mynames[mynames=="AL99"]<-"Altre passivita'" mynames[mynames=="AL06"]<-"Tot passivita'" mynames[mynames=="EC01"]<-"Ricavi netti" mynames[mynames=="EC02"]<-"Produzione int. capitalizzate" mynames[mynames=="EC03"]="Variazione scorte prod finiti" mynames[mynames=="EC04"]<-"Acquisti" mynames[mynames=="EC05"]<-"Variazioni scorte mat. prime" mynames[mynames=="EC06"]<-"Costi per servizi e god. di beni terzi" mynames[mynames=="EC07"]<-"Costo del lavoro tot" mynames[mynames=="EC08"]<-"Ammortamenti e accantonamenti" mynames[mynames=="EC08A"]<-"Ammortamenti" mynames[mynames=="EC08B"]<-"Accantonamenti e utilizzi di riserve" mynames[mynames=="EC09"]<-"Oneri fin." mynames[mynames=="EC10"]<-"Proventi fin." mynames[mynames=="EC11"]<-"Ricavi diversi netti" mynames[mynames=="EC11A"]<-"Altri ricavi netti ord" mynames[mynames=="EC11C"]<-"Contributi in conto esercizio" mynames[mynames=="EC12"]<-"Proventi straord. netti" mynames[mynames=="EC13"]<-"Imposte" mynames[mynames=="EC14"]<-"Utile netto rettificato" mynames[mynames=="EC15"]<-"Rettifiche" mynames[mynames=="EC16"]<-"Utile dell'esercizio" names(report)<-mynames report=split(report,report$CFISCALE) report1=lapply(report,function(x){ t(x)}) @ <>= report2=lapply(report1, function(x) { print(xtable(x,na.string="-"))}) @ \end{document} Even if I put the code referring to the title, in my pdf document I don't get it and I don't know why. Secondly I get the following error message:(\end occurred when \ifnum on line 2150 was incomplete) the results of this error is that I loose a lot of tables. Instead of having 500 tables I have just 250 tables. Another problem is that the format is not what I would like to get, my tables appear at the center of the page and I would like to put them at the left (the result is that my table are cut), and I don't know how to do that, I've tried to put in the xtable function the option table.placement="H" but it seems that it doesn't work.An example of what I get by using the split function and then the xtable function is: & 49 & 48 & 47 \\ \hline CFISCALE & 5060157 & 5060157 & 5060157 \\ RAGSOCB & GIUSEPPE TARENZI S.R.L. & GIUSEPPE TARENZI S.R.L. & GIUSEPPE TARENZI S.R.L. \\ ANNO & 2005 & 2006 & 2007 \\ Ricavi netti & 77 & 98 & 124 \\ Produzione int. capitalizzate & 0 & 0 & 0 \\ Variazione scorte prod finiti & 2059 & 2105 & 2120 \\ Acquisti & 1542 & 1564 & 1576 \\ Costi per servizi e god. di beni terzi & 122 & 135 & 121 \\ Costo del lavoro tot & 273 & 281 & 301 \\ Ammortamenti e accantonamenti & 11 & 5 & 7 \\ Ammortamenti & 9.9 & 4.5 & 6.3 \\ Accantonamenti e utilizzi di riserve & 1.1 & 0.5 & 0.7 \\ Oneri fin. & 38 & 42 & 35 \\ Proventi fin. & 1 & 0 & 1 \\ Ricavi diversi netti & 0 & -13 & -33 \\ Altri ricavi netti ord & 0 & -13 & -33 \\ Contributi in conto esercizio & 0 & 0 & 0 \\ Proventi straord. netti & 1 & 0 & 0 \\ Imposte & 73 & 78 & 80 \\ Utile netto rettificato & 79 & 85 & 92 \\ Utile dell'esercizio & 79 & 85 & 92 \\ Immobilizzazioni tecniche nette & 269 & 267 & 274 \\ Partecipazioni e crediti fin. & 0 & 3 & 0 \\ Magazzino & 592 & 623 & 656 \\ Crediti commerciali & 17.56393 & 28.15887 & 26.14891 \\ Liquidita' & 14 & & 177 \\ Altre attivita' & -892.564 & & -1133.149 \\ Tot attivita' & 0.0 & 0.005924951 & 0.0 \\ Immobilizzazioni imm. nette & 53.8 & 53.4 & 54.8 \\ Immobilizzazioni mat. nette & 215.2 & 213.6 & 219.2 \\ Attivita' fin. a breve & 0.0 & 1.5 & 0.0 \\ Immobilizzazioni finan. & 0.0 & 1.5 & 0.0 \\ Capitale netto & 0.0 & 0.002773298 & 0.0 \\ Fondo tfr & -558.4306 & -666.3115 & -533.6478 \\ Altri fondi &
[R] Sweave function
Dear list, I have a question about the interaction between R code and Latex language trough the Sweave function in the package "utils". What I'm trying to do is to write a report. Contrary to the examples shown in the Sweave Manual in which table already constructed by R are "exported" on Latex files, what I would like to do is to build a table in which I combine text and specific columns of my data frame. I will give you the following example to be much more clear. Suppose I have a data frame like this: FirmsYear IIA IIB IIC electrolux1995100 45 65 electrolux1996340 67 97 electrolux199735 99 31 fiat1995 76 34 45 fiat1996567 35 66 fiat1997453 89 37 Where IIA is the turnover of the firm, IIB is the production and IIC is the cost of labour. I would like to get a table like this in the latex format this: Firms 1 electrolux --- variables 1995 19971997 -- turnover 100 34035 production 4567 99 cost of labour 6597 31 I use the following code: \documentclass[a4paper]{article} \title{example} \begin{document} \maketitle <>= mydata$firms @ variables <>= mydata$year @ and so on. I have two problem, first I'm not able to put on the same line text and output of R. So on my Latex document I get for example variable 1995 1996 1997 and I don't want this. The secondo problem is that at the beginnig of the R output I get the index, namely variable [1] 1995 1996 1997 and I don't want to see it. Anyone Knows how to do it or if there is another package in R that give me the possibility to create a Report by constructing table without any problems??? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] inverse function of melt
Dear list, I'm looking for an inverse function of melt(which is in package reshape).Namely, I had a data frame like this (Table1) YEAR VAR1 VAR2 VAR3 1995 7 3 45 1996 5 632 1997 6 10 15 I transformed my data by using the melt function and my data was reshaped in the following format: (Table2) YEARvariable value 1995VAR1 7 1996 VAR1 5 1997 VAR1 6 1995VAR2 7 1996 VAR2 5 1997 VAR2 6 1995VAR3 7 1996 VAR3 5 1997 VAR3 6 Now I would like to come back to the original format, namely table1. Anyone could help me?? Thanks for your attention! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] big big problem
Dear list, I'll try to be more clear in explaining my problem. I have a data frame like this called X: CLUSTERYEAR variable value1 value2 M1 2005 EC01 NA NA M1 2006 EC0125 M1 2007 EC0145 M2 2005 EC01 NA NA M2 2006 EC01 57 M2 2007 EC01 8 7 M1 2005 EC02 NA NA M1 2006 EC023 8 M12007EC02 1 8 M22005EC02 NA NA M22006EC02 9 10 M22007EC026 10 I'm trying to build the time series of the variables (EC01,EC02) by applying the following formulas in a recursive way(by starting from value2 at time 2007). The formulas needed to get the time series are series(2006)=value2(2007)-value1(2007) series(2005)=value2(2006)-value1(2006) In terms of number I would have for example for variable EC01: series(2006)=5-4=1 series(2005)=1-2=-1 In addition, this calculations should be down grouping by variable e cluster.So the result should be CLUSTERYEAR variableseries M1 2005 EC01 -1 M1 2006 EC01 1 M1 2007 EC01 5 M2 2005 EC01 -6 M2 2006 EC01 -1 M2 2007 EC01 7 M1 2005 EC02 4 M1 2006 EC02 7 M12007EC02 8 M22005EC02 -5 M22006EC024 M22007EC02 10 I applied the following formula which gives what I want but not at all: series=ddply(X,.(variable,CLUSTER),transform,series=rev(value2-cumsum(rev(value1[-1])) The first problems is that I get the following warning message: longer object length is not a multiple of shorter object length Secondly If I try to add new years(My aim was to do a check in order to see if this procedure works for all type of data frame) R does the right calculations but the order of the results referred to the variable called series is not right. Thanks for your attention!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RKWARD
Dear list, I have a question. I have the RKward configuration. I don't know what happened but now when I open R I have in my workspace data frames with which I used in the past sessions.How can I set RKward in order to open a new workspace? Thanks a lot [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data frame
Dear list, I have the following problem. I have a data frame like this CLUSTERYEAR variableDelta R_pivot M1 2005 EC01 NA NA M1 2006 EC012NA M1 2007 EC0145 M2 2005 EC01 NA NA M2 2006 EC01 5NA M2 2007 EC01 8 7 M1 2005 EC02 NA NA M1 2006 EC023 NA M12007EC02 1 8 M22005EC02 NA NA M22006EC02 9 NA M22007EC026 10 I'm trying to build the time series of the variables by applying the following formulas in a recursive way(by starting from the value of R_pivot at time 2007) R_EC01(2006)=R_EC01(2007)-Delta_EC01(2007) R_EC01(2005)=R_EC01(2006)-Delta_EC01(2006) In terms of number I would have: R_EC01(2006)=5-4=1 R_eco1(2005)=1-2=-1 And the same should be done for variable EC02. In addition, this calculations should be down grouping by variable e cluster..so the result should be CLUSTERYEAR variableseries M1 2005 EC01 -1 M1 2006 EC01 1 M1 2007 EC01 5 M2 2005 EC01 -6 M2 2006 EC01 -1 M2 2007 EC01 7 M1 2005 EC02 4 M1 2006 EC02 7 M12007EC02 8 M22005EC02 -5 M22006EC024 M22007EC02 10 I applied the following formula which gives me a partial good result but not at all: series=ddply(x,.(variable,CLUSTER),transform,series=rev(c(R_pivot,rev(R_pivot-cumsum(rev(Delta[-1])) Thanks for your attention!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data frame
Dear list, I have the following problem. I have a data frame like this CLUSTERYEAR variableDelta R_pivot M1 2005 EC01 NA NA M1 2006 EC012NA M1 2007 EC0145 M2 2005 EC01 NA NA M2 2006 EC01 5NA M2 2007 EC01 8 7 M1 2005 EC02 NA NA M1 2006 EC023 NA M12007EC02 1 8 M22005EC02 NA NA M22006EC02 9 NA M22007EC026 10 I'm trying to build the time series of the variables by applying the following formulas in a recursive way(by starting from the value of R_pivot at time 2007) R_EC01(2006)=R_EC01(2007)-Delta_EC01(2007) R_EC01(2005)=R_EC01(2006)-Delta_EC01(2006) In terms of number I would have: R_EC01(2006)=5-4=1 R_eco1(2005)=1-2=-1 And the same should be done for variable EC02. In addition, this calculations should be down grouping by variable e cluster..so the result should be CLUSTERYEAR variableseries M1 2005 EC01 -1 M1 2006 EC01 1 M1 2007 EC01 5 M2 2005 EC01 -6 M2 2006 EC01 -1 M2 2007 EC01 7 M1 2005 EC02 4 M1 2006 EC02 7 M12007EC02 8 M22005EC02 -5 M22006EC024 M22007EC02 10 I applied the following formula which gives me a partial good result but not at all: series=ddply(x,.(variable,CLUSTER),transform,series=rev(c(R_pivot,rev(R_pivot-cumsum(rev(Delta[-1])) Thanks for your attention!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data frame
Dear list, I have the following problem. I have a data frame like this CLUSTERYEAR variableDelta R_pivot M1 2005 EC01 NA NA M1 2006 EC012NA M1 2007 EC0145 M2 2005 EC01 NA NA M2 2006 EC01 5NA M2 2007 EC01 8 7 M1 2005 EC02 NA NA M1 2006 EC023 NA M12007EC02 1 8 M22005EC02 NA NA M22006EC02 9 NA M22007EC026 10 I'm trying to build the time series of the variables by applying the following formulas in a recursive way(by starting from the value of R_pivot at time 2007) R_EC01(2006)=R_EC01(2007)-Delta_EC01(2007) R_EC01(2005)=R_EC01(2006)-Delta_EC01(2006) In terms of number I would have: R_EC01(2006)=5-4=1 R_eco1(2005)=1-2=-1 And the same should be done for variable EC02. In addition, this calculations should be down grouping by variable e cluster..so the result should be CLUSTERYEAR variableseries M1 2005 EC01 -1 M1 2006 EC01 1 M1 2007 EC01 5 M2 2005 EC01 -6 M2 2006 EC01 -1 M2 2007 EC01 7 M1 2005 EC02 4 M1 2006 EC02 7 M12007EC02 8 M22005EC02 -5 M22006EC024 M22007EC02 10 I applied the following formula which gives me a partial good result but not at all: series=ddply(x,.(variable,CLUSTER),transform,series=rev(c(R_pivot,rev(R_pivot-cumsum(rev(Delta[-1])) Thanks for your attention!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merge
Dear list I have two different data frame the first one is like this CLUSTER year variablevalue m1 2006 EC01 4 m1 2007 EC01 5 m2 2006 EC01 42 m2 2007 EC019 and other variables this data frame has 800 number of rows and 14 number of columns the second data frame has more or less the same structure CLUSTER year m1 2005 m1 2006 m1 2007 m2 2005 m2 2006 m2 2007 This data frame has 548833 number of rows and 18 number of columns What im trying to do is to merge the Year columns of the second data frame with the whole First data frame in order to get the following new data frame CLUSTER year variablevalue m1 2005 EC01 / m1 2006 EC01 4 m1 2007 EC01 5 m2 2005EC01/ m2 2006 EC0142 m2 2007 EC019 Someone could help me??? Thanks a lot __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] recursive function
Dear list, I have the following problem, what i'm trying to do is to built a function which does the following calculationg in a recursive way: I have a data frame more or less like this: variableyear DELTA EC01 2006/ EC01 2007 10 EC01 20085 EC01 20099 And then I have at time 2009 a variable called R_EC01(2009)=5 What I have to do is to construct the R_EC01 time series by starting from the 2009 value: R_EC01(2008)=R_EC01(2009)-DELTA(2009) R_EC01(2007)=R_EC01(2008)-DELTA(2008) R_EC01(2006)=R_EC01(2007)-DELTA(2007) In terms of number, the results that i should get are: R_EC01(2008)=5-9=-4 R_EC01(2007)=-4-5=-9 R_EC01(2006)=-9-10=-19 so my data frame should looks like this SERIESYEAR value R_EC01 2006 -19 R_EC012007 -9 R_EC012008 -4 R_EC01 2009 5 Anyone Knows hot to do it?? My dataframe is not set as a time series... Thanks a lot!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cumsum function with data frame
Dear list, I have a problem with the cumsum function. I have a data frame like the following one variableYear value EC01 2005 5 EC01 2006 10 AAO12005 2 AAO1 2006 4 what I would like to obtain is variableYear value cumsum EC01 2005 5 5 EC01 2006 10 15 AAO12005 22 AAO1 2006 46 if I use the by function or the aggregate function the result is a list or something else, what I want is a data frame as I showed above... anyone knows how to get it??? THANKS A LOT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function
Dear list, I would like to ask you a question. I'm trying to build the time series' production with the Divisia index. The final step would require to do the following calculations: a)PROD(2006)=PROD(2007)/[1+DELTA_PROD(2007)/100] b)PROD(2005)=PROD(2006)/[1+DELTA_PROD(2006)/100] c)PROD(2004)=PROD(2005)/[1+DELTA_PROD(2005)/100] my question is how can I tell R to take the value generated in the previous step (for example is the case of the produciton of 2005 that need the value of the production of 2006) in order to generate the time series production?? I have the value of the following variables: prod(2007)=2 delta_prod(2007)=3 delta_prod(2006)=5 delta_prod(2005)=4 What i would like to do is prod(2006)=2/(1+3/100) which is equal to 1.95 prod(2005)=1.95/(1+5/100) and so on... (PS:my data.frame is not set as a time series) Thanks for your attention!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function
Dear list, I would like to ask you a question. I'm trying to build the time series' production with the Divisia index. The final step would require to do the following calculations: a)PROD(2006)=PROD(2007)/1+[DELTA_PROD(2007)] b)PROD(2005)=PROD(2006)+[1+DELTA_PROD(2006)] c)PROD(2004)=PROD(2005)+[1+DELTA_PROD(2005)] my question is how can I tell R to take the value generated in the previous step (for example is the case of the produciton of 2005 that need the value of the production of 2006) in order to generate the time series production?? (PS:my data.frame is not set as a time series) Thanks for your attention!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pie3D
Dear list, I would like to know if is it possible to add a legend to a pie3D?? Thanks for your attention! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function
Dear list, I'm trying to implement the following function, but what I get is an error message and I don't understand where is the error: #outliers'identification: iqr=lapply(bb,function(){ inner_fencesl=quantile(x,0.25)-1.5*IQR(x) inner_fencesh=quantile(x,0.75)+1.5*IQR(x) outer_fencesl=quantile(x,0.25)-3*IQR(x) outer_fencesh=quantile(x,0.75)+3*IQR(x)}) where bb is a dataframe containing all the variables over wich the function must be applied. thanks of your attention! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] for loop
Dear list, in the following loop im generating objects of type table. What I would like to do is to put all those objects together in a list (that i called cc).I did this but the result is not what i espect to get: cc=list() d=1 for (i in data) { cc=list(cc,assign(paste("n",d,sep=""),table(i,subsample$vD31NADD))) d=d+1} I know that this won't work properly: cc=list(cc,assign(paste("n",d,sep=""),table(i,subsample$vD31NADD))) but I dont know a way to add to my list the new objects generated at each step of the loop.Another information that I can give you is that data is a list. Thanks for your attention! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] for loop
Dear list, in the following loop im generating objects of type table. What I would like to do is to put all those objects together in a list (that i called cc).I did this but the result is not what i espect to get: cc=list() d=1 for (i in data) { cc=list(cc,assign(paste("n",d,sep=""),table(i,subsample$vD31NADD))) d=d+1} I know that this won't work properly: cc=list(cc,assign(paste("n",d,sep=""),table(i,subsample$vD31NADD))) but I dont know a way to add to my list the new objects generated at each step of the loop. Thanks for your attention! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] frequency
Dear list, Im trying to do the following operation but im not able to do it This is my table: 1 2 3 1 0 7 4 2 0 2 0 3 0 1 3 4 0 3 4 what i would like to do is divide each row values with the corresponding column' sum,namely: 1 2 3 1 0 0.54 0.36 2 0 0.150 3 0 0.08 0.27 4 0 0.23 0.36 thanks for your attention [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] concatenate values of two columns
Dear list, I'm trying to concatenate the values of two columns but im not able to do it: i have a dataframe with the following two columns: X VAR1 VAR2 1 2 2 1 3 2 4 3 5 4 6 4 what i would like to obtain is: X VAR3 1 2 2 1 3 2 4 3 5 4 6 4 I try with paste but what I obtain is: X VAR3 1 NA2 21NA 32NA 4NA3 5NA4 64NA Thanks a lot!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data frame
Dear list, I have a big data frame which looks like this: variable YEAR VAR EC01 2006 100 EC01 2007 200 EC02 2006 500 EC02 2007 450 PROD 2006 567 PROD 2007 543 What I would like to do is to divide each variables by PROD,namely: EC01(2006)/PROD(2006) EC01(2007)/PROD(2007) EC02(2006)/PROD(2006) EC02(2007)/PROD(2007) Anyone knows how to do it?? THANKS!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] data frame
Dear list, I have a big data frame which looks like this: variable YEAR VAR EC01 2006 100 EC01 2007 200 EC02 2006 500 EC02 2007 450 PROD 2006 567 PROD 2007 543 What I would like to do is to divide each variables by PROD,namely: EC01(2006)/PROD(2006) EC01(2007)/PROD(2007) EC02(2006)/PROD(2006) EC02(2007)/PROD(2007) Anyone knows how to do it?? THANKS!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dataframe
Dear list, >I have a question about the selection of Variables in dataframes. >I have a dataframes like this: > >CFISCAFIRMSYEAR VARVALUE >20345 nike2005EC01 34 >20345 nike2006 EC01 45 >56779mediaset 2005 EC01 65 >64568 agazzini 2005 EC01 78 >64568agazzini2006EC01 56 >78907 uniteam 2006 EC01 46 > > >what my result should be is a new dataframes which have only firms which have >data in both years (2005,2006) > >CFISCA FIRMSYEAR VARVALUE >20345 nike 2005 EC0134 >20345 nike2006 EC01 45 >64568agazzini 2005 EC01 78 >64568 agazzini2006 EC01 56 > > >Thanks for your attention!!! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dataframe
Dear list, I have a question about the selection of Variables in dataframes. I have a dataframes like this: CFISCA FIRMS YEARVAR VALUE 20345nike 2005 EC01 34 20345nike 2006 EC01 45 56779 mediaset 2005 EC01 65 64568 agazzini 2005 EC01 78 64568 agazzini 2006EC01 56 78907 uniteam 2006 EC0146 what my result should be is a new dataframes which have only firms which have data in both years (2005,2006) CFISCA FIRMS YEARVAR VALUE 20345nike 2005 EC01 34 20345nike 2006 EC01 45 64568 agazzini 2005 EC01 78 64568 agazzini 2006EC01 56 Thanks for your attention!!! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dataframe
Dear list I have a question, I would like to get the following results but I dont know how to do it: I have a dataframe like this: NC8PROD X 1X2 1423 P1342 10 1564 G5 56 20 123G5 3 4 1568H2 6 10 7864H2 5 72 5693 P3 7 43 What I would like to do is the sum of the X1 and X2 variables by PROD, namely getting another dataframe which looks like the following NC8PROD X 1 X2 1423 P1342 10 1564 G5 5924 123G5 59 24 1568H211 82 7864H2 1182 5693 P3 7 43 In Sas I know a function called proc means that can do it. How can I do this in R??? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] local and global variables
Hi all, I have a question about global and local variables.First of all, a variable defined in a for loop is it a local or global variable?? Second, I'm trying to build a loop in the following way: I have these 3 data frames bilanci_2005<-bilanci1[ANNO==2005,] bilanci_2006<-bilanci1[ANNO==2006,] bilanci_2007 <--bilanci1[ANNO==2007,] LOOP: v=list(2005,2006,2007) for (a in v){ anno1=a anno2=a+1 for (i in 1:length(bilanci_a)) { assign(paste(""bilanci",anno1,anno2,sep=""), rbind(paste("bilanci",anno1,anno2, sep=""), bilanci_anno2[bilanci_anno2$CFISCALE==bilanci_anno1 [i,]$CFISCALE,], "bilanci_anno1[i,]) } } what I'm trying to do is for example to give the contents of a (so the values which are in the list named v) to the bilanci variable. In Stata this means using a particular kind of "". How can I do this in R? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merge
I have a problem with the merge function. I have to merge two big dataframes which look like the following example.The problems is that I get duplicated rows. CODPROD N1 N3 N4 23 3 55 4 24 5 6736 25 3 73 24 second data frame CODPROD N1 N2 30 34 45 45 078 65056 The result that I get its like: CODPROD N1 N2 N3N4 N1.1 23 3 NA55 4 3 24 5 NA67 36 0 25 3 NA73 24 0 30 34 45 NA NA 0 45 0 78 NA NA 0 65 0 56 NA NA . 0 So N1.1 is a duplication of N1.I think I could solve the problems by specifying the same columns but I have a lot of colums which have the same names in the two dataframe so I think its not the right way to solve it. Anyone knows how to avoid duplication?? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] dataframe
Hi all, I'm trying to load a csv file in which all the variables must be of type number.The object is a dataframe.When i load the file what i get is a dataframe in wich the variables are of type factor.How can I get variables of type number??? Thanks all __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merge
I have a problem with the merge command. I have to merge two dataframe that looks like the following example: CODPROD N1 N3 N4 23 3 55 4 24 5 6736 25 3 73 24 second data frame CODPROD N1 N2 30 34 45 45 078 65056 The result should be: CODPROD N1 N2 N3N4 23 3 NA554 24 5 NA67 36 25 3 NA73 24 30 34 45 NA NA 45 0 78 NA NA 65 0 56 NANA Anyone knows how to do it?? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merge
I have a problem with the merge function: I need to merge the data.frames that you will find as arrachmente...I try all the possible combinationsbut none seems to work properly Does anyone knows how to do it?? thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to construct a time series
Hi, I need to generate the time series of the production, but as I'm new to this topic I am not able to do that. This is what the time series should be: PROD(t)=PROD(t,T) PROD(t-1)=PROD(t-1,T) PROD(t-2)=PROD(t-1)*PROD(t-2,T-1)/PROD(t-1,T-1) PROD(t-3)=PROD(t-2)*PROD(t-3,T-2)/PROD(t-2,T-2) ... ... ... from PROD(t-2)...it will get the same expression; where PROD(t,T) is the value of the production at t for the sample of firms presented at T and T-1; Someone knows how to get it??? Thanks for your attention!!! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] large dataset
Hi I have a question, as im not able to import a csv file which contains a big dataset(100.000 records) someone knows how many records R can handle without giving problems? What im facing when i try to import the file is that R generates more than 100.000 records and is very slow... thanks a lot!!! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] merging two datasets
I have some probems in merging the following datasets: table1 Paese Continente Italia EU franciaEU germania EU stati uniti AM canadaAM table2 Continente valuta EU euro AMdollaro the results should be PaeseValuta Italia euro francia euro germaniaeuro stati unitidollaro canada dollaro there is anyone who can help me?? THANKS A LOT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.