[R] SOLVED: How to change size of xlab inplot?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/01/2011 12:12 PM, Henrique Dallazuanna wrote: Try cex.lab: plot(1,1, xlab=Label, cex.lab = 2) Thanks - that is what I was looking for. Cheers, Rainer On Tue, Feb 1, 2011 at 7:31 AM, Rainer M Krug r.m.k...@gmail.com mailto:r.m.k...@gmail.com wrote: Hi I want to increase the size of the text for xlab in the plot command: plot(1,1, xlab=Label) I tried cex, cex.caption and others, but none worked. Is there a way of using cex=2 for the xlab? Thanks, Rainer __ R-help@r-project.org mailto: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 - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1ICgAACgkQoYgNqgF2egoqtQCfevifpfHcIbJ4bWYH3cR48LRV T0wAn11xzK13E3UAgWtk9bmfTIYWxMkt =olNC -END PGP SIGNATURE- __ 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] Unexpected behaviour of write.csv - read.csv
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 07:06 PM, Prof Brian Ripley wrote: On Thu, 13 Jan 2011, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame':10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. You need to read it with read.csv(x.csv, row.names=1) Thanks - that makes sense. Nothing in the csv format lets R know that the first column is the row names (in the format used by read.table, having a header that is one column short does). Now R could guess that a .csv file with an empty string for the first column name is meant to be the row names, but that would be merely a guess based on one (barely documented for spreadsheets) convention. OK - accepted - assuming things which are only barely documented is the first step towards incompatibilities - and that is the last thing would like to have. Just for clarification, it might be useful to state this in the help page - or did I miss it there? - as this is an important point and difference between write.table and write.csv. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). Or one of the other serialization options such as serialize() and .saveRDS(). R's own admin uses .saveRDS() for such purposes. They look exactly like what I was looking for, but it says in the help page: Details: Since these are internal, the file format is subject to change without notice. The current format is that of ‘serialize’, compressed as if by ‘gzip’ if ‘compress = FALSE’. This sounds frightening - unless, that the existing version is kept and can be used even if the default version changes. Cheers, Rainer Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0wBHcACgkQoYgNqgF2egpXRQCfcmEfGcAyziEjT+Z9yr5LblMm 1fMAnRzcnlkyE27/IcMOh/Wjjum0KtZt =as6T -END PGP SIGNATURE- __ 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] Unexpected behaviour of write.csv - read.csv
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Assuming the following: x - data.frame(a=1:10, b=runif(10)) str(x) 'data.frame': 10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2 - read.csv(x.csv) str(x2) 'data.frame': 10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0u4X8ACgkQoYgNqgF2egrLIgCeIqAevHGcOAK56qPcpNJ+vWav iF0An2pk1RsY1GLJbvdMHG7FFpx437gB =d5aG -END PGP SIGNATURE- __ 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] Unexpected behaviour of write.csv - read.csv
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/13/2011 02:56 PM, Duncan Murdoch wrote: On 11-01-13 6:26 AM, Rainer M Krug wrote: Hi Assuming the following: x- data.frame(a=1:10, b=runif(10)) str(x) 'data.frame':10 obs. of 2 variables: $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... write.csv(x, x.csv) x2- read.csv(x.csv) str(x2) 'data.frame':10 obs. of 3 variables: $ X: int 1 2 3 4 5 6 7 8 9 10 $ a: int 1 2 3 4 5 6 7 8 9 10 $ b: num 0.692 0.325 0.634 0.16 0.873 ... Using the two functions write.csv and read.csv, I would assume, that the resulting data.frame x2 be identical with x, but it has an additional column X, which contains the row names of x. I know read.table and write.table which work as expected, but I would like to use a csv for data exchange reasons. I know that I can use write.csv(x, x.csv, row.names=FALSE) and it would work, but shouldn't that be the default behaviour? I don't think so. The CSV format is an export format which holds less information than a dataframe. By exporting the dataframe to CSV and importing the result, you are discarding information and you should expect to get something different. OK - I can follow this logic - and I think I can accept it. If you want to save a dataframe to disk and read it back unchanged, you should use save() and load(). And now my question from a previous thread (write.table equivalent for lists?) comes up again: using save() and load() definitely works, but it is highly unsave - as it even keeps the names of the object, more then one can be saved, I can not easily assign the saved object to a new name, I have problems using the saved object if I have forgotten what the variable name was. So I would like to expand my previous question: what are the proper functions to store R objects? One could argue that all write... functions are export functions - therefore keeping the data, but not necessarily column names, rownames, attributes, ... So what can I really do to save an R object for later usage in R? Rainer Duncan Murdoch And if this is not compliant with csv files, shouldn't the function read.csv convert the first column into the row names? Cheers, Rainer __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0vB2oACgkQoYgNqgF2egqenQCeJJNdIiX2faKBPGeilzOz73wM RmoAn05oGZvo41wCp1+hWwTqTmNoQrNo =xfWD -END PGP SIGNATURE- __ 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] Add line to plot from stl decomposed time series?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I would like to add a line to the plot of the data panel of a stl decomposed time series. Example: plot(stl(nottem, per)) plots a 4(or is t 8?) panel graph. I thought that I might be able to use mfg to plot in the top (left?) panel (data), but it is not working. Any help appreciated, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0sRFQACgkQoYgNqgF2egpFHgCggCR2bxRmc+2rt1DILLoW3a04 tkcAni8QAfaCK6ulKcvSKggRZKcoe00Q =18GE -END PGP SIGNATURE- __ 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] write.table equivalent for lists?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I am writing simulations in R, and quite regularly, I have to save lists and objects to HDD and load it later again. So I am wondering: why is there no function to write lists (and S3, S4 objects) onto HDD WITHOUT keeping the name? What I mean is: For data.frames I can use x - data.frame(x = runif(10)) write.table(x, x.txt) rm(x) y - read.table(x.txt) to load it into y. But for lists and S3, S4 objects, I have to use save() and load(): x - list(x=1:10, y=letters(1:10)) save(x, file=x.rdata) rm(x) load(x.rdata) #1 y - x #2 rm(x) #3 to load it into y. I don't mind the binary of save - what I am really missing is a command which combines lines #1, #2 and #3. I know - I could write my own save.list - function(x, file) { save(s, file=file) } load.list - function(file) { load(file) return(x) } which I could then use as: x - list(x=1:10, y=letters(1:10)) save.list(x, test.rdata) rm(x) y - load.list(test.rdata) but: why is there not such a function? Am I missing something here? Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0rFocACgkQoYgNqgF2egoLMgCfQmZFnLx4Olkb55DtLKmuRXYY yvoAnieTY3/CsGM9pqyoownLxgeuaDrd =VOFu -END PGP SIGNATURE- __ 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 equivalent for lists?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/10/2011 03:35 PM, Ivan Calandra wrote: Hi, If I understood you correctly, you can use saveObject()/loadObject() from package R.utils, like this: Correct - thanks - that is what I was looking for. But why is no such function in R base? library(R.utils) saveObject(x, x.Rbin) rm(x) y - loadObject(x.Rbin) HTH, Ivan Le 1/10/2011 15:24, Rainer M Krug a écrit : Hi I am writing simulations in R, and quite regularly, I have to save lists and objects to HDD and load it later again. So I am wondering: why is there no function to write lists (and S3, S4 objects) onto HDD WITHOUT keeping the name? What I mean is: For data.frames I can use x- data.frame(x = runif(10)) write.table(x, x.txt) rm(x) y- read.table(x.txt) to load it into y. But for lists and S3, S4 objects, I have to use save() and load(): x- list(x=1:10, y=letters(1:10)) save(x, file=x.rdata) rm(x) load(x.rdata) #1 y- x #2 rm(x) #3 to load it into y. I don't mind the binary of save - what I am really missing is a command which combines lines #1, #2 and #3. I know - I could write my own save.list- function(x, file) { save(s, file=file) } load.list- function(file) { load(file) return(x) } which I could then use as: x- list(x=1:10, y=letters(1:10)) save.list(x, test.rdata) rm(x) y- load.list(test.rdata) but: why is there not such a function? Am I missing something here? Cheers, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0rGugACgkQoYgNqgF2egrnPwCfVM3v/pyJdZQ5f9Fd9w9Mnsfm dDYAnAgkcuZqcI+QG6YRU2pEui6PvE/Q =4j0d -END PGP SIGNATURE- __ 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 equivalent for lists?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/10/2011 04:27 PM, Ivan Calandra wrote: I agree that the R-Core team has better things to do than that, but since it's already there, why not just add it to the base functions? Agree completely - and R.utils is not such an obscure package which nobody uses - so that these functions should be quite bug-free. Rainer Le 1/10/2011 16:19, Peter Ehlers a écrit : On 2011-01-10 06:45, Ivan Calandra wrote: Why isn't it in R base? Good question... I'm definitely not the one able to answer to it! Maybe someone more involved in the development can? Ivan Well, I suspect that Rainer has been on this list long enough to know the answer: Because no has convinced R-Core to implement it! While I might _occasionally_ find it useful, I don't mind if R-Core prefer to pursue other language enhancements. Peter Ehlers Le 1/10/2011 15:42, Rainer M Krug a écrit : -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/10/2011 03:35 PM, Ivan Calandra wrote: Hi, If I understood you correctly, you can use saveObject()/loadObject() from package R.utils, like this: Correct - thanks - that is what I was looking for. But why is no such function in R base? [...snip...] - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0rJw4ACgkQoYgNqgF2egreYACfTbfDH4E1SadVzq/WoZD9Tw9h A5EAnREavj5Wy6ru2ALJeKNc8kZPXIlM =OoKQ -END PGP SIGNATURE- __ 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] algorithm help
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/06/2011 11:57 PM, (Ted Harding) wrote: On 06-Jan-11 22:16:38, array chip wrote: Hi, I am seeking help on designing an algorithm to identify the locations of stretches of 1s in a vector of 0s and 1s. Below is an simple example: dat-as.data.frame(cbind(a=c(F,F,T,T,T,T,F,F,T,T,F,T,T,T,T,F,F,F,F,T) ,b=c(4,12,13,16,18,20,28,30,34,46,47,49,61,73,77,84,87,90,95,97))) dat a b 1 0 4 2 0 12 3 1 13 4 1 16 5 1 18 6 1 20 7 0 28 8 0 30 9 1 34 10 1 46 11 0 47 12 1 49 13 1 61 14 1 73 15 1 77 16 0 84 17 0 87 18 0 90 19 0 95 20 1 97 In this dataset, b is sorted and denotes the location for each number in a. So I would like to find the starting ending locations for each stretch of 1s within a, also counting the number of 1s in each stretch as well. Hope the results from the algorithm would be: stretch start end No.of.1s 1 13 204 2 34 462 3 49 774 4 97 971 I can imagine using for loops can do the job, but I feel it's not a clever way to do this. Is there an efficient algorithm that can do this fast? Thanks for any suggestions. John The basic information you need can be got using rle() (run length encoding). See '?rle'. In your example: rle(dat$a) # Run Length Encoding # lengths: int [1:8] 2 4 2 2 1 4 4 1 # values : num [1:8] 0 1 0 1 0 1 0 1 ## Note: F - 0, T - 1 The following has a somewhat twisted logic at the end, and may be flawed, but you can probably adapt it! L - rle(dat$a)$lengths V - rle(dat$a)$values pos - c(1,cumsum(L)) V1 - c(-1,V) 1+pos[V1==0] # [1] 3 9 12 20 ## Positions in the series dat$a where each run of T (i.e. 1) ## starts A different approach would be to use the diff() function: Where diff(dat$a) [1] 0 1 0 0 0 -1 0 1 0 -1 1 0 0 0 -1 0 0 0 1 is not equal 0, the value is changing from 0 to 1 or one to 0. The indices of the first new value can be found by: which(diff(dat$a)!=0) + 1 [1] 3 7 9 11 12 16 20 where it is changing from 0 to 1 is at which(diff(dat$a)==1) + 1 [1] 3 9 12 20 where it is changing from 1 to 0 is at which(diff(dat$a)==-1) + 1 [1] 7 11 16 By taking into consideration if the first value and the last values are 0 or 1, you can calculate the length. Cheers, Rainer Hoping this helps, Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 06-Jan-11 Time: 22:57:44 -- 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0m1dMACgkQoYgNqgF2egoQbACcCB3iFQ6SKYfL4KVX8AMAN9Gp 1awAn0Z+8KXnOmwCLu61gihc8xZIT++j =O+xA -END PGP SIGNATURE- __ 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] LaTeX, MiKTeX, LyX: A Guide for the Perplexed
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/16/2010 09:16 PM, Paul Miller wrote: Hello Everyone, Thanks to all who replied to my earlier message. I got quite a few responses and several suggestions about how to create nice looking documents that incorporate output from R. It took some time to investigate these, and in some ways I'm more perplexed than when I started. After some investigating, I'm thinking about two possibilities. One is to use Org-Mode/Org-Babel, EMACS, ESS. My impression is that this would allow me to make really nice documents, and hopefully it wouldn't be too difficult to create a decent looking .rtf version for other people to work on using Pandoc, LaTeX2rtf, etc. Absolutely agreed. With org mode, you have a tool which will grow with your needs - from literate programming, reports involving evaluation of code, to composing emails (very interesting feature I just discovered: export your org file *or subtree* to html / ascii and mail it from emacs. Very nice indeed. Cheers, Rainer Another possibility might be Sword. This likely would involve continuing to process words the way a food processor processes food and the software is only free for non-commercial use. The nice thing though is that it works directly with Word and would make collaboration with others a snap. I'm still trying to convince people that R is a good thing. And so a method for creating reports using output from R that doesn't affect them in any way seems particularly appealing. Well - you can do the same with org mode and sweave - the resulting report is html or pdf. Cheers, Rainer At any rate, I'm going to continuing experimenting with this and I hope people will be willing to entertain any questions I might have in the future. Thanks again, Paul [[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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0LLlYACgkQoYgNqgF2egrh3gCdFybdVKTCmkjQCSKtfC9tnzwm TS0AnjElP04CwD7VzDYx+XvVoST0lIfs =s6kb -END PGP SIGNATURE- __ 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] 300 dpi and eps:
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/15/2010 09:31 AM, Philipp Pagel wrote: Everything works fine to place them in a pdf file , or eps file, but when it comes to have a high quality of 300 dpi these graphs are not good. For example I open the eps file with Adobe Illustrator (AI) and it shows that it is a 72dpi graph. This is simply not true: it's an eps and thus of essentually infinite resolution for all practial purposes. Just to clarify this: eps / ps are vector formats - i.e. it says in the file draw a line from point x to point y. In contrast, bmp (and e.g. jpg, png, tiff) are raster formats: in these formats save the PICTURE of the line from point x to y. Consequently, only raster formats have dpi (dots per inch). So your problem is not with the R-generated eps but somewhere downstream from that. Any postprocessing, conversion or editing? Or in Adobe illustrator? It strikes me, that 72dpi is usually the screen resolution. Cheers, Rainer cu Philipp - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0Ij8gACgkQoYgNqgF2egolFwCfbcSKiB4xyc7B/mOzdRRu2/dr iOEAn1KoMR1C4RgYuRRIixUVtLbXN1zE =W0bk -END PGP SIGNATURE- __ 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] X11 -- Wayland under Ubuntu WAS: Re: RGL crashes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/09/2010 12:53 PM, Duncan Murdoch wrote: On 09/12/2010 5:52 AM, Matthew Dowle wrote: Weyland is the project to remove X11 from Linux. http://en.wikipedia.org/wiki/Wayland_(display_server) Ubuntu chiefs have said they support Weyland and aim to include it in the next release (April 2011 == version 11.04 == Natty Narwhal). Fedora developers apparenly said that they are likely to adopt Weyland too. I don't know if packages in R such as rgl would need changing to work with Weyland, or perhaps R itself, if at all. However it seems that Linux is moving away from X11. If X11 calls aren't supported in Wayland, then rgl won't work there. The Wayland people will need to write a replacement for the glx interface to OpenGL, and an rgl user will need to write the code to use this in rgl (i.e. equivalents of the x11gui.* and x11lib.* files in the rgl sources). rgl is designed to work on multiple systems (currently Windows, Cocoa in OSX, and X11), but it's not trivial to implement a new one. While we are at X11 and Wayland - are there any other aspects of R which would need to be rewritten or adapted? I guess, a new graphic device might be necessary? It might be an important exercise to find this out as it will be relevant for all the Ubuntu users in the medium future (probably earlier?) I send this to the r-sig-debian as well, as it might be more relevant where. Rainer Duncan Murdoch Mentioned it here because the issue in this thread appears to be X11 specific. X11's days seem to be numbered if I understand correctly. Matthew Duncan Murdochmurdoch.dun...@gmail.com wrote in message news:4cffca13.7070...@gmail.com... Matthew Dowle wrote: Might Wayland fix it in Narwhal ? I hope those names mean something to Rainer, because they mean nothing to me. Duncan Murdoch Duncan Murdochmurdoch.dun...@gmail.com wrote in message news:4cff7177.7030...@gmail.com... On 08/12/2010 6:07 AM, Rainer M Krug wrote: On 12/08/2010 12:05 PM, Duncan Murdoch wrote: Rainer M Krug wrote: Hi rgl crashes my R session, when resizing the rgl graphic window. I am using Ubuntu Maversick, with dual monitor setup. If I disconnect one monitor, I can resize it a little bit, but it still craches if I enlarge it to much. I assume that the problem has to do with allocated graphic memory in the kernel, but why is R crashing completely, and not evn giving the usual crash options? Cheers, Rainer sessionInfo() R version 2.12.0 (2010-10-15) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.92.794 version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) After executing library(rgl) example(rgl) and resizing the graph window, R crashes witrh the following message: drmRadeonCmdBuffer: -22. Kernel failed to parse or rejected command stream. See dmesg for more info. from dmesg: [ 7349.471959] [drm:r100_cs_track_check] *ERROR* [drm] Buffer too small for color buffer 0 (need 413696 have 262144) ! [ 7349.471964] [drm:r100_cs_track_check] *ERROR* [drm] color buffer 0 (256 4 0 404) [ 7349.471967] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream ! Those messages look like they're coming from your graphics driver, not from R. So rgl may be doing something it shouldn't do, but you'll probably have to diagnose what that is. It's unlikely to be reproducible on another system. That's what I fear as well - could you give me any tips on how to proceed to identify the problem? It might help to know which line of code in rgl actually triggered the error, but debugging X11 code is tricky. The function that likely triggered the problem is X11WindowImpl::setWindowRect in rgl/src/x11gui.cpp; it makes calls to X11 functions that do the actual work. Duncan Murdoch Rainer Duncan Murdoch -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44
Re: [R] LaTeX, MiKTeX, LyX: A Guide for the Perplexed
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/08/2010 12:29 AM, Paul Miller wrote: Hello Everyone, Hi Paul, Been learning R over the past several months. Read several books and have learned a great deal about data manipulation, statistical analysis, and graphics. Now I want to learn how to make nice looking documents and about literate programming. My understanding is that R users normally do this using LaTeX, MiKTeX, LyX, etc. in conjuction with Sweave. An alternative might be to use the R2wd package to create Word documents. Different option to sweave: I am using org-mode in emacs. You have to get used to emacs, but then you have huge advantages (probably over sweave as well): 1) in emacs, you use ESS, the most useful R editor (personal opinion - no war vim versus emacs versus rkward versus ... intended) 2) your document, as in sweave, can be exported to LaTeX, but also to html and other formats 3) as in sweave, you can tangle your code, but not only that: org-mode (or more accurate the included org-babel) allows you to combine different programming language in your document (e.g. http://repo.or.cz/w/Worg.git/blob_plain/HEAD:/org-contrib/babel/examples/data-collection-analysis.org which combines ruby, R and gnuplot) last but not least, 4) org mode, apart from its use for literate programming, is a task manager, time manager, ... . Therefore you can easily include TODO items in your document, selectively show your all TODO items, kepp track of your time you spend on certain projects (usefull for consultancies but also simply to keep track what you are doing). Finally: it is no as difficult as it sounds, as you only have to know about the literate programming with org-babel, and then you can start. The rest will follow. Here is a link which gives an introduction to R in org-babel: http://blogisticreflections.wordpress.com/2010/05/23/introduction-to-using-r-with-org-babel-part-1/ and also http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.php See also http://orgmode.org/worg/org-contrib/babel/uses.php for a comparison between sweave and org-mode / org-babel. - From personal experience, org-mode has dramatically changed (and improved) the way I use R and how I write code (long simulation models). Cheers, Rainer So I guess I have four questions: 1. How do I choose between the various options? Why would someone decide to use LaTeX instead of MiKTeX or vice versa for example? 2. What are the best sources of information about LaTeX, MiKTeX, LyX, etc.? 3. What is the learning curve like for each of these? What do you get for the time you put in learning something that is more difficult? 4. How do people who use LaTeX, MiKTeX, LyX, etc. share documents with people who are just using Word? How difficult does using LaTeX, MiKTeX, LyX, etc. make it to collaborate on projects with others? Thanks, Paul [[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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz/TqQACgkQoYgNqgF2egpPTwCfeDJrzhGI2U5nTM9N15QnCL/h k28An1XAw0nq1LTEgUwC0WaMSCM3lzt7 =OR5g -END PGP SIGNATURE- __ 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] Lists and functions in data.frame?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I would like to have a data.frame, where one column contains functions, and another one lists. i.e.: FUN - function(l) {return(l$a+l$b+l$c} LIST - list(a=1, b=2, c=3) d - data.frame(fun=FUN, no=LIST, value=2, b=TRUE) FUN - function(l) {return(l$a*l$b*l$c} LIST - list(a=4, b=5, c=6) d - rbind(d, data.frame(fun=FUN, no=LIST, value=2, b=FALSE) I would like d$FUN[1](d$l[1] == 6 to be TRUE I want to use it to save a parameterset for a simulation model, which consists of functions, lists, and vectors of different length. Is this possible? Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz/WSIACgkQoYgNqgF2egocEwCeIErcuxDxVa8RFs1SlWiY/hQp T84An1XAtE3tFNKajBnGQngTig4srlIb =6AG3 -END PGP SIGNATURE- __ 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] RGL crashes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi rgl crashes my R session, when resizing the rgl graphic window. I am using Ubuntu Maversick, with dual monitor setup. If I disconnect one monitor, I can resize it a little bit, but it still craches if I enlarge it to much. I assume that the problem has to do with allocated graphic memory in the kernel, but why is R crashing completely, and not evn giving the usual crash options? Cheers, Rainer sessionInfo() R version 2.12.0 (2010-10-15) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.92.794 version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) After executing library(rgl) example(rgl) and resizing the graph window, R crashes witrh the following message: drmRadeonCmdBuffer: -22. Kernel failed to parse or rejected command stream. See dmesg for more info. from dmesg: [ 7349.471959] [drm:r100_cs_track_check] *ERROR* [drm] Buffer too small for color buffer 0 (need 413696 have 262144) ! [ 7349.471964] [drm:r100_cs_track_check] *ERROR* [drm] color buffer 0 (256 4 0 404) [ 7349.471967] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream ! - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz/X/MACgkQoYgNqgF2egr1pQCeMBJFYu6W21bYG1K8NBFV3kQo Hg4An0RHmwplw5ox213ZZYYFtMXwvLJw =X/sg -END PGP SIGNATURE- __ 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] Lists and functions in data.frame?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/08/2010 11:22 AM, jim holtman wrote: It sounds like you want to use a list instead of a dataframe, No - I would like to have a data,frame. I am aware of the differences, but as far as I understand, each column in a data.frame can have a differnt type. So I thought that the type of column fun could be function, column no list, column value numeric and column b boolean. especially if the elements are a different length. OK - forget about the different length - I could convert the vectors to lists, and store them as lists in the data.frame (if possible). d - list() # initialize d[[length(d) + 1]] - list() # extend d[[length(d)]]$fun - sin # add a function d[[length(d) + 1]] - list() # extend again d[[length(d)]]$fun - cos # another function d[[length(d)]]$val - 42 # some value d [[1]] [[1]]$fun function (x) .Primitive(sin) [[2]] [[2]]$fun function (x) .Primitive(cos) [[2]]$val [1] 42 Sure - that would work, but I would prefer to have it in a data.frame. Cheers, Rainer On Wed, Dec 8, 2010 at 5:08 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I would like to have a data.frame, where one column contains functions, and another one lists. i.e.: FUN - function(l) {return(l$a+l$b+l$c} LIST - list(a=1, b=2, c=3) d - data.frame(fun=FUN, no=LIST, value=2, b=TRUE) FUN - function(l) {return(l$a*l$b*l$c} LIST - list(a=4, b=5, c=6) d - rbind(d, data.frame(fun=FUN, no=LIST, value=2, b=FALSE) I would like d$FUN[1](d$l[1] == 6 to be TRUE I want to use it to save a parameterset for a simulation model, which consists of functions, lists, and vectors of different length. Is this possible? Cheers, Rainer __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz/YQEACgkQoYgNqgF2egoTSACfVeYcUqQZCXgxAEqWVw/bYmhm onUAoIXfDH7dFw+X8P7eEw7fX62cEUzf =YjUK -END PGP SIGNATURE- __ 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] RGL crashes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/08/2010 12:05 PM, Duncan Murdoch wrote: Rainer M Krug wrote: Hi rgl crashes my R session, when resizing the rgl graphic window. I am using Ubuntu Maversick, with dual monitor setup. If I disconnect one monitor, I can resize it a little bit, but it still craches if I enlarge it to much. I assume that the problem has to do with allocated graphic memory in the kernel, but why is R crashing completely, and not evn giving the usual crash options? Cheers, Rainer sessionInfo() R version 2.12.0 (2010-10-15) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rgl_0.92.794 version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) After executing library(rgl) example(rgl) and resizing the graph window, R crashes witrh the following message: drmRadeonCmdBuffer: -22. Kernel failed to parse or rejected command stream. See dmesg for more info. from dmesg: [ 7349.471959] [drm:r100_cs_track_check] *ERROR* [drm] Buffer too small for color buffer 0 (need 413696 have 262144) ! [ 7349.471964] [drm:r100_cs_track_check] *ERROR* [drm] color buffer 0 (256 4 0 404) [ 7349.471967] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream ! Those messages look like they're coming from your graphics driver, not from R. So rgl may be doing something it shouldn't do, but you'll probably have to diagnose what that is. It's unlikely to be reproducible on another system. That's what I fear as well - could you give me any tips on how to proceed to identify the problem? Rainer Duncan Murdoch -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz/ZuUACgkQoYgNqgF2egoPDwCfYQqfotaTxJ2dkFDMqrVt/Kzr /REAmwQIWe2N3iiFxYYjCEcaPYgTx8As =VpUe -END PGP SIGNATURE- __ 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] Loading .RData from Internet
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/06/2010 10:29 AM, zhiji19 wrote: I tried the load() already. It does not work. The erro is shown as following: load() works - I downloaded the data and then used load() - it works. I don't know if load() accepts an URL as a source, because that gave me IMMEDIATELY an error. Cheers, Rainer Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection In addition: Warning message: In readChar(con, 5L, useBytes = TRUE) : cannot open compressed file 'http://rss.acs.unt.edu/Rdoc/library/twang/data/raceprofiling.RData', probable reason 'Invalid argument' - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz8sJQACgkQoYgNqgF2egr/owCdETedL3WT81cJ93WGL/8oCvi7 aAgAniZtSnlK2jBcSeIUXGffls+fdZ3n =LVfP -END PGP SIGNATURE- __ 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] using foreach (parallel processing)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/02/2010 10:56 AM, Santosh Srinivas wrote: Hello group, Hi First of all: there is a special interest group for high performance computing in R, which includes parallel computing, wghich would be more appropriate to ask. But I will try anyway: I am experimenting with parallel processing on my quad core Win 7 32 bit machine. Using these packages for the first time. I can see all my processor running at full performance when I use a smaller dataset require(snow) require(doSNOW) require(foreach) #change the 8 to however many cores\phys processors you have on your machine cl.tmp = makeCluster(rep(localhost,4), type=SOCK) registerDoSNOW(cl.tmp) optData.df - head(pristine,10) system.time( optData.df$impliedVol - foreach(i=1:NROW(optData.df),.packages=RQuantLib) %dopar% with(optData.df[i,], tryCatch({EuropeanOptionImpliedVolatility(type,value,underlying, strike, dividendYield, riskFreeRate, maturity, volatility)$impliedVol}, error = function (ex){0})) ) This works fine! PROBLEM: However, when I do the same but with optData.df - pristine ... which has about 3.8 million options data ... the cores do not seem to be fully utilized (they seem to run at 25%). I noticed some slight delay before the processing starts running ... when I did with the 100k dataset ... do i need to wait longer for any allocations to be done? Communication to setup the threads ould definitly take some time. So why don't you try to increase from 100.000 to 1.000.000 and see how long it takes to initialize the threads? You are not mentioning how long you wait? Cheers, Rainer Thank you. __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkz3b5YACgkQoYgNqgF2egrqtQCfQKXKZln5tz5eZDTYBmbFvruH H/4AoIOXZJ7F3lKL6QLRkaQPHZbqBDQn =odY/ -END PGP SIGNATURE- __ 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 catch warnings
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/18/2010 11:11 AM, Alaios wrote: Dear Michael, I would like to thank you for your reply. This line made things easier. One more question what If I want to halt or pause the program when a warning happens? Right now I get only a message printed but it would be nicer if the execution is paused so to try to print more values. What about the following? Is that what x - 1:4 y - list(good=2:5, bad=3:5) for (yy in y) { tryCatch( x - cbind(x, yy), warning=browser ) } Cheers, Rainer Best REgards Alex --- On Thu, 11/18/10, Michael Bedward michael.bedw...@gmail.com wrote: From: Michael Bedward michael.bedw...@gmail.com Subject: Re: [R] How to catch warnings To: Alaios ala...@yahoo.com Cc: Rhelp r-help@r-project.org Date: Thursday, November 18, 2010, 1:26 AM Hi Alex, Something like this ? x - 1:4 y - list(good=2:5, bad=3:5) for (yy in y) { tryCatch( x - cbind(x, yy), warning=function(w) cat(problem values: , yy, \n) ) } Michael On 18 November 2010 03:19, Alaios ala...@yahoo.com wrote: Hello when my code executes I receive the message that were some warnings. I want to catch warning messages at run time so to print some local variables and try to understand why this warning happens. I searched on internet and I tried withCallingHandlers( which seems to work but as I used Rkward the result is awful. I get a prompt to copy paste a value only while at the same time my background window with my code is not anymore accessible. Actually I get the warning that In f[cbind(shweights[, 1], shweights[, 2])] * shweights[, ... : longer object length is not a multiple of shorter object length and what I want is when the warning appear to be able to print the value shweights[,1] shweights[,2] to see what is going on. Any easier way to do that? Best REgards Alex [[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. [[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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzlEBUACgkQoYgNqgF2egr9dgCfdkQYIpkzqAHw13KwszvNJfhe ttUAn0ckAcT1AS+RCeeDVc5wn7sVD9gU =CmU6 -END PGP SIGNATURE- __ 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 catch warnings
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/18/2010 12:54 PM, Alaios wrote: Thanks a lot. Unfortunately browser() works pretty bad for me. As I am using Rkward this gives me a prompt while at the same time R console is blocked which make things not very easy. First option: you know where the error occurs, so enlarge the script window, so that you can see the code you want to debug. Second option: Start a second rkward independent R session and debug from there. I would suggest to contact the rkward mailing list, as one should at least be able to scroll in the rkward windows while the prompt is shown. Cheers, Rainer Regards Alex --- On *Thu, 11/18/10, Rainer M Krug /r.m.k...@gmail.com/* wrote: From: Rainer M Krug r.m.k...@gmail.com Subject: Re: [R] How to catch warnings To: Alaios ala...@yahoo.com Cc: Michael Bedward michael.bedw...@gmail.com, Rhelp r-help@r-project.org Date: Thursday, November 18, 2010, 11:37 AM On 11/18/2010 11:11 AM, Alaios wrote: Dear Michael, I would like to thank you for your reply. This line made things easier. One more question what If I want to halt or pause the program when a warning happens? Right now I get only a message printed but it would be nicer if the execution is paused so to try to print more values. What about the following? Is that what x - 1:4 y - list(good=2:5, bad=3:5) for (yy in y) { tryCatch( x - cbind(x, yy), warning=browser ) } Cheers, Rainer Best REgards Alex --- On Thu, 11/18/10, Michael Bedward michael.bedw...@gmail.com /mc/compose?to=michael.bedw...@gmail.com wrote: From: Michael Bedward michael.bedw...@gmail.com /mc/compose?to=michael.bedw...@gmail.com Subject: Re: [R] How to catch warnings To: Alaios ala...@yahoo.com /mc/compose?to=ala...@yahoo.com Cc: Rhelp r-help@r-project.org /mc/compose?to=r-h...@r-project.org Date: Thursday, November 18, 2010, 1:26 AM Hi Alex, Something like this ? x - 1:4 y - list(good=2:5, bad=3:5) for (yy in y) { tryCatch( x - cbind(x, yy), warning=function(w) cat(problem values: , yy, \n) ) } Michael On 18 November 2010 03:19, Alaios ala...@yahoo.com /mc/compose?to=ala...@yahoo.com wrote: Hello when my code executes I receive the message that were some warnings. I want to catch warning messages at run time so to print some local variables and try to understand why this warning happens. I searched on internet and I tried withCallingHandlers( which seems to work but as I used Rkward the result is awful. I get a prompt to copy paste a value only while at the same time my background window with my code is not anymore accessible. Actually I get the warning that In f[cbind(shweights[, 1], shweights[, 2])] * shweights[, ... : longer object length is not a multiple of shorter object length and what I want is when the warning appear to be able to print the value shweights[,1] shweights[,2] to see what is going on. Any easier way to do that? Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org /mc/compose?to=r-h...@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. [[alternative HTML version deleted]] __ R-help@r-project.org /mc/compose?to=r-h...@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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzlGnoACgkQoYgNqgF2ego/kQCeOdnA6RTOV8aRIREOnOuu7HH4 EMsAn1ZLGaibFByPYbMqYCJQgYiZReHI =mkOi -END PGP SIGNATURE- __ 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] Debugging segfault in foreach
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/16/2010 04:53 AM, Steve Lianoglou wrote: Hi, I'm using R-2.12 on a linux 64bit machine. When I run a chunk of code inside a foreach() %do% { ...} or %dopar% {...} (with doMC backend) I keep getting a segfault. Running the *same* code within lapply(something, function(x) ... ) doesn't result in any segfaults. I'll paste the output below, but I'm not sure it would be helpful. Have you tried using mclapply instead? Does that work? If yes, the problem is in foreach and I would contact revolution analytics - if no, the problem is in multicore (or your code ...) I don't think you can go much further then that, unless you want to debug foreach (or multicore) to that effect. Cheers, Rainer I'm more curious how to go about smoking out what's causing this, as getting back into the code block that is crashing is tricky inside the code block executed by foreach(). If anybody has any suggestions on how they debug with foreach, I'd be happy to hear them. Setting .veborse=TRUE isn't providing anything informative. Anyway, I'll paste the segfault bomb below, followed by sessionInfo() Segfault dump == result of evaluating expression: *** caught segfault *** address 0x30, cause 'memory not mapped' Traceback: 1: format(x[[i]], ..., justify = justify) 2: format.data.frame(x, digits = digits, na.encode = FALSE) 3: as.matrix(format.data.frame(x, digits = digits, na.encode = FALSE)) 4: print.data.frame(r) 5: print(r) 6: doTryCatch(return(expr), name, parentenv, handler) 7: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 8: tryCatchList(expr, classes, parentenv, handlers) 9: tryCatch({repeat {args - nextElem(it)if (obj$verbose) {cat(sprintf(evaluation # %d:\n, i)) print(args)}for (a in names(args)) assign(a\ , args[[a]], pos = envir, inherits = FALSE)r - tryCatch(eval(expr, envir = envir), error = function(e) e)if (obj$verbose) {cat(result of evaluating expression\ :\n)print(r)} tryCatch(accumulator(list(r), i), error = function(e) { cat(error calling combine function:\n)print(e) NULL}) \ i - i + 1}}, error = function(e) {if (!identical(conditionMessage(e), StopIteration)) stop(simpleError(conditionMessage(e), expr))}) 10: doSEQ(obj, substitute(ex), parent.frame()) 11: foreach(chr = chrs, .packages = GenomicFeaturesX, .verbose = TRUE) %do% {.gc - duplicate(gcache, pre.load = NULL) on.exit(dispose(.gc))cat(===, chr, ===\n) \ apaSummary(expt, .gc, chr, pvd.policy, utr.index, polya.variants, gene.collapse)} 12: apaSummaryCrank(bpm[[1]], gcr, chrs[21:22], gene.collapse = longest) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace = sessionInfo == R version 2.12.0 (2010-10-15) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] reshape2_1.0 ShortRead_1.8.0 lattice_0.19-13 [4] ggplot2_0.8.8 proto_0.3-8 reshape_0.8.3 [7] doMC_1.2.1multicore_0.1-3 foreach_1.3.0 [10] codetools_0.2-2 iterators_1.0.3 data.table_1.5.1 [13] plyr_1.2.1GenomeGraphs_1.10.0 biomaRt_2.6.0 [16] bitops_1.0-4.1Rsamtools_1.2.0 RSQLite_0.9-2 [19] DBI_0.2-5 Biostrings_2.18.0 GenomicFeaturesX_0.2 [22] GenomicFeatures_1.2.0 GenomicRanges_1.2.1 IRanges_1.8.2 loaded via a namespace (and not attached): [1] annotate_1.28.0 AnnotationDbi_1.12.0 Biobase_2.10.0 [4] BSgenome_1.18.0 hwriter_1.2 RCurl_1.4-3 [7] rtracklayer_1.10.2 stringr_0.4 XML_3.2-0 [10] xtable_1.5-6 -steve - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
[R] Optimizing compilation of R
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I know this has been asked before, but I can not find it - so my apologies. I want to compile R myself, to optimize it for speed. There is a small section (a few lines actually) in the R-admin manual (Compilation-flags) which states that the LDFLAGS on recent systems ‘'-Bdirect,--hash-style=both,-Wl,-O1'’ is recommended. But I set LDFLAGS, and it is actually slightly slower then the Ubuntu binary. So are there any other ressources (probably HotTos?) on how I can tune the compilation of R to make it faster? I am using Maverick, and R info is below: sessionInfo() R version 2.12.0 (2010-10-15) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.0 version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 12.0 year 2010 month 10 day15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) Thanks, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzdVHEACgkQoYgNqgF2egqGEQCfSH59J4RgjDS8mcDjDWVEW/Fi ri4An16SQEP6b3VCGGZVWEi9RVC+dzWp =nyqn -END PGP SIGNATURE- __ 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] Optimizing compilation of R
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Patrick, thanks a lot. No, I am not using MKL, but I am going to try the flags you mention in your blog. Cheers, Rainer On 11/12/2010 03:58 PM, Richardson, Patrick wrote: Rainer, The attached link might give you some insight. It's for compiling R with MKL. I'm not sure if you're using MKL or not (but it does make R faster). And to your question, it does contain code for setting flags which I have used and found to be beneficial. http://psyccomputing.blogspot.com/2010/04/compiling-64-bit-r-2101-with-mkl-in.html Best, Patrick -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rainer M Krug Sent: Friday, November 12, 2010 9:51 AM To: R-help Subject: [R] Optimizing compilation of R Hi I know this has been asked before, but I can not find it - so my apologies. I want to compile R myself, to optimize it for speed. There is a small section (a few lines actually) in the R-admin manual (Compilation-flags) which states that the LDFLAGS on recent systems ''-Bdirect,--hash-style=both,-Wl,-O1'' is recommended. But I set LDFLAGS, and it is actually slightly slower then the Ubuntu binary. So are there any other ressources (probably HotTos?) on how I can tune the compilation of R to make it faster? I am using Maverick, and R info is below: sessionInfo() R version 2.12.0 (2010-10-15) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.0 version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 12.0 year 2010 month 10 day 15 svn rev53317 language R version.string R version 2.12.0 (2010-10-15) Thanks, Rainer __ 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. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzdaA0ACgkQoYgNqgF2egr3FgCeO8gbjOuFdWB8VvPlnXAYgtTe 3ZoAn2n/O6RGu5rBULU9OA9O9EY5EYMU =DcH/ -END PGP SIGNATURE- __ 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] Checking existance of a directory
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 29/10/10 13:08, Ron Michael wrote: Hi all, I am wondering is there any way to check whether some Directory exists or not, given the parent path of that directory? After searching for a while I found that there is a function dir.create() to create some directory. However I need to know whether such directory already exists or not, otherwise I will create that. Just use dir.create(showWarnings=FALSE) This will create the directory if it does not exist, and do nothing if it does. If showWarnings=TRUE, it will give you a warning that the directory exists. Cheers, Rainer Thanks, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzKtV0ACgkQoYgNqgF2egpRSACgiB498c+M0ICsoJMZxS051lkw k4UAn0XAI52H1LtRZAJSUQcB6haK8xWO =66jA -END PGP SIGNATURE- __ 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] 0.3 is not 0.3, bug in seq() function?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 28/10/10 12:23, Enrico R. Crema wrote: Dear List, I've been running a numerical simulation and I found this odd error in my code where the which command could not identify which rows of a column of data.frame were corresponding to the value 0.3. There are 7 unique values in this column (0.01,0.05,0.1,0.2,0.3,0.4,0.5), and this does not work only for 0.3. So I looked at the column and manually tried to use the which() command, and the results were all FALSE despite I could see those number. So I recreated my sequence of number and tested: seq(0.1,0.5,0.1)[3]==0.3 which gave me FALSE!!! All the other numbers (0.1,0.2,0.4,0.5) give me TRUE, but 0.3 was not working. So I did: seq(0.1,0.5,0.1)[3]-0.3 which gave me 5.551115e-17. If you run a similar sequence like: seq(0.2,0.6,0.1)[2]==0.3 this will still give me FALSE. No, for my own purpose, I fixed the problem in this way: zerothree=seq(0.1,0.5,0.1)[3] which(data[,1]==zerothree) but I guess this bug is a bit of problem...Apologies if it is the wrong place to post this bug, and apologies also if this was a known issue. My version of R is : platform x86_64-pc-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 10.1 year 2009 month 12 day14 svn rev50720 language R version.string R version 2.10.1 (2009-12-14) This is not a bug, but based on the internal representation of numbers in the binary format. Numbers like 0.3 can not be represented as exactly 0.3, wherefore errors accumulate in a sequence. I can't provide you a link for more details, but the topic comes up every now and then in this mailing list. Cheers, Rainer Many Thanks, Enrico __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzJVOEACgkQoYgNqgF2egpVXACeNO9GyRh9XKLg1g4EhcFs4Qa5 WXgAmgOdNB/xgmRS4UsMaEtunxS6NB/u =azme -END PGP SIGNATURE- __ 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] Implementing R's recycling rule
Hi I want to use R's recycling rule. At the moment I am using the following: x - c(1, 2, 3) n - 10 ## so using the recycling rules, I would like to get from FUN(x, n)==1 ## I am doing: xRecycled - rep(x, length.out=n)[n] This works, but it seems to me that I am missing something really basic here - is there more straightforward way of doing this? Cheers, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Implementing R's recycling rule
On Tue, Oct 19, 2010 at 11:30 AM, richard.cot...@hsl.gov.uk wrote: x - c(1, 2, 3) n - 10 ## so using the recycling rules, I would like to get from FUN(x, n)==1 ## I am doing: xRecycled - rep(x, length.out=n)[n] This works, but it seems to me that I am missing something really basic here - is there more straightforward way of doing this? x[n %% length(x)] gives you the same answer as rep(x, length.out=n)[n], without having to create the longer vector. Thanks a lot - works perfectly and looks much nicer, Rainer Regards, Richie. Mathematical Sciences Unit HSL 4D Pie Charts ATTENTION: This message contains privileged and confidential information intended for the addressee(s) only. If this message was sent to you in error, you must not disseminate, copy or take any action in reliance on it and we request that you notify the sender immediately by return email. Opinions expressed in this message and any attachments are not necessarily those held by the Health and Safety Laboratory or any person connected with the organisation, save those by whom the opinions were expressed. Please note that any messages sent or received by the Health and Safety Laboratory email system may be monitored and stored in an information retrieval system. Think before you print - do you really need to print this email? Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.com -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] compare histograms
On Fri, Oct 15, 2010 at 2:47 AM, Michael Bedward michael.bedw...@gmail.comwrote: Hi Rainer, Great - many thanks for that. Yes, I'm using OSX I initially tried to use install.packages to get get a pre-built binary of earthmovdist from Rforge, but it failed with... In getDependencies(pkgs, dependencies, available, lib) : package earthmovdist is not available Yes - we had some problems with getting the package build for OSX, but we (more specifically Dirk) are working on that. When I tried installing with type=source this was also failing. However, after reading your post I looked at the error messages properly and it turned out to be a trivial problem. The .First function defined in my .Rprofile was printing some text to the console with cat() which was being incorrectly picked up by the package build as if it was a makefile argument. When I commented out the call to cat the package installed successfully. I haven't had this problem installing other packages from source so I think there must be a little problem with your setup (?) Thanks for letting us know - could you send us the offending entry in your .Rprofile (or the whole .Rprofile?), so that we can see if it is an OSX or general problem? Now that it's installed I look forward to trying it out shortly. Great - please give us some feedback on what you think about it. Cheers, Rainer Thanks again. Michael On 15 October 2010 03:17, Rainer M Krug r.m.k...@gmail.com wrote: On Thu, Oct 14, 2010 at 3:15 AM, Michael Bedward michael.bedw...@gmail.com wrote: Hi Juan, Yes, you can use EMD to quantify the difference between any pair of histograms regardless of their shape. The only constraint, at least the way that I've done it previously, is to have compatible bins. The original application of EMD was to compare images based on colour histograms which could have all sorts of shapes. I looked at the package that Dennis alerted me to on RForge but unfortunately it seems to be inactive No - well, it depends how you define inactive: the functionality we wanted to include is included, therefore no further development was necessary. and the nightly builds are broken. I've downloaded the source code and will have a look at it sometime in the next few days. Thanks for alerting us - we will look into that. But just don't use the nightly builds, as they are not different to the last release. Just download the package for your system (I assume Windows or mac, as I just installed from source without problems under Linux). Let me know if it doesn't work, Cheers, Rainer Meanwhile, let me know if you want a copy of my own code. It uses the lpSolve package. Michael On 14 October 2010 08:46, Juan Pablo Fededa jpfed...@gmail.com wrote: Hi Michael, I have the same challenge, can you use this earth movers distance it to compare bimodal distributions? Thanks cheers, Juan On Wed, Oct 13, 2010 at 4:39 AM, Michael Bedward michael.bedw...@gmail.com wrote: Just to add to Greg's comments: I've previously used 'Earth Movers Distance' to compare histograms. Note, this is a distance metric rather than a parametric statistic (ie. not a test) but it at least provides a consistent way of quantifying similarity. It's relatively easy to implement the metric in R (formulating it as a linear programming problem). Happy to dig out the code if needed. Michael On 13 October 2010 02:44, Greg Snow greg.s...@imail.org wrote: That depends a lot on what you mean by the histograms being equivalent. You could just plot them and compare visually. It may be easier to compare them if you plot density estimates rather than histograms. Even better would be to do a qqplot comparing the 2 sets of data rather than the histograms. If you want a formal test then the ks.test function can compare 2 datasets. Note that the null hypothesis is that they come from the same distribution, a significant result means that they are likely different (but the difference may not be of practical importance), but a non-significant test could mean they are the same, or that you just do not have enough power to find the difference (or the difference is hard for the ks test to see). You could also use a chi-squared test to compare this way. Another approach would be to use the vis.test function from the TeachingDemos package. Write a small function that will either plot your 2 histograms (density plots), or permute the data between the 2 groups and plot the equivalent histograms. The vis.test function then presents you with an array of plots, one of which is the original data and the rest based on permutations. If there is a clear meaningful difference in the groups you
Re: [R] compare histograms
. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] OT: What distribution is this?
Hi Peter, H Berwin, thanks a lot for your clarifications, it makes more sense now. But having our input and thinking a little bit more about the problem, I realized that I am simply interested in the pdf p(y) that y *number* of entities (which ones is irrelevant) in N are are *not* drawn after the sampling process has been completed. Even simpler (I guess), in a first step, I would only need the mean number of expected non-drawn entities in N (pMean). The range of my values: N is in the range of 1 --- 100 000 x is in the range of 10 --- 40 000 000 n is in the range of 20 I guess in cases where n*x is substantially smaller then N, I could simply use a binominal distribution for n*x samples to approximate it -- right? For cases where n*x is substantially bigger then N, I can safely (especially in the context of my simulation) assume that all entities in N are drawn at least once. But what about the range in between? Thanks again, Cheers, Rainer On Sat, Sep 25, 2010 at 5:19 PM, Peter Dalgaard pda...@gmail.com wrote: On 09/25/2010 04:24 PM, Rainer M Krug wrote: Hi This is OT, but I need it for my simulation in R. I have a special case for sampling with replacement: instead of sampling once and replacing it immediately, I sample n times, and then replace all n items. So: N entities x samples with replacement each sample consists of n sub-samples WITHOUT replacement, which are all replaced before the next sample is drawn My question is: which distribution can I use to describe how often each entity of the N has been sampled? Thanks for your help, Rainer How did you know I was in the middle of preparing lectures on the variance of the hypergeometric distribution and such? ;-) If you look at a single item, the answer is of course that you have a binomial with size=x and prob=n/N. The problem is that these binomials are correlated between items. If you can make do with a 2nd order approximation, then the covariances between the indicators for two items being selected is easily found from the symmetry and the fact that if you sum all N indicators you get the constant n. I.e. the variance is p(1-p) and the covariance is -p(1-p)/(N-1). For sums over repeated samples, just multiply everything by the number x of samples. If you intend to just count the frequency of a particular feature in each of your n-samples, i.e., you have x replications of a hypergeometric experiment, then you can do somewhat better by computing the explicit convolution of x hypergeometrics (convolve(x, rev(y), type=o) and Reduce() are your friends). I'm not sure this is actually worth the trouble, but it should be doable for decent-sized N and x. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Measure Difference Between Two Distributions
On Sat, Sep 25, 2010 at 3:53 PM, Lorenzo Isella lorenzo.ise...@gmail.comwrote: On 09/25/2010 03:23 PM, Rainer M Krug wrote: Evaluate, for me, does not necessary mean test if they are significantly different, but rather to quantify the difference. If that is what you are looking for, you could look at the Earth Movers Distance, where a package is available at R-forge (https://r-forge.r-project.org/projects/earthmovdist/) which I co-wrote and used before. Cheers, Rainer Thanks Rainer. I had a quick look at wikipedia and the package you mention, and it seems what I am looking for. Great - could you please give me some feedback after using the package, if something could be improved? Thanks. Just a question about normalization of the distance calculated by the algorithm. Let us say that I have 4 distributions A,B,C,D coupled this way (A,B) and (C,D). The length of data in A is equal to the length of data in B, same applies to C and D but length(A)!=length(C). Now, the argument I would like to make is that A and B are more similar than C and D and show a couple of numbers to prove this. Bottom line: provided my data lists are long enough, does this distance scale with the number of data? and if they do, how should I normalize this distance to compare the results? You could represent the distance as the proportion of maximum possible distance, i.e. scaling it to be between 0 and 1. An example: A and B have the same length (x), and you calculate the emd(A, B), which is d. Now you have to determine the maximum distance between these two: remembering the analogy of moving earth, the biggest distance between the two distributions would be if in A, all elements would be in A(1) and all other would be zero, and in B all elements would be zero, except of B(x). Now you can calculate the difference between these two, and you get dmax The last step is to divide d/dmax, i.e. scaling to a value between 0 and 1. this value then can be compared with the same ratio obtained from C and D with length y. One important point to keep in mind when using the emd: if the sum(A) is not the same as sum(B), emd(A,B) is NOT EQUAL to emd(B,A). If this applies to your case, you have to decide what to do, but one option is to standardise A and B so that their sum is the same (effectively comparing the SHAPES and not the actual values. If you need a reference where we used this approach (for comparison of different maps from different areas), see : @ARTICLE{Roura-Pascual2009_rmkc, author = {Roura-Pascual, N\'{u}ria and Krug, Rainer M. and Richardson, David M. and Hui, Cang}, title = {Spatially-explicit sensitivity analysis for conservation management: exploring the influence of decisions in invasive alien plant management}, journal = {Diversity and Distributions}, year = {2010}, volume = {16}, pages = {426--438}, doi = {10./j.1472-4642.2010.00659.x}, file = {Article:Roura-Pascual2009_rmkc.pdf:PDF}, owner = {rkrug}, timestamp = {2009.03.11} } Please feel free to contact me if you have further questions, Cheers, Rainer Cheers Lorenzo -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] OT: What distribution is this?
Hi This is OT, but I need it for my simulation in R. I have a special case for sampling with replacement: instead of sampling once and replacing it immediately, I sample n times, and then replace all n items. So: N entities x samples with replacement each sample consists of n sub-samples WITHOUT replacement, which are all replaced before the next sample is drawn My question is: which distribution can I use to describe how often each entity of the N has been sampled? Thanks for your help, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Measure Difference Between Two Distributions
On Sat, Sep 25, 2010 at 6:24 PM, Lorenzo Isella lorenzo.ise...@gmail.comwrote: ld represent the distance as the proportion of maximum possible distance, i.e. scaling it to be between 0 and 1. An example: A and B have the same length (x), and you calculate the emd(A, B), which is d. Now you have to determine the maximum distance between these two: remembering the analogy of moving earth, the biggest distance between the two distributions would be if in A, all elements would be in A(1) and all other would be zero, and in B all elements would be zero, except of B(x). Now you can calculate the difference between these two, and you get dmax The last step is to divide d/dmax, i.e. scaling to a value between 0 and 1. this value then can be compared with the same ratio obtained from C and D with length y. One important point to keep in mind when using the emd: if the sum(A) is not the same as sum(B), emd(A,B) is NOT EQUAL to emd(B,A). If this applies to your case, you have to decide what to do, but one option is to standardise A and B so that their sum is the same (effectively comparing the SHAPES and not the actual values. OK, I see. The standardization part is not a terrible problem, I guess. The other bit is less clear (to me). What are A(1) and B(x)? Am I piling up all the elements in A and B in a single bin? Cheers OK. Some code: set.seed(13) B - sample(1:10, 10) B [1] 8 3 4 1 6 7 9 10 2 5 set.seed(13) A - sample(1:10, 10) B - sample(1:10, 10) A [1] 8 3 4 1 6 7 9 10 2 5 B [1] 7 8 9 4 10 2 5 6 3 1 A[1] - sum(A) A[-1] - 0 B[length(B)] - sum(B) B[-length(B)] - 0 A [1] 55 0 0 0 0 0 0 0 0 0 B [1] 0 0 0 0 0 0 0 0 0 55 And now you can calculate the emd(A, B), which then is the maximum distance between A and B. Imagine: the distance is the work you have to do to convert A into B. Work equals distance times mass you have to move. Therefore you have to maximise the distance you have to carry the earth and the amount you have to carry. Therefore, in A, piling everything up in the first element, and in B, piling everything up in the last element, gives you the most work you have to du, which equals the largest distance. Even though it is rather straight forward, I should probably integrate a function in the package which gives you the largest distance between two distributions - I'll think about it. Hope this helps, Cheers, Rainer Lorenzo -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Measure Difference Between Two Distributions
On Sat, Sep 25, 2010 at 3:16 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: On Sat, Sep 25, 2010 at 3:47 AM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: Dear All, Suppose you are given two distributions (or better: two equally-sized lists of data); how can you evaluate the difference between them? Evaluate, for me, does not necessary mean test if they are significantly different, but rather to quantify the difference. If that is what you are looking for, you could look at the Earth Movers Distance, where a package is available at R-forge (https://r-forge.r-project.org/projects/earthmovdist/) which I co-wrote and used before. Cheers, Rainer I need something like an overlap measure of the two (let us say 0 == no overlap and 1== complete overlap). I should add that there is a 1-1 correspondence of the data in the two distributions (they are ordered lists and e.g. the third element in the first distribution matches the third element in the second distribution). To visualize the two distributions, you could do an empirical Q-Q plot (qqplot(x, y)); if the distributions are identical, they should lie on a 45 degree line - location shifts are indicated by level shifts (parallel lines) to the 45 degree line, differences in scale by slope differences away from 1. There are many types of tests to test equality of distribution, the simplest one being the two-sample Kolmogorov-Smirnov test. It is sensitive to changes in both location and scale of the two edf's (empirical distribution functions). An alternative is the two-sample Cramer-von Mises test. I have no doubt there are others... HTH, Dennis The two distributions are not analytical (I mean they do not belong to any well known family). I wonder if mutual information could be what I am looking for. Cheers Lorenzo __ 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. [[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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] R Founding
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 17/09/10 08:38, Peter Dalgaard wrote: On 09/17/2010 12:14 AM, Jeremy Miles wrote: I know from organizing a conference in Germany that the only really good way was and is ordinary money transfer via BIC and IBAN numbers. Unfortunately, this system is pretty unknown in the US. Europeans can easily use money transfer to the R foundation. Paypal? Many open source projects have a 'donate with paypal' button. Jeremy As far as I remember, this requires that a real person opens the account, and takes on the associated tax issues. It may be different for US-based projects. Another option is to get the hosting institutions to accept credit cards, but they tend to balk at the transaction costs (with the result that conference organizers get driven to conference agencies with much greater handling fees...) But seriously, even Springer can do wire transfers nowadays. Maybe we should just wait for the US banks to join the 21st century? 1) I agree Jaroslaw - you can not buy the motivation you get from participants who are doing it for the love of it, but especially now, in tweaking out issues like memory usage and multicore, which effectively are issues with which the user is only indirectly confronted (Wow - in this release I can load a data.frame of 3GB... That's brilliant) would be very suitable to be done by paid developers who have long working expertise in these fields. I agree that the further development on the outside (cli, packages, ...) will be most effectively done as it is now - - by enthusiasts --- It worked so far, and why change it? Especially as the main problems seem to be with the internal internals. 2) I just looked at GRASS and qgis - both have donate buttons ( see http://grass.fbk.eu/donation.php and http://www.qgis.org/en/sponsorship.html ). Foundations to GRASS are managed through the Italien OSGeo Chapter. Maybe something similar would be an option for R as well? 3) Funding not only has to contribute to financing coding, but also to organise conferences, support participants, organise courses, etc. Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyTE8MACgkQoYgNqgF2egquPQCbBGUve3/cLj6focACw7OFHrBx uPkAnjM2r2r1crizQJKKMxKInMQM5/2Y =dlem -END PGP SIGNATURE- __ 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] count frequency
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 17/09/10 14:19, Alaios wrote: Hello everyone, please consider the following lines of a matrix [574,] 59 32 [575,] 59 32 [576,] 59 32 [577,] 59 32 [578,] 59 32 [579,] 59 32 [580,] 59 32 [581,] 60 32 [582,] 60 33 [583,] 60 33 [584,] 60 33 [585,] 60 33 [586,] 60 33 [587,] 60 33 [588,] 60 33 [589,] 60 33 [590,] 60 33 [591,] 61 33 [592,] 61 33 [593,] 61 33 [594,] 61 33 [595,] 61 33 [596,] 61 33 [597,] 61 33 [598,] 61 33 [599,] 61 33 [600,] 61 33 [601,] 62 34 Is it possible somehow to count the similarities between the first and second column and put them on a third column like this? 59 32 3 60 33 5 62 34 1 where (3,5,1 are the frequencies for (59,32), (60,33) and (62,34) One solution: x - data.frame(a=trunc(runif(10)*10), b=trunc(runif(10)*10)) x a b 1 6 5 2 7 5 3 1 5 4 0 4 5 3 9 6 6 8 7 4 3 8 0 4 9 2 7 10 7 2 x$comb - paste(x$a, x$b) x a b comb 1 6 5 6 5 2 7 5 7 5 3 1 5 1 5 4 0 4 0 4 5 3 9 3 9 6 6 8 6 8 7 4 3 4 3 8 0 4 0 4 9 2 7 2 7 10 7 2 7 2 table(x$comb) 0 4 1 5 2 7 3 9 4 3 6 5 6 8 7 2 7 5 2 1 1 1 1 1 1 1 1 I am sure, there are better ones Cheers, Rainer Best Regards Alex [[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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyTXoQACgkQoYgNqgF2egrgrgCfUOvMaUOwOC7HPSdbC2fFzdLo 4scAmwQ2M1E000PH4HoQmkpkLbANtjLy =B2y8 -END PGP SIGNATURE- __ 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] Enumerating unit cell traversals Re: Interpolate? a line
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 15/09/10 14:46, Michael Bedward wrote: Nice posts David. I like the way that 'simple' problems such as this one give rise to an interesting assortment of approaches and gotchas :) Michael On 15 September 2010 22:41, David Winsemius dwinsem...@comcast.net wrote: On Sep 15, 2010, at 7:55 AM, David Winsemius wrote: On Sep 15, 2010, at 7:24 AM, David Winsemius wrote: Replacing context: Hello everyone. I have created a 100*100 matrix in R. Let's now say that I have a line that starts from (2,3) point and ends to the (62,34) point. In other words this line starts at cell (2,3) and ends at cell (62,34). Is it possible to get by some R function all the matrix's cells that this line transverses? This is a known problem in computer graphics and the algorythm used to identify these cells is the Bresenham's Line Drawing Algorithm You can check out one version at http://www.falloutsoftware.com/tutorials/dd/dd4.htm or http://en.wikipedia.org/wiki/Bresenham's_line_algorithm Cheers, Rainer I would like to thank you for your feedback. Best Regards Alex On Sep 15, 2010, at 6:52 AM, Michael Bedward wrote: Hello Alex, Here is one way to do it. It works but it's not pretty :) If you want an alternative, consider that produces the Y cell indices (since the x cell indices are already 2:62): linefn - function(x) 3+((34-3)/(62-2)) *(x-2) findInterval(linefn(2:62), 3:34) [1] 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 [28] 14 15 15 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 [55] 28 29 29 30 30 31 32 # that seems off by two linefn(62) [1] 34 linefn(2) [1] 3 # but that checks out and I realized those were just indices for the 3:34 findInterval vector (3:34)[findInterval(linefn(2:62), 3:34)] [1] 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 [28] 16 17 17 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 [55] 30 31 31 32 32 33 34 ( no rounding and I think the logic is clearer.) But I also realized it didn't enumerate all the the cells were crossed either, only indicating which cell was associated with an integer value of x. Also would have even more serious problems if the slope were greater than unity. To enumerate the cell indices that were crossed, try: unique( floor( cbind( seq(2,62, by=0.1), linefn(seq(2,62, by=0.1)) ) ) ) [,1] [,2] [1,]23 [2,]33 [3,]44 [4,]54 [5,]55 [6,]65 [7,]75 [8,]76 snipping interior results [83,] 58 32 [84,] 59 32 [85,] 60 32 [86,] 60 33 [87,] 61 33 [88,] 62 34 That could probably be passed to rect() to illustrate (and check logic): rect(cellidxs[,1], cellidxs[,2], cellidxs[,1]+1, cellidxs[,2]+1, col=red) #redraw line : lines(2:62, 3+(34-3)/(62-2)*(0:60)) And then I got to wondering if every 0.1 was sufficient to catch all the corners and discovered I could identify 3 more cell traversals with by=0.01 cellid2 -unique( floor(cbind(seq(2,62, by=0.01), linefn(seq(2,62, by=0.01) )) ) ) NROW(cellid2) # 91 cells rect(cellid2[,1], cellid2[,2], cellid2[,1]+1, cellid2[,2]+1, col=blue) rect(cellidxs[,1], cellidxs[,2], cellidxs[,1]+1, cellidxs[,2]+1, col=red) lines(2:62, 3+(34-3)/(62-2)*(0:60)) (Trying by=0.001 did not change the count, but did take longer) -- David. - David. interp - approx(c(2, 62), c(3, 34), method=linear, xout=2:62) m - matrix(c(interp$x, round(interp$y)), ncol=2) tie - m[,2] == c(-Inf, m[-nrow(m),2]) m - m[ !tie, ] You might want to examine the result like this... plot(m) # plots points lines(c(2,26), c(3, 34)) # overlay line for comparison you can add a grid with abline(v=2:62, h=3:34) Michael David Winsemius, MD West Hartford, CT __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP
Re: [R] Enumerating unit cell traversals Re: Interpolate? a line
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 15/09/10 15:23, David Winsemius wrote: On Sep 15, 2010, at 8:58 AM, Rainer M Krug wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 15/09/10 14:46, Michael Bedward wrote: Nice posts David. I like the way that 'simple' problems such as this one give rise to an interesting assortment of approaches and gotchas :) Michael On 15 September 2010 22:41, David Winsemius dwinsem...@comcast.net wrote: On Sep 15, 2010, at 7:55 AM, David Winsemius wrote: On Sep 15, 2010, at 7:24 AM, David Winsemius wrote: Replacing context: Hello everyone. I have created a 100*100 matrix in R. Let's now say that I have a line that starts from (2,3) point and ends to the (62,34) point. In other words this line starts at cell (2,3) and ends at cell (62,34). Is it possible to get by some R function all the matrix's cells that this line transverses? This is a known problem in computer graphics and the algorythm used to identify these cells is the Bresenham's Line Drawing Algorithm You can check out one version at http://www.falloutsoftware.com/tutorials/dd/dd4.htm or http://en.wikipedia.org/wiki/Bresenham's_line_algorithm After viewing the Wikipedia description and the illustration I think that may not be the same problem. Note that the cells traversed only at their very outer corners do not get chosen. The goal is to approximate a line rather than to enumerate traversals. You might actually be right. Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyQyl8ACgkQoYgNqgF2egpdnACfS3zQX3MUAPraxIm5ExbFcnQu bdYAn0vpYs3Gy2XmutNoJQKaVVZ+hnYH =ByN/ -END PGP SIGNATURE- __ 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] Object oriented programming in R.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 14/09/10 13:51, Liviu Andronic wrote: On Tue, Sep 14, 2010 at 12:55 PM, Alaios ala...@yahoo.com wrote: Thank you very much. I checked the tutorials that on that list but still I do not know how to create many objects of the same type. Can you please help me with that? Is this what you need? for(i in 1:100){ assign(paste('tmp', i, sep=''), NULL) } ls() Liviu __ 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. look at ?rep: x - rep(list(createTheObject(), 10) x will be a list containing 10 times the object created by createTheObject() Cheers, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyPY0kACgkQoYgNqgF2egr5hQCePJ+20z2d64SPVOtIFxv7dmBs ASwAnAhQbm4snJFqYj1dOn2w6NSRLIC+ =wuQC -END PGP SIGNATURE- __ 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] Reproducible research
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/09/10 07:47, David Scott wrote: I am investigating some approaches to reproducible research. I need in the end to produce .html or .doc or .docx. I have used hwriter in the past but have had some problems with verbatim output from R. Tables are also not particularly convenient. I am interested in R2HTML and R2wd in particular, and possibly odfWeave. Does anyone have sample documents using any of these approaches which they could let me have? Hi David I am using emacs + org-mode (http://orgmode.org/) for exactly this (see http://orgmode.org/worg/org-contrib/babel/intro.php#reproducable-research for an example for Reproducible research andhttp://orgmode.org/worg/org-contrib/babel/languages/org-babel-doc-R.php about R in emacs + org-mode + ESS. It is literate programming at its best. Concerning reproducible research and report generating, org-babel has one HUGE advantage: you an combine different programming languages easily in the report - so e.g. you can do your analysis in R, do some data preparation in python, and some final file manipulations in bash - and everything is in one file and reproducible (see http://orgmode.org/worg/org-contrib/babel/intro.php#meta-programming-language and http://orgmode.org/worg/org-contrib/babel/examples/data-collection-analysis.php). I think that would be the best tool for the job (see http://orgmode.org/worg/org-contrib/babel/uses.php for examples for what it can be used - some will be relevant for your intended application). Although emacs has a steep learning curve, it is definitely worth it (and it works on Linux, Windows and Mac) - and the mailing list is also really good. Cheers, Rainer David Scott _ David ScottDepartment of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email:d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyIltUACgkQoYgNqgF2egpb/QCfW0zgFrNqC6/58sounMDwmsNm VgIAn3ZaDhcKGmo+Fwv+yz0UxXqiDaBC =vZV+ -END PGP SIGNATURE- __ 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] Which language is faster for numerical computation?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/09/10 12:26, Christofer Bogaso wrote: Dear all, R offers integration mechanism with different programming languages like C, C++, Fortran, .NET etc. Therefore I am curious on, for heavy numerical computation which language is the fastest? Is there any study? I specially want to know because, if there is some study saying that C is the fastest language for numerical computation then I would change some of my R code into C. As far as I am aware, the two choices are C and Fortran - where it depends on the calculations, which one is faster. Cheers, Rainer Thanks for your time. __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyIxHYACgkQoYgNqgF2egofwQCePvkN3xewbSNEeKUiuxlL7Utx CxMAniGRwoAWfJ8VNTPHLXIbtpiZCrMd =fmFx -END PGP SIGNATURE- __ 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] Replace last element in a vector - elegant solution?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I have to replace the last element of a vector with 0, but the length of x is not known at coding time. So I do the following: x - 1:10 x x[length(x)] - 0 x it is working nicely, but I am wondering: is there a more elegant solution( like tail(x, 1) - 0 , which does not work)? Thanks, Rainer - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxRYh0ACgkQoYgNqgF2ego4iQCePSFCnWMPuY1eD2fyXUUXGRmF PXgAnjIDIB0EnODWv4HuYjwgU3SJW01x =JVQu -END PGP SIGNATURE- __ 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] Syntax Highlightning and Editor for Linux
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 23/07/2010 14:17, Alaios wrote: I would like to thank you for your immediate reply. Actually I do not like vim and emacs.. I am trying to find an editor with a gui that will work fine in Linux. Well - you are missing out with not using emacs + ess - but it is quite a learning curve. Despite this: Try rkward - syntax highlighting and many other nice features. Another option: eclipse with statet plugin( http://www.walware.de/goto/statet) Cheers, Rainer One more question. If I am editing a file using my external text editor is it possible to execute directly one of the functions that are inside the file without executing the source(myfile.R) command first? Best Regards Alex - Original Message From: Duncan Murdoch murdoch.dun...@gmail.com To: alaios ala...@yahoo.com Cc: r-help@r-project.org Sent: Fri, July 23, 2010 2:13:48 PM Subject: Re: [R] Syntax Highlightning and Editor for Linux On 23/07/2010 8:08 AM, alaios wrote: Hello to the community . First post :) I would like to ask you which text editor do you use in Linux and how did you setup the syntax highlightning? I don't use Linux, but I think the most popular editors there are vim and emacs, the latter with ESS. one more question is it possible to debug any program in R by inserting breakpoints? Yes, see the setBreakpoint() and trace() functions. Duncan Murdoch I would like to thank you in advance for your help Best Regards Alex __ 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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxJjjMACgkQoYgNqgF2egqmgACeK5OXtqsKvAcK1Pyli6zlLpW6 ttkAoIzeKgwKeo7cj4oH+jSOr8QMgFFP =B7JP -END PGP SIGNATURE- __ 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] Syntax Highlightning and Editor for Linux
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 23/07/2010 15:56, Alaios wrote: I would like oto thank everyone for the replies. I instaled rkward.. It looks like an editor.. Is it possible to execute Yes also your code from the text editor. Look into the Run menu If there is a function call myfunc inside my file test.R Is it possible to exectute the function from the rwkard? How do you mean? You can open an R console in rkward (by pressing the R console button on the bottom. Then you can type there. You can submit to the R Console via the Run menu or keyboard shortcuts. Cheers, Rainer Best Regards Alex *From:* Federico Andreis federico.andr...@gmail.com *To:* Rainer M Krug r.m.k...@gmail.com *Cc:* Alaios ala...@yahoo.com; r-help@r-project.org *Sent:* Fri, July 23, 2010 3:46:08 PM *Subject:* Re: [R] Syntax Highlightning and Editor for Linux I have been trying emacs with ess, Kate, plain gedit..nothing really satisfied me.. but then I found a nice plugin for gedit: Rgedit ! it supports split screen with R terminal window (you can also personalize colour if, like me, do like to stick with old habits :) ), moreover gedit has a brackets completion and a brackets highlight plugin which are very useful. check it out here http://www.stattler.com/article/using-gedit-or-rgedit-r http://www.stattler.com/article/using-gedit-or-rgedit-rsimple send code to terminal shortcuts (much simpler than emacs, in my opinion) and nice interface..give it a try! /federico On Fri, Jul 23, 2010 at 2:42 PM, Rainer M Krug r.m.k...@gmail.com mailto:r.m.k...@gmail.com wrote: On 23/07/2010 14:17, Alaios wrote: I would like to thank you for your immediate reply. Actually I do not like vim and emacs.. I am trying to find an editor with a gui that will work fine in Linux. Well - you are missing out with not using emacs + ess - but it is quite a learning curve. Despite this: Try rkward - syntax highlighting and many other nice features. Another option: eclipse with statet plugin( http://www.walware.de/goto/statet) Cheers, Rainer One more question. If I am editing a file using my external text editor is it possible to execute directly one of the functions that are inside the file without executing the source(myfile.R) command first? Best Regards Alex - Original Message From: Duncan Murdoch murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.com To: alaios ala...@yahoo.com mailto:ala...@yahoo.com Cc: r-help@r-project.org mailto:r-help@r-project.org Sent: Fri, July 23, 2010 2:13:48 PM Subject: Re: [R] Syntax Highlightning and Editor for Linux On 23/07/2010 8:08 AM, alaios wrote: Hello to the community . First post :) I would like to ask you which text editor do you use in Linux and how did you setup the syntax highlightning? I don't use Linux, but I think the most popular editors there are vim and emacs, the latter with ESS. one more question is it possible to debug any program in R by inserting breakpoints? Yes, see the setBreakpoint() and trace() functions. Duncan Murdoch I would like to thank you in advance for your help Best Regards Alex __ R-help@r-project.org mailto: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 mailto: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. - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Tel:+33 - (0)9 53 10 27 44 Cell: +27 - (0)8 39 47 90 42 Fax (SA): +27 - (0)8 65 16 27 82 Fax (D) : +49 - (0)3 21 21 25 22 44 Fax (FR): +33 - (0)9 58 10 27 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxJoq0ACgkQoYgNqgF2egq8sACffnYZQ0bkWm+bL51UxtG/LRAq YmgAn1qivOiOOcopqk6CD7FTQqtHVc9I =2wCL -END PGP SIGNATURE- __ 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 process this in R
Hi On Wed, Jul 7, 2010 at 7:49 PM, jd6688 jdsignat...@gmail.com wrote: Here are what i am going to accomplish: I have 400 files named as xxx.txt. the content of the file looks like the following: namecount 1. aaa 100 2. bbb2000 3. ccc300 4. ddd 3000 more that 1000 rows in each files. these are the areas i need help: 1. how can i only read in the files with the string patterns ggg or fff as part of the file names? for instance, I only need the file names with the ggg or fff in it x_ggg_y_1.txt _fff__xxx.txt i don't need to read in the files, such as _aaa_.txt Look at the function list.files() and grep(). list.fiels reads all filenames in a directory into R, with grep you can search the file for the pattern ggg and fff finally, use read.table to load them. 2.how cam rename the files: for instance: x_ggg_y_1.txt==changed to ggg1a.txt ? file.rename There are several functions, starting with file. , to do file operations operation system independent. 3.after the files read in, how can i only keep the rows with the aaa and bbb, everything elses show be removed from the files, but the files still remain the same file name? for instance, in the x_ggg_y_1.txt file, it shouls looks like: namecount 1. aaa100 2. bbb2000 3. aaa300 4. bbb400 again, check grep or subset. Cheers, Rainer Thanks so lot, I am very new to R, I am looking forward to any helps from you. -- View this message in context: http://r.789695.n4.nabble.com/how-to-process-this-in-R-tp2281283p2281283.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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] x-axis labels for barplot of zoo object
Hi Let's assume, I have a dataset of 1000 datapoints, which represent daily recordings of a measurement. They are stored as a ts object (see example below) Now I want to represent them as a barplot. I found the barplot in the zoo package, but I have one problem: the x-axis labels. I would like to have the x-axis labels as either years only (located at the beginning of the year), or year/month. So my question: How can I set the x-axis labels to years I can change the start / end of the time series if necessary or use another barplot. Below find a small example: library(zoo) x - ts(runif(1000), start=c(2000, 150), frequency=365) barplot(zoo(x)) Cheers, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] x-axis labels for barplot of zoo object
On Thu, Jul 8, 2010 at 12:42 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Thu, Jul 8, 2010 at 4:17 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi Let's assume, I have a dataset of 1000 datapoints, which represent daily recordings of a measurement. They are stored as a ts object (see example below) Now I want to represent them as a barplot. I found the barplot in the zoo package, but I have one problem: the x-axis labels. I would like to have the x-axis labels as either years only (located at the beginning of the year), or year/month. So my question: How can I set the x-axis labels to years I can change the start / end of the time series if necessary or use another barplot. Below find a small example: library(zoo) x - ts(runif(1000), start=c(2000, 150), frequency=365) barplot(zoo(x)) Try this: library(zoo) plot(as.zoo(x), type = h, xaxt = n) axis(1, unique(floor(time(x or this: plot(x, type = h, xaxt = n) axis(1, unique(floor(time(x Thanks a lot Gabor - works perfectly. Cheers, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] sharing experience - installing R Spatial Views
On Sat, Jun 12, 2010 at 2:37 AM, Hendro Wibowo hendrohwib...@gmail.comwrote: Hi Guys, I would like to share my experience when installing the Spatial views packages for R. I could not install 32 packages which are parts of the Spatial views, and I use google-search and search to solve ALL those problems for about 2 days. I hope maybe somebody would benefit from my experience. I admitted that I do not have excellent programming skills at all. So, perhaps some of steps I did are not necessary to solve the problem at hands. But it works and I am happy. I was lucky if the problem I have was already solved by someone else, or if the problem is just a matter of installing another R packages that depends on other packages. Sometimes it has something to do not with R package but with a package that has to be installed in my operating system (in my case LinuxMint 8, based on ubuntu karmic). so I just guessed the nature of the problem, and try to solve it via already solved similar problem. i found many problems solved direct or indirect from Nabble - OSGeo FOSS4G websites. of course many problem are also solved from other website other than Nabble, but I forgot their address, as I google search again and again for all those problems. But I do appreciate everyone who post their problems, solved or not solved, so I can solved my own problem, either directly or indirectly (by using the idea and guessing from already solved problem). I found that we need to change from gcc version 4 to 3, in order to some packages to be installed (I forgot which one). The script i used to achieve that, taken from the internet, is placed at the bottom of this message. and finally below here are lists of problems and solutions of installing Spatial Views. . . . SNIP The main complication here seems to be that packages have (obviously) dependencies and that especially Task View packages have MANY dependencies which can not be resolved by R but on the operating system (Linux and Mac - Windows is a different story) level. To make the installation easier, would it be possible to put these dependencies on the website of the task views, and possibly even provide commands for the most widely used Linux distros on how to install them? This could save quite some time in installing those. Cheers, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] R Output and ArcGIS
On Tue, Jan 26, 2010 at 11:42 AM, Steve Murray smurray...@hotmail.comwrote: Dear all, Thanks for the replies so far. Just to emphasise, I'm not using Excel in any way. I have many many files to output, so it'd take considerable time to export from R, reprocess in Excel, then load into Arc! On a PC I'm able to go directly from R to ArcMap (9.3) without having to go via Excel. I've simply been viewing the data in Notepad, which was fine for observing the removal of the end-of-line characters and general format of the data (3 columns). My data are structured as follows: str(mrunoff) 'data.frame':61538 obs. of 3 variables: $ Latitude : chr 5.75 6.25 6.75 7.25 ... $ Longitude: Factor w/ 720 levels 0.25,0.75,..: 1 1 1 1 1 1 1 1 1 1 ... $ Runoff : num 0.687 2.661 0 0 0 ... what about changing the class from Longitude and Latitude to numeric? This could probably solve the problem? I can't use col.names=NA, as I do have column names! These are also required by Arc as identifiers. Also, as you can see, there are no complications in the variable names which, as you rightly say, can cause problems in Arc. If anyone has any further suggestions regarding how to overcome this problem of generating data from R on a Mac for input to ArcGIS on a PC, then I'd be very grateful to hear them. In addition, as far as I know, Arc can read dbf and from R, you can export to dbf, via the package foreign - might be worth a try. Cheers, Rainer Many thanks again, Steve _ Got a cool Hotmail story? Tell us now __ 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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] superimpose histogram and fitted gamma pdf
On Thu, Jan 21, 2010 at 8:47 AM, Roslina Zakaria zrosl...@yahoo.com wrote: Hi r-users, I try to draw histogram (in terms of probabilty) and superimpose with the gamma pdf. Using this code below I can get the plots BUT the y scale for the density is out of scale. How do I change the y-axis scale to max 1? Another thing, how I do draw smooth line rather that points? Nota that my observed data is hume_pos and the fitted data is rgam1. hist(hume_pos,prob=TRUE) points(density(rgam1), add=TRUE, col=red) Check the thread Histogram and Density on the the same graph from 11/30/09 - there is the questions discussed and also includes a link to an earlier thread. Rainer Thank you so much for your help. [[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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] OT: Software for specific visualisation of data...ideas?
On Tue, Jan 19, 2010 at 6:56 PM, Ista Zahn istaz...@gmail.com wrote: You might be able to do that with Rgraphviz or another R package, but if I was doing it I would probably use PGF/tikZ. The homepage is here: http://pgf.sourceforge.net/ I second that - gives you really good results. Cheers, Rainer -Ista On Tue, Jan 19, 2010 at 4:27 PM, Gavin Simpson gavin.simp...@ucl.ac.uk wrote: Dear List, A student in the Department where I work would like to produce a graphic similar to this one: http://image.guardian.co.uk/sys-files/Guardian/documents/2009/09/16/Public_spending_160909.pdf Does anyone know if the figure in the pdf can be generated in a specific software application for example? Any suggestions would be most gratefully received by the student concerned. Many thanks, G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ 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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ 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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Can I save R graphs as a R objects
On Fri, Jan 15, 2010 at 11:26 AM, vikrant vikrant.shi...@tcs.com wrote: Can I save R graphs as a R objects ? I have seen that feature in the rkward GUI (which is by the way the BEST GUI I have seen for a long time!), but I haven't played with that feature a lot, so I can not comment on your second question. By the way: rkward has SOME editing functionality for graphs, after they are created (GUI type) Cheers, Rainer IF yes then if I click this R object can I edit my chart as in Excel. Please suggest your views -- View this message in context: http://n4.nabble.com/Can-I-save-R-graphs-as-a-R-objects-tp1014621p1014621.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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Playing with rgl: a Youtube video
On Tue, Dec 22, 2009 at 8:10 PM, Duncan Murdoch murd...@stats.uwo.cawrote: On 22/12/2009 12:49 PM, Mark Knecht wrote: On Mon, Dec 21, 2009 at 4:42 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: I've just posted a demo made with the rgl package to Youtube, visible here: http://www.youtube.com/watch?v=prdZWQD7L5c For future reference, here are the steps I used: 1. Design a shape to be displayed, and then play with the animation functions to make it change over time. Use play3d to do it live in R, movie3d to write the individual frames of the movie to .png files. 2. Use the ffmpeg package (not an R package, a separate project at http://ffmpeg.org) to convert the .png files to an .mp4 file. The individual frames totalled about 1 GB; the compressed movie is about 45 MB. Could you please post the command line options you used for ffmpeg? I remember I wanted to do an animation, also from .png, and I struggled a lot. Rainer 3. Upload to Youtube. I'm not a musician, so I had to use one of their licensed background tracks, I couldn't write my own. I spent a lot of time picking one and then adjusting the timing of the video to compensate. Each render/upload cycle at full resolution took about an hour and a half. It's a lot faster to render in a smaller window with fewer frames per second, but it's still tedious. It's easier to synchronize if you actually have a copy of the music locally, but Youtube doesn't let you download their music. So the timing isn't perfect, but it's good enough for me! Duncan Murdoch Cool enough video. Thanks for sharing. I'm curious - did you do the equations for the knot in R? If so what did they look like, assuming there's no reason you cannot share it. The knot has equation cbind(sin(theta)+2*sin(2*theta), 2*sin(3*theta), cos(theta)-2*cos(2*theta)) The threads in the braid have equation cbind(sin(theta) + sin(2*theta)/2, sin(theta-pi) + sin(2*theta)/2, theta) in the local coordinates of the knot. Overall it's about 100 lines of R code, too ugly to post. Duncan Murdoch __ 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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Creating bibtex file of all installed packages?
On Fri, Dec 11, 2009 at 9:41 AM, Achim Zeileis achim.zeil...@wu-wien.ac.atwrote: On Fri, 11 Dec 2009, Rainer M Krug wrote: Hi is there an easy and fast way, to generate a BibTeX file of all installed / loaded packages and R? I know about toBibtex(citation()) to extract the BibTeX for a single package, but how can I generate a file containg citations for all installed / loaded packages? I don't think that there is a way other than calling citation() for each of the installed.packages(). You could do something like this: ## try to get BibTeX for each of the installed packages b - lapply(installed.packages()[,1], function(x) try(toBibtex(citation(x ## omit failed citation calls b - b[-which(sapply(b, class) == try-error)] ## unify to list of Bibtex b - lapply(b, function(x) if(inherits(x, Bibtex)) list(x) else x) ## list of unique entries b - unique(do.call(c, b)) ## write everything to a single .bib file writeLines(do.call(c, lapply(b, as.character)), Rpackages.bib) Thanks a lot Achim. That works. It would actually be nice, if the citation() function could take more then one package name, and probably have an option to save the citations into a BibTeX file. Thanks, Rainer hth, Z Cheers, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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 bibtex file of all installed packages?
Hi is there an easy and fast way, to generate a BibTeX file of all installed / loaded packages and R? I know about toBibtex(citation()) to extract the BibTeX for a single package, but how can I generate a file containg citations for all installed / loaded packages? Cheers, Rainer -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Histogram and Density on the the same graph
Chek the topic Second y-axis --- alternative to par(new= which was discussed recently - in that one, there are a few examples, how that can be achieved. Essentially, you have to make sure, that the xlims of the hist() and plot(density()) are the same, and you have to use the par(new=TRUE) (or FALSE - I always forget) before the plot(density()) Cheers, Rainer On Mon, Nov 30, 2009 at 2:51 PM, Hrishi Mittal hrishimit...@gmail.comwrote: Trafim, If you are plotting more than one variables on the same plot e.g. by using the lines() or points() function, then the limits of the X and Y axes are set based on the first variable you plot. So, you would have to set the xlim and ylim to the limits of the variable with the widest range, otherwise you would sometimes see some data left out. Check the topic Second y-axis --- alternative to par(new= which was discussed recently - in that one, there are a few examples, how that can be achieved. Essentially, you have to make sure, that the xlims of the hist() and plot(density()) are the same, and you have to use the par(new=TRUE) (or FALSE - I always forget) before the plot(density()) Cheers, Rainer -- View this message in context: http://n4.nabble.com/Histogram-and-Density-on-the-the-same-graph-tp931182p931236.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. -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)321 2125 2244 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Keeping package sources for recompilation with new R version?
2009/10/25 Uwe Ligges lig...@statistik.tu-dortmund.de Rainer M Krug wrote: Hi I am using Ubuntu Hardy, and I installing many packages from source. I am keeping my R packages fairly up to date. My question is: is there a way, of keeping the source packages, so that when I am installing a new version of R, an update.packages(checkBuilt=TRUE) will only fetch the packages when newer ones are available, but otherwise will use the local copies? To rephrase it, is it possible to have some kind of local repository for the source packages which are installed, so that only packages are downloaded when newer ones are available? I could use destdir to specify the directory in which to save the source files of the packages, but how can I use this directory as a first choice, and only download if a newer version exists? Rainer Hi Uwe I think it won't work out of the box, but you can do it with little efforts. The probably easiest way is to That's a pity - I think it would be an usefull feature, if this could be done automatically. 1) make the local directory of source packages a repository by adding a PACKAGES file using write_PACKAGES() from package tools, 2) choose your local repository first on the list of repositories and second a repository on a CRAN and/or BioC mirror etc., 3) use update.packages() and it will grab from your first repository if there is no repository with a newer version number. This sounds easy enough - I'll look into that. Thanks a lot, Rainer Best, Uwe Ligges -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] sunflowerplot - digits parameter separate for x and y values?
Hi I have a sunflowerplot, in which the x and y axis cover different ranges (different orders of magnitude). Is it possible to specify different digits for the x and y axis? Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Keeping package sources for recompilation with new R version?
Hi I am using Ubuntu Hardy, and I installing many packages from source. I am keeping my R packages fairly up to date. My question is: is there a way, of keeping the source packages, so that when I am installing a new version of R, an update.packages(checkBuilt=TRUE) will only fetch the packages when newer ones are available, but otherwise will use the local copies? To rephrase it, is it possible to have some kind of local repository for the source packages which are installed, so that only packages are downloaded when newer ones are available? I could use destdir to specify the directory in which to save the source files of the packages, but how can I use this directory as a first choice, and only download if a newer version exists? Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Pausing R
On Mon, Oct 19, 2009 at 2:40 PM, Anders Carlsson anders.carls...@immun.lth.se wrote: Peter Dalgaard wrote: Anders Carlsson wrote: Hello, I’m currently running a script that takes several days to complete, and have therefore chosen to start two instances of R, each doing half the work (since I have a two-processor machine). The problem is that this renders my computer worthless to do other work on. So - is it possible to pause one of the running R instances to do other things for a while, and then starting it again without losing anything? TL;DR I want to know if it is possible to pause a running script. Well it is easy on Unix/Linux and presumably also MacOSX, but (as Brian Ripley once put it) since you're not telling us what OS you are using, it is probably Windows... Looks like iet is possible there via 3rd party tools; e.g., there's something called DTaskManager. I realized I missed that just after submitting... But you were right of course - I am a Windows user. I am not - I am using Linux. Just for interests sake: how can I pause a task in Linux? Rainer DTaskManager did the trick - many thanks! /Anders __ 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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.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.
Re: [R] Pausing R
On Mon, Oct 19, 2009 at 3:01 PM, Karl Ove Hufthammer k...@huftis.org wrote: In article fb7c7e870910190551i5fb96074t76f2c800e3e5cf33 @mail.gmail.com, r.m.k...@gmail.com says... I am not - I am using Linux. Just for interests sake: how can I pause a task in Linux? If you start the application using the command line, just press 'Ctrl + Z' to pause/suspend it. Then type 'fg' when you want to resume it. Perfect - thanks Rainer -- Karl Ove Hufthammer __ 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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.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.
Re: [R] Pausing R
On Mon, Oct 19, 2009 at 3:21 PM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Mon, Oct 19, 2009 at 2:01 PM, Karl Ove Hufthammer k...@huftis.org wrote: If you start the application using the command line, just press 'Ctrl + Z' to pause/suspend it. Then type 'fg' when you want to resume it. If you can't get to the command line where you started R, then you can send the process the 'STOP' and 'CONT' signals using the 'kill' command. You need to get the process ID (see man ps for this) and then use kill -STOP 12345 and kill -CONT 12345 where 12345 is the process ID. That is how it works - that is ALLY good to know. Quite what happens if you are running multiple R threads via the multicore package or any of the other multiple process packages... I don't know... Of course the real answer is to run long processes on a server - preferably one with an uninterruptible power supply and a diesel I agree - that is the best way of doing it (and I am using a cluster), but if there is none, a simulation, activated in the evenings, and paused in the mornings, via a cron job, is an interesting thing to play with. generator - or make your process checkpointable so you can kill it and restart it again. Checkpoints - have thought about it for a few times, but dismissed as beeing to complicated for my cases. Rainer Barry __ 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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.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.
Re: [R] intersection of 2 density curves
On Thu, Oct 8, 2009 at 4:26 PM, Monica Pisica pisican...@hotmail.comwrote: fb7c7e870910080701o1683a41q7d4295d97af8c...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Hi=2C =20 Thanks so much for your answer. It works beautifully for my example and of = course i will test it on thereal data as well. Just make sure, that it is choosing the right value - it might be that it is choosing one to big or one to small (because of the diff()). =20 Thanks again=2C Pleasure Rainer =20 Monica Date: Thu=2C 8 Oct 2009 16:01:36 +0200 Subject: Re: [R] intersection of 2 density curves From: r.m.k...@gmail.com To: pisican...@hotmail.com CC: r-h...@stat.math.ethz.ch On Thu=2C Oct 8=2C 2009 at 3:48 PM=2C Monica Pisica wrote: Hi=2C I would like to find out the coordinates of the intersection points of 2 = density curves. I did a search but i didn't get any significant results. I = really hope some of you have some ideas. here it is an example: set.seed(123) x1 - rnorm(100=2C 1=2C 1) x2 - rnorm(100=2C 0=2C 1) d1 - density(x1) d2 - density(x2) plot(d1=2C col =3D 2) lines(d2=2C col =3D 4) if you specify n=2C from ant to in density() and keep them the same=2C th= en the density estimates are done for the same x-coordinates. Therefore you= can compare d1$y with d2$y to deternine=2C where they intersect: d2 - density(x2=2C from=3D-3=2C to=3D5=2C n=3D2048) d1 - density(x1=2C from=3D-3=2C to=3D5=2C n=3D2048) plot(d1=2C col =3D 2) lines(d2=2C col =3D 4) d1$y d2$y intersX - d1$x[as.logical(abs(diff(d1$y d2$y)))] intersY - d1$y[as.logical(abs(diff(d1$y d2$y)))] abline(v=3Dinters) abline(h=3DintersY) Cheers=2C Rainer Now i would like to know the coordinates of the intersection point. I did= some trial and error and i come up with these (that means i did sev= eral vertical and horizontal lines through the graph until visually i hit= the intersection point) abline(v =3D 0.35=2C lty =3D 2) abline(h =3D 0.34=2C lty =3D 2) I really appreciate any hints you may have=2C thanks so much=2C Monica _ Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. http://clk.atdmt.com/GBL/go/171222985/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.h= tml and provide commented=2C minimal=2C self-contained=2C reproducible code. -- Rainer M. Krug=2C PhD (Conservation Ecology=2C SUN)=2C MSc (Conservation = Biology=2C UCT)=2C Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus=2C Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax: +27 - (0)86 516 2782 Fax: +49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com =0A= _=0A= Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.=0A= http://clk.atdmt.com/GBL/go/171222985/direct/01/= -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Question about mirroring CRAN
Hi this might be the wrong mailing list, but it also does not fit the dev list. As we are planning to setup a mirror of CRAN, we would like to know the approximate size of the mirror and the necessary bandwidth requirements to keep it updated. Thanks a lot in advance, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Second y-axis --- alternative to par(new=
Hi is there an alternative to par(new), for ading data to a plot for a different y-axis? My problem with par(new=TRUE) is, that it re-defines all axis and labels (as in example 1) and one has to use xlim=... to fix the x-axis. I am looking for something, which simply resets the y-axis, so that a new plot() (or points()/lines()) keeps the x-axis, but re-defines the y-axis. Is there something available? I could re-scale the y-data to fit the existing y-axis, but that would mean to define all the labels and tickmarks for axis 4 manually. HEre is an example about what I mean: x1 - 1:10 y1 - runif(10) x2 - 1:11 y2 - c(y1*100, 0) ## (1) Does not plot points where (x-axis) they should be plot(x1, y1, type=l) par(new=TRUE) plot(x2, y2, type=p) axis(4) ## (2) Does plot points where (x-axis) they should be xlim - range(x1) plot(x1, y1, type=l, xlim=xlim) par(new=TRUE) plot(x2, y2, type=p, xlim=xlim) axis(4) Cheers, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Second y-axis --- alternative to par(new=
On Wed, Oct 7, 2009 at 11:28 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Try ?twoord.plot from plotrix package. Thanks Petr - I was not aeware of this command. But I would prefer a more general solution. An example on where I am using is, to plot a histogram overlayed by its density estimate (easier to digest for others then only a density estimate). And a newY() (or par(newY=TRUE) command would enable exactly this. Regards, Rainer Regards Petr r-help-boun...@r-project.org napsal dne 07.10.2009 10:29:53: Hi is there an alternative to par(new), for ading data to a plot for a different y-axis? My problem with par(new=TRUE) is, that it re-defines all axis and labels (as in example 1) and one has to use xlim=... to fix the x-axis. I am looking for something, which simply resets the y-axis, so that a new plot() (or points()/lines()) keeps the x-axis, but re-defines the y-axis. Is there something available? I could re-scale the y-data to fit the existing y-axis, but that would mean to define all the labels and tickmarks for axis 4 manually. HEre is an example about what I mean: x1 - 1:10 y1 - runif(10) x2 - 1:11 y2 - c(y1*100, 0) ## (1) Does not plot points where (x-axis) they should be plot(x1, y1, type=l) par(new=TRUE) plot(x2, y2, type=p) axis(4) ## (2) Does plot points where (x-axis) they should be xlim - range(x1) plot(x1, y1, type=l, xlim=xlim) par(new=TRUE) plot(x2, y2, type=p, xlim=xlim) axis(4) Cheers, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Second y-axis --- alternative to par(new=
On Wed, Oct 7, 2009 at 11:53 AM, Petr PIKAL petr.pi...@precheza.cz wrote: r-help-boun...@r-project.org napsal dne 07.10.2009 11:37:22: On Wed, Oct 7, 2009 at 11:28 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Try ?twoord.plot from plotrix package. Thanks Petr - I was not aeware of this command. But I would prefer a more general solution. An example on where I am using is, to plot a histogram overlayed by its density estimate (easier to digest for others then only a density estimate). That is quite different from your example. Well - in both cases, I want to overlay two graphs - in my example, it is a line and a point plot, in the other a histogram and a density estimate. I believe overlay of density curve over histogram was discussed several times e.g. http://tolstoy.newcastle.edu.au/R/e4/help/08/06/14198.html Thanks - but if I want to have the histogram with counts (freq=TRUE), then I have exactly the situation I was talking about - sorry for not being clear: x - rnorm(200) hist(x, col = blue, freq = TRUE) lines(density(x), col = red, lwd = 2) i.e. left y-axis (histogram): count right y-axis (density estimate): probability density And a newY() (or par(newY=TRUE) command would enable exactly this. This is something beyond my knowledge and it could be that this need some deep redefining in base R graphics. That's what I guess as well - let's see. Rainer Regards Petr Regards, Rainer Regards Petr r-help-boun...@r-project.org napsal dne 07.10.2009 10:29:53: Hi is there an alternative to par(new), for ading data to a plot for a different y-axis? My problem with par(new=TRUE) is, that it re-defines all axis and labels (as in example 1) and one has to use xlim=... to fix the x-axis. I am looking for something, which simply resets the y-axis, so that a new plot() (or points()/lines()) keeps the x-axis, but re-defines the y-axis. Is there something available? I could re-scale the y-data to fit the existing y-axis, but that would mean to define all the labels and tickmarks for axis 4 manually. HEre is an example about what I mean: x1 - 1:10 y1 - runif(10) x2 - 1:11 y2 - c(y1*100, 0) ## (1) Does not plot points where (x-axis) they should be plot(x1, y1, type=l) par(new=TRUE) plot(x2, y2, type=p) axis(4) ## (2) Does plot points where (x-axis) they should be xlim - range(x1) plot(x1, y1, type=l, xlim=xlim) par(new=TRUE) plot(x2, y2, type=p, xlim=xlim) axis(4) Cheers, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[alternative HTML version deleted]] __ R
Re: [R] Second y-axis --- alternative to par(new=
On Wed, Oct 7, 2009 at 12:26 PM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Rainer M Krug r.m.k...@gmail.com napsal dne 07.10.2009 12:09:21: On Wed, Oct 7, 2009 at 11:53 AM, Petr PIKAL petr.pi...@precheza.cz wrote: r-help-boun...@r-project.org napsal dne 07.10.2009 11:37:22: On Wed, Oct 7, 2009 at 11:28 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Try ?twoord.plot from plotrix package. Thanks Petr - I was not aeware of this command. But I would prefer a more general solution. An example on where I am using is, to plot a histogram overlayed by its density estimate (easier to digest for others then only a density estimate). That is quite different from your example. Well - in both cases, I want to overlay two graphs - in my example, it is a line and a point plot, in the other a histogram and a density estimate. I believe overlay of density curve over histogram was discussed several times e.g. http://tolstoy.newcastle.edu.au/R/e4/help/08/06/14198.html Thanks - but if I want to have the histogram with counts (freq=TRUE), then I have exactly the situation I was talking about - sorry for not being clear: x - rnorm(200) hist(x, col = blue, freq = TRUE) lines(density(x), col = red, lwd = 2) i.e. left y-axis (histogram): count right y-axis (density estimate): probability density And a newY() (or par(newY=TRUE) command would enable exactly this. This is something beyond my knowledge and it could be that this need some deep redefining in base R graphics. That's what I guess as well - let's see. In the meantime, what about x - rnorm(200) hist(x, col = blue, freq = TRUE) ddd-density(x) lines(ddd$x, ddd$y*100, col = red, lwd = 2) and then add suitable y axis. axis(4, at=pretty(ddd$y*100), labels=pretty(ddd$y), col=2) Yes - that definitely works. I usually use the following approach: determine the xlims in advance, and then set them manually for each plot: x - rnorm(200) xlim - trunc(range(x)) + c(-1, +1) hist(x, col = blue, freq = TRUE, xlim=xlim) par(new=TRUE) plot(density(x), xlim=xlim, ann=FALSE, axes=FALSE) axis(4) But it is sometimes tricky to get the xlims for the plot. Regards Petr Rainer Regards Petr Regards, Rainer Regards Petr r-help-boun...@r-project.org napsal dne 07.10.2009 10:29:53: Hi is there an alternative to par(new), for ading data to a plot for a different y-axis? My problem with par(new=TRUE) is, that it re-defines all axis and labels (as in example 1) and one has to use xlim=... to fix the x-axis. I am looking for something, which simply resets the y-axis, so that a new plot() (or points()/lines()) keeps the x-axis, but re-defines the y-axis. Is there something available? I could re-scale the y-data to fit the existing y-axis, but that would mean to define all the labels and tickmarks for axis 4 manually. HEre is an example about what I mean: x1 - 1:10 y1 - runif(10) x2 - 1:11 y2 - c(y1*100, 0) ## (1) Does not plot points where (x-axis) they should be plot(x1, y1, type=l) par(new=TRUE) plot(x2, y2, type=p) axis(4) ## (2) Does plot points where (x-axis) they should be xlim - range(x1) plot(x1, y1, type=l, xlim=xlim) par(new=TRUE) plot(x2, y2, type=p, xlim=xlim) axis(4) Cheers, Rainer -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype
Re: [R] Second y-axis --- alternative to par(new=
On Wed, Oct 7, 2009 at 1:48 PM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Rainer M Krug r.m.k...@gmail.com napsal dne 07.10.2009 12:40:39: On Wed, Oct 7, 2009 at 12:26 PM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Rainer M Krug r.m.k...@gmail.com napsal dne 07.10.2009 12:09:21: snip In the meantime, what about x - rnorm(200) hist(x, col = blue, freq = TRUE) ddd-density(x) lines(ddd$x, ddd$y*100, col = red, lwd = 2) and then add suitable y axis. axis(4, at=pretty(ddd$y*100), labels=pretty(ddd$y), col=2) Yes - that definitely works. I usually use the following approach: determine the xlims in advance, and then set them manually for each plot: x - rnorm(200) xlim - trunc(range(x)) + c(-1, +1) hist(x, col = blue, freq = TRUE, xlim=xlim) hhh - hist(x, col = blue, freq = TRUE) gives you object from which you can extract limits for plotting maybe better then from original data and you do not need to call par(new=TRUE) True. Thanks a lot, Rainer Regards Petr plot(density(x), xlim=xlim, ann=FALSE, axes=FALSE) axis(4) But it is sometimes tricky to get the xlims for the plot. Regards Petr -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] nls not accepting control parameter?
On Fri, Oct 2, 2009 at 7:23 PM, Peter Ehlers ehl...@ucalgary.ca wrote: Hello Rainer, I think that your problem is with trying to fit a logistic model to data that don't support that model. Removing the first two points from your data will work (but of course it may not represent reality). The logistic function does not exhibit the kind of minimum that your data suggest. Hi Peter partly - when I do as you suggest, it definitely works, but this does not change the behavioyur, that the error message always says: step factor 0.000488281 reduced below 'minFactor' of 0.000976562 and it does not change to whichever value I try to set minFactor. So either I am misunderstanding what the control argument for nls is doing, or there is a bug in nls or in the error message. Rainer -Peter Ehlers Rainer M Krug wrote: Hi I want to change a control parameter for an nls () as I am getting an error message step factor 0.000488281 reduced below 'minFactor' of 0.000976562. Despite all tries, it seems that the control parameter of the nls, does not seem to get handed down to the function itself, or the error message is using a different one. Below system info and an example highlighting the problem. Thanks, Rainer version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.2 year 2009 month 08 day24 svn rev49384 language R version.string R version 2.9.2 (2009-08-24) sessionInfo() R version 2.9.2 (2009-08-24) i486-pc-linux-gnu locale: LC_CTYPE=en_ZA.UTF-8;LC_NUMERIC=C;LC_TIME=en_ZA.UTF-8;LC_COLLATE=en_ZA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_ZA.UTF-8;LC_PAPER=en_ZA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_ZA.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] R.utils_1.2.0 R.oo_1.5.0R.methodsS3_1.0.3 maptools_0.7-26 [5] sp_0.9-44 foreign_0.8-37 loaded via a namespace (and not attached): [1] grid_2.9.2 lattice_0.17-25 # EXAMPLE: dat - data.frame( x = 2006:2037, y = c(143088, 140218, 137964, 138313, 140005, 141483, 142365, 144114, 145335, 146958, 148584, 149398, 151074, 152241, 153919, 155580, 157258, 158981, 160591, 162126, 163743, 165213, 166695, 168023, 169522, 170746, 172057, 173287, 173977, 175232, 176308, 177484) ) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, trace=TRUE) (newMinFactor - 1/(4*1024)) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=nls.control(minFactor=newMinFactor), trace=TRUE) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=c(minFactor=newMinFactor), trace=TRUE) (newMinFactor - 4/1024) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=nls.control(minFactor=newMinFactor), trace=TRUE) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=c(minFactor=newMinFactor), trace=TRUE) -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Compress (gzip) a pdf device
On Thu, Oct 1, 2009 at 7:26 PM, Martin Renner martin.ren...@stonebow.otago.ac.nz wrote: try pdftk. Not quite on the fly but should do the trick. (I saw this on this list a little while ago) pdftk compresses the pdf internally - it is still a pdf, can be opened as a pdf, and is not an externally compressed pdf (pdf in an archive). Below is the approach which I am using, but as stated earlier, if somebody could provide a way of only doing dev.off() whhich then calls pdfComp() with the filename, I would be glad to know. Otherwise. Rainer pdfComp - function (pdfname){ if (0){ x - tempfile() system (paste (mv, pdfname, x)) system (paste (pdftk, x, output, pdfname, compress)) unlink (x) } } pdf (test.pdf) plot (1:10) dev.off() pdfComp (test.pdf) On 30 Sep 2009, at 00:25 , Rainer M Krug wrote: 2009/9/30 Daniele Amberti daniele.ambe...@ors.it I have not found an easy way to compress a file on filesystem. Especially I'd like to compress a pdf from pdf() function/device. Is it possible to compress It on the flight? I'd like to do something like: pdf(gzipconnection()) dev.off() I guess this boils down to a question I asked some time ago concerning getting the filename of a pdf() device, as I wanted to create a compressed pdf from the uncompressed pdf created by R (not zipping the pdf). It does not seem to be possible, at least I did not get any response which I could use to implement my idea (create my dev.off(), which calls dev.off() and afterwards compresses the pdf by using the file name). If you find a solution, please let me know. Cheers, Rainer If It is not possible, how can I create a gzip with the pdf? Thanks Daniele A. ORS Srl Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy Tel. +39 0173 620211 Fax. +39 0173 620299 / +39 0173 433111 Web Site www.ors.it Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi allegati ? vietato e potrebbe costituire reato. Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se provvedesse alla distruzione dello stesso e degli eventuali allegati. Opinioni, conclusioni o altre informazioni riportate nella e-mail, che non siano relative alle attivit? e/o alla missione aziendale di O.R.S. Srl si intendono non attribuibili alla societ? stessa, n? la impegnano in alcun modo. [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Compress (gzip) a pdf device
On Fri, Oct 2, 2009 at 9:02 AM, Gábor Csárdi csa...@rmki.kfki.hu wrote: Rainer, if you are willing to patch the R source, then a solution might be the R connection patch, see http://wiki.r-project.org/rwiki/doku.php?id=developers:r_connections_api It is a bit outdated, but with a little work I could use it for R 2.9.2 and works fine. Thanks - I will look into it and give feedback as soon as I have done. Cheers, Rainer Best, Gabor On Fri, Oct 2, 2009 at 8:54 AM, Rainer M Krug r.m.k...@gmail.com wrote: On Thu, Oct 1, 2009 at 7:26 PM, Martin Renner martin.ren...@stonebow.otago.ac.nz wrote: try pdftk. Not quite on the fly but should do the trick. (I saw this on this list a little while ago) pdftk compresses the pdf internally - it is still a pdf, can be opened as a pdf, and is not an externally compressed pdf (pdf in an archive). Below is the approach which I am using, but as stated earlier, if somebody could provide a way of only doing dev.off() whhich then calls pdfComp() with the filename, I would be glad to know. Otherwise. Rainer pdfComp - function (pdfname){ if (0){ x - tempfile() system (paste (mv, pdfname, x)) system (paste (pdftk, x, output, pdfname, compress)) unlink (x) } } pdf (test.pdf) plot (1:10) dev.off() pdfComp (test.pdf) On 30 Sep 2009, at 00:25 , Rainer M Krug wrote: 2009/9/30 Daniele Amberti daniele.ambe...@ors.it I have not found an easy way to compress a file on filesystem. Especially I'd like to compress a pdf from pdf() function/device. Is it possible to compress It on the flight? I'd like to do something like: pdf(gzipconnection()) dev.off() I guess this boils down to a question I asked some time ago concerning getting the filename of a pdf() device, as I wanted to create a compressed pdf from the uncompressed pdf created by R (not zipping the pdf). It does not seem to be possible, at least I did not get any response which I could use to implement my idea (create my dev.off(), which calls dev.off() and afterwards compresses the pdf by using the file name). If you find a solution, please let me know. Cheers, Rainer If It is not possible, how can I create a gzip with the pdf? Thanks Daniele A. ORS Srl Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy Tel. +39 0173 620211 Fax. +39 0173 620299 / +39 0173 433111 Web Site www.ors.it Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi allegati ? vietato e potrebbe costituire reato. Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se provvedesse alla distruzione dello stesso e degli eventuali allegati. Opinioni, conclusioni o altre informazioni riportate nella e-mail, che non siano relative alle attivit? e/o alla missione aziendale di O.R.S. Srl si intendono non attribuibili alla societ? stessa, n? la impegnano in alcun modo. [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing
[R] nls not accepting control parameter?
Hi I want to change a control parameter for an nls () as I am getting an error message step factor 0.000488281 reduced below 'minFactor' of 0.000976562. Despite all tries, it seems that the control parameter of the nls, does not seem to get handed down to the function itself, or the error message is using a different one. Below system info and an example highlighting the problem. Thanks, Rainer version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.2 year 2009 month 08 day24 svn rev49384 language R version.string R version 2.9.2 (2009-08-24) sessionInfo() R version 2.9.2 (2009-08-24) i486-pc-linux-gnu locale: LC_CTYPE=en_ZA.UTF-8;LC_NUMERIC=C;LC_TIME=en_ZA.UTF-8;LC_COLLATE=en_ZA.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_ZA.UTF-8;LC_PAPER=en_ZA.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_ZA.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] R.utils_1.2.0 R.oo_1.5.0R.methodsS3_1.0.3 maptools_0.7-26 [5] sp_0.9-44 foreign_0.8-37 loaded via a namespace (and not attached): [1] grid_2.9.2 lattice_0.17-25 # EXAMPLE: dat - data.frame( x = 2006:2037, y = c(143088, 140218, 137964, 138313, 140005, 141483, 142365, 144114, 145335, 146958, 148584, 149398, 151074, 152241, 153919, 155580, 157258, 158981, 160591, 162126, 163743, 165213, 166695, 168023, 169522, 170746, 172057, 173287, 173977, 175232, 176308, 177484) ) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, trace=TRUE) (newMinFactor - 1/(4*1024)) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=nls.control(minFactor=newMinFactor), trace=TRUE) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=c(minFactor=newMinFactor), trace=TRUE) (newMinFactor - 4/1024) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=nls.control(minFactor=newMinFactor), trace=TRUE) nls( y ~ SSlogis(x, Asym, xmid, scal), data = dat, control=c(minFactor=newMinFactor), trace=TRUE) -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Compress (gzip) a pdf device
2009/9/30 Daniele Amberti daniele.ambe...@ors.it I have not found an easy way to compress a file on filesystem. Especially I'd like to compress a pdf from pdf() function/device. Is it possible to compress It on the flight? I'd like to do something like: pdf(gzipconnection()) dev.off() I guess this boils down to a question I asked some time ago concerning getting the filename of a pdf() device, as I wanted to create a compressed pdf from the uncompressed pdf created by R (not zipping the pdf). It does not seem to be possible, at least I did not get any response which I could use to implement my idea (create my dev.off(), which calls dev.off() and afterwards compresses the pdf by using the file name). If you find a solution, please let me know. Cheers, Rainer If It is not possible, how can I create a gzip with the pdf? Thanks Daniele A. ORS Srl Via Agostino Morando 1/3 12060 Roddi (Cn) - Italy Tel. +39 0173 620211 Fax. +39 0173 620299 / +39 0173 433111 Web Site www.ors.it Qualsiasi utilizzo non autorizzato del presente messaggio e dei suoi allegati ? vietato e potrebbe costituire reato. Se lei avesse ricevuto erroneamente questo messaggio, Le saremmo grati se provvedesse alla distruzione dello stesso e degli eventuali allegati. Opinioni, conclusioni o altre informazioni riportate nella e-mail, che non siano relative alle attivit? e/o alla missione aziendale di O.R.S. Srl si intendono non attribuibili alla societ? stessa, n? la impegnano in alcun modo. [[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. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] fitting logistic model with constant harvesting
Hi I am fitting simulated data to a logistic model usin SSlogis as follow: nls( cove ~ SSlogis(year, Asym, xmid, scal), data = dat, trace = TRUE, model = TRUE, ... ) This works niocely, but now I have a situation where I have constant harvesting, i.e. where p is the population size, N the carrying capacity, k the growth rate and a the constant harvest. My question is, how can I fit this logistic growth with constant harvesting to my data? Thanks, Raine -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax:+27 - (0)86 516 2782 Fax:+49 - (0)721 151 334 888 email: rai...@krugs.de Skype: RMkrug Google: r.m.k...@gmail.com [[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] Four concurrent Markov chains
A few comments below On Mon, Sep 21, 2009 at 3:10 PM, drlucyasher las...@rvc.ac.uk wrote: Hi, I am trying to write a simulation of the movements of four animals between six patches. The movement between patches is based on a first-order Markov chain so that the next patch they visit depends on the patch they were in before. I have written code that allows me to simulate the movement of one animal but when I add more there seems to be a problem and all chains come back as N/A. I can fix the problem if I run the animals as separate sub-routines but whilst this is adequate for this stage of my model it won't allow me to progress to the next stage. The next stage will be to make the animals move in reference to each other using a moving average variable. Therefore I think I need all animals simulated within one subroutine (loop). I probably haven't explained thie very well but here is the code I have been working on #creation of a 6*6 matrix with the transition probabilities transitions-matrix(0,nrow=6,ncol=6); transitions[1,1]- (0/6); transitions[1,2]- (0/6); transitions[1,3]-(0/6); transitions[1,4]-(0/6);transitions[1,5]-(0/6); transitions[1,6]-(6/6);transitions[2,1]- (1/6);transitions[2,2]- (1/6); transitions[2,3]-(1/6); transitions[2,4]-(1/6);transitions[2,5]-(1/6); transitions[2,6]-(1/6);transitions[3,1]- (1/6);transitions[3,2]- (1/6); transitions[3,3]-(1/6); transitions[3,4]-(1/6);transitions[3,5]-(1/6); transitions[3,6]-(1/6);transitions[4,1]- (1/6);transitions[4,2]- (1/6); transitions[4,3]-(1/6); transitions[4,4]-(1/6);transitions[4,5]-(1/6); transitions[4,6]-(1/6);transitions[5,1]- (1/6);transitions[5,2]- (1/6); transitions[5,3]-(1/6); transitions[5,4]-(1/6);transitions[5,5]-(1/6); transitions[5,6]-(1/6);transitions[6,1]- (1/6);transitions[6,2]- (1/6); transitions[6,3]-(1/6); transitions[6,4]-(1/6);transitions[6,5]-(1/6); transitions[6,6]-(1/6); transitions # start position probalities w - c((1/6), (1/6), (1/6), (1/6), (1/6), (1/6)) #length of the chain n-241 #matrices creation for birds 1-4 observationb1-matrix(nrow=n+1,ncol=6) observationb2-matrix(nrow=n+1,ncol=6) observationb3-matrix(nrow=n+1,ncol=6) observationb4-matrix(nrow=n+1,ncol=6) #chains starting position i-1;observationb1[1,2]-sample(1:6, 1, prob=w, repl=T) i-1;observationb2[1,2]-sample(1:6, 1, prob=w, repl=T) i-1;observationb3[1,2]-sample(1:6, 1, prob=w, repl=T) i-1;observationb4[1,2]-sample(1:6, 1, prob=w, repl=T) the i - 1 above is not necessary. rather use a for loop instead of the while - easier to use. while(in+1){ Here your i == 1 stateb1-observationb1[i,2]; probsb1-transitions[stateb1,1:6]; nextstateb1-rmultinom(1,1,probsb1); seqb1-which.max(nextstateb1); j-i+1; observationb1[j,2]-seqb1;i-j #-if I close the brackets here this Here you set your i to j, i.e. i+1 works but I want to inlcude this next bit of code for bird 2 stateb2-observationb2[i,2]; probsb2-transitions[stateb2,1:6]; nextstateb2-rmultinom(1,1,probsb2); seqb2-which.max(nextstateb2); j-i+1; observationb2[j,2]-seqb2;i-j #and so on for birds 3 and 4. Any help you could give me would be much appreciated. Hope this helps, Rainer Lucy -- View this message in context: http://www.nabble.com/Four-concurrent-Markov-chains-tp25530321p25530321.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. -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] extracting one element from all list elements
Hi I have a list which cosists out of dataframes of the same structure. Now I want to extract one column (let's say column A) from all dataframes and have them in a matrix (or dataframe). At the moment I am doiong: d - data.frame(A=runif(100), B=rnorm(100)) theList - list(e1=d, e2=d, e3=d, e4=d) f - sapply(theList, function(l){l$A} ) But I am sure ther is a more elegant way? Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] extracting one element from all list elements
On Wed, Sep 16, 2009 at 1:35 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: sapply(theList, '[[', 'A') Thanks Henrique - that is much more elegant. Rainer On Wed, Sep 16, 2009 at 8:34 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I have a list which cosists out of dataframes of the same structure. Now I want to extract one column (let's say column A) from all dataframes and have them in a matrix (or dataframe). At the moment I am doiong: d - data.frame(A=runif(100), B=rnorm(100)) theList - list(e1=d, e2=d, e3=d, e4=d) f - sapply(theList, function(l){l$A} ) But I am sure ther is a more elegant way? Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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 -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] List of tags in roxygen and use for S4 classes?
On Mon, Sep 7, 2009 at 9:41 AM, Peter Danenbergp...@roxygen.org wrote: I would also wish for a better (online) documentation, as I think the general idea of roxygen is great. I agree completely. Good call; the vignette is terse and outdated. Manuel and I are in the process of preparing a paper based on our DSC talks; that should fill in some of the details w.r.t. S4. That sounds exciting. I am really looking forward to it - because roxygen is the way to go for documenting. Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] List of tags in roxygen and use for S4 classes?
On Fri, Sep 4, 2009 at 4:47 PM, Bernd Bischlbernd_bis...@gmx.net wrote: Rainer M Krug wrote: Hi is there a list of all roxygen tags which are available? I couldn't find them. I am asking specifically towards the use of roxygen in documenting S4 classes - is that implemented yet (i am using roxygen 0.1 from CRAN at the moment)? Thanks Rainer I am using it do document a now rather large S4 package - with the new development version on rforge (its 0.1-1). It basically works, _but_ : - It took me quite some time to write everything the way roxygen wants it - Error messages are often not very informative. - Many (legal) ways to specify S4 classes / signatures will produce errors, you need to be very verbose. Thanks a lot for the info. - Even disregarding there are still some clear bugs left IMHO. I would also wish for a better (online) documentation, as I think the general idea of roxygen is great. I agree completely. . So it's worth a try but expect some obstacles. There's also a roxygen devel list, where you could go with questions. Good idea. I will post there with questions. I got some S4 examples from one of the recent roxygen talks, If you want them I could forward those. Yes - that would be great. It would give me an idea abut the tags. Cheers, Rainer Bernd -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] getting name from function?
Hi I have the following function which should return the name of FUN: myFUN - function(FUN) { return( THE_NAME_OF_FUN(FUN)) } Is it possible? What do I have tio use here instead of THE_NAME_OF_FUN? Thanks, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] getting name from function?
On Mon, Sep 7, 2009 at 11:26 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Try this, myFUN - function(FUN) { return(deparse(substitute(FUN))) } Thanks - that's it Rainer HTH, baptiste 2009/9/7 Rainer M Krug r.m.k...@gmail.com Hi I have the following function which should return the name of FUN: myFUN - function(FUN) { return( THE_NAME_OF_FUN(FUN)) } Is it possible? What do I have tio use here instead of THE_NAME_OF_FUN? Thanks, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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. -- _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK http://newton.ex.ac.uk/research/emag __ -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] List of tags in roxygen and use for S4 classes?
Hi is there a list of all roxygen tags which are available? I couldn't find them. I am asking specifically towards the use of roxygen in documenting S4 classes - is that implemented yet (i am using roxygen 0.1 from CRAN at the moment)? Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] Getting file name from pdf device?
Hi IU would like to modify the dev.off function, so that it automatically compresses the created pdf. I am thinking of doing the following in the modified dev.off: 1) Get the filename of the pdf device 2) close the device by calling the original dev.off() 3) compress the pdf file with a system call of pdftk. My question: how can I get the filename of the pdf from the device before it is closed? Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] Adding picture to graph?
Thanks a lot for all your responses - I'll check them out and pass them on. Cheers Rainer On Wed, Jul 29, 2009 at 6:32 PM, Greg Snowgreg.s...@imail.org wrote: In addition to the other responses, you may want to look at the subplot function in the TeachingDemos package for a way to place the image at a location within the plot (the other answers so far use the image as a full background), see the last example on the help page for a way to use the R logo as a plotting symbol. If you want to define your own symbols for plotting, look at the my.symbols function in the TeachingDemos package. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Rainer M Krug Sent: Wednesday, July 29, 2009 2:27 AM To: r-h...@stat.math.ethz.ch Subject: [R] Adding picture to graph? Hi while teaching R, the question came up if it would be possible to add a picture (saved on the HDD) to a graph (generated by plot()), which we could not answer. It might easily kill a clean graph, but: is there a way of doing this, even one should not do it? On a similar line of thought: is it possibe to define own symbols so that they can be used in the plot function with pch=? Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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. -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] Adding picture to graph?
Hi while teaching R, the question came up if it would be possible to add a picture (saved on the HDD) to a graph (generated by plot()), which we could not answer. It might easily kill a clean graph, but: is there a way of doing this, even one should not do it? On a similar line of thought: is it possibe to define own symbols so that they can be used in the plot function with pch=? Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] SweaveOpts(eval=false) not working
Hi I hope this is the right mailing list - if not, could you please refer me to a mora appropriate? My question: I am using sweave (in LyX with beamer) for a lecture and I would like to evaluate the R code chunks for the handout, but not for the presentation. I thought that I can use \SweaveOpts(eval=FALSE) to set this option for all code chunks, but it is still evaluating them and showing the output. If I set this option separately for each chunk(i.e. eval=FALSE=), it is, as expected, not evaluating. Am I doing something wrong here or is there a bug in sveawe, so that it is not axcepting eval=FALSE as a global option? Thanks a lot, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] SweaveOpts(eval=false) not working - CORRECTION
On Thu, Jul 23, 2009 at 3:04 PM, Duncan Murdochmurd...@stats.uwo.ca wrote: On 23/07/2009 8:58 AM, Rainer M Krug wrote: Hi I hope this is the right mailing list - if not, could you please refer me to a mora appropriate? My question: I am using sweave (in LyX with beamer) for a lecture and I would like to evaluate the R code chunks for the handout, but not for the presentation. I thought that I can use \SweaveOpts(eval=FALSE) to set this option for all code chunks, but it is still evaluating them and showing the output. If I set this option separately for each chunk(i.e. eval=FALSE=), it is, as expected, not evaluating. Am I doing something wrong here or is there a bug in sveawe, so that it is not axcepting eval=FALSE as a global option? Looks like you used parentheses () instead of braces {} in the \SweaveOpts line. Even though LaTeX never sees it, it uses LaTeX-like syntax. Sorry - typo in the email. In the preamble, it says: \SweaveOpts{keep.source=FALSE, echo=TRUE, eval=FALSE, height=4} Again - Duncan Murdoch Thanks a lot, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sweave output
Hi I am using sweave and have read somewhere a way of adding ... when printing vectors / dataframes which are longer then a given length, but I can't find this anymore. Could somebody point me into the right direction, where I could find it? Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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 get best performance from R on Linux?
On Wed, Jul 1, 2009 at 2:47 AM, Dirk Eddelbuettel e...@debian.org wrote: Rainer, On 30 June 2009 at 14:30, Rainer M Krug wrote: | following a discussion on difference in speed of R between R and Linux, I am | wondering: is there a howto to get the most (concerning speed) out of R? I | am not talking about vectorisation and techniques in doing the analysis, but | what should I look at when I want to get the fastest R on my computer - | compiling myself? specific switches? compile libraries?, ... Did you look at R Admin manual and its Appendix B on Unix configuration? Yes - thanks - but I seem to have skipped Appendix B.There it says: ### On most platforms using gcc, having ‘-O3’ in CFLAGS produces worthwhile performance gains. On systems using the GNU linker (especially those using R as a shared library), it is likely that including ‘-Wl,-O1’ in LDFLAGS is worthwhile, and on recent systems21 ‘'-Bdirect,--hash-style=both,-Wl,-O1'’ is recommended at http://lwn.net/Articles/192624/. Tuning compilation to a specific CPU family (e.g. ‘-mtune=core2’ for gcc) can give worthwhile performance gains, especially on older architectures such as ‘ix86’. ### I'll try it out when I compile R 2.9.1 and will see if it improves compared to the default values. Some more looking around, I found the following pages which might be helpful: GNU optimisation page: http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html Linux Review page on optimized gcc compiling: http://linuxreviews.org/howtos/compiling/ Gentoo Wiki CFLAG guide http://en.gentoo-wiki.com/wiki/CFLAGS There seems to be a lot to learn. And the end of the day, it will most likely depend on exactly what it is you are trying to do, so you get back to square one and the need to profile, benchmark, ... Yup - so much to benchmark and so little time... Cheers and thanks, Rainer Hth, Dirk -- Three out of two people have difficulties with fractions. -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to get best performance from R on Linux?
Hi following a discussion on difference in speed of R between R and Linux, I am wondering: is there a howto to get the most (concerning speed) out of R? I am not talking about vectorisation and techniques in doing the analysis, but what should I look at when I want to get the fastest R on my computer - compiling myself? specific switches? compile libraries?, ... Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] Indexing matrix
Hi imagine the following situation: a - runif(100) plot(a[a0.5]) plots only the elements in the vector which are larger then 0.5 Now imagine a matrix: b - matrix(runif(2), ncol=40, nrow=50) image(b[b0.5]) Error in image.default(b[b 0.5]) : argument must be matrix-like Is there a similar way then above to plot an image from the matrix with only the elements larger then 0.5, and the remaining elements equals NA? I know I could do something like image(b, zlim=c(0.5, 1)) but this includes 0.5 in the image, bb - b bb[bb=0.5] - NA image(bb) but this includes an additional assignment. This is not of practical use at the moment - the question came up when preparing a lecture. Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] Indexing matrix
On Tue, Jun 30, 2009 at 3:26 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Tue, Jun 30, 2009 at 9:19 AM, Rainer M Krugr.m.k...@gmail.com wrote: Hi imagine the following situation: a - runif(100) plot(a[a0.5]) plots only the elements in the vector which are larger then 0.5 Now imagine a matrix: b - matrix(runif(2), ncol=40, nrow=50) image(b[b0.5]) Error in image.default(b[b 0.5]) : argument must be matrix-like Is there a similar way then above to plot an image from the matrix with only the elements larger then 0.5, and the remaining elements equals NA? I know I could do something like image(b, zlim=c(0.5, 1)) but this includes 0.5 in the image, bb - b bb[bb=0.5] - NA image(bb) but this includes an additional assignment. Although this does involve an assignment underneath as well perhaps its sufficient for your purposes: image(replace(b, b = 0.5, NA)) Yes - thanks. I always forget about replace(). The result would work, but the principle is different to the indexing for vectors. But as I am expecting something different then in vector indexing (same dimension), I think the replace() is the best way to go. -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] stringsAsFactors has no impact in expand.grid()?
Hi I have the feeling, that the argument stringsAsFactors has no impact in the function expand.grid: a - c(PR, NC, A2, BS) b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125) class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]]) [1] factor class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]]) [1] factor Also, when I look at the code of expand.grid, stringsAsFactors does not occur in the code. Am I missing something? version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.0 year 2009 month 04 day17 svn rev48333 language R version.string R version 2.9.0 (2009-04-17) Cheers, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] stringsAsFactors has no impact in expand.grid()?
On Thu, Jun 25, 2009 at 1:38 PM, Henrique Dallazuanna www...@gmail.comwrote: I also not find this in the source code, but you can rewrite the function with this: That's true - but this should be fixed in the package itself. I have just converted the factor to characters. Cheers Rainer expand.grid - function (..., KEEP.OUT.ATTRS = TRUE, stringsAsFactors = FALSE) { nargs - length(args - list(...)) if (!nargs) return(as.data.frame(list())) if (nargs == 1L is.list(a1 - args[[1L]])) nargs - length(args - a1) if (nargs == 0L) return(as.data.frame(list())) cargs - args iArgs - seq_len(nargs) nmc - paste(Var, iArgs, sep = ) nm - names(args) if (is.null(nm)) nm - nmc else if (any(ng0 - nzchar(nm))) nmc[ng0] - nm[ng0] names(cargs) - nmc rep.fac - 1L d - sapply(args, length) if (KEEP.OUT.ATTRS) { dn - vector(list, nargs) names(dn) - nmc } orep - prod(d) if (orep == 0L) { for (i in iArgs) cargs[[i]] - args[[i]][FALSE] } else { for (i in iArgs) { x - args[[i]] if (KEEP.OUT.ATTRS) dn[[i]] - paste(nmc[i], =, if (is.numeric(x)) format(x) else x, sep = ) nx - length(x) orep - orep/nx x - x[rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep)] if(stringsAsFactors){ if (!is.factor(x) is.character(x)) x - factor(x, levels = unique(x)) }else{ x } cargs[[i]] - x rep.fac - rep.fac * nx } } if (KEEP.OUT.ATTRS) attr(cargs, out.attrs) - list(dim = d, dimnames = dn) rn - .set_row_names(as.integer(prod(d))) structure(cargs, class = data.frame, row.names = rn) } On Thu, Jun 25, 2009 at 8:21 AM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I have the feeling, that the argument stringsAsFactors has no impact in the function expand.grid: a - c(PR, NC, A2, BS) b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125) class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]]) [1] factor class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]]) [1] factor Also, when I look at the code of expand.grid, stringsAsFactors does not occur in the code. Am I missing something? version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.0 year 2009 month 04 day17 svn rev48333 language R version.string R version 2.9.0 (2009-04-17) Cheers, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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 -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] stringsAsFactors has no impact in expand.grid()?
On Thu, Jun 25, 2009 at 2:55 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: It works for me. Try a more recent version of R. Good to see that it is fixed in 2.9.1. I am using the latest release and am going to wait till 2.9.1 is released. Thanks, Rainer a - c(PR, NC, A2, BS) b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125) class(expand.grid(a, b, stringsAsFactors=FALSE)[[1]]) [1] character class(expand.grid(a, b, stringsAsFactors=TRUE)[[1]]) [1] factor R.version.string [1] R version 2.9.1 RC (2009-06-19 r48804) On Thu, Jun 25, 2009 at 7:21 AM, Rainer M Krugr.m.k...@gmail.com wrote: Hi I have the feeling, that the argument stringsAsFactors has no impact in the function expand.grid: a - c(PR, NC, A2, BS) b - c(1, 0.5, 0.25, 0.125, 0.0625, 0.03125) class(expand.grid(css, fscs, stringsAsFactors=FALSE)[[1]]) [1] factor class(expand.grid(css, fscs, stringsAsFactors=TRUE)[[1]]) [1] factor Also, when I look at the code of expand.grid, stringsAsFactors does not occur in the code. Am I missing something? version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.0 year 2009 month 04 day17 svn rev48333 language R version.string R version 2.9.0 (2009-04-17) Cheers, Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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. -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa [[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] Problem with generic methods
On Sat, Jun 6, 2009 at 12:14 AM, Martin Morganmtmor...@fhcrc.org wrote: Rainer M Krug r.m.k...@gmail.com writes: Hi I want to create a new generic method, but I end up with an error (evaluation nested too deeply). see the transcript below. The function beginYear.Fun() works, but not beginYear. I have no idea why. Any ideas welcome, Rainer setClass(fun, representation(x = numeric)) [1] fun new(fun) An object of class “fun” Slot x: numeric(0) setGeneric( beginYear, function(object, ...) standardGeneric(beginYear) ) setGeneric( + beginYear, + function(object, ...) standardGeneric(beginYear) + ) [1] beginYear beginYear.Fun = function(x) x^2 beginYear.Fun(4) [1] 16 Are you confusing S3 and S4 method systems? The .Fun has no special meaning in S4 I am trying to use S4, and don't know much about S3 - The is simply a separator - I probably should have used _ instead. setMethod( beginYear, signature( object = numeric ), beginYear ) here the beginYear,numeric-method is defined to invoke the beginYear generic, so you end up calling yourself. You might have meant setMethod(beginYear, signature(object=numeric), beginYear.Fun) That's it exactly. but I would have written setMethod(beginYear, signature(object=numeric), function(object, ...) object^2) That also would have been an option. Thanks, Rainer Martin setMethod( + beginYear, + signature( object = numeric ), + beginYear + ) [1] beginYear beginYear.Fun(4) [1] 16 beginYear(4) Error: evaluation nested too deeply: infinite recursion / options(expressions=)? -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with generic methods
Hi I want to create a new generic method, but I end up with an error (evaluation nested too deeply). see the transcript below. The function beginYear.Fun() works, but not beginYear. I have no idea why. Any ideas welcome, Rainer setClass(fun, representation(x = numeric)) [1] fun new(fun) An object of class “fun” Slot x: numeric(0) setGeneric( beginYear, function(object, ...) standardGeneric(beginYear) ) setGeneric( +beginYear, +function(object, ...) standardGeneric(beginYear) + ) [1] beginYear beginYear.Fun = function(x) x^2 beginYear.Fun(4) [1] 16 setMethod( beginYear, signature( object = numeric ), beginYear ) setMethod( + beginYear, + signature( object = numeric ), + beginYear + ) [1] beginYear beginYear.Fun(4) [1] 16 beginYear(4) Error: evaluation nested too deeply: infinite recursion / options(expressions=)? -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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] order() with randomised order in ties?
On Thu, Jun 4, 2009 at 12:36 PM, Patrick Burns pbu...@pburns.seanet.com wrote: How about: order(x, runif(length(x))) Thanks - that is really elegant. Rainer Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) Rainer M Krug wrote: Sorry for replying to my own post, but I found a solution. Still, a more elegant solution would be preferred. On Thu, Jun 4, 2009 at 12:02 PM, Rainer M Krug r.m.k...@gmail.com wrote: Hi I want to use order() to get the order of a vector. But I would need a different behavior when ties occur: similar to the parameter ties.method = random in the rank() function, I would need to randomise the ties. Is this possible? The solution is to randomize the vector before submitting to order(): x - rep(1:10, 2) iS - sample( length(x) ) o - order( x[iS], na.last=NA, decreasing=TRUE) o [1] 8 16 12 17 2 9 7 15 10 11 4 14 3 5 13 20 1 6 18 19 x[iS][o] [1] 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 iS - sample( length(x) ) o - order( x[iS], na.last=NA, decreasing=TRUE) o [1] 14 19 13 20 2 18 3 10 1 15 4 9 11 12 6 7 8 16 5 17 x[iS][o] [1] 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 Thanks Rainer Example: x - rep(1:10, 2) order(x) [1] 1 11 2 12 3 13 4 14 5 15 6 16 7 17 8 18 9 19 10 20 order(x) [1] 1 11 2 12 3 13 4 14 5 15 6 16 7 17 8 18 9 19 10 20 ## I would need different order for the ties, as below in rank() example: rank(x, ties.method=random) [1] 1 4 6 7 10 12 13 15 18 19 2 3 5 8 9 11 14 16 17 20 rank(x, ties.method=random) [1] 2 4 5 7 9 12 14 15 18 19 1 3 6 8 10 11 13 16 17 20 Thanks Rainer -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa -- Rainer M. Krug, Centre of Excellence for Invasion Biology, Stellenbosch University, South Africa __ 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.