[R] win.metafile() and family
Hi all, I recently discovered how great win.metafile is for getting high resolution graphics into word. Having problems with specifying families though... #pdf works fine pdf(test.pdf,width=14,height=9) par(family=Helvetica) plot(1:10) text(4,4,trial) dev.off() windows 2 #metafile doesnt like helvetica family win.metafile(test.wmf,width=14,height=9) par(family=Helvetica) plot(1:10) There were 12 warnings (use warnings() to see them) text(4,4,trial) Warning message: In text.default(4, 4, trial) : Font family not found in Windows font database dev.off() windows 2 Trawled through messages on here and read Rdegva but couldnt find the answer. Are there any user friendly windows user guides about all this? R 2.8.1 Windows XP 2003 Cheers, Si. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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.
Re: [R] filtering number of values in a data frame
I think you can then use merge() to merge them back together n- merge(n, df, by.x = c(m.values), by.y = c(Start), all.x = F, all.y = F) also see ?aggregate for a more efficient solution. HTH, Si. - Original Message - From: Schönemann, Rene rschoenem...@railways.tu-berlin.de To: R-help@r-project.org Sent: Thursday, June 18, 2009 1:37 PM Subject: [R] filtering number of values in a data frame Dear list, given is the following data frame df(): Number Place Start End 1 218024740787 HHO 5 263 2008-01-02 00:21:14 2008-01-03 15:25:16 2 218024740787 HHO 5 263 2008-01-02 00:21:14 2008-01-02 00:21:14 3 318039091794 HHO 5 263 2008-01-02 00:21:14 2008-01-02 13:22:54 4 318039091794 HHO 5 263 2008-01-02 00:21:14 2008-01-02 00:21:14 5 318039379900 HHO 1 104 2008-01-02 06:45:01 2008-01-02 09:15:23 Now, I want to count the number of equal values of column Start but I also want the other columns to be preserved. Using: rle(as.character(df$Start)) - m n - data.frame(m$values, m$lengths) produces a list of items according to their frequency of the Start point: m.values m.lengths 1 2008-01-02 00:21:14 4 2 2008-01-02 06:45:01 1 I want now also other columns to be in this new data frame. It should look like that: Number Place m.values m.lengths 1 218024740787 HHO 5 263 2008-01-02 00:21:14 4 2 318039379900 HHO 1 104 2008-01-02 06:45:01 1 Does anybody can help me with this? Thanking you in advance! René Schönemann -- __ Technische Universität Berlin Institut für Land- und Seeverkehr Fachgebiet Schienenfahrwege und Bahnbetrieb Prof. Dr.-Ing. habil. Jürgen Siegmann PostSekretariat SG 18 Salzufer 17-19 D-10587 Berlin Telefon +49 (0)30 314 - 23 314 Internethttp://www.railways.tu-berlin.de __ Dipl.-Verk.wirtsch. René Schönemann - Wissenschaftlicher Mitarbeiter - Telefon +49 (0)30 314 - 22 710 Telefax +49 (0)30 314 - 25 530 E-Mail rschoenem...@railways.tu-berlin.de __ Technische Universität Berlin Körperschaft öffentlichen Rechts Präsident Prof. Dr. Kurt Kutzler __ 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-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 manipulation involving aggregate
hi all, I often have a data frame like this example data.frame(sq=c(1,1,1,2,2,3,3,3,3),area=c(1,2,3,1,2,3,1,2,3),habitat=c(garden,garden,pond,field,garden,river,garden,field,field)) for each sq I have multiple habitats each with an associated area. I want to aggregate the data frame so that for each sq I have a column of all possible habitats and another column for the calculation of the summed areas for each habitat. If a certain habitat doesnt exist in that square I want a zero, like this.. data.frame(sq=rep(seq(1:3),each=4),area.sum=c(3,3,0,0,2,0,1,0,1,0,5,3),habitat=rep(c(garden,pond,field,river) )) Is there an eloquent, efficient way of doing this? My solution involves lots of intermediate aggregated data frames, one for each habitat, then a series of merges onto a bigger data frame. Thanks peeps and have a good weekend, Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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.
Re: [R] Help me...!!!
have a read at these pdfs http://cran.r-project.org/other-docs.html you are likely to get a bashing for asking people to do your homework for you! Simon. - Original Message - From: abel1682 lizard_1...@yahoo.it To: r-help@r-project.org Sent: Tuesday, May 26, 2009 3:37 PM Subject: [R] Help me...!!! Hi to all...i'm a new R'user and i have to solve some exercies so i ask to tou for an help... 1.) How i can demonstrate in R that the limit for x--infinite of (1+1/x)^x is equal to e? 2.) if i have a vector of values how can i create a function that, applied to my vector, give me median, mean, Var and length togheter? 3.)Find the minimum of this function: f(x)=(x-3)^4 with the Newton method. 4.) Define a function that is able to calculate the geometric mean of a seriation: Sorry for all these questions... Thanks a lot!!!... -- View this message in context: http://www.nabble.com/Help-me...%21%21%21-tp23724167p23724167.html Sent from the R help mailing list archive at Nabble.com. __ 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-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.
Re: [R] Concatenating two vectors into one
z-c(x,y) cheers, Simon. - Original Message - From: Henning Wildhagen hwildha...@gmx.de To: r-help@r-project.org Sent: Monday, May 18, 2009 12:09 PM Subject: [R] Concatenating two vectors into one Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[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-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.
Re: [R] Simple plotting errors
you mean you want to plot SUM against month? (assuming these12 data frames are 12 months). you could first bind them all together using data.frame(), see ?data.frame which would make it much easier. you need to create a variable for months then plot it against your variable. If you dont want to make it easier with a data frame then you would have a long piece of code as follows (assuming I have understood you correctly) plot(seq(1:12),c(FeketeJAN$(SUM_)[row.names(FeketeJAN)==AMAZON],FeketeFEB$(SUM_)[row.names(FeketeFEB)==AMAZON]etc)) Cheers, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Monday, May 18, 2009 12:17 PM Subject: [R] Simple plotting errors Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ 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-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.
Re: [R] Simple plotting errors
you mean you want to plot SUM against month? (assuming these12 data frames are 12 months). you could first bind them all together using data.frame(), see ?data.frame which would make it much easier. you need to create a variable for months then plot it against your variable. If you dont want to make it easier with a data frame then you would have a long piece of code as follows (assuming I have understood you correctly) plot(seq(1:12),c(FeketeJAN$(SUM_)[row.names(FeketeJAN)==AMAZON],FeketeFEB$(SUM_)[row.names(FeketeFEB)==AMAZON]etc)) Cheers, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Monday, May 18, 2009 12:17 PM Subject: [R] Simple plotting errors Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ 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-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.
Re: [R] Concatenating two vectors into one
Sorry, I saw the word concatenate and dived in. Andrew Dolmans solution works fine. Simon. - Original Message - From: Linlin Yan yanlinli...@gmail.com To: Simon Pickett simon.pick...@bto.org Cc: Henning Wildhagen hwildha...@gmx.de; r-help@r-project.org Sent: Monday, May 18, 2009 12:30 PM Subject: Re: [R] Concatenating two vectors into one It seems that c(x,y) is not correct: z-c(x,y) z [1] A B C D E F 1 2 3 4 5 6 On Mon, May 18, 2009 at 7:17 PM, Simon Pickett simon.pick...@bto.org wrote: z-c(x,y) cheers, Simon. - Original Message - From: Henning Wildhagen hwildha...@gmx.de To: r-help@r-project.org Sent: Monday, May 18, 2009 12:09 PM Subject: [R] Concatenating two vectors into one Dear users, a very simple question: Given two vectors x and y x-as.character(c(A,B,C,D,E,F)) y-as.factor(c(1,2,3,4,5,6)) i want to combine them into a single vector z as A1, B2, C3 and so on. z-x*y is not working, i tried several others function, but did not get to the solution. Thanks for your help, Henning -- [[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-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-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.
Re: [R] Simple plotting errors
you mean you want to plot SUM against month? (assuming these12 data frames are 12 months). you could first bind them all together using data.frame(), see ?data.frame which would make it much easier. you need to create a variable for months then plot it against your variable. If you dont want to make it easier with a data frame then you would have a long piece of code as follows (assuming I have understood you correctly) plot(seq(1:12),c(FeketeJAN$(SUM_)[row.names(FeketeJAN)==AMAZON],FeketeFEB$(SUM_)[row.names(FeketeFEB)==AMAZON]etc)) Cheers, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Monday, May 18, 2009 12:17 PM Subject: [R] Simple plotting errors Dear R Users, I have 12 data frames, each of 12 rows and 2 columns. e.g. FeketeJAN MEANSUM_ AMAZON 144.4997874 68348.4 NILE 5.4701955 1394.9 CONGO71.3670036 21196.0 MISSISSIPPI 18.9273250 6511.0 AMUR 1.8426874 466.2 PARANA 58.3835497 13486.6 YENISEI 1.4668313 592.6 OB1.4239179 559.6 LENA 0.9342164 387.7 NIGER 4.7245709 826.8 ZAMBEZI 76.6893794 8665.9 YANGTZE 10.6759257 1729.5 I want to do a line plot of the value of Amazon 'Sum' (in this case, 68348.4) for each of the 12 data frames. I've tried doing this as follows: plot(FeketeJAN[1,2], FeketeFEB[1,2], FeketeMAR[1,2], *through to December* type=l) but receive: Error in strsplit(log, NULL) : non-character argument I've also tried: plot(FeketeJAN$AMAZON[,2], FeketeFEB$AMAZON[,2], *through to December* type=l) but receive: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf What is it that I'm doing wrong?! Many thanks for any advice, Steve _ [[elided Hotmail spam]] __ 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-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.
Re: [R] Simple plotting errors
read ?par 1.use ylab= to suppress y labels, then mxtext to manually draw em yourself OR use mgp=... within par() 2.use xlab not xlim to change the x axis labels HTH, Si. - Original Message - From: Steve Murray smurray...@hotmail.com To: simon.pick...@bto.org; r-help@r-project.org; ba...@exeter.ac.uk; jholt...@gmail.com Sent: Monday, May 18, 2009 1:39 PM Subject: RE: [R] Simple plotting errors Thanks for all the useful information; use of 'c(...)' did the trick, although in future I'll try to hold the data in a more user-friendly setup. I've now got a plot, but have two issues that I can't seem to resolve: 1, The ylab is overlapping the y-axis tick mark values. I've tried using oma and mar to adjust the outer and plot margins respectively, but this doesn't seem to 'detach' the overlapping text. 2. The x-axis currently has tick mark values of 2 to 12. How do change this to single-letter month labels? So far I've tried xlim=c(J,F,M,A,M...) and names.arg=c(J,F,M...), but these result in errors. Any suggestions would be much appreciated. Thanks again, Steve _ View your Twitter and Flickr updates from one place – Learn more! http://clk.atdmt.com/UKM/go/137984870/direct/01/ __ 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.
Re: [R] Superscripts and subscripts in trellis graphics
Hi Steve, you need to use the expression() function. I think it is described under ?plotmath. Defo works with mtext, not sure about ylab. try ylab(text=c(expression(paste(Hatched Eggs R^{2} etc. - Original Message - From: steve_fried...@nps.gov To: r-help@r-project.org Sent: Monday, May 18, 2009 3:25 PM Subject: [R] Superscripts and subscripts in trellis graphics I'd like to annotate an xyplot with an R^2 value, but can not find the syntax to define the superscript format for the text. I'd appreciate suggestions, xyplot(SharkSloughEggs.df$Sharkeggs.rel + SharkSloughEggs.df$SharkHatched.rel + SharkSloughEggs.df$SharkFlooded.rel + HSI.shark$MEAN ~ Year, pch=c(1,9,5,4), lty=c(1,6,3,4), lwd = c(2), col = c(black, blue, green, red), scales=list(tick.number=length(Year)), data=SharkSloughEggs.df, ylab=Relative Egg Success, main=Shark Slough Alligators, par.settings = graph.sets, type = b) trellis.focus() panel.text(x=1999, y = 0.95, labels=Hatched Eggs\nR^2 = -0.18, cex = 0.75) panel.text(x=1998, y = 0.35, labels=Number of Eggs\nR^2 = 0.43,cex = 0.75) panel.text(x=1995, y = 0.25, labels=Flooded Eggs\nR^2 = -0.50, cex = 0.75) panel.text(x=1986, y = 0.3, labels=Mean HSI, cex = 0.75) trellis.unfocus() Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ 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-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.
Re: [R] need help
Read about glm by typing ?glm There are tons of books and pdfs out there to show you the basics. http://cran.r-project.org/other-docs.html HTH, Si. - Original Message - From: H Z zamani_...@yahoo.com To: r-help@r-project.org Sent: Friday, May 15, 2009 12:26 PM Subject: [R] need help Dear all please ,I need to write a function in R to estimate the parameters of negative binomial distribution and then calculate the loglikelihood amount for given data.Is there any one to help me. thank you very much for any help Best regards [[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-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.
Re: [R] displaying results
Absolutely no idea what you mean, Try reconstructing your question in concise English with reproducible code. Simon. - Original Message - From: deanj2k dl...@le.ac.uk To: r-help@r-project.org Sent: Friday, May 15, 2009 1:33 PM Subject: [R] displaying results Hi everyone, can anyone tell me how i can change how i display mean(age), i want it to say The mean age of patients within the sample is mean(age) -- View this message in context: http://www.nabble.com/displaying-results-tp23558890p23558890.html Sent from the R help mailing list archive at Nabble.com. __ 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-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.
Re: [R] name siz ein cluster
I'm afraid I have no experience with the clue package, but if all else fails you could consider the hclust package. You change font size in the conventional way with this. Cheers, Simon. - Original Message - From: Penner, Johannes johannes.pen...@mfn-berlin.de To: r-help@r-project.org Sent: Wednesday, May 13, 2009 3:08 PM Subject: [R] name siz ein cluster I would like to change to size of the names in a cluster dendrogram (not the axis or the header) (package clue). The normal things (pch, cex.label, font) do not work here. Thanks in advance! Johannes __ 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-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.
Re: [R] read multiple large files into one dataframe
can you provide reproducible code please? even a fake example would help. I would 1) set up a loop to read in each file from a directory 2) inside the loop chop up/ aggregate the data, each file in turn and spit each new aggreagated file out to a directory using write.table(). This will reduce the memory needed by only including the info you want. Make sure each file is a data frame with the same names. 3) set up a new loop to read in each new small file and rbind them all together to make your new master file. The R gurus may have a more parsimonious solution. HTH Simon. - Original Message - From: SYKES, Jennifer jennifer.sy...@nats.co.uk To: r-help@r-project.org Sent: Wednesday, May 13, 2009 11:45 AM Subject: [R] read multiple large files into one dataframe Hello Apologies if this is a simple question, I have searched the help and have not managed to work out a solution. Does anybody know an efficient method for reading many text files of the same format into one table/dataframe? I have around 90 files that contain continuous data over 3 months but that are split into individual days data and I need the whole 3 months in one file for analysis. Each days file contains a large amount of data (approx 30MB each) and so I need a memory efficient method to merge all of the files into the one dataframe object. From what I have read I will probably want to avoid using for loops etc? All files are in the same directory, none have a header row, and each contain around 180,000 rows and the same 25 columns/variables. Any suggested packages/routines would be very useful. Thanks Jennifer - ***If you are not the intended recipient, please notify our Help Desk at Email postmas...@nats.co.uk immediately. You should not copy or use this email or attachment(s) for any purpose nor disclose their contents to any other person. NATS computer systems may be monitored and communications carried on them recorded, to secure the effective operation of the system and for other lawful purposes. Please note that neither NATS nor the sender accepts any responsibility for viruses or any losses caused as a result of viruses and it is your responsibility to scan or otherwise check this email and any attachments. NATS means NATS (En Route) plc (company number: 4129273), NATS (Services) Ltd (company number 4129270), NATSNAV Ltd (company number: 4164590) or NATS Ltd (company number 3155567) or NATS Holdings Ltd (company number 4138218). All companies are registered in England and their registered office is at 5th Floor, Brettenham House South, Lancaster Place, London, WC2E 7EN. ** [[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-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.
Re: [R] I'm offering $300 for someone who know R-programming to dothe assignments for me.
at least he/she is resourceful! (but also very naughty) - Original Message - From: steve_fried...@nps.gov To: ayaku1...@gmail.com Cc: r-help@r-project.org; r-help-boun...@r-project.org Sent: Friday, May 08, 2009 12:48 PM Subject: Re: [R] I'm offering $300 for someone who know R-programming to dothe assignments for me. Shame on you! Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 ayaku1...@gmail. com ayaku1...@gmail. To com r-help@r-project.org Sent by: cc r-help-boun...@r- project.org Subject [R] I'm offering $300 for someone who know R-programming to do the 05/07/2009 09:19 assignments for me. PM MST There are six assignments in total. It won't take you long if you were familiar with R. For those who are interested, please send me an email with your profile (your experience with R, how long and how often have you been using it.) I will be paying through paypal. 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-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-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.
Re: [R] I'm offering $300 for someone who know R-programming to do the assignments for me.
I bet at least a few people offered their services! It might be an undercover sting operation to weed out the unethical amongst us :-) - Original Message - From: Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no To: Tung86 wyut...@gmail.com Cc: R help r-h...@stat.math.ethz.ch Sent: Friday, May 08, 2009 3:18 PM Subject: Re: [R] I'm offering $300 for someone who know R-programming to do the assignments for me. Tung86 wrote: well..why shame? He doesn't say it's a homework really. indeed; while it might of course have been a serious offer, i can't get rid of the feeling that what we see could also be a deliberate -- and quite successful -- provocation, and that the author might be now having lots of fun reading all that preaching... vQ On May 8, 4:48 am, steve_fried...@nps.gov wrote: Shame on you! Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 ayaku1...@gmail. com ayaku1...@gmail. To com r-h...@r-project.org Sent by: cc r-help-boun...@r- project.org Subject [R] I'm offering $300 for someone who know R-programming to do the 05/07/2009 09:19 assignments for me. PM MST There are six assignments in total. It won't take you long if you were familiar with R. For those who are interested, please send me an email with your profile (your experience with R, how long and how often have you been using it.) I will be paying through paypal. Thanks! __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ 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. -- --- Wacek Kusnierczyk, MD PhD Email: w...@idi.ntnu.no Phone: +47 73591875, +47 72574609 Department of Computer and Information Science (IDI) Faculty of Information Technology, Mathematics and Electrical Engineering (IME) Norwegian University of Science and Technology (NTNU) Sem Saelands vei 7, 7491 Trondheim, Norway Room itv303 Bioinformatics Gene Regulation Group Department of Cancer Research and Molecular Medicine (IKM) Faculty of Medicine (DMF) Norwegian University of Science and Technology (NTNU) Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway Room 231.05.060 __ 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-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.
Re: [R] Do you use R for data manipulation?
My institute uses SAS religiously, I am the only R heathen. I have resisted learning to use SAS because I dont see the point after years of using R and I like being able to do everything using one program. However, my colleagues maintain that SAS is better for programming without really ever giving me a good reason why other than memory issues. dont want to hi-jack the thread but would be interested in hearing some other views, especially since my organisation spends (wastes?) alot of money every year on SAS licences... Simon. - Original Message - From: Laura Arsanto ghin...@hotmail.it To: jrkrid...@yahoo.ca; r-h...@stat.math.ethz.ch; fjb...@gmail.com Cc: ross.laza...@gmail.com; gregory_war...@urmc.rochester.edu; g...@warnes.net Sent: Wednesday, May 06, 2009 2:53 PM Subject: Re: [R] Do you use R for data manipulation? I used R for my master thesis (with big effort, anyway) and now I find difficult to use R in my daily work, becasue it has really serious problems with datasets of big dimension, both in the data manipulation step and in the analysis step. But I really would love to use it, as I like its transparence, compared to other software. Laura *** Date: Wed, 6 May 2009 06:42:45 -0700 From: jrkrid...@yahoo.ca To: r-h...@stat.math.ethz.ch; fjb...@gmail.com CC: ross.laza...@gmail.com; gregory_war...@urmc.rochester.edu; g...@warnes.net Subject: Re: [R] Do you use R for data manipulation? --- On Wed, 5/6/09, Farrel Buchinsky fjb...@gmail.com wrote: Is R an appropriate tool for data manipulation and data reshaping and data organizing? I think so but someone who recently joined our group thinks not. I only do small scale projects and am by no means a programmer. Isn't Perl something for earings? That said, I find R to be extremely useful at data manipulation and have used it exclusively in my last three projects. The different data structures alone are worth their weight in gold, if for nothing else than making it harder to make stupid mistakes in coding. The new recruit believes that python or another language is a far better tool for developing data manipulation scripts that can be then used by several members of our research group. Her assessment is that R is useful only when it comes to data analysis and working with statistical models. Any reason that she thinks this? How well does she know R? It is not exactly a language that one picks up in a week, especially if one is coming from using a stats package like SAS or SPSS. As an ex-SAS and SYSTAT user it took me weeks to just get comfortable with the power of subscripting and the ability to do all kinds of calculations in-line. So what do you think: 1)R is a phenomenally powerful and flexible tool and since you are going to do analyses in R you might as well use it to read data in and merge it and reshape it to whatever you need. Definately. I am not a computer scientist or a statistician. I usually am working as a single contractor and normally with small datasets as part of a larger project. R does what I want, usually very elegantly (albeit perhaps after a lot of headbanging and calls for help to the R-list) and it would be stupid for me to use more than one language when it is not needed. Another plus is that I can easily leave my data analysis work and a working copy of R with the client. He/she may have a problem seeing what I did but it is clearly readable replicable by either the client or another consultant. OR 2) Are you crazy? Nobody in their right mind uses R to pipe the data around their lab and assemble it for analysis. Well I don't work in a lab but why complicate things? If everyone is using the same tools then you have a good situation. Others who do work in labs can address this point more cogently From a personnel point of view do you expect everyone in the lab to be proficient with R and, for example, Perl? What happens when/if you lose your Perl expert(s)? I've had occasions where I waited a week for data simply because the division's MS Access expert was on holiday and the only other Access person there only knew how to enter data and run the monthly reports. Anything more complicated required the expert. __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ __ 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. _ [[elided Hotmail spam]] [[alternative HTML version deleted]]
Re: [R] Do you use R for data manipulation?
Thanks Laura, I deal with huge data sets and have to do alot of fancy juggling of data to get the job done in R. I have recently been granted access to a cluster at a university which means 64 bit machines with 8gb of memory, which could prove to be a saviour hopefully. Simon. - Original Message - From: Laura Arsanto To: simon.pick...@bto.org Sent: Wednesday, May 06, 2009 3:09 PM Subject: RE: [R] Do you use R for data manipulation? dear simon, my job now is doing a benchmark between SAS and open source tools (like R, weka, etc) for data and text mining, so I'm using both of them. personally I would prefer using the open source tools and I really would do it if possible, but at the moment...they simply do not work! and 99% of cases because of the dimensions of data! From: simon.pick...@bto.org To: ghin...@hotmail.it; jrkrid...@yahoo.ca; r-h...@stat.math.ethz.ch; fjb...@gmail.com CC: ross.laza...@gmail.com; gregory_war...@urmc.rochester.edu; g...@warnes.net Subject: Re: [R] Do you use R for data manipulation? Date: Wed, 6 May 2009 15:01:33 +0100 My institute uses SAS religiously, I am the only R heathen. I have resisted learning to use SAS because I dont see the point after years of using R and I like being able to do everything using one program. However, my colleagues maintain that SAS is better for programming without really ever giving me a good reason why other than memory issues. dont want to hi-jack the thread but would be interested in hearing some other views, especially since my organisation spends (wastes?) alot of money every year on SAS licences... Simon. - Original Message - From: Laura Arsanto ghin...@hotmail.it To: jrkrid...@yahoo.ca; r-h...@stat.math.ethz.ch; fjb...@gmail.com Cc: ross.laza...@gmail.com; gregory_war...@urmc.rochester.edu; g...@warnes.net Sent: Wednesday, May 06, 2009 2:53 PM Subject: Re: [R] Do you use R for data manipulation? I used R for my master thesis (with big effort, anyway) and now I find difficult to use R in my daily work, becasue it has really serious problems with datasets of big dimension, both in the data manipulation step and in the analysis step. But I really would love to use it, as I like its transparence, compared to other software. Laura *** Date: Wed, 6 May 2009 06:42:45 -0700 From: jrkrid...@yahoo.ca To: r-h...@stat.math.ethz.ch; fjb...@gmail.com CC: ross.laza...@gmail.com; gregory_war...@urmc.rochester.edu; g...@warnes.net Subject: Re: [R] Do you use R for data manipulation? --- On Wed, 5/6/09, Farrel Buchinsky fjb...@gmail.com wrote: Is R an appropriate tool for data manipulation and data reshaping and data organizing? I think so but someone who recently joined our group thinks not. I only do small scale projects and am by no means a programmer. Isn't Perl something for earings? That said, I find R to be extremely useful at data manipulation and have used it exclusively in my last three projects. The different data structures alone are worth their weight in gold, if for nothing else than making it harder to make stupid mistakes in coding. The new recruit believes that python or another language is a far better tool for developing data manipulation scripts that can be then used by several members of our research group. Her assessment is that R is useful only when it comes to data analysis and working with statistical models. Any reason that she thinks this? How well does she know R? It is not exactly a language that one picks up in a week, especially if one is coming from using a stats package like SAS or SPSS. As an ex-SAS and SYSTAT user it took me weeks to just get comfortable with the power of subscripting and the ability to do all kinds of calculations in-line. So what do you think: 1)R is a phenomenally powerful and flexible tool and since you are going to do analyses in R you might as well use it to read data in and merge it and reshape it to whatever you need. Definately. I am not a computer scientist or a statistician. I usually am working as a single contractor and normally with small datasets as part of a larger project. R does what I want, usually very elegantly (albeit perhaps after a lot of headbanging and calls for help to the R-list) and it would be stupid for me to use more than one language when it is not needed. Another plus is that I can easily leave my data analysis work and a working copy of R with the client. He/she may have a problem seeing what I did but it is clearly readable replicable by either the client or another consultant. OR 2) Are you crazy?
Re: [R] joined R-today
Hi, Check out the FAQ on the home page about installing packages. You need to 1. Install the package from a local mirror, you can do this from the drop down menu (Install packages) 2. then call the package using library(name of the package) It helps to know where your R library directory is on your computer. HTH Simon. - Original Message - From: Bala subramanian bala.biophys...@gmail.com To: r-help@r-project.org Sent: Tuesday, April 21, 2009 9:34 AM Subject: [R] joined R-today Friends, I am a newbie to R. Just installed and started with R. I installed netcdf library (netcdf-4.0.tar.gz) and then ncdf package of R from CRAN with the following command. R CMD INSTALL --configure-args=-with-netcdf_incdir=/usr/local/netcdf/include -with-netcdf_libdir=/usr/local/netcdf/lib ncdf_1.6.tar.gz The installation was successful. But when i try to use ncdf inside R, i get the following error. Kindly help me how to resolve the problem. trjfile-system.file('test.netcdf',package='bio3d') trj-read.ncdf(trjfile) Loading required package: ncdf Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/lib/R/library/ncdf/libs/ncdf.so': /usr/lib/R/library/ncdf/libs/ncdf.so: cannot restore segment prot after reloc: Permission denied Error in read.ncdf(trjfile) : Please install the ncdf package from CRAN Thanks in advance, Bala [[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-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.
Re: [R] R graph into MS Word: which format to use?
I actually get superior results from creating a pdf, opening it in adobe acrobat, adjust the image size so it is big as possible with the screen, then copying it into word (by using the little square capture icon). HTH, Simon. - Original Message - From: jjh21 jjhar...@gmail.com To: r-help@r-project.org Sent: Monday, April 20, 2009 11:01 AM Subject: [R] R graph into MS Word: which format to use? Hello, The journal I am publishing in requires MS Word files. What is my best option for getting a high quality image of a graph done in R into Word? JPEG? Postscript? Thanks. -- View this message in context: http://www.nabble.com/R-graph-into-MS-Word%3A-which-format-to-use--tp23133745p23133745.html Sent from the R help mailing list archive at Nabble.com. __ 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-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] reading an image and adding a legend
Hi all, I would like to 1. Read in an arcmap image into R (I can export pretty much any type of image jpeg, bitmap etc from arcmap) 2. Use R to create a nice colour legend in the plot First of all, Is this possible? So far I'm stuck on point 1. I have tried read.pnm() from pixmap and read.jpeg() from rgl. the pnm example provided works fine x - read.pnm(system.file(pictures/logo.ppm, package=pixmap)[1]) plot(x) #draws an R logo, nice :-) But my code returns an error x-read.pnm(C:/Documents and Settings/simonp/My Documents/Simon BTO/RELU/GIS data/ten km areas in analysis.bmp) Error in pm.readmagicnumber(con) : Not a PNM format file I have tried changing the dpi when I export the image but still no cigar. I have dredged the help forum for related files and read the help files. My Os is windows XP and i'm running 2.8.1. I feel I'm missing something obvious! Thanks Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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.
Re: [R] Manual sort in a for loop
I would suggest avoiding the function ?assign inside a loop. I used top use this until someone here kindly pointed out that it was much easier to catch the data of interest in a list... eg. df.list - vector(list, length(10)) for (i in 1:10)} df.list[[i]]-data.frame(arunoff_,table_year,_temp)[c(10,7,9,5,4,12,1,3,2,8,11,6),] } HTH Simon. - Original Message - From: Steve Murray smurray...@hotmail.com To: r-help@r-project.org Sent: Wednesday, March 25, 2009 5:58 PM Subject: [R] Manual sort in a for loop Dear all, I am trying to manually re-sort rows in a number of tables. The rows aren't sorted on any particular values but are simply ordered by user choice (as shown by the row numbers in the code). I have been able to carry out each re-arrangement without the use of the 'for' loop, but cannot seem to successfully execute the statements when incorporated into the loop. The code I have is as follows: table_year=1951 for (i in (paste(arunoff_,year,_temp,sep=))) { assign(paste(arunoff_,table_year, sep=),paste(arunoff_,table_year,_temp)[c(10,7,9,5,4,12,1,3,2,8,11,6),]) table_year = table_year+1 } The error I get is: Error in paste(arunoff_, table_year, _temp)[c(10, 7, 9, 5, 4, 12, : incorrect number of dimensions ...depsite this not occurring when I do each table individually (so it can't be a case of there not being enough rows, as dim(arunoff_1951_temp) gives [1] 12 11 I have a feeling that it may be a syntax error, possibly between 'temp' and the square bracket, but I can't be sure of this. Any solutions or advice offered would be gratefully received. Many thanks, Steve _ [[elided Hotmail spam]] __ 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-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.
Re: [R] Merging
Hi, I'm pretty sure you dont mean merge since merge() creates a new big data frame from two small ones. It appears that you want to omit some rows. As I said before, get used to selecting rows like this data.frame-data.frame[data.frame$conditional.rows1000,] (for example) Although I dont have a clue what criteria you are using to select the rows you want... Simon. Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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-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.
Re: [R] who can give me some hint?
Hi All, act_2 DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle I want to change act_2 to DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle in other word, I want to keep 1st if there are many repeated value, I made the program as: Not sure what you mean here, can you describe this more fully? It seems that you might be able to avoid using loops if all you want to do is select only the rows where column x is less than a threshold value. e.g. a-a[a$columnx1000,] Hope this helps Simon. rm_r-function(act_2){ dm-dim(act_2)[1]-1 for(i in 2:dm){ if(act_2$Rep[i+1]==act_2$Rep[i]){ act_2-act_2[-(i+1),] }else{ act_2-act_2 } } return(act_2) } when it moved one row on 1st loop, i should still start 2 but it become 3 at 2nd loop, if I add i-i-1, then i go to 1 seems not reasonbale. How should I modify it`? Tammy _ Drag n' drop-Get easy photo sharing with Windows LiveT Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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-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.
Re: [R] Mixed models fixed effects
Also check out these pdfs http://cran.r-project.org/other-docs.html and try to get your hands on the bible http://www.amazon.co.uk/R-Book-Michael-J-Crawley/dp/0470510242 Simon. Hi Emma, Continuous predictors are no problem at all. You can mix both continuous and categorial predictors if needed. I suppose your response are counts (the number of bats that passes)? In that case a generalised linear mixed model is more appropriate. With the lme4 package you could try something like this: library(lme4) Model - glmer(BatPasses ~ Width + Height + (1|Site), family = poisson) HTH, Thierry PS There is a mailing list dedicated to mixed models: R-Sig-MixedModels ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Emma Stone Verzonden: woensdag 11 maart 2009 15:29 Aan: r-help@r-project.org Onderwerp: Re: [R] Mixed models fixed effects Dear All, This may sound like a dumb question but I am trying to use a mixed model to determine the predictors of bat activity along hedges within 8 sites. So my response is continuous (bat passes) my predictors fixed effects are continuous (height metres), width (metres) etc and the random effect is site - can you tell me if the fixed effects can be continuous as all the examples I have read show them as categorical, but this is not covered in any documents I can find. Help! Emma __ 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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-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] help structuring mixed model using lmer()
Hi all, This is partly a statistical question as well as a question about R, but I am stumped! I have count data from various sites across years. (Not all of the sites in the study appear in all years). Each site has its own habitat score habitat that remains constant across all years. I want to know if counts declined faster on sites with high habitat scores. I can construct a model that tests for the effect of habitat as a main effect, controlling for year model1-lmer(count~habitat+yr+(1|site), family=quasibinomial,data=m) model2-lmer(count~yr+(1|site), family=quasibinomial,data=m) anova(model1,model2) , but how do I test the interaction? Thanks in advance, Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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.
Re: [R] help structuring mixed model using lmer()
Cheers, Actually I was using quasipoisson for my models, but for the puposes of my example, it doesnt really matter. I am trying to work out a way of quantifying whether the slopes (for years) are covary with habitat scores. The more I think about it, the more I am convinced that it isnt possible do to that using a glm approach. I think I have to run separate models for each site, calculate the gradient, then do a lm with gradient explained by habitat score Thanks, Simon. On Tue, Mar 10, 2009 at 10:15 AM, Simon Pickett simon.pick...@bto.org wrote: This is partly a statistical question as well as a question about R, but I am stumped! I have count data from various sites across years. (Not all of the sites in the study appear in all years). Each site has its own habitat score habitat that remains constant across all years. I want to know if counts declined faster on sites with high habitat scores. I can construct a model that tests for the effect of habitat as a main effect, controlling for year model1-lmer(count~habitat+yr+(1|site), family=quasibinomial,data=m) model2-lmer(count~yr+(1|site), family=quasibinomial,data=m) anova(model1,model2) I'm curious as to why you use the quasibinomial family for count data. When you say count data do you mean just presence/absence or an actual count of the number present? Generally the binomial and quasibinomial families are used when you have a binary response, and the poisson or quasipoisson family are used for responses that are counts. __ 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.
Re: [R] Inference for R Spam
I got the same spam message today and I havent signed up for anything except this forum mailing list. The software they are trying to sell doesnt seem to cover any new ground anyway. Simon. - Original Message - From: Thomas Lumley tlum...@u.washington.edu To: ronggui ronggui.hu...@gmail.com Cc: r-h...@stat.math.ethz.ch Sent: Tuesday, February 24, 2009 1:39 PM Subject: Re: [R] Inference for R Spam The same company caused a complaint about a year ago https://stat.ethz.ch/pipermail/r-help/2008-March/157423.html The mailing company they are using (iContact.com) claims to have a tough antispam policy. So does everyone, of course. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.edu University of Washington, Seattle __ 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-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.
Re: [R] write.table
Hi Laura, You need to specify where you want to write your table. Like this... write.table(result, file=C:/Documents and Settings/simonp/Desktop/result.csv, sep = ,,row.names = F) If you have to do this alot I think you can set your working drive up to always write table in the same place... setwd(C:/Documents and Settings/simonp/Desktop/) If you wanna get really smart you can download a pckage called RDCOMClient from the omegahat repository. This enables you to open tables and view them on screen using excel (amongst a plethora of other things) Hope this helps? S - Original Message - From: lauramorg...@bluewin.ch To: r-help@r-project.org Sent: Friday, February 20, 2009 7:56 AM Subject: [R] write.table Hello, I tried to turn lists into vectors and then bind them together in order to create a dataframe but if, after this, I try to use the function write.table I get the following error message: Error in write.table(x, file, nrow(x), p, rnames, sep, eol, na, dec, as.integer(quote), : 'list' type not implemented in 'EncodeElement' Here is what I've done: as.vector(c(unique(portate$Anno)))-anno as.vector(loadListPO4)-loadPO4 as.vector(loadListPTG)-loadPTG as.vector(loadListNT)-loadNT as.vector(loadListNH4)-loadNH4 as.vector(loadListNO3)-loadNO3 as.vector(loadListBOD5)-loadBOD5 as.vector(loadListSiO2)-loadSiO2 cbind(anno,loadPTG,loadPO4,loadNT,loadNH4,loadNO3,loadBOD5,loadSiO2)-carichi as.data.frame(carichi)-carichi.annui #if I type carichi.annui #I get anno loadPTG loadPO4 loadNT loadNH4 loadNO3 loadBOD5 loadSiO2 1 2002 3.399518 1.382235 390.6959 22.07992 256.2244 492.9177 150.6505 2 2003 1.559606 0.6271712 202.9181 6.198592 145.9498 63.07578 68.08632 3 2004 2.363862 0.9493779 292.0841 12.21207 200.2545 141.0533 105.2409 4 2005 1.64 0.6570313 217.2192 6.58045 155.7393 66.44154 73.0394 5 2006 1.827174 0.7290634 235.7914 7.858396 166.8327 79.2474 80.92576 6 2007 1.742629 0.6891045 228.0253 7.130082 162.6692 71.91434 77.22507 7 2008 0.8382246 0.3612176 110.9079 2.024197 86.60459 25.46127 32.9733 #which looks lika a data frame #And if I type is.data.frame(carichi.annui) # I get this: [1] TRUE #but if I try write.table(carichi.annui, carichi.annui.lav) #It doesn't work?!?!?! Does someone have an explanation? Thanks a lot for any help!! Laura __ 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-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.
Re: [R] plotting questions
Hi Oliver, 1) thats easy, if you want to display several graphs at once type windows(), once for each new graph. 2) Not sure exactly what you mean here but you have complete control over graphs in R. e.g. plot a blank graph then add axex using axis(), add points using points(), etc. etc. Check out these pdfs http://cran.r-project.org/other-docs.html particularly Emanuel Paradis's great intro to using R, very helpful for plots. Hope this helps, Si. - Original Message - From: Oliver fwa...@gmail.com To: r-help@r-project.org Sent: Friday, February 20, 2009 3:33 AM Subject: [R] plotting questions hi, There are two types of plotting I miss dearly in Matlab, can anyone enlighten me how to do similar stuff in R? - multiple figures with individual windows (not multiple figures in same window)? - draw something, hold on the drawing, wait for a key action, then overlay on top? Not sure if this makes sense, just want to check if there are developed techniques for them. Thanks Oliver __ 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-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] type III effect from glm()
Hi all, This could be naivety/stupidity on my part rather than a problem with model output, but here goes I have fitted a fairly simple model m1-glm(count~siteall+yrs+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) I want to know if yrs (a continuous variable) has a significant unique effect in the model, so I fit a simplified model with the main effect ommitted... m2-glm(count~siteall+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) then compare models using anova() anova(m1,m1b,test=F) Analysis of Deviance Table Model 1: count ~ siteall + yrs + yrs:district Model 2: count ~ siteall + yrs:district Resid. Df Resid. Dev Df Deviance F Pr(F) 1 1936 75913 2 1936 7591300 The d.f.'s are exactly the same, is this right? Can I only test the significance of a main effect when it is not in an interaction? Thanks in advance, Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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.
Re: [R] type III effect from glm()
Sorry, that was a typo in the email, not the model. So I still have the problem. Cheers, Simon. - Original Message - From: Ted Harding ted.hard...@manchester.ac.uk To: Simon Pickett simon.pick...@bto.org; r-help@r-project.org Sent: Thursday, February 19, 2009 10:56 AM Subject: RE: [R] type III effect from glm() On 19-Feb-09 10:38:50, Simon Pickett wrote: Hi all, This could be naivety/stupidity on my part rather than a problem with model output, but here goes I have fitted a fairly simple model m1-glm(count~siteall+yrs+yrs:district,family=quasipoisson, weights=weight,data=m[x[[i]],]) I want to know if yrs (a continuous variable) has a significant unique effect in the model, so I fit a simplified model with the main effect ommitted... m2-glm(count~siteall+yrs:district,family=quasipoisson, weights=weight,data=m[x[[i]],]) So, above, you have fitted two models: m1, m2 then compare models using anova() anova(m1,m2,test=F) And here you are comparing two models: m1, m1b Could this be the reason for your result? Analysis of Deviance Table Model 1: count ~ siteall + yrs + yrs:district Model 2: count ~ siteall + yrs:district Resid. Df Resid. Dev Df Deviance F Pr(F) 1 1936 75913 2 1936 7591300 The d.f.'s are exactly the same, is this right? Can I only test the significance of a main effect when it is not in an interaction? Thanks in advance, Simon. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 19-Feb-09 Time: 10:56:12 -- XFMail -- __ 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.
Re: [R] type III effect from glm()
Cheers Mark, I did originally think too, i.e. that not including the main effect was the problem. However, the same thing happens when I include main effects test1-glm(count~siteall+yrs*district,family=quasipoisson,weights=weight,data=m[x[[i]],]) test2-glm(count~siteall+district+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) anova(test1,test2,test=F) Model 1: count ~ siteall + yrs * district Model 2: count ~ siteall + district + yrs:district Resid. Df Resid. Dev Df Deviance F Pr(F) 1 1933 75665 2 1933 7566500 Simon. - Original Message - From: markle...@verizon.net To: Simon Pickett simon.pick...@bto.org Sent: Thursday, February 19, 2009 10:50 AM Subject: RE: [R] type III effect from glm() Hi Simon: John Fox can say a lot more about below but I've been reading his book over and over recently and one thing he constantly stresses is marginality which he defines as always including the lower order term if you include it in a higher order term. So, I think below is problematic because you are including an interaction that includes the main effect but not including the main effect. This definitely causes problems when trying to interpret the anova table or the Anova table. That's as much as I can say. I highly recommed his text for this sort of thing and hopefully he will respond. Oh, my point is that if you want to check the effect of yrs, then I think you have to take it out of model 2 totally in order to interpret the anova ( or the Anova ) table. On Thu, Feb 19, 2009 at 5:38 AM, Simon Pickett wrote: Hi all, This could be naivety/stupidity on my part rather than a problem with model output, but here goes I have fitted a fairly simple model m1-glm(count~siteall+yrs+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) I want to know if yrs (a continuous variable) has a significant unique effect in the model, so I fit a simplified model with the main effect ommitted... m2-glm(count~siteall+yrs:district,family=quasipoisson,weights=weight,data=m[x[[i]],]) then compare models using anova() anova(m1,m1b,test=F) Analysis of Deviance Table Model 1: count ~ siteall + yrs + yrs:district Model 2: count ~ siteall + yrs:district Resid. Df Resid. Dev Df Deviance F Pr(F) 1 1936 75913 2 1936 75913 0 0 The d.f.'s are exactly the same, is this right? Can I only test the significance of a main effect when it is not in an interaction? Thanks in advance, Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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-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.
Re: [R] Unadulterated plot
Hi James, What you really need to do is to check out the many freely available pdfs for R beginners. Here is a good place to start http://cran.r-project.org/other-docs.html If I am right interpreting what you want, I think you need to create a blank plot with no axes, axis labels etc. Try plot(x,y,xlab=,ylab=,xaxt=NULL,yaxt=NULL,type=n) #blank plot points(x,y) type ?par into R and see how you can set parameters like this up as the default. Hope this helps? Simon. - Original Message - From: James Nicolson jlnicol...@gmail.com To: r-help@r-project.org Sent: Sunday, February 15, 2009 10:29 PM Subject: [R] Unadulterated plot To all, Apologies if this question has already been asked but I can't find anything. I can't seem to think of more specific search terms. I want to display/create a file of a pure plot with a specific height and width. I want to utilise every single pixel inside the axes. I do not want to display any margins, legends, axes, titles or spaces around the edges. Is this possible? Additionally, the plot I am working with is a filled.contour plot and I can not remove the legend? How can I do this? Kind Regards, James __ 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-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.
Re: [R] How to split a character vector into 3 vectors
someone has probably answered this already but use substr() new variable-substr(old.variable,1,1) Simon. - Original Message - From: kayj kjaj...@yahoo.com To: r-help@r-project.org Sent: Tuesday, February 10, 2009 6:50 PM Subject: [R] How to split a character vector into 3 vectors Hi , Does any one know how to split a character vector , I have a vector X that looks like this and each row has 3 characters X ASK DGH ASG AUJ FRT I would like to split the vector into 3 vectors that look like this X1 X2 X3 A S K D G H A S G A U J U R T thanks -- View this message in context: http://www.nabble.com/How-to-split-a-character-vector-into-3-vectors-tp21939492p21939492.html Sent from the R help mailing list archive at Nabble.com. __ 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-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 editor in R- could it be improved?
Hi all, I've used R for basic programming and data management for a few years now. One of the things that I think could be improved is the data editor. Its a great feature and I use it alot by calling edit(data.frame); very useful to see if what you tried to do actually worked. However, one of the annoying things about it is that when you scroll down the window it doesnt show you all the data (for a large data frame), just subsets of it. It would also be quite useful if the width of the columns could be adjusted or didnt default to the size of the name of the column. (since the names might often be very big if the data frame was created using a function). Side-ways scrolling is quite jerky too. Just wondered if this was on anyone else's wish list? Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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] help using zeroinfl()
Hi all, I have been trying to use zeroinfl() with the pscl package with R version 2.1.1. and with the newest versions of the contrib packages compatible with R 2.1.1. I have read the examples, the vignette and all the posts relating to zeroinfl() but I am still confused as to how to structure the model. Here is a small example; the error message is the same for big data sets library(mvtnorm,lib.loc=C:/Documents and Settings/simonp/My Documents/R backup library) library(pscl,lib.loc=C:/Documents and Settings/simonp/My Documents/R backup library) y-c(0,0.2,0.4,0.7,0,0,0,0.8,0,0,0,0,0) x-c(3,4,5,2,3,6,3,7,4,8,5,8,3) m1-zeroinfl(y~x|x) Zero-Inflated Count Model Using logit to model zero vs non-zero Using Poisson for counts Error in terms.formula(formula, data = data) : argument is not a valid model Can anyone shed any light please? Simon. Dr. Simon Pickett Research Ecologist Land Use Department Terrestrial Unit British Trust for Ornithology The Nunnery Thetford Norfolk IP242PU 01842750050 [[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] creating a list of matrices or data frames
Hi all, How would you create a list of data.frames within a loop, then bind all the elements of the list using rbind? take this example of matrices with differing numbers of rows for(i in 1:3){ assign(paste(s,i, sep=),matrix(data = NA, nrow = i, ncol = 3, byrow = FALSE, dimnames = NULL)) } s1 s2 s3 I want to bind all the matrices at the end with do.call(rbind...) rather than listing all the elements manually with rbind(s1,s2,s3...) and so on. thanks in advance. Simon. __ 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] faster version of split()?
Hi all, I want to calculate the number of unique observations of y in each level of x from my data frame df. this does the job but it is very slow for this big data frame (159503 rows, 11 columns). group.list - split(df$y,df$x) count - function(x) length(unique(na.omit(x))) sapply(group.list, count, USE.NAMES=TRUE) I couldnt find the answer searching for slow split and split time on help forum. I am running R version 2.2.1, on a machine with 4gb of memory and I'm using windows 2000. thanks in advance, Simon. - Original Message - From: Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no To: Gundala Viswanath gunda...@gmail.com Cc: R help r-h...@stat.math.ethz.ch Sent: Friday, January 16, 2009 9:30 AM Subject: Re: [R] Value Lookup from File without Slurping you might try to iteratively read a limited number of line of lines in a batch using readLines: # filename, the name of your file # n, the maximal count of lines to read in a batch connection = file(filename, open=rt) while (length(lines - readLines(con=connection, n=n))) { # do your stuff here } close(connection) ?file ?readLines vQ Gundala Viswanath wrote: Dear all, I have a repository file (let's call it repo.txt) that contain two columns like this: # tag value AAA0.2 AAT0.3 AAC 0.02 AAG 0.02 ATA0.3 ATT 0.7 Given another query vector qr - c(AAC, ATT) I would like to find the corresponding value for each query above, yielding: 0.02 0.7 However, I want to avoid slurping whole repo.txt into an object (e.g. hash). Is there any ways to do that? The reason I want to do that because repo.txt is very2 large size (milions of lines, with tag length 30 bp), and my PC memory is too small to keep 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-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.
Re: [R] Two Noobie questions
Allen, I would suggest reading about the str() function. It's great for getting inside model outputs and seeing how they are constructed so you can extract all the specific calculations you want. Its a bit fiddly to get used to but there are plenty of examples on this forum. Hope this helps. Simon. - Original Message - From: AllenL allen.laroc...@gmail.com To: r-help@r-project.org Sent: Tuesday, January 06, 2009 7:47 PM Subject: Re: [R] Two Noobie questions Thanks for your help! I combined the above two to get the following, which seems to work (if somewhat inelegant): int.List-unlist(lapply(lmList, function(x) {coef(x)[1]}),use.names=FALSE) lmList is my list of lm objects. -Allen David Winsemius wrote: On Jan 6, 2009, at 1:50 PM, AllenL wrote: 1. I have a list of lm (linear model) objects. Is it possible to select, through subscripts, a particular element (say, the intercept) from all the models? I've tried something like this: ?coef if your list of models is ml, then perhaps something like this partially tested idea: lapply(ml, function(x) coef(x)[1] ) This is what I get using that formulation an available logistic model: coef(lr.TC_HDL_BMI)[1] Intercept -6.132448 List[[1:length(list)]][1] All members of the list are similar. My goal is to have a list of the intercepts and lists of other estimated parameters. Is it better to convert to a matrix? How to do this? 2. Connected to this, how do I convert from a list back to a vector? This problem arose from using split to split a vector by a factor, then selecting a subset of this (ie. length10), leaving me with subset list of my original. Unsplit(newList, factor) doesn't work, presumably due to my removal of some values. Thoughts? ?unlist ll - list(1,2,3,4) ll [[1]] [1] 1 [[2]] [1] 2 [[3]] [1] 3 [[4]] [1] 4 unlist(ll) [1] 1 2 3 4 str(unlist(ll)) num [1:4] 1 2 3 4 is.vector(unlist(ll)) [1] TRUE -- David Winsemius Thanks! -Allen -- View this message in context: http://www.nabble.com/Two-Noobie-questions-tp21316554p21316554.html Sent from the R help mailing list archive at Nabble.com. __ 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-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. -- View this message in context: http://www.nabble.com/Two-Noobie-questions-tp21316554p21317630.html Sent from the R help mailing list archive at Nabble.com. __ 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-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.
Re: [R] R in the NY Times
I would like to add that I would have spent many more years doing my PhD if it wasnt for R! all data management, statistics and graphics were conducted using it. This was the direction my university and many more research institutes appear to be heading. It probably doesnt get said enough and I am sure I speak for all young researchers I am very much in debt for all the kind souls who have helped me and other newbies on this forum over the years, Thanks very much R team. - Original Message - From: Frank E Harrell Jr f.harr...@vanderbilt.edu To: Bill Pikounis billpikou...@gmail.com Cc: r-help@r-project.org Sent: Wednesday, January 07, 2009 2:25 PM Subject: Re: [R] R in the NY Times Bill Pikounis wrote: Pardon my exuberance, but this is simply awesome. What a treat to find on the front web page of the NY Times this morning under Technology. I think the article is very well written by the author, and I think it captures top highlights of why the software and community are so special. Continued high gratitude to all of R-core and the R community for its unique accomplishments. Every bit of praise is well-earned and deserved. I have continuously claimed to colleagues (primarily pharma industry) for the past 8 years or so that R is the most exciting going on in the area of statistics. Thanks, Bill Amen to that, and in addition, R is now the top tool for everyday analysis, not just a research statistician's tool. Frank Bill Pikounis Statistician On Wed, Jan 7, 2009 at 08:10, Zaslavsky, Alan M. zasla...@hcp.med.harvard.edu wrote: This article is accompanied by nice pictures of Robert and Ross. Data Analysts Captivated by Power of R http://www.nytimes.com/2009/01/07/technology/business-computing/07program.html January 7, 2009 Data Analysts Captivated by R's Power By ASHLEE VANCE __ 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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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-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.
Re: [R] Changing Matrix Header
Hi Gundala, try chopping off the top row like newx-as.matrix(x[2:dim(x)[1],]) OR try changing it to a data frame... new x-data.frame(x,row.names=NULL) #pretty sure its not row.names but there is probably an equivalent for col.names OR look into ?read.table and specify header = F Cheers, Si. - Original Message - From: Gundala Viswanath gunda...@gmail.com To: r-h...@stat.math.ethz.ch Sent: Tuesday, January 06, 2009 8:14 AM Subject: [R] Changing Matrix Header Dear all, I have the following matrix. dat A A A A A A A A A A [1,] 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 1 [3,] 0 0 0 0 0 0 0 0 0 2 How can I change it into: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0 0 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 0 1 [3,] 0 0 0 0 0 0 0 0 02 I tried: as.matrix(x) But failed. - Gundala Viswanath Jakarta - Indonesia __ 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-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.
Re: [R] Large Dataset
type ?memory into R and that will explain what to do... S - Original Message - From: Edwin Sendjaja edw...@web.de To: r-help@r-project.org Sent: Tuesday, January 06, 2009 11:41 AM Subject: [R] Large Dataset Hi alI, I have a 3.1 GB Dataset ( with 11 coloumns and lots data in int and string). If I use read.table; it takes very long. It seems that my RAM is not big enough (overload) I have 3.2 RAM and 7GB SWAP, 64 Bit Ubuntu. Is there a best sultion to read a large data R? I have seen, that people suggest to use bigmemory package, ff. But it seems very complicated. I dont know how to start with that packages. i have tried to use bigmemory. But I got some kind of errors. Then I gave up. can someone give me an simple example how ot use ff or bigmemory?or maybe re better sollution? Thank you in advance, Edwin __ 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-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.
Re: [R] Large Dataset
Only a couple of weeks ago I had to deal with this. adjust the memory limit as follows, although you might not want 4000, that is quite high memory.limit(size = 4000) Simon. - Original Message - From: Edwin Sendjaja edw...@web.de To: Simon Pickett simon.pick...@bto.org Cc: r-help@r-project.org Sent: Tuesday, January 06, 2009 12:24 PM Subject: Re: [R] Large Dataset Hi Simon, Thank for your reply. I have read ?Memory but I dont understand how to use. I am not sure if that can solve my problem. Can you tell me more detail? Thanks, Edwin type ?memory into R and that will explain what to do... S - Original Message - From: Edwin Sendjaja edw...@web.de To: r-help@r-project.org Sent: Tuesday, January 06, 2009 11:41 AM Subject: [R] Large Dataset Hi alI, I have a 3.1 GB Dataset ( with 11 coloumns and lots data in int and string). If I use read.table; it takes very long. It seems that my RAM is not big enough (overload) I have 3.2 RAM and 7GB SWAP, 64 Bit Ubuntu. Is there a best sultion to read a large data R? I have seen, that people suggest to use bigmemory package, ff. But it seems very complicated. I dont know how to start with that packages. i have tried to use bigmemory. But I got some kind of errors. Then I gave up. can someone give me an simple example how ot use ff or bigmemory?or maybe re better sollution? Thank you in advance, Edwin __ 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-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.
Re: [R] Large Dataset
Yup, it was a typo. But I always try capital if lower case doesnt work, Sorry. - Original Message - From: David Winsemius dwinsem...@comcast.net To: Simon Pickett simon.pick...@bto.org Cc: Edwin Sendjaja edw...@web.de; r-help@r-project.org Sent: Tuesday, January 06, 2009 12:40 PM Subject: Re: [R] Large Dataset When I do it on a Mac installation I get: Help for the topic memory was not found. Is that a Linux-specific function? Or perhaps you meant to type: ?Memory Which does produce useful information. -- David Winsemius sessionInfo() R version 2.8.0 Patched (2008-11-14 r46932) i386-apple-darwin9.5.0 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] vcd_1.2-1colorspace_1.0-0 MASS_7.2-45 rattle_2.4.0 loaded via a namespace (and not attached): [1] tools_2.8.0 On Jan 6, 2009, at 6:43 AM, Simon Pickett wrote: type ?memory into R and that will explain what to do... S - Original Message - From: Edwin Sendjaja edw...@web.de To: r-help@r-project.org Sent: Tuesday, January 06, 2009 11:41 AM Subject: [R] Large Dataset Hi alI, I have a 3.1 GB Dataset ( with 11 coloumns and lots data in int and string). If I use read.table; it takes very long. It seems that my RAM is not big enough (overload) I have 3.2 RAM and 7GB SWAP, 64 Bit Ubuntu. Is there a best sultion to read a large data R? I have seen, that people suggest to use bigmemory package, ff. But it seems very complicated. I dont know how to start with that packages. i have tried to use bigmemory. But I got some kind of errors. Then I gave up. can someone give me an simple example how ot use ff or bigmemory?or maybe re better sollution? Thank you in advance, Edwin __ 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-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-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.
Re: [R] Large Dataset
Hi, I am not very knowledgeable about this kind of stuff but my guess is that if you have a fairly slow computer and massive data sets there isnt alot you can do except get a better computer, buy more RAM or use something like SAS instead? Hopefully someone else will chip in Edwin, best of luck. Simon. - Original Message - From: Edwin Sendjaja edw...@web.de To: Simon Pickett simon.pick...@bto.org Cc: r-help@r-project.org Sent: Tuesday, January 06, 2009 2:53 PM Subject: Re: [R] Large Dataset Hi Simon, My RAM is only 3.2 GB (actually it should be 4 GB, but my Motherboard doesnt support it. R use almost of all my RAM and half of my swap. I think memory.limit will not solve my problem. It seems that I need RAM. Unfortunately, I can't buy more RAM. Why R is slow reading big data set? Edwin Only a couple of weeks ago I had to deal with this. adjust the memory limit as follows, although you might not want 4000, that is quite high memory.limit(size = 4000) Simon. - Original Message - From: Edwin Sendjaja edw...@web.de To: Simon Pickett simon.pick...@bto.org Cc: r-help@r-project.org Sent: Tuesday, January 06, 2009 12:24 PM Subject: Re: [R] Large Dataset Hi Simon, Thank for your reply. I have read ?Memory but I dont understand how to use. I am not sure if that can solve my problem. Can you tell me more detail? Thanks, Edwin type ?memory into R and that will explain what to do... S - Original Message - From: Edwin Sendjaja edw...@web.de To: r-help@r-project.org Sent: Tuesday, January 06, 2009 11:41 AM Subject: [R] Large Dataset Hi alI, I have a 3.1 GB Dataset ( with 11 coloumns and lots data in int and string). If I use read.table; it takes very long. It seems that my RAM is not big enough (overload) I have 3.2 RAM and 7GB SWAP, 64 Bit Ubuntu. Is there a best sultion to read a large data R? I have seen, that people suggest to use bigmemory package, ff. But it seems very complicated. I dont know how to start with that packages. i have tried to use bigmemory. But I got some kind of errors. Then I gave up. can someone give me an simple example how ot use ff or bigmemory?or maybe re better sollution? Thank you in advance, Edwin __ 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-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.
Re: [R] Large Dataset
Increase the memory as much as you can, read in the data, (however long it takes) then aggregate the data into smaller chunks, selecting only the bits you want. Remove the big original data set from memory (using rm()) and keep (or save the smaller aggregated data using wite.table()) If this doesnt work you may be out of luck I am afraid. Sorry i cant be of more help but it seems that if you want to deal with collosal data sets, you need to get the right tools for the job (i.e. a better computer or more suitable software) Simon. - Original Message - From: Edwin Sendjaja edw...@web.de To: Simon Pickett simon.pick...@bto.org Cc: r-help@r-project.org Sent: Tuesday, January 06, 2009 5:04 PM Subject: Re: [R] Large Dataset Hi Simons, Is SAS more powerfull than R? Well, I think I cannot afford to buy SAS. actually, my computer isn't really slow. I think 4GB RAM is big enough for personal PC. I am just wondering, why R running so slow with these specs to handling 3 GB data set. What if the data set were 1 TB?mmm.. Edwin Hi, I am not very knowledgeable about this kind of stuff but my guess is that if you have a fairly slow computer and massive data sets there isnt alot you can do except get a better computer, buy more RAM or use something like SAS instead? Hopefully someone else will chip in Edwin, best of luck. Simon. - Original Message - From: Edwin Sendjaja edw...@web.de To: Simon Pickett simon.pick...@bto.org Cc: r-help@r-project.org Sent: Tuesday, January 06, 2009 2:53 PM Subject: Re: [R] Large Dataset Hi Simon, My RAM is only 3.2 GB (actually it should be 4 GB, but my Motherboard doesnt support it. R use almost of all my RAM and half of my swap. I think memory.limit will not solve my problem. It seems that I need RAM. Unfortunately, I can't buy more RAM. Why R is slow reading big data set? Edwin Only a couple of weeks ago I had to deal with this. adjust the memory limit as follows, although you might not want 4000, that is quite high memory.limit(size = 4000) Simon. - Original Message - From: Edwin Sendjaja edw...@web.de To: Simon Pickett simon.pick...@bto.org Cc: r-help@r-project.org Sent: Tuesday, January 06, 2009 12:24 PM Subject: Re: [R] Large Dataset Hi Simon, Thank for your reply. I have read ?Memory but I dont understand how to use. I am not sure if that can solve my problem. Can you tell me more detail? Thanks, Edwin type ?memory into R and that will explain what to do... S - Original Message - From: Edwin Sendjaja edw...@web.de To: r-help@r-project.org Sent: Tuesday, January 06, 2009 11:41 AM Subject: [R] Large Dataset Hi alI, I have a 3.1 GB Dataset ( with 11 coloumns and lots data in int and string). If I use read.table; it takes very long. It seems that my RAM is not big enough (overload) I have 3.2 RAM and 7GB SWAP, 64 Bit Ubuntu. Is there a best sultion to read a large data R? I have seen, that people suggest to use bigmemory package, ff. But it seems very complicated. I dont know how to start with that packages. i have tried to use bigmemory. But I got some kind of errors. Then I gave up. can someone give me an simple example how ot use ff or bigmemory?or maybe re better sollution? Thank you in advance, Edwin __ 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-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.
Re: [R] I need course in R
R is not as daunting as it first seems and you might get by without having to get formal training. Speaking as someone who taught themselves to use R for statistics, graphics and data manipulation, I found that the Introduction to R book (the small yellow one) and the numerous pdfs available online are fantastic and walk you through the very basics (the one by Emanuel Paradis is excellent). So, as long as you can read and understand English there are alot of free resources out there (maybe there are some of these already translated to other languages, I dont know). It is a steep learning curve, but once you get to grips with the basics, I've found that I can find out everything else I need to know by searching these archives... Hope this helps, Simon Pickett. - Original Message - From: Uwe Ligges lig...@statistik.tu-dortmund.de To: xavier ordoñez rlistxa...@gmail.com Cc: R help r-h...@stat.math.ethz.ch Sent: Friday, December 19, 2008 10:24 AM Subject: Re: [R] I need course in R xavier ordoñez wrote: I am interested to take a course in R. Someone know of some course in europe for the first semester of the next year?. Yes, some, but hard to suggest commercial companies or universities and certain courses, because it depends on so many facts: - the languages you understand - the European regions that are fine for you to travel to - the level and kind of R stuff you expect in the course (basics, applications in a certain field, or just programming) - your a priori knowledge about statistics Best wishes, Uwe Ligges Happy Year Thank you, Xavier [[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-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-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.
Re: [R] Akaike weight in R
I'm pretty sure you have to work it out yourself. Here is an example of how you would tabulate the AIC weights from three models (check that my calculations are correct before using this yourself!). Basically model.name$aic will cut out the AIC values then write a formula to calculate the weights... m1-glm(trantot~unimpgrass+impgrass,family=poisson,data=bbs[bbs$species==unique(bbs$species)[1],]) m2-glm(trantot~marginwidth,family=poisson,data=bbs[bbs$species==unique(bbs$species)[1],]) m3-glm(trantot~impgrass,family=poisson,data=bbs[bbs$species==unique(bbs$species)[1],]) aics-data.frame(paste(m,1:3,sep=),c(m1$aic,m2$aic,m3$aic),row.names=NULL) colnames(aics)-c(model,AIC) aics-aics[order(-aics$AIC),] for(i in 1:dim(aics)[1]){ aics$diff[i]-aics$AIC[1]-aics$AIC[i]} aics$wi-2.71828182845904523536^(-0.5*aics$diff) aics$aic.weights-aics$wi/sum(aics$wi) - Original Message - From: Odette Gaston odette.gas...@gmail.com To: r-help@r-project.org Sent: Friday, December 19, 2008 11:26 AM Subject: [R] Akaike weight in R Hi folks, Wondering how can I generate Akaike weight with R? I know the description, but is there any function to generate by R on the web-site or R library? I am using GLM or GLMM (family=binomial), so would be appreciated if you help me. Thanks for your contributions in advance, Regards, Odette [[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-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.
Re: [R] re ad.table
probably best just to change each variable one by one to the correct classification after you have read the data frame in. variable-as.character(variable) - Original Message - From: threshold r.kozar...@gmail.com To: r-help@r-project.org Sent: Friday, December 19, 2008 12:35 PM Subject: [R] re ad.table Hi , I want to use the read.table to the following example 'data.txt' format: a b c d e f SPX LSZ 100 C 0 34.4 SPX LSZ 100 P 0 1.3 SPX LSZ 105 C 0 30.3 SPX LSZ 105 P 0 1.85 SPX LSZ 110 C 0 26.4 and I want to have the columns a,b,d read as the 'character' data, a the remaining columns as 'numeric'. What I did was: read.table(data.txt,header=T, colClasses=c(character,character,numeric,character, numeric,numeric), but I could not get what I want, since all values were in the 'character' format. I will apprecaite any suggestions. best, robert -- View this message in context: http://www.nabble.com/read.table-tp21090550p21090550.html Sent from the R help mailing list archive at Nabble.com. __ 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-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.
Re: [R] I need course in R
yes I did, sorry. obviously good for stats rather than general code but still good bed time reading :-) Simon. - Original Message - From: June Kim junea...@gmail.com To: Simon Pickett simon.pick...@bto.org Sent: Friday, December 19, 2008 3:28 PM Subject: Re: [R] I need course in R On Fri, Dec 19, 2008 at 7:50 PM, Simon Pickett simon.pick...@bto.org wrote: R is not as daunting as it first seems and you might get by without having to get formal training. Speaking as someone who taught themselves to use R for statistics, graphics and data manipulation, I found that the Introduction to R book (the small yellow one) and the numerous pdfs available online are fantastic and walk I can't find a book named Introduction to R whose cover is yellow. You must be talking about Dalgaard's. http://www.amazon.com/Introductory-Statistics-R-Computing/dp/0387790535 you through the very basics (the one by Emanuel Paradis is excellent). So, as long as you can read and understand English there are alot of free resources out there (maybe there are some of these already translated to other languages, I dont know). It is a steep learning curve, but once you get to grips with the basics, I've found that I can find out everything else I need to know by searching these archives... Hope this helps, Simon Pickett. - Original Message - From: Uwe Ligges lig...@statistik.tu-dortmund.de To: xavier ordoñez rlistxa...@gmail.com Cc: R help r-h...@stat.math.ethz.ch Sent: Friday, December 19, 2008 10:24 AM Subject: Re: [R] I need course in R xavier ordoñez wrote: I am interested to take a course in R. Someone know of some course in europe for the first semester of the next year?. Yes, some, but hard to suggest commercial companies or universities and certain courses, because it depends on so many facts: - the languages you understand - the European regions that are fine for you to travel to - the level and kind of R stuff you expect in the course (basics, applications in a certain field, or just programming) - your a priori knowledge about statistics Best wishes, Uwe Ligges Happy Year Thank you, Xavier [[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-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-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-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.
Re: [R] inserting zero instances with zeroes in a matrix
Wow, thats amazing, thanks very much!!! Simon. - Original Message - From: Henrique Dallazuanna To: Simon Pickett Cc: r-help@r-project.org Sent: Thursday, December 18, 2008 11:25 AM Subject: Re: [R] inserting zero instances with zeroes in a matrix Try this: with(d.f, {merge(data.frame(house = rep(unique(house), each = length(unique(pet))), pet = unique(pet)), d.f, by = c(house, pet), all = TRUE) } ) On Thu, Dec 18, 2008 at 8:58 AM, Simon Pickett simon.pick...@bto.org wrote: Hi all, Suppose I had the below example where a survey was carried out recording the number of each type of pet in each house count-c(2,1,2,1,2,3,4) house-c(house1,house1,house2,house3,house4,house4,house4) pet-c(dogs,cats,dogs,dogs,budgie,cat,hamster) d.f-data.frame(house,pet,count) How would I acheive a dataframe that had every instance of house in column 1, all possible pets in column 2 and counts in column 3 like this... newhouse-rep(unique(house),1,each=4) newpets-rep(unique(pet),4) newcount-c(2,1,0,0,2,0,0,0,1,0,0,0,0,3,2,4) newdf-data.frame(newhouse,newpets,newcount) Is there a way of doing this without creating a new matrix and using programming loops? Thanks in advance, Simon. [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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.
Re: [R] inserting zero instances with zeroes in a matrix
Thanks Gregor and Henrique for the eloquent and masterful replies, These solutions have saved me hours (maybe even days) of work in the future, I am very grateful. :-) Simon. - Original Message - From: Gabor Grothendieck ggrothendi...@gmail.com To: Henrique Dallazuanna www...@gmail.com Cc: Simon Pickett simon.pick...@bto.org; r-help@r-project.org Sent: Thursday, December 18, 2008 11:51 AM Subject: Re: [R] inserting zero instances with zeroes in a matrix Try this: as.data.frame(xtabs(count ~., d.f)) On Thu, Dec 18, 2008 at 6:25 AM, Henrique Dallazuanna www...@gmail.com wrote: Try this: with(d.f, {merge(data.frame(house = rep(unique(house), each = length(unique(pet))), pet = unique(pet)), d.f, by = c(house, pet), all = TRUE) } ) On Thu, Dec 18, 2008 at 8:58 AM, Simon Pickett simon.pick...@bto.orgwrote: Hi all, Suppose I had the below example where a survey was carried out recording the number of each type of pet in each house count-c(2,1,2,1,2,3,4) house-c(house1,house1,house2,house3,house4,house4,house4) pet-c(dogs,cats,dogs,dogs,budgie,cat,hamster) d.f-data.frame(house,pet,count) How would I acheive a dataframe that had every instance of house in column 1, all possible pets in column 2 and counts in column 3 like this... newhouse-rep(unique(house),1,each=4) newpets-rep(unique(pet),4) newcount-c(2,1,0,0,2,0,0,0,1,0,0,0,0,3,2,4) newdf-data.frame(newhouse,newpets,newcount) Is there a way of doing this without creating a new matrix and using programming loops? Thanks in advance, Simon. [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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-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.
Re: [R] inserting zero instances with zeroes in a matrix
Actually, Both these solutions create contingency tables, with frequency rather than the original count values. Is there a way to retain the original count values? Thanks again, Simon. - Original Message - From: Simon Pickett simon.pick...@bto.org To: Gabor Grothendieck ggrothendi...@gmail.com; Henrique Dallazuanna www...@gmail.com Cc: r-help@r-project.org Sent: Thursday, December 18, 2008 12:11 PM Subject: Re: [R] inserting zero instances with zeroes in a matrix Thanks Gregor and Henrique for the eloquent and masterful replies, These solutions have saved me hours (maybe even days) of work in the future, I am very grateful. :-) Simon. - Original Message - From: Gabor Grothendieck ggrothendi...@gmail.com To: Henrique Dallazuanna www...@gmail.com Cc: Simon Pickett simon.pick...@bto.org; r-help@r-project.org Sent: Thursday, December 18, 2008 11:51 AM Subject: Re: [R] inserting zero instances with zeroes in a matrix Try this: as.data.frame(xtabs(count ~., d.f)) On Thu, Dec 18, 2008 at 6:25 AM, Henrique Dallazuanna www...@gmail.com wrote: Try this: with(d.f, {merge(data.frame(house = rep(unique(house), each = length(unique(pet))), pet = unique(pet)), d.f, by = c(house, pet), all = TRUE) } ) On Thu, Dec 18, 2008 at 8:58 AM, Simon Pickett simon.pick...@bto.orgwrote: Hi all, Suppose I had the below example where a survey was carried out recording the number of each type of pet in each house count-c(2,1,2,1,2,3,4) house-c(house1,house1,house2,house3,house4,house4,house4) pet-c(dogs,cats,dogs,dogs,budgie,cat,hamster) d.f-data.frame(house,pet,count) How would I acheive a dataframe that had every instance of house in column 1, all possible pets in column 2 and counts in column 3 like this... newhouse-rep(unique(house),1,each=4) newpets-rep(unique(pet),4) newcount-c(2,1,0,0,2,0,0,0,1,0,0,0,0,3,2,4) newdf-data.frame(newhouse,newpets,newcount) Is there a way of doing this without creating a new matrix and using programming loops? Thanks in advance, Simon. [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[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-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-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] help: programming loop, binding columns between data sets
Hi, I often have the problem of combining data sets of different lengths together. Simple example: I have data frame a, with two columns C1 and C2 and another data frame b with only one column V1. Data frame b is much bigger than a, but C1 of a has the same levels as V1 of b. (so in other words there are multiple instances of a$C1 in b$V1) I wish to paste a$C2 into a new column in b, where a$C1 == b$V1. I have always done it this way... for (i in 1:dim(a)[1]) {b[b$V1 == a$C1[i],c(V2)]=a[i,c(C2)]} However, 1. It is very slow 2. It is unreliable (in that for no reason at all, I often get NA's in the new column of B) -This usually happens when the code is within a loop, or I have to paste multiple columns from a across to b all at once. In this case I often have to paste each column one at a time which takes forever. I often am dealing with very large data sets. I am using R 2.1.1 on Windows Vista. Can anyone suggest a faster/more reliable alternative alternative please? Needless to say I am a programming novice. Thanks in advance, Simon Pickett. __ 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.