Re: [R] Rounding variables in a data frame

2011-01-15 Thread Pete B
Bill, Joshua, Phil Thanks for the suggestions. Very much appreciated. Kind regards Pete -- View this message in context: http://r.789695.n4.nabble.com/Rounding-variables-in-a-data-frame-tp3218729p3219060.html Sent from the R help mailing list archive at Nabble.com. _

[R] Rounding variables in a data frame

2011-01-14 Thread Pete B
Hi All I am trying to use the round function on some columns of a dataframe while leaving others unchanged. I wish to specify those columns to leave unchanged. My attempt is below - here, I would like the column d3 to be left but columns d1, d2 and d4 to be rounded to 0 decimal places. I would w

Re: [R] zoo column names

2011-01-08 Thread Pete B
Achim Thanks. Much appreciated. Best regards Pete -- View this message in context: http://r.789695.n4.nabble.com/zoo-column-names-tp3205568p3205584.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list h

[R] zoo column names

2011-01-08 Thread Pete B
Hi All I am trying to find a way to prevent column names from changing on zoo objects when I merge them. I have column names that contain a "-" that after merging have become "." # Example zz1 = zoo(as.matrix(1:5)) zz2 = zoo(as.matrix(10:12)) names(zz1)=c("aa-1") names(zz2)=c("bb-1") zz3=merg

Re: [R] Merging zoo objects

2011-01-07 Thread Pete B
Thanks Gabor. Much appreciated (as always). -- View this message in context: http://r.789695.n4.nabble.com/Merging-zoo-objects-tp3184696p3186113.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:/

[R] Merging zoo objects

2011-01-07 Thread Pete B
Hi I have n zoo objects M1, M2, M3, ... , Mn that I want to merge where n is a number calculated at run-time. I am struggling to find the correct syntax to do this Assuming n is calculated as 10 (for example), I have tried n = 10 # First Effort alldata= merge(paste("M",rep(1:n), sep=""),all=T

Re: [R] function()

2010-12-30 Thread Pete B
If, as a new R user, you find the help page difficult to follow then Google offers plenty of support to understand the apply function e.g. http://www.ats.ucla.edu/stat/r/library/advanced_function_r.htm http://www.slideshare.net/dataminingtools/r-apply-functions http://nsaunders.wordpress.com/2

Re: [R] Good documentation about Sweave

2010-09-26 Thread Pete B
Colin Some links I used to get me going ... http://www.ics.uci.edu/~vqnguyen/talks/SweaveSeminaR.pdf http://www.r-bloggers.com/getting-started-with-sweave-r-latex-eclipse-statet-texlipse/ http://www.statistik.lmu.de/~leisch/Sweave/ http://stat.epfl.ch/webdav/site/stat/shared/Regression/EPFL-S

Re: [R] appending to a list

2010-09-05 Thread Pete B
Is this what you are looking for ... mylist=list() for (i in 1:3){ mylist[i] = rnorm(1) } print(mylist) HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/appending-to-a-list-tp2527597p2527635.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] R time series analysis

2010-09-05 Thread Pete B
1. try the predict function e.g. predict(arima1, n.ahead=10) 2. try the resid function e.g. resid(arima1) HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/R-time-series-analysis-tp2527513p2527625.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] legend outside plot area

2010-08-15 Thread Pete B
Emily Maybe this will help # Data y1=rnorm(10) y2=runif(10) x=1:10 # Set XPD and Outer Margin par(xpd=NA,oma=c(3,0,0,0)) # Plot and Legend plot(x,y1,type="n",ylab="") lines(x,y1, col="red") lines(x,y2, col="blue") legend(par("usr")[1],par("usr")[3],c("Y1","Y2"),col=c("red","blue"),lty=1,xjust=

[R] Download xls file from internet

2010-08-05 Thread Pete B
I am trying to download an Excel file from the the internet with the following R command download.file("http://ir.eia.gov/wpsr/psw09.xls","C:\\Temp\\psw09.xls";) The file is downloaded but when I try and open it I get a message from Excel telling me that the file is corrupt and it cannot be open

Re: [R] adding a row of names to data.frame

2010-07-05 Thread Pete B
Jim Is this what you need? #create data Lines <- "Drug1 Drug2 Drug3 Drug4 153 133 145 111 189 177 200 170 221 241 187 243 215 228 201 178 302 283 292 248 223 255 220 202 201 238 233 163 173 164 172 139 121 128 119 120 100 200 300 400" # read in

Re: [R] Factor to variable

2010-06-05 Thread Pete B
Hi How about ... # Data lines = "Col1 Col2 Col3 Col4 Text1 Text2 X0.1 5 Text1 Text2 X0.2 10 Text1 Text2 X0.3 15 Text1 Text3 X0.1 5 Text1 Text3 X0.2 10 Text1 Text3 X0.3 15" # Create Dataframe DF <- read.table(textConnection(lines), header = TRUE, check.names = FALSE) # Create Numeric Variable

Re: [R] Fwd: R apply() help -urgent

2010-05-09 Thread Pete B
Venkatesh Is this what you are looking for? # Example data df=data.frame(A=c(1,0,0,0,1),B=c(1,1,0,0,0),C=c(1,0,0,0,0),Val=c(1,0,1,0,1)) # Variation of code of David Winsemius tbl = lapply(df[, 1:3] , function(x) table(x, df$Val)) fet = lapply(tbl, function(x) fisher.test(x)) # Identify intern

Re: [R] How to set proxy settings for R

2010-04-20 Thread Pete B
Hi Alessandra Did you restart R? You should be able to download packages using the Packages> Install Package(s) ... from the menu bar in the GUI. Once the package has been downloaded select Packages> Load Package ... you should see what you just downloaded in a list of available packa

Re: [R] How to set proxy settings for R

2010-04-19 Thread Pete B
Also, the FAQ suggests using the alternative internet2.dll by starting R with the flag --internet2 If you start R from a desktop icon, you can add the --internet flag to the target line (right click, properties) e.g. "C:\Program Files\R\R-2.8.1\bin\Rgui.exe" --internet2 see http://cran.r-projec

Re: [R] merge

2010-04-19 Thread Pete B
Maybe this what you are looking for lines1 <- "CODPROD N1 N3 N4 23 3 55 4 24 5 67 36 25 3 73 24" df1 <- read.table(textConnection(lines1),header=TRUE) lines2 <-"CODPROD N1 N2 30 34 45 45 0 78 65 0 56" df2 <- read.table(textConnection(lines2),header=TRUE) merge(df1, df2, by = inter

Re: [R] Summarization

2010-04-14 Thread Pete B
Dennis Very nice! Thanks Pete -- View this message in context: http://n4.nabble.com/Summarization-tp1840718p1840730.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/lis

[R] Summarization

2010-04-14 Thread Pete B
Hi All I have a vector x containing 2 levels x = c(1,1,1,0,0,0,0,1,1,0,0,0,1,1,0) I would like to derive the following summarization Level Count 1 3 0 4 1 2 0 3 1 2 0 1 I have generated an inelegant solution using lags and loops but feel sure that there must be a better approach. If anyone ha

Re: [R] Operating on each row of data frame

2010-01-13 Thread Pete B
Look at the apply function ?apply x = data.frame(x1=c(1,2,3,4,5),x2=c(2,4,6,8,10),x3=c(1,3,5,7,9)) x$x5=apply(x,1,mean) x$x6=apply(x,1,sd) print(x) Abhishek Pratap wrote: > > Hi All > > I have a data frame in which there are 4 columns . > > Column 1 : name > > Column 2-4 : values > > I w

Re: [R] merging issue.........

2010-01-13 Thread Pete B
Try the merge function ?merge in1 = "id trait1 110.2 211.1 39.7 610.2 78.9 10 9.7 11 10.2 " in2 = "id trait2 1 9.8 2 10.8 4 7.8 5 9.8 6 10.1 1210.2 1310.1 " data1 = read.table(textConnection(in1), header=T) data2 = read.table(tex

[R] Rollapply

2010-01-13 Thread Pete B
Hi I would like to understand how to extend the function (FUN) I am using in rollapply below. ## With the following simplified data, test1 yields parameters for a rolling regression data = data.frame(Xvar=c(70.67,70.54,69.87,69.51,70.69,72.66,72.65,73.36),