Re: [R] question re. package playwith not able to run command getting error message that I'm attempting to use non function
Hcan you give session info (after loading playwith)? I'm able to get that code to work...also -- can you get the basic RGtk functions (like gwindow() ) to work? Michael On Thu, Jan 19, 2012 at 5:28 PM, Farhat Maha mar...@gmail.com wrote: Hello, I managed to install playwith package and all its prerequisites. My R version is R 2.14: R version 2.14.1 (2011-12-22) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) All my packages were updated, and recently installed. When I attempt to use the command playwith I get the following error message: library(playwith) Loading required package: lattice Loading required package: cairoDevice Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Loading required package: grid playwith(plot(1:10)) Error in playwith(plot(1:10)) : attempt to apply non-function playwith(xyplot(Income ~ log(Population / Area), + data = data.frame(state.x77), groups = state.region, + type = c(p, smooth), span = 1, auto.key = TRUE, + xlab = Population density, 1974 (log scale), + ylab = Income per capita, 1974) + ) Error in playwith(xyplot(Income ~ log(Population/Area), data = data.frame(state.x77), : attempt to apply non-function interactive() [1] TRUE autoplay(on = TRUE, lattice.on = TRUE, base.on = TRUE, grid.on = TRUE, ask = FALSE) Automatic `playwith` for Lattice graphics is now ON. Automatic `playwith` for base graphics is now ON. Automatic `playwith` for grid graphics is now ON. plot(1:10) Error in playwith(plot(1:10), envir = environment) : attempt to apply non-function Error in plot.xy(xy, type, ...) : plot.new has not been called yet Any advice about why it is not working. thanks Maha [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error
This is discussed in the help of seq(). See the details section of ?sec Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Neeraj Kohli Verzonden: vrijdag 20 januari 2012 7:19 Aan: r-help@r-project.org Onderwerp: [R] error Unable to resolve error in seq.default(which(text == )[1] + 1, length(text), 1): wrong sign in 'by' argument I am trying to run this code get.msg - function(path) { con - file(path, open = rt, encoding = latin1) text - readLines(con) # The message always begins after the first full line break msg - text[seq(which(text == )[1] + 1,length(text),1)] close(con) return(paste(msg, collapse = \n)) Kindly 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] fitting an exp model
Thank You! -- View this message in context: http://r.789695.n4.nabble.com/fitting-an-exp-model-tp4310752p4312661.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rsp
Could anyone please tell how to pass parameters of form to server in rsp? -- View this message in context: http://r.789695.n4.nabble.com/rsp-tp4312635p4312635.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Symlet package in R Cran
Dear all, I would like to ask you if you know there is a symlet package that can be used to create those and apply them in a DWT . B.R 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.
[R] show plot
Dear All I have 54000 plots in R, How can I observe them? If Iâ have to save them one-by-one? Soheila [[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] dataframe: how to select an element from a row
Thank you Jorge and Florent for your responses. Now, I 'd like to get the date *(and its index) *where myvalue 2000 for the first time. I expect for a result like (index, date) = (3, 2012-01-07 ) This way does not work: ind = match(df$myvalue 2000, df$myvalue) res = df$DateTime[ind] -- View this message in context: http://r.789695.n4.nabble.com/dataframe-how-to-select-an-element-from-a-row-tp4311881p4312847.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Legend appearance
Hi All, I want small modification in apperance of legend. I want seperate legend for each graph representing the lines present in that graph only (not all the lines in all graphs) . Can you please help? Thank you Regards Devarayalu Orange1 - structure(list(REFID = c(7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9), ARM = c(1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2), SUBARM = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ACTTRT = structure(c(3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c(ABC, DEF, LCD, Vehicle), class = factor), TIME1 = c(0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6, 12, 0, 12, 0, 12), ENDPOINT = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = PGA, class = factor), BASCHGA = c(0, -39, -47, -31, 0, -34, -25, -12, 0, -45, -47, -20, 0, -25, -30, -35, 0, -30, 0, -40), STATANAL = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = UNK, class = factor), Art_Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(Bela_2010_206878, Dansinger_2010_20687812 ), class = factor)), .Names = c(REFID, ARM, SUBARM, ACTTRT, TIME1, ENDPOINT, BASCHGA, STATANAL, Art_Name ), row.names = c(NA, 20L), class = data.frame) unique(Orange1$REFID) - refid for (i in refid) { Orange2 - Orange1[i == Orange1$REFID, ] pdf(paste (PGA, i, .pdf, sep='')) print(qplot(TIME1, BASCHGA, data=Orange2, geom= c(line), colour= ACTTRT)) dev.off() } [[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] dataframe: how to select an element from a row
This works but I do not know if there is a better way tmp = df[df$myvalue2000,] ind = match(tmp$myvalue, df$myvalue) res = df$DateTime[ind] solution = list(ind[1], res[1]) -- View this message in context: http://r.789695.n4.nabble.com/dataframe-how-to-select-an-element-from-a-row-tp4311881p4312890.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.
Re: [R] show plot
Huh If you spend only 10 seconds inspecting one plot you will need about 150 hours for that task. I would recommend to reconsider this issue for your own sanity. Anyway you can save them either to separate files or in multi page PDF document although I do not know if there is some limit in pdf pages. I have never seen any single pdf document with more than several hundred pages. Regards Petr Dear All I have 54000 plots in R, How can I observe them? If I‌ have to save them one-by-one? Soheila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Legend appearance
Hi You shall at least read what others wrote you about your code. here is a quote from what I wrote you yesterday and what stays valid for today too. Also be aware that all levels of a factor are preserved in a subset unless you specifically strip the unused levels. Therefore there is a mismatch in legend colours and line colours. Orange2 - Orange1[i == Orange1$REFID, ] Orange2$ACTTRT [1] ABC ABC DEF DEF Levels: ABC DEF LCD Vehicle You can see all levels here and they are used for plotting unless you get rid of them. Orange2$ACTTRT-factor(Orange2$ACTTRT) Orange2$ACTTRT [1] ABC ABC DEF DEF Levels: ABC DEF See ?factor [.factor for subsetting of factors. However in that case you will have same line colours for different ACTTRT values. I believe you will also benefit from reading about object properties in R intro. Believe me after reading those about 30 pages you will be master in R. Regards Petr Hi All, I want small modification in apperance of legend. I want seperate legend for each graph representing the lines present in that graph only (not all the lines in all graphs) . Can you please help? Thank you Regards Devarayalu Orange1 - structure(list(REFID = c(7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9), ARM = c(1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2), SUBARM = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ACTTRT = structure(c(3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c(ABC, DEF, LCD, Vehicle), class = factor), TIME1 = c(0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6, 12, 0, 2, 6, 12, 0, 12, 0, 12), ENDPOINT = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = PGA, class = factor), BASCHGA = c(0, -39, -47, -31, 0, -34, -25, -12, 0, -45, -47, -20, 0, -25, -30, -35, 0, -30, 0, -40), STATANAL = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = UNK, class = factor), Art_Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(Bela_2010_206878, Dansinger_2010_20687812 ), class = factor)), .Names = c(REFID, ARM, SUBARM, ACTTRT, TIME1, ENDPOINT, BASCHGA, STATANAL, Art_Name ), row.names = c(NA, 20L), class = data.frame) unique(Orange1$REFID) - refid for (i in refid) { Orange2 - Orange1[i == Orange1$REFID, ] pdf(paste (PGA, i, .pdf, sep='')) print(qplot(TIME1, BASCHGA, data=Orange2, geom= c(line), colour= ACTTRT)) dev.off() } [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] show plot
Thank you very much, but in *.pdf I can see 1 plot, may I ask you another question? How can see more than one in each page? You just press page down or up for moving through pdf document. But seriously, try it yourself lll - split(rnorm(100) , rep(1:10, each=10)) pdf(test.pdf) for (i in 1:10) { plot(lll[[i]]) } dev.off() R comes usually with quite extensive set of help for every function. see ?pdf onefile logical: if true (the default) allow multiple figures in one file. If false, generate a file with name containing the page number for each page. Defaults to TRUE, and forced to true if file is a pipe. Regards Petr Best regards, Khodakarim On Fri, Jan 20, 2012 at 11:57 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Huh If you spend only 10 seconds inspecting one plot you will need about 150 hours for that task. I would recommend to reconsider this issue for your own sanity. Anyway you can save them either to separate files or in multi page PDF document although I do not know if there is some limit in pdf pages. I have never seen any single pdf document with more than several hundred pages. Regards Petr Dear All I have 54000 plots in R, How can I observe them? If I‌ have to save them one-by-one? Soheila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] test if text is part of vector
Hello, this is a very simple question: How can I find out if a word is part of a list of words like: a - word1 b - word4 vector - c(word1,word2,word3) I tried it with match(a,vector) but this gives the position of the word. I am not sure if and how that can be done with a logical operator like if: IF text is part of vector THEN print is part Probably a very easy thing to do, but I am missing the logical operator... and help(if) is not working best regards, johannes -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] test if text is part of vector
Hi Hello, this is a very simple question: How can I find out if a word is part of a list of words like: a - word1 b - word4 vector - c(word1,word2,word3) I tried it with match(a,vector) but this gives the position of the word. Perhaps a %in% vector Regards Petr I am not sure if and how that can be done with a logical operator like if: IF text is part of vector THEN print is part Probably a very easy thing to do, but I am missing the logical operator... and help(if) is not working best regards, johannes -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] test if text is part of vector
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/01/12 12:50, Johannes Radinger wrote: Hello, this is a very simple question: How can I find out if a word is part of a list of words like: a - word1 b - word4 vector - c(word1,word2,word3) I tried it with match(a,vector) but this gives the position of the word. I am not sure if and how that can be done with a logical operator like if: IF text is part of vector THEN print is part Probably a very easy thing to do, but I am missing the logical operator... and help(if) is not working check out %in% help: ?%in% Cheers, Rainer best regards, johannes - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D):+49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8ZV7IACgkQoYgNqgF2egroawCfYAN/eOBMKN4VDTbBZtiBVGdS LAUAnR+h9kg2INJTICiGIAUTfYm2fCbC =Ws2h -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] VarCov matrix - quantile regression.
Dear all, I would like to know how to print the variance-covariance matrix used in the function anova.rq () when investigating whether the coefficients of a quantile regression model is the same for a range of quantiles. To be more precise, when I use the function summary.rq(, cov=TRUE) considering a range of quantiles tau, I need to find one way to print the VarCov matrix. For a given quantile level, I can use [[3]]. However, for a range of quantiles, I cannot find. This variance-covariance matrix should give me the VarCov among the coefficients of a given quantile level and also among the coefficients of different quantile levels. Thank you in advance! All the best, Julia [[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] test if text is part of vector
Hi, thank you very much... %in% is the operator I was looking for. cheers, johannes Original-Nachricht Datum: Fri, 20 Jan 2012 13:01:54 +0100 Von: Rainer M Krug r.m.k...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] test if text is part of vector -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/01/12 12:50, Johannes Radinger wrote: Hello, this is a very simple question: How can I find out if a word is part of a list of words like: a - word1 b - word4 vector - c(word1,word2,word3) I tried it with match(a,vector) but this gives the position of the word. I am not sure if and how that can be done with a logical operator like if: IF text is part of vector THEN print is part Probably a very easy thing to do, but I am missing the logical operator... and help(if) is not working check out %in% help: ?%in% Cheers, Rainer best regards, johannes - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D):+49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8ZV7IACgkQoYgNqgF2egroawCfYAN/eOBMKN4VDTbBZtiBVGdS LAUAnR+h9kg2INJTICiGIAUTfYm2fCbC =Ws2h -END PGP SIGNATURE- -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Split values in vector
Hello all, I think I am now on the way to correctly split the vector as I want it using for loops. I got now to a point where I got stuckedSo maybe someone can help me out... Remember the result I am looking for should look like (for the input vector I want to split see below: var3) var1 var2 var3_00 var3_01 var3_02 var3_04 1 A 1 0 0 0 2 B 0 1 3 1 3 C 0 2 1 0 4 D 0 0 0 12 5 E NANANANA The input and my approach so far: It is probably not the most elegant solution but I think I will get where I want..I am very open for your improvements: var1 -seq(1,5) var2 -c(A,B,C,D,E) var3 -c(00,01-1;02-3;04-1,01-2;02-1,01-0;04-2,NA) x - data.frame(var1,var2,var3) #create new columns and prefill with 0 x$var3_01 - 0 x$var3_02 - 0 x$var3_03 - 0 x$var3_04 - 0 a - strsplit(as.character(x$var3), split = ;, fixed = TRUE) for (i in 1:length(a)){ A - length(a[[i]]) for (j in 1:A){ column - (unlist(strsplit((a[[i]][j]), split=-,fixed=TRUE))[1]) if(column!=00){ value - (unlist(strsplit((a[[i]][j]), split=-,fixed=TRUE))[2]) print(column) print(value) if(is.na(column)) { x$var3_01[i] - NA x$var3_02[i] - NA x$var3_03[i] - NA x$var3_04[i] - NA } else if(column %in% c(01,02,03,04)) { #print(paste(x$var3_,column,sep=)) (paste(x$var3_,column,sep=))[i]- as.numeric(value) } else print(Problem with category) } } } I think there is a problme with (paste(x$var3_,column,sep=))[i] which is not recognized correctly as it is interpreted as a string. Thank you... best regards, /johannes Original-Nachricht Datum: Thu, 19 Jan 2012 13:42:24 +0100 (MET) Von: Gerrit Eichner gerrit.eich...@math.uni-giessen.de An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Split values in vector Hi, Johannes, maybe X - unlist( strsplit( as.character( x$ART), split = ;, fixed = TRUE)) X - strsplit( X, split = -, fixed = TRUE) X - sapply( X, function( x) if( length(x) == 2) rep( x[1], as.numeric( x[2])) else x[1] ) table(X, useNA = always) comes close to what you want. Hth -- Gerrit On Thu, 19 Jan 2012, Johannes Radinger wrote: Hello, I have a vector which looks like x$ART ... [35415] 0001-1;02-1;05-1; [35417] 01-1; 01-1;02-1; [35419] 01-1; 00 [35421] 01-1;04-1;05-1; [35423] 02-1; 01-1;02-1; [35425] 01-1;02-1;NA [35427] 01-1; NA ... This is a vector I got in this format. To explain it: there are several categories (00,01,02 etc) and its counts (values after -) So I have to split each value and create new dataframe-columns/vectors for each categories one column and the value should be then in the corresponding cell. I know that this vector has 7 categories (00-06) and NA values but each case (row) has not all the categories (as you can see). How can do such as split? In the end I should get: x$ART_00, x$ART_01, x$ART_03,... with its values. In the case of NA all the categories should have also NA. Maybe someone can help. Thank you, Best regards Johannes -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] test if text is part of vector
You also might look at grepl() if you have time: it allows regular expressions and will be a little (a lot?) more flexible in how you define a match if you want to ignore things like capitalization. (mnemonic: the L in grepl indicates its like grep but returns logicals instead of positions) Michael On Jan 20, 2012, at 7:42 AM, Johannes Radinger jradin...@gmx.at wrote: Hi, thank you very much... %in% is the operator I was looking for. cheers, johannes Original-Nachricht Datum: Fri, 20 Jan 2012 13:01:54 +0100 Von: Rainer M Krug r.m.k...@gmail.com An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] test if text is part of vector -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 20/01/12 12:50, Johannes Radinger wrote: Hello, this is a very simple question: How can I find out if a word is part of a list of words like: a - word1 b - word4 vector - c(word1,word2,word3) I tried it with match(a,vector) but this gives the position of the word. I am not sure if and how that can be done with a logical operator like if: IF text is part of vector THEN print is part Probably a very easy thing to do, but I am missing the logical operator... and help(if) is not working check out %in% help: ?%in% Cheers, Rainer best regards, johannes - -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D):+49 - (0)3 21 21 25 22 44 email: rai...@krugs.de Skype: RMkrug -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8ZV7IACgkQoYgNqgF2egroawCfYAN/eOBMKN4VDTbBZtiBVGdS LAUAnR+h9kg2INJTICiGIAUTfYm2fCbC =Ws2h -END PGP SIGNATURE- -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] show plot
Use layout() to put multiple plots on a single page. (Note that with 50k plots you'll want layout() and multiple pages.) Michael On Jan 20, 2012, at 6:46 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Thank you very much, but in *.pdf I can see 1 plot, may I ask you another question? How can see more than one in each page? You just press page down or up for moving through pdf document. But seriously, try it yourself lll - split(rnorm(100) , rep(1:10, each=10)) pdf(test.pdf) for (i in 1:10) { plot(lll[[i]]) } dev.off() R comes usually with quite extensive set of help for every function. see ?pdf onefile logical: if true (the default) allow multiple figures in one file. If false, generate a file with name containing the page number for each page. Defaults to TRUE, and forced to true if file is a pipe. Regards Petr Best regards, Khodakarim On Fri, Jan 20, 2012 at 11:57 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Huh If you spend only 10 seconds inspecting one plot you will need about 150 hours for that task. I would recommend to reconsider this issue for your own sanity. Anyway you can save them either to separate files or in multi page PDF document although I do not know if there is some limit in pdf pages. I have never seen any single pdf document with more than several hundred pages. Regards Petr Dear All I have 54000 plots in R, How can I observe them? If I‌ have to save them one-by-one? Soheila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Contour plot on a triangular mesh
Hi All, I have 3 variables which present a perfect linear dependency such that the third is the sum of the first two. I have an ordinary 2D contour plot on a square grid with the first two variables forming the axes and the third naturally being the diagonals. From an interpretive point of view it would be nice to plot these two variables on a finer grid such that the third can have the same scaling (i.e. a finer grid) as the first two and this would look better on a triangular mesh. Is this possible in R? Many thanks, Roary -- View this message in context: http://r.789695.n4.nabble.com/Contour-plot-on-a-triangular-mesh-tp4313098p4313098.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.
Re: [R] Serial Date
Hi, How I should convert Fractional days in Year Month Days Hour Minute and Day format ? -- View this message in context: http://r.789695.n4.nabble.com/Serial-Date-tp3353123p4313144.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Point biserial correlation = Is there any specific command or could I just use cor.test?
Hello, I found in the forum two threads about point biserial correlation. One of them (1) mentioned a point-biserial correlation is just a Pearson correlation where one of the variables is dichotomous. Thus, the command is just the normal cor function. The other (2) mentioned Professor Fox's package polycor as a way to calculate point biserial correlation? HELP: I am a little confused about what to do. I just need to obtain the correlation index and p-value. Could I just use cor.test? Or is necessary to use other command or even Professor Fox's package polycor? Thanks in advance, Cadu 1. http://r.789695.n4.nabble.com/Point-biserial-correlation-td862060.html 2. http://r.789695.n4.nabble.com/Correlation-dichotomous-factor-continous-numer ical-and-ordered-factor-td865214.html#a865215 [[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] Split values in vector
Hello again, No I managed to do everything correctly... the code now looks like: var1 -seq(1,5) var2 -c(A,B,C,D,E) var3 -c(00,01-1;02-3;04-1,01-2;02-1,01-0;04-2,NA) x - data.frame(var1,var2,var3) #create new columns and prefill with 0 x$var3_01 - 0 x$var3_02 - 0 x$var3_03 - 0 x$var3_04 - 0 a - strsplit(as.character(x$var3), split = ;, fixed = TRUE) for (i in 1:length(a)){ A - length(a[[i]]) for (j in 1:A){ column - (unlist(strsplit((a[[i]][j]), split=-,fixed=TRUE))[1]) if(column!=00|is.na(column)){ value - (unlist(strsplit((a[[i]][j]), split=-,fixed=TRUE))[2]) if(is.na(column)) { x$var3_01[i] - NA x$var3_02[i] - NA x$var3_03[i] - NA x$var3_04[i] - NA } else if(column %in% c(01,02,03,04)) { x[i,paste(var3_,column,sep=)]- as.numeric(value) } else print(Problem with category) } } } Original-Nachricht Datum: Thu, 19 Jan 2012 13:42:24 +0100 (MET) Von: Gerrit Eichner gerrit.eich...@math.uni-giessen.de An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] Split values in vector Hi, Johannes, maybe X - unlist( strsplit( as.character( x$ART), split = ;, fixed = TRUE)) X - strsplit( X, split = -, fixed = TRUE) X - sapply( X, function( x) if( length(x) == 2) rep( x[1], as.numeric( x[2])) else x[1] ) table(X, useNA = always) comes close to what you want. Hth -- Gerrit On Thu, 19 Jan 2012, Johannes Radinger wrote: Hello, I have a vector which looks like x$ART ... [35415] 0001-1;02-1;05-1; [35417] 01-1; 01-1;02-1; [35419] 01-1; 00 [35421] 01-1;04-1;05-1; [35423] 02-1; 01-1;02-1; [35425] 01-1;02-1;NA [35427] 01-1; NA ... This is a vector I got in this format. To explain it: there are several categories (00,01,02 etc) and its counts (values after -) So I have to split each value and create new dataframe-columns/vectors for each categories one column and the value should be then in the corresponding cell. I know that this vector has 7 categories (00-06) and NA values but each case (row) has not all the categories (as you can see). How can do such as split? In the end I should get: x$ART_00, x$ART_01, x$ART_03,... with its values. In the case of NA all the categories should have also NA. Maybe someone can help. Thank you, Best regards Johannes -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... -- Feel free - 10 GB Mailbox, 100 FreeSMS/Monat ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] show plot
Hi Yes with layout she can put several plots on one page, but if I consider 20 plots per page and one minute per page inspection, 54000 plots is still more than 2000 pages and about 40 hours, which I do not consider as a well spent time. Regards Petr Use layout() to put multiple plots on a single page. (Note that with 50k plots you'll want layout() and multiple pages.) Michael On Jan 20, 2012, at 6:46 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Thank you very much, but in *.pdf I can see 1 plot, may I ask you another question? How can see more than one in each page? You just press page down or up for moving through pdf document. But seriously, try it yourself lll - split(rnorm(100) , rep(1:10, each=10)) pdf(test.pdf) for (i in 1:10) { plot(lll[[i]]) } dev.off() R comes usually with quite extensive set of help for every function. see ?pdf onefile logical: if true (the default) allow multiple figures in one file. If false, generate a file with name containing the page number for each page. Defaults to TRUE, and forced to true if file is a pipe. Regards Petr Best regards, Khodakarim On Fri, Jan 20, 2012 at 11:57 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Huh If you spend only 10 seconds inspecting one plot you will need about 150 hours for that task. I would recommend to reconsider this issue for your own sanity. Anyway you can save them either to separate files or in multi page PDF document although I do not know if there is some limit in pdf pages. I have never seen any single pdf document with more than several hundred pages. Regards Petr Dear All I have 54000 plots in R, How can I observe them? If I‌ have to save them one-by-one? Soheila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Serial Date
If you are going to resurrect old threads, it's kind to at least read them. Use the chron package as suggested by Gabor. Michael On Fri, Jan 20, 2012 at 7:54 AM, uday uday_143...@hotmail.com wrote: Hi, How I should convert Fractional days in Year Month Days Hour Minute and Day format ? -- View this message in context: http://r.789695.n4.nabble.com/Serial-Date-tp3353123p4313144.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bayesian data analysis recommendations
On Thu, 2012-01-19 at 19:23 -0500, C W wrote: Thanks, Rich, I will look at the book. I agree, there are many nice packages, but what if the package changes in a few years? I would have no idea what is going on! I've heard from predecessor in the industry who emphasize the learning, not just plug and chug. I really want to learn the material and understand it, above all, it is interesting. I am looking more towards Bayesian statistics or Bayesian inference. I am in statistics graduate school, though not my field, the biology application could help in the understand I suppose? This list (r-help) may not be the best place to look for advice on this. But here is some anyway :) For a well-rounded introduction, I recommend Robert's 'The Bayesian Choice'. This is a great foundation for Bayesians who intend to defend their positions on statistical inference. For a more practical approach, Gelman, Carlin, Stern, and Rubin's book 'Bayesian Data Analysis' has been very popular (THE most popular, according to some). Regarding the software tools for Bayesian data analysis, the most mature _and_ active _and_ best integrated with the R project is Martyn Plummer's JAGS (See also the R package rjags, by the same author). Another tool that I'm planning to check out is PyMC: http://code.google.com/p/pymc/ Best, Matt On Thu, Jan 19, 2012 at 7:07 PM, Rich Shepard rshep...@appl-ecosys.com wrote: On Thu, 19 Jan 2012, C W wrote: I am trying to learn Bayesian inference and Bayesian data analysis, I am new in the field. Would any experts on the list recommend any good sites or materials for beginners? My approach is to learn and understand the theory first, then program on my own using R, though I see there are already packages. I'm far from an expert, but why not avoid re-inventing the wheel while you learn? Buy and read Jim Albert's Bayesian Computation with R. If you're a population ecologist (or willing to extend pesented examples and ideas to communities and ecosystems), Ben Bolker's Ecological Models and Data in R explains when Bayesian and frequentist approaches each have advantages over the other. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Calling Windows DLL using .C; function name not known but in exports.
First time ever that I try to call subroutines in a Win DLL using R. Have done this before using VBA and Python. The C code's function argument list contains only double pointers (double *x). The function is declared void, the output value is one of the arguments. C calling sequence is used. When inspecting the exports of the DLL with dumpbin I can see that the function I need is exported under the name 'planckwR'. Loading the DLL with dyn.load(dllpath). Works fine. getLoadedDLLs() shows info on the 'Planck.dll' that I made. So far so good. Made a function i R like this: Planckw-function(Temp) { wavelength-0.0 .C('planckwR',as.double(Temp),as.double(wavelength)) return(wavelength) } Calling this function, R complains the function 'planckwR' is not in the DLL. This baffled me as I can see it in the exports table using dumpbin. I use Visual C++ 97 compiler. Old but works. It does change the FPU control word, which I know it should not. Working on that one too. Any tips? Any help much appreciated. Alex van der Spek __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] a question about taylor.diagram in plotrix package
Hi. I have a question about the taylor.diagram() in plotrix package. How can I control the label correlation? In the embedded figure you can see the label correlation is too close to the ticks. How can I move it and make it larger? Another problem is the labels 0.95 and 0.99 are too close to the plotting area. I do not find any method to control it. I have been struggling in this problem for a long time. Thanks a lot if anyone can help. http://r.789695.n4.nabble.com/file/n4313328/taylor.png -- View this message in context: http://r.789695.n4.nabble.com/a-question-about-taylor-diagram-in-plotrix-package-tp4313328p4313328.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.
Re: [R] forecasting a time series
Hi Michael, I think you're right, I should be looking for predict instead of forecast. I'm still fairly new to R so often don't know what to look for. As a simplified example (let's neglect the fourier terms): fit = auto.arima(data) but now I have data.latest, so I want to use the ARIMA terms from fit but with data.latest I'll look into predicting, thank you On 1/20/2012 1:35 AM, Michael Weylandt [via R] wrote: Can you clarify what exactly you mean by this? [N]ow [I] would like to use the last X values to predict tomorrow's weather. I'm at a loss. All the functions I've come across (like forecast()) use the series and then forecast from the end point. It sounds like a prediction to me. Anyways, I think most methods do allow new values for the independent variables: e.g., the newdata argument to most predict() methods and the xreg arguments to forecast::forecast(). Do you know which method you are using? Hope this helps, Michael On Wed, Jan 18, 2012 at 4:17 PM, nhomeier [hidden email] /user/SendEmail.jtp?type=nodenode=4312525i=0 wrote: Couldn't find this in the archives. I'm fitting a series of historical weather-related data, but would like to use the latest values to forecast. So let's say that I'm using 1970-2000 to fit a model (using fourier terms and arima/auto.arima), but now would like to use the last X values to predict tomorrow's weather. I'm at a loss. All the functions I've come across (like forecast()) use the series and then forecast from the end point. Do I need to decompose the fit and write it out the long way? For example, Tomorrow = fit$coef[1]*Yesterday + fit$coef[2]*BeforeYesterday + etc or is there a function that I'm not finding? Thank you, Nicole -- View this message in context: http://r.789695.n4.nabble.com/forecasting-a-time-series-tp4308147p4308147.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] /user/SendEmail.jtp?type=nodenode=4312525i=1 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [hidden email] /user/SendEmail.jtp?type=nodenode=4312525i=2 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/forecasting-a-time-series-tp4308147p4312525.html To unsubscribe from forecasting a time series, click here http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4308147code=bmhvbWVpZXJAYWVyLmNvbXw0MzA4MTQ3fDE0Mzc1NzAwMzQ=. NAML http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.InstantMailNamespacebreadcrumbs=instant+emails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml -- Nicole L. Homeier, PhD Staff Scientist Atmospheric Environmental Research 131 Hartwell Avenue Lexington, MA 02421-3126 781 761-2387 -- View this message in context: http://r.789695.n4.nabble.com/forecasting-a-time-series-tp4308147p4313351.html Sent from the R help mailing list archive at Nabble.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] colored outliers
Dear Petr and Justin, my problem ist, that I only want to have the 4 highest values for Ni as a red point or with a red circle. The other points should not be modificated. In your proposals always all points get a red circle or a red point not only the 4 highest Ni values! I hope you could understand me! Thanks for your help! GeO -- View this message in context: http://r.789695.n4.nabble.com/colored-outliers-tp4282207p4313278.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Stacked barchart in ggplot (or other library)
Hey, I want to create a stacked barchart in R for the following dataset (http://pastebin.com/pyHUNgr2): # usage capacitydiff 1 4 10 6 2 2 20 18 3 5 10 5 The stacked barchart should, in one plot show each line of the dataset as a stacked bar using data from 'usage' and 'diff' to create the stacked bar. I can't find a good example of how to do this on the ggplot2 site. Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/Stacked-barchart-in-ggplot-or-other-library-tp4313455p4313455.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Incorrect DateTime using ISOdatetime in R
Dear list, I need to transform the DateTime of my GPS data from: 666.1751 into /mm/dd hh:mm:ss I have the following code: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d$Date*(24*3600) This gives me: 2010-10-29 04:12:09, which is wrong. It should be 2010-10-29 06:12:09 Another example: 418.3219 corresponds to: 2010-02-23 07:43:30, but it should be 2010-02-23 08:43:30. However, not always is the difference + 2 h, it's sometimes less or more. There are a lot of postings here regarding ISOdatetime, but I'm still not able to solve this . Any ideas or suggestions will be very much appreciated. Best regards, Julia PS. I've tried to find the answer in all sorts of R help forums and also in my R books - no luck so far. Maybe I'm missunderstanding the entire ISOdatetime function? -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-DateTime-using-ISOdatetime-in-R-tp4313470p4313470.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] break an axis.POSIXct
Hi I like to use axis.POSIXct to plot days from 2006 till 2008. But I only have datas for the summer months. Is it possible to get two axis breaks, to have not so long distances without points? thx Christof __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] free memory in large list?
Hi all, Lets say I have a huge list which is indexed in the following format: mylist[[i]][[j]][[k]] where the size is 100 x 100 x 10 If I want to set mylist[[2]][[3]]=NULL How do I free the memory used by that sub-list? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] colored outliers
TOC_NI-read.csv2(C:/Users/hilliges/Desktop/Master/Daten/Statistik/TOC-NI.csv, sep=;, dec=,, encoding=UTF-8) circ-TOC_NI[order(TOC_NI$NI,decreasing=T),][1:4,] plot(NI~TOC,data=TOC_NI,col=blue, pch=16, xlim=c(0,450)) abline(lm(NI~TOC,data=TOC_NI),col = red,lwd=3) points(NI~TOC,data=TOC_NI,col='red',pch=1,size=3) ## this line is coloring all points because you're using TOC_NI still points(NI~TOC,data=circ,col='red',pch=1,size=3) ## now we're only plotting the four points in circ. sorry for the confusion. however, in the future please provide a reproducible data set along with your question so we can more easily help. Justin On Fri, Jan 20, 2012 at 5:49 AM, Geophagus falk.hilli...@twain-systems.comwrote: Dear Petr and Justin, my problem ist, that I only want to have the 4 highest values for Ni as a red point or with a red circle. The other points should not be modificated. In your proposals always all points get a red circle or a red point not only the 4 highest Ni values! I hope you could understand me! Thanks for your help! GeO -- View this message in context: http://r.789695.n4.nabble.com/colored-outliers-tp4282207p4313278.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. [[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] free memory in large list?
?gc --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Michael comtech@gmail.com wrote: Hi all, Lets say I have a huge list which is indexed in the following format: mylist[[i]][[j]][[k]] where the size is 100 x 100 x 10 If I want to set mylist[[2]][[3]]=NULL How do I free the memory used by that sub-list? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] break an axis.POSIXct
It may be possible, but perhaps not a good idea. A better approach would be to use multiple graphs (panels in lattice or facets in ggplot2). Provide a reproducible example and you might get a more concrete example. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Christof Kluß ckl...@email.uni-kiel.de wrote: Hi I like to use axis.POSIXct to plot days from 2006 till 2008. But I only have datas for the summer months. Is it possible to get two axis breaks, to have not so long distances without points? thx Christof __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] break an axis.POSIXct
On Jan 20, 2012, at 10:46 AM, Christof Kluß wrote: Hi I like to use axis.POSIXct to plot days from 2006 till 2008. But I only have datas for the summer months. Is it possible to get two axis breaks, to have not so long distances without points? There are worked examples of broken axes in package plotrix but I don't know if they are set up for multiple breaks, or if they support data formats. At any rate, the plotrix package is something you should investigate because it has a wealth of useful examples demonstrating taking R's base graphics to the next level. -- 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] z-transform each column of a data.frame
Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] arc length of noisy time series?
Hi, I have data of the form: tx y trip t1x1+e y1+eA t2x2+e y2+eA t3x3+e y3+eB t4x4+e y4+eB t5x5+e y5+eB ... ... ... ... where t is time and x/y are positions in space and e is a random error term. Trips A/B/C/etc are entirely independent from each other. I'd like to estimate the total distance traveled for each series (trip) of points (there are actually a few thousand points in each trip, and thousands of trips). A loess curve fits the data nicely, essentially eliminating the error term (I realize not exactly but it is close enough for my purposes). However I don't see an easy way to find arc length of a loess fit (without using an inefficient loop of distance between t1,t2 + distance t2,t3, etc.) Thanks for any advice. [[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] z-transform each column of a data.frame
On Fri, Jan 20, 2012 at 9:04 AM, Martin Batholdy batho...@googlemail.com wrote: Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) scale(x) will scale each column of a matrix/ data frame to mean 0 and variance 1. Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] z-transform each column of a data.frame
On Fri, 2012-01-20 at 18:04 +0100, Martin Batholdy wrote: Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) ?scale scale(x) c.0.10. c.10.20. [1,] -1.5075567 -1.5075567 [2,] -1.2060454 -1.2060454 [3,] -0.9045340 -0.9045340 [4,] -0.6030227 -0.6030227 [5,] -0.3015113 -0.3015113 [6,] 0.000 0.000 [7,] 0.3015113 0.3015113 [8,] 0.6030227 0.6030227 [9,] 0.9045340 0.9045340 [10,] 1.2060454 1.2060454 [11,] 1.5075567 1.5075567 attr(,scaled:center) c.0.10. c.10.20. 5 15 attr(,scaled:scale) c.0.10. c.10.20. 3.316625 3.316625 thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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.
Re: [R] z-transform each column of a data.frame
? scale apply(x, 2, scale) Michael On Fri, Jan 20, 2012 at 12:04 PM, Martin Batholdy batho...@googlemail.com wrote: Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] z-transform each column of a data.frame
great, thank you! On 20.01.2012, at 18:10, R. Michael Weylandt wrote: ? scale apply(x, 2, scale) Michael On Fri, Jan 20, 2012 at 12:04 PM, Martin Batholdy batho...@googlemail.com wrote: Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect DateTime using ISOdatetime in R
666.1751 sure seems like it should return 2010-10-29 04:12:09 based on your example. 666.1751 days from 2009-01-01 is 2010-10-29 + some hours/min/seconds. 0.1751 days * 24 hrs/day = 4.2024 (i.e. 4:00AM + some minutes). 0.2024 hours * 60 min/hr = 12.144 (i.e. 12 minutes + some seconds). 0.144 minutes * 60 sec/min = 8.64 (i.e. 8.64 seconds). Put it all together and I get 2010-10-29 04:12:08.64 in the GMT time zone. What makes you think it should be 2010-10-29 06:12:09? Are you running into a time zone issue, such as your GPS adjusting its time zone and reported the time based on the time zone where a reading was taken? If you crossed between time zones for some of your readings it might explain the fluctuating difference between the answer you expect and the answer that ISOdatetime gives you. -Luke On Fri, Jan 20, 2012 at 6:59 AM, Sula2011 julia.so...@gmx.de wrote: Dear list, I need to transform the DateTime of my GPS data from: 666.1751 into /mm/dd hh:mm:ss I have the following code: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d$Date*(24*3600) This gives me: 2010-10-29 04:12:09, which is wrong. It should be 2010-10-29 06:12:09 Another example: 418.3219 corresponds to: 2010-02-23 07:43:30, but it should be 2010-02-23 08:43:30. However, not always is the difference + 2 h, it's sometimes less or more. There are a lot of postings here regarding ISOdatetime, but I'm still not able to solve this . Any ideas or suggestions will be very much appreciated. Best regards, Julia PS. I've tried to find the answer in all sorts of R help forums and also in my R books - no luck so far. Maybe I'm missunderstanding the entire ISOdatetime function? -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-DateTime-using-ISOdatetime-in-R-tp4313470p4313470.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] z-transform each column of a data.frame
Hi Martin, On Fri, Jan 20, 2012 at 12:04 PM, Martin Batholdy batho...@googlemail.com wrote: Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) The `scale` function essentially does this except it divides by the sample standard deviation. Punch `scale.default` into your R session to see the code if you want to see how one way you could write the code yourself. HTH, -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] z-transform each column of a data.frame
If you use apply the result will be a matrix, not a data.frame. You could use a for loop for(j in seq_len(ncol(x))) { x[,j] - scale(x[,j]) } or the odd looking x[] - lapply(x, scale) to scale all the columns and keep x a data.frame. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Martin Batholdy Sent: Friday, January 20, 2012 9:17 AM To: R Help Subject: Re: [R] z-transform each column of a data.frame great, thank you! On 20.01.2012, at 18:10, R. Michael Weylandt wrote: ? scale apply(x, 2, scale) Michael On Fri, Jan 20, 2012 at 12:04 PM, Martin Batholdy batho...@googlemail.com wrote: Hi, I am currently trying to z-transform (that is subtracting the mean and divide by the standard deviation) multiple columns of a data.frame at the same time. My first approach was: x - data.frame(c(0:10), c(10:20)) (x - colMeans(x)) / apply(x, 2, sd) This is obviously not working. Is there a convenient way to z-transform each column separately (so in this case, each column represents an independent variable that should be z-transformed) thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question re. package playwith not able to run command getting error message that I'm attempting to use non function
Thanks for your reply Michael, gwindow() command does work. and here is my sessionInfo gwindow() guiWidget of type: gWindowRGtk for toolkit: guiWidgetsToolkitRGtk2 *(opens a window)* sessionInfo() R version 2.14.1 (2011-12-22) Platform: i486-pc-linux-gnu (32-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=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] tcltk grid stats graphics grDevices utils [7] datasets methods base other attached packages: [1] RGtk2_2.20.21gridBase_0.4-4 [3] gWidgetstcltk_0.0-48 digest_0.5.1 [5] tcltk2_1.1-5 playwith_0.9-53 [7] gWidgetsRGtk2_0.0-78 gWidgets_0.0-47 [9] cairoDevice_2.19 lattice_0.20-0 loaded via a namespace (and not attached): [1] tools_2.14.1 again any advice appreciated. Maha On Fri, Jan 20, 2012 at 3:05 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Hcan you give session info (after loading playwith)? I'm able to get that code to work...also -- can you get the basic RGtk functions (like gwindow() ) to work? Michael On Thu, Jan 19, 2012 at 5:28 PM, Farhat Maha mar...@gmail.com wrote: Hello, I managed to install playwith package and all its prerequisites. My R version is R 2.14: R version 2.14.1 (2011-12-22) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) All my packages were updated, and recently installed. When I attempt to use the command playwith I get the following error message: library(playwith) Loading required package: lattice Loading required package: cairoDevice Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Loading required package: grid playwith(plot(1:10)) Error in playwith(plot(1:10)) : attempt to apply non-function playwith(xyplot(Income ~ log(Population / Area), +data = data.frame(state.x77), groups = state.region, +type = c(p, smooth), span = 1, auto.key = TRUE, +xlab = Population density, 1974 (log scale), +ylab = Income per capita, 1974) + ) Error in playwith(xyplot(Income ~ log(Population/Area), data = data.frame(state.x77), : attempt to apply non-function interactive() [1] TRUE autoplay(on = TRUE, lattice.on = TRUE, base.on = TRUE, grid.on = TRUE, ask = FALSE) Automatic `playwith` for Lattice graphics is now ON. Automatic `playwith` for base graphics is now ON. Automatic `playwith` for grid graphics is now ON. plot(1:10) Error in playwith(plot(1:10), envir = environment) : attempt to apply non-function Error in plot.xy(xy, type, ...) : plot.new has not been called yet Any advice about why it is not working. thanks Maha [[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.
Re: [R] Incorrect DateTime using ISOdatetime in R
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sula2011 Sent: Friday, January 20, 2012 7:00 AM To: r-help@r-project.org Subject: [R] Incorrect DateTime using ISOdatetime in R Dear list, I need to transform the DateTime of my GPS data from: 666.1751 into /mm/dd hh:mm:ss I have the following code: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d$Date*(24*3600) This gives me: 2010-10-29 04:12:09, which is wrong. It should be 2010-10- 29 06:12:09 Another example: 418.3219 corresponds to: 2010-02-23 07:43:30, but it should be 2010-02-23 08:43:30. However, not always is the difference + 2 h, it's sometimes less or more. There are a lot of postings here regarding ISOdatetime, but I'm still not able to solve this . Any ideas or suggestions will be very much appreciated. Best regards, Julia PS. I've tried to find the answer in all sorts of R help forums and also in my R books - no luck so far. Maybe I'm missunderstanding the entire ISOdatetime function? Julia, are the times from your GPS really GMT times, or are they your local time (it looks like you are in Germany)? It looks like you are dealing with local times that are further complicated by changes between daylight and standard time. Could that be the issue? Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 package dev: how to export constant?
So you are still unable to cite the previous part of the thread? On 19.01.2012 00:13, Jonas Stein wrote: Jonas, I've just seen your function 'sistring' code and it's different from the code in Thanks a lot for reporting this bug. It is fixed now in the git repository. I added some examples, but they do not work: R CMD check sitools = snip ### ** Examples library(sitools) We do not know the details about that package # volume of a dice in metres a- 1 * centi Error: object 'centi' not found We do not know hoe you tried to make that object available now. = snap Any hints? No, given you do not manage to tell us how your setup looks like now. Do you think i should rename the convert function Which convert function? You do not call such a function in the example you gave above, do you? Uwe Ligges to float2si or something like that? Perhaps someone needs a si2float converter in future... Betatesters are welcome. After some more testing i want to upload the package to the R package collection. kind regards, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] rsp
On 20.01.2012 09:01, Ashy wrote: Could anyone please tell how to pass parameters of form to server in rsp? Could you please ask questions that are semantically understandable and additionally read the posting guide? Thanks, Uwe Ligges -- View this message in context: http://r.789695.n4.nabble.com/rsp-tp4312635p4312635.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Contour plot on a triangular mesh
Not sure if I understand the question: If you have more data the grid produced by image() or contour() will be finer anyway... Perhaps we just need an example what you are actually asking for. Uwe Ligges On 20.01.2012 13:28, Roary wrote: Hi All, I have 3 variables which present a perfect linear dependency such that the third is the sum of the first two. I have an ordinary 2D contour plot on a square grid with the first two variables forming the axes and the third naturally being the diagonals. From an interpretive point of view it would be nice to plot these two variables on a finer grid such that the third can have the same scaling (i.e. a finer grid) as the first two and this would look better on a triangular mesh. Is this possible in R? Many thanks, Roary -- View this message in context: http://r.789695.n4.nabble.com/Contour-plot-on-a-triangular-mesh-tp4313098p4313098.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extract fixed width fields from a string
Hi, I have a data frame with one column containing string of the form ABC...|XYZ... where ABC etc are fields of 6 alphanumeric characters each and XYZ etc are fields of 8 alphanumeric characters each; | is a mandatory separator; I do not know in advance how many fields of each kind will each row contain. I need to extract these fields from the string. === How do I do that? first I need to split the string in 2 on '|' - how? then I need to split the two strings by 6/8 characters -- how? then I need to convert each 6/8 character string into an integer base 36 or 64 (depending on the field) - how? === What do I do with them once I extract them? First thing I want to do is to have a count table of them. Then I thought of adding an extra column for each field value and putting 0/1 there, e.g., frame 1,AB 2,BCD will turn into 1,1,1,0,0 2,0,1,1,1 however this would work only if the number of different field values is manageable. What do people do? Can I have a columns of sets in data frame? Does R support the set data type? Thanks! PS. thanks to Sarah Goslee who answered my previous question in so much detail! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://camera.org http://openvotingconsortium.org http://iris.org.il http://mideasttruth.com http://memri.org http://honestreporting.com Don't take life too seriously, you'll never get out of it alive! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] extract fixed width fields from a string
Reproducible example, please. This doesn't make a whole lot of sense otherwise. On Fri, Jan 20, 2012 at 1:52 PM, Sam Steingold s...@gnu.org wrote: Hi, I have a data frame with one column containing string of the form ABC...|XYZ... where ABC etc are fields of 6 alphanumeric characters each and XYZ etc are fields of 8 alphanumeric characters each; | is a mandatory separator; I do not know in advance how many fields of each kind will each row contain. I need to extract these fields from the string. This is already a data frame, so you don't need to import it into R, just process it? === How do I do that? first I need to split the string in 2 on '|' - how? strsplit() then I need to split the two strings by 6/8 characters -- how? substring() perhaps then I need to convert each 6/8 character string into an integer base 36 or 64 (depending on the field) - how? base 36? Really? How are you representing that? Somehow I think you mean something other than what you said. Either way, please clarify. === What do I do with them once I extract them? I don't know. Save them as a list, most likely. First thing I want to do is to have a count table of them. Then I thought of adding an extra column for each field value and putting 0/1 there, e.g., frame 1,AB 2,BCD I thought we had integers at this point? will turn into 1,1,1,0,0 2,0,1,1,1 however this would work only if the number of different field values is manageable. But we have no idea, because you haven't told us. What do people do? Can I have a columns of sets in data frame? Does R support the set data type? factor() seems to be what you're looking for. PS. thanks to Sarah Goslee who answered my previous question in so much detail! You're welcome, but you'd be even more welcome if you'd listened to the parts of my reply about reproducible examples, clear problem statements, and reading the posting guide. Sarah -- Sarah Goslee http://www.functionaldiversity.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.
Re: [R] extract fixed width fields from a string
Sam: On Fri, Jan 20, 2012 at 10:52 AM, Sam Steingold s...@gnu.org wrote: Hi, I have a data frame with one column containing string of the form ABC...|XYZ... where ABC etc are fields of 6 alphanumeric characters each and XYZ etc are fields of 8 alphanumeric characters each; | is a mandatory separator; I do not know in advance how many fields of each kind will each row contain. I need to extract these fields from the string. === How do I do that? first I need to split the string in 2 on '|' - how? ?strsplit strsplit(thecolumn, |,fixed=TRUE) then I need to split the two strings by 6/8 characters -- how? This makes no sense to me. strsplit takes care of this. then I need to convert each 6/8 character string into an integer base 36 or 64 (depending on the field) - how? No clue. Depends on the encoding AFAICS. -- Bert === What do I do with them once I extract them? First thing I want to do is to have a count table of them. Then I thought of adding an extra column for each field value and putting 0/1 there, e.g., frame 1,AB 2,BCD will turn into 1,1,1,0,0 2,0,1,1,1 however this would work only if the number of different field values is manageable. What do people do? Can I have a columns of sets in data frame? Does R support the set data type? Thanks! PS. thanks to Sarah Goslee who answered my previous question in so much detail! -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://camera.org http://openvotingconsortium.org http://iris.org.il http://mideasttruth.com http://memri.org http://honestreporting.com Don't take life too seriously, you'll never get out of it alive! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Estimation of the mode
Hi all, I am trying to estimate the mode of a 4-dimensional nonparametric density estimator (any) using a sample of size n=10,000. I have tried using the package 'ks' and 'np' but they are extremely slow; this is related to the estimation of the bandwidth matrix. I also checked the package 'modeest' but it contains only methods for univariate distributions. I am only interested in the mode. Any suggestion? Thanks in advance. Kind regards. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Date seq question
Can anyone please help me with this? I have a list of business dates. What I want is to have last day of last month and paste them on next month. What i haveWhat i want 5725 2011-09-22 5726 2011-09-23 5727 2011-09-26 5728 2011-09-27 5729 2011-09-28 5730 2011-09-29 5731 2011-09-30 5742 2011-10-17 2011-09-30 5743 2011-10-18 2011-09-30 5744 2011-10-19 2011-09-30 5745 2011-10-20 2011-09-30 5746 2011-10-21 2011-09-30 5747 2011-10-24 2011-09-30 5748 2011-10-25 2011-09-30 *5749 2011-10-26* 2011-09-30 5765 2011-11-17 2011-10-26 5766 2011-11-18 2011-10-26 5767 2011-11-21 2011-10-26 5768 2011-11-22 2011-10-26 5769 2011-11-23 2011-10-26 5770 2011-11-25 2011-10-26 5771 2011-11-28 2011-10-26 5772 2011-11-29 2011-10-26 *5773 2011-11-30* 2011-10-26 5780 2011-12-09 2011-11-30 5781 2011-12-12 2011-11-30 5782 2011-12-13 2011-11-30 5783 2011-12-14 2011-11-30 5784 2011-12-15 2011-11-30 5785 2011-12-16 2011-11-30 5786 2011-12-19 2011-11-30 5787 2011-12-20 2011-11-30 5788 2011-12-21 2011-11-30 5789 2011-12-22 2011-11-30 date - c(9/22/2011,9/23/2011,9/26/2011,9/27/2011,9/28/2011,9/29/2011,9/30/2011,10/17/2011, 10/18/2011,10/19/2011,10/20/2011,10/21/2011,10/24/2011,10/25/2011,10/26/2011,11/17/2011,11/18/2011,11/21/2011,11/22/2011,11/23/2011,11/25/2011,11/28/2011,11/29/2011,11/30/2011, 12/9/2011,12/12/2011,12/13/2011,12/14/2011,12/15/2011,12/16/2011,12/19/2011,12/20/2011,12/21/2011,12/22/2011) -- View this message in context: http://r.789695.n4.nabble.com/Date-seq-question-tp4313861p4313861.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read Analyze Google spreadsheets
Hi, Would like to analyze this survey: https://docs.google.com/spreadsheet/ccc?key=0Al8vE0D1FPpldEVKWEpZalVELXRhdXo1RU5pTXJWUlE I know how to read in the data like this: require(RCurl) myCsv - getURL(https://docs.google.com/spreadsheet/pub?hl=en_UShl=en_USkey=0Al8vE0D1FPpldEVKWEpZalVELXRhdXo1RU5pTXJWUlEoutput=csv;) read.csv(textConnection(myCsv)) Q: How to read in the data column by column? For each column I would like to plot the data like a pie chart or with bars meant that this made sense. Regards Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] abline by groups
Hello, I have 2 variables - x and y, that belong to separate groups. I want to plot all the x and y together, but show separate abline for each group. It can be done in ggplot2, but is there a simpler way to draw ablines by group? e.g., mydata - data.frame(x = 1:20+rnorm(20, -3, 1), y = seq(1,20,by=1), group = rep(letters[1:5],20)) plot(x,y,col=mydata$group) # need to get separate ablines for each color-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.
[R] fit Johnson Sb with fitdist(method=mme)
Dear R-helpers, I am trying to fit my data to a 4-parameter lognormal distribution (aka Johnson Sb dist) with fitdist function from the library(fitdistrplus). So far, I have learnt that with mle method it's not always possible to estimate the gamma and delta parameters even if the bounding estimates are known/guessed. Therefore, I tried to fit it with the mme method giving: #xi = xi #lambda =l #delta =d #gamma = g data1 - rlnorm(1,-2.79,0.598) ## the parameters have been estimated for a 2-parms lognormal dist. djohn - function(x,xi,l,d,g) { ## probability density function of Johnson SB distribution (source: http://www.ntrand.com/johnson-sb-distribution/) (d/(l*sqrt(2*pi)*((x-xi)/l)*(1-((x-xi)/l*exp(-0.5*(g + d*log(((x-xi)/l)/(1-((x-xi)/l^2) } pjohn - function(x,xi,l,d,g) { pnorm(g + d*log(((x-xi)/l)/(1-((x-xi)/l } qjohn - function(p,xi,l,d,g) { qnorm(xi + (l*exp((qnorm(p) - g)/d))/(1 + exp((qnorm(p) - g)/d))) } library(moments) memplog - function(x,order) { ifelse(order==1, mean(x), moment(x,order,central=TRUE)) } fjsb - fitdist(c(data1),john,method=mme,order=c(1,2),memp=memplog,start=list (xi=0,l=max(data1),d=1,g=1)) But it results in: fjsb - fitdist(c(data1),john,method=mme,order=c(1,2),memp=memplog,start=list (xi=0,l=max(data1),d=1,g=1)) Error in mmedist(data, distname, start = start, fix.arg = fix.arg, ...) : wrong dimension for the moment order to match. And I just can't figure out where the mistake is. Thank you very much for your help in advance. Regards, Tanya [[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] abline by groups
Hello, I have 2 variables - x and y, that belong to separate groups. I want to plot all the x and y together, but show separate abline for each group. It can be done in ggplot2, but is there a simpler way to draw ablines by group? e.g., mydata - data.frame(x = 1:20+rnorm(20, -3, 1), y = seq(1,20,by=1), group = rep(letters[1:5],20)) plot(x,y,col=mydata$group) # need to get separate ablines for each color-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.
Re: [R] Date seq question
Try this: date - c(9/22/2011,9/23/2011,9/26/2011,9/27/2011,9/28/2011,9/29/2011,9/30/2011,10/17/2011, 10/18/2011,10/19/2011,10/20/2011,10/21/2011,10/24/2011,10/25/2011,10/26/2011,11/17/2011,11/18/2011,11/21/2011,11/22/2011,11/23/2011,11/25/2011,11/28/2011,11/29/2011,11/30/2011, 12/9/2011,12/12/2011,12/13/2011,12/14/2011,12/15/2011,12/16/2011,12/19/2011,12/20/2011,12/21/2011,12/22/2011) library(lubridate) date - as.Date(date, format = %m/%d/%Y) # Convert character to an actual date day(date) - 1; # Shift every date to the first day of its month date - 1 # And go one day previous Michael On Fri, Jan 20, 2012 at 12:12 PM, cameron raymond...@invesco.com wrote: Can anyone please help me with this? I have a list of business dates. What I want is to have last day of last month and paste them on next month. What i have What i want 5725 2011-09-22 5726 2011-09-23 5727 2011-09-26 5728 2011-09-27 5729 2011-09-28 5730 2011-09-29 5731 2011-09-30 5742 2011-10-17 2011-09-30 5743 2011-10-18 2011-09-30 5744 2011-10-19 2011-09-30 5745 2011-10-20 2011-09-30 5746 2011-10-21 2011-09-30 5747 2011-10-24 2011-09-30 5748 2011-10-25 2011-09-30 *5749 2011-10-26* 2011-09-30 5765 2011-11-17 2011-10-26 5766 2011-11-18 2011-10-26 5767 2011-11-21 2011-10-26 5768 2011-11-22 2011-10-26 5769 2011-11-23 2011-10-26 5770 2011-11-25 2011-10-26 5771 2011-11-28 2011-10-26 5772 2011-11-29 2011-10-26 *5773 2011-11-30* 2011-10-26 5780 2011-12-09 2011-11-30 5781 2011-12-12 2011-11-30 5782 2011-12-13 2011-11-30 5783 2011-12-14 2011-11-30 5784 2011-12-15 2011-11-30 5785 2011-12-16 2011-11-30 5786 2011-12-19 2011-11-30 5787 2011-12-20 2011-11-30 5788 2011-12-21 2011-11-30 5789 2011-12-22 2011-11-30 date - c(9/22/2011,9/23/2011,9/26/2011,9/27/2011,9/28/2011,9/29/2011,9/30/2011,10/17/2011, 10/18/2011,10/19/2011,10/20/2011,10/21/2011,10/24/2011,10/25/2011,10/26/2011,11/17/2011,11/18/2011,11/21/2011,11/22/2011,11/23/2011,11/25/2011,11/28/2011,11/29/2011,11/30/2011, 12/9/2011,12/12/2011,12/13/2011,12/14/2011,12/15/2011,12/16/2011,12/19/2011,12/20/2011,12/21/2011,12/22/2011) -- View this message in context: http://r.789695.n4.nabble.com/Date-seq-question-tp4313861p4313861.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] abline by groups
On 20.01.2012 16:38, Sam Chand wrote: Hello, I have 2 variables - x and y, that belong to separate groups. I want to plot all the x and y together, but show separate abline for each group. It can be done in ggplot2, but is there a simpler way to draw ablines by group? e.g., mydata- data.frame(x = 1:20+rnorm(20, -3, 1), y = seq(1,20,by=1), group = rep(letters[1:5],20)) plot(x,y,col=mydata$group) # need to get separate ablines for each color-code 1. The code does not run as is. 2. abline for more than two points is nonsense for your data, since the groups are not at all on one line. 3. So you may want separate regressions? Or a whole model of the data with different intercepts and same slope? Or in one model with different intercepts and different slopes? Hence we cannot help and for now I assume this is a homework problem and you have not even repeated the question properly. Uwe Ligges [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] abline by groups
I believe you are looking for analysis of covariance. I recommend the ancova function in the HH package. ## install.packages(HH) ## if needed library(HH) tmp - ancova(y ~ x + group, data=mydata) tmp ## You suggested that you want the superpose panel. You can get ## that on a single page with the last page from update(attr(tmp, trellis), layout=c(1,1)) On Fri, Jan 20, 2012 at 10:38 AM, Sam Chand sam.cs2...@gmail.com wrote: Hello, I have 2 variables - x and y, that belong to separate groups. I want to plot all the x and y together, but show separate abline for each group. It can be done in ggplot2, but is there a simpler way to draw ablines by group? e.g., mydata - data.frame(x = 1:20+rnorm(20, -3, 1), y = seq(1,20,by=1), group = rep(letters[1:5],20)) plot(x,y,col=mydata$group) # need to get separate ablines for each color-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.htmlhttp://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.
[R] Building R on RHEL 5
Hello, I am trying to upgrade to the latest R release on a machine running Red Hat el5. Previously I was successful at building R 2.11, but now I am having troubles with R 2.14. Configure goes fine, but then make throws a lot of errors (output below). Any idea what I am doing wrong this time around? Thanks in advance, Erik make output: ... gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../src/extra/pcre -I../../src/extra -I../../src/extra/xz/api -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c vfonts.c -o vfonts.o gfortran -g -O2 -c xxxpr.f -o xxxpr.o ar cr libR.a CConverters.o CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o arithmetic.o array.o attrib.o base.o bind.o builtin.o character.o coerce.o colors.o complex.o connections.o context.o cov.o cum.o dcf.o datetime.o debug.o deparse.o deriv.o devices.o dotcode.o dounzip.o dstruct.o duplicate.o engine.o envir.o errors.o eval.o format.o fourier.o gevents.o gram.o gram-ex.o gramLatex.o gramRd.o graphics.o grep.o identical.o inlined.o inspect.o internet.o iosupport.o lapack.o list.o localecharset.o logic.o main.o mapply.o match.o memory.o model.o names.o objects.o optim.o optimize.o options.o par.o paste.o platform.o plot.o plot3d.o plotmath.o print.o printarray.o printvector.o printutils.o qsort.o random.o raw.o registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o size.o sort.o source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o summary.o sysutils.o unique.o util.o version.o vfonts.o xxxpr.o libs/*o ranlib libR.a gcc -std=gnu99 -Wl,--export-dynamic -L/usr/local/lib64 -o R.bin Rmain.o libR.a -L../../lib -lRblas -lgfortran -lm -lreadline -lncurses -lrt -ldl -lm libR.a(main.o): In function `feof_unlocked': /usr/include/bits/stdio.h:123: multiple definition of `feof_unlocked' Rmain.o:/usr/include/bits/stdio.h:123: first defined here libR.a(main.o): In function `ferror_unlocked': /usr/include/bits/stdio.h:130: multiple definition of `ferror_unlocked' Rmain.o:/usr/include/bits/stdio.h:130: first defined here libR.a(main.o): In function `putchar_unlocked': /usr/include/bits/stdio.h:104: multiple definition of `putchar_unlocked' Rmain.o:/usr/include/bits/stdio.h:104: first defined here libR.a(main.o): In function `putc_unlocked': /usr/include/bits/stdio.h:97: multiple definition of `putc_unlocked' Rmain.o:/usr/include/bits/stdio.h:97: first defined here libR.a(main.o): In function `fputc_unlocked': ... several thousand similar errors... ... /usr/include/stdlib.h:330: multiple definition of `atof' libR.a(main.o):/usr/include/stdlib.h:330: first defined here collect2: ld returned 1 exit status make[3]: *** [R.bin] Error 1 make[3]: Leaving directory ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Estimation of the mode
You realize, I trust, that the mode of a continuous distribution has no meaning without prior specification of the distribution, which, for a fitted density estimate would mean specification of the fitting parameters (bandwidth, etc.) at a minimum. So perhaps you need to rethink what you are trying to do and/or perhaps get some advice from a local statistical resource. -- Bert On Fri, Jan 20, 2012 at 8:27 AM, Javier xyz chikwi...@hotmail.com wrote: Hi all, I am trying to estimate the mode of a 4-dimensional nonparametric density estimator (any) using a sample of size n=10,000. I have tried using the package 'ks' and 'np' but they are extremely slow; this is related to the estimation of the bandwidth matrix. I also checked the package 'modeest' but it contains only methods for univariate distributions. I am only interested in the mode. Any suggestion? Thanks in advance. Kind regards. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] extract fixed width fields from a string
On Fri, Jan 20, 2012 at 14:05, Sarah Goslee sarah.gos...@gmail.com wrote: then I need to convert each 6/8 character string into an integer base 36 or 64 (depending on the field) - how? base 36? 10 decimal digits + 26 english characters = 36. ThusThisLongWordWithLettersAndDigitsFrom0to9isAnIntegerBase36 (case insensitive). So, how do I convert the above long word to a bignum? actually, my numbers will fit into int64, no bignum support is necessary. thanks. -- Sam Steingold http://sds.podval.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.
Re: [R] extract fixed width fields from a string
On Fri, Jan 20, 2012 at 14:05, Sarah Goslee sarah.gos...@gmail.com wrote: Reproducible example, please. This doesn't make a whole lot of sense otherwise. here is the string: 1288915200|070400905a0A118 I want the following data extracted from it: 1. the decimal number before |: 1288915200 2. the string after | split into 3 parts, each of length 9 bytes, and then split into 3 more parts: id: the first 6 bytes, int, base 36; count: the next 2 bytes, int, base 10; offset: the last 1 byte, int, base 64 (0-9a-zA-Z-_) i.e., the above line is: id=7, count=4, days=0 id=9; count=5; offset=10 id=10; count=11; offset=8 thanks. On Fri, Jan 20, 2012 at 1:52 PM, Sam Steingold s...@gnu.org wrote: Hi, I have a data frame with one column containing string of the form ABC...|XYZ... where ABC etc are fields of 6 alphanumeric characters each and XYZ etc are fields of 8 alphanumeric characters each; | is a mandatory separator; I do not know in advance how many fields of each kind will each row contain. I need to extract these fields from the string. This is already a data frame, so you don't need to import it into R, just process it? yes. I don't know. Save them as a list, most likely. can a column contain lists? First thing I want to do is to have a count table of them. Then I thought of adding an extra column for each field value and putting 0/1 there, e.g., frame 1,AB 2,BCD I thought we had integers at this point? yes, A..D are placeholders for integers What do people do? Can I have a columns of sets in data frame? Does R support the set data type? factor() seems to be what you're looking for. no, a column of factors will contain a single factor item in each row. e.g.: 1 A 2 B 3 A 4 C I want each row to contain a set of factor items: 1 AB 2 A 3 C 4 void -- Sam Steingold http://sds.podval.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.
Re: [R] Stacked barchart in ggplot (or other library)
Bart6114 wrote on 01/20/2012 08:54:39 AM: Hey, I want to create a stacked barchart in R for the following dataset (http://pastebin.com/pyHUNgr2): # usage capacity diff 1 4 10 6 2 2 20 18 3 5 10 5 The stacked barchart should, in one plot show each line of the dataset as a stacked bar using data from 'usage' and 'diff' to create the stacked bar. I can't find a good example of how to do this on the ggplot2 site. Thanks in advance! See the help on barplot: ?barplot For example: df - data.frame(usage=c(4, 2, 5), capacity=c(10, 20, 10), diff=c(6, 18, 5)) barplot(t(as.matrix(df[, 1:2]))) Jean [[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] Bayesian data analysis recommendations
You might look at John Kruschke's book, Doing Bayesian Data Analysis (AP), which starts with basics and goes from there. It also relies on R and Bugs. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] extract fixed width fields from a string
Here part of it. This is the conversion of base 36 to numeric that is case insensitive. This makes use of mapping the alphabetics to characters that start just after '9' and then doing the conversion. You can extend it to base 64 using the same approach. base36ToInteger - function (Str) + { + common - chartr( + abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ # input + , :;=?@ABCDEFGHIJKLMNOPQRS:;=?@ABCDEFGHIJKLMNOPQRS # 'magic' translation + , Str + ) + x - as.numeric(charToRaw(common)) - 48 + sum(x * 36 ^ rev(seq(length(x)) - 1)) + } base36ToInteger('1') [1] 1 base36ToInteger('12') [1] 38 base36ToInteger('123') [1] 1371 base36ToInteger('1234') [1] 49360 base36ToInteger('12345') [1] 1776965 base36ToInteger('123456') [1] 63970746 On Fri, Jan 20, 2012 at 3:25 PM, Sam Steingold s...@gnu.org wrote: On Fri, Jan 20, 2012 at 14:05, Sarah Goslee sarah.gos...@gmail.com wrote: Reproducible example, please. This doesn't make a whole lot of sense otherwise. here is the string: 1288915200|070400905a0A118 I want the following data extracted from it: 1. the decimal number before |: 1288915200 2. the string after | split into 3 parts, each of length 9 bytes, and then split into 3 more parts: id: the first 6 bytes, int, base 36; count: the next 2 bytes, int, base 10; offset: the last 1 byte, int, base 64 (0-9a-zA-Z-_) i.e., the above line is: id=7, count=4, days=0 id=9; count=5; offset=10 id=10; count=11; offset=8 thanks. On Fri, Jan 20, 2012 at 1:52 PM, Sam Steingold s...@gnu.org wrote: Hi, I have a data frame with one column containing string of the form ABC...|XYZ... where ABC etc are fields of 6 alphanumeric characters each and XYZ etc are fields of 8 alphanumeric characters each; | is a mandatory separator; I do not know in advance how many fields of each kind will each row contain. I need to extract these fields from the string. This is already a data frame, so you don't need to import it into R, just process it? yes. I don't know. Save them as a list, most likely. can a column contain lists? First thing I want to do is to have a count table of them. Then I thought of adding an extra column for each field value and putting 0/1 there, e.g., frame 1,AB 2,BCD I thought we had integers at this point? yes, A..D are placeholders for integers What do people do? Can I have a columns of sets in data frame? Does R support the set data type? factor() seems to be what you're looking for. no, a column of factors will contain a single factor item in each row. e.g.: 1 A 2 B 3 A 4 C I want each row to contain a set of factor items: 1 AB 2 A 3 C 4 void -- Sam Steingold http://sds.podval.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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extract fixed width fields from a string
On Fri, Jan 20, 2012 at 03:14:21PM -0500, Sam Steingold wrote: On Fri, Jan 20, 2012 at 14:05, Sarah Goslee sarah.gos...@gmail.com wrote: then I need to convert each 6/8 character string into an integer base 36 or 64 (depending on the field) - how? base 36? 10 decimal digits + 26 english characters = 36. ThusThisLongWordWithLettersAndDigitsFrom0to9isAnIntegerBase36 (case insensitive). So, how do I convert the above long word to a bignum? Hi. Try the following. x - tolower(ThusThisLongWordWithLettersAndDigitsFrom0to9isAnIntegerBase36) x - strsplit(x, )[[1]] digits - 0:35 names(digits) - c(0:9, letters) y - digits[x] # solution using gmp package library(gmp) b - as.bigz(36) sum(y * b^(length(y):1 - 1)) [1] 7045519072280024341066246294410591724807773749367607882253153084991978813070206061584038994 # solution using Rmpfr package library(Rmpfr) b - mpfr(36, precBits=500) sum(y * b^(length(y):1 - 1)) [1] 7045519072280024341066246294410591724807773749367607882253153084991978813070206061584038994 actually, my numbers will fit into int64, no bignum support is necessary. The default R numeric data type is double precision, which represents integers up to 53 bits, so the largest exactly representable integer is 2^53. The integer type is 32 bits. Hope this helps. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Stacked barchart in ggplot (or other library)
to use ggplot: dat-data.frame(num=1:3,usage=c(4,2,5),cap=c(10,20,10),diff=c(6,18,5)) dat.melt-melt(dat,id.var=c('num','cap')) ggplot(dat.melt)+geom_bar(aes(x=num,y=value,fill=variable),stat='identity') On Fri, Jan 20, 2012 at 12:30 PM, Jean V Adams jvad...@usgs.gov wrote: Bart6114 wrote on 01/20/2012 08:54:39 AM: Hey, I want to create a stacked barchart in R for the following dataset (http://pastebin.com/pyHUNgr2): # usage capacity diff 1 4 10 6 2 2 20 18 3 5 10 5 The stacked barchart should, in one plot show each line of the dataset as a stacked bar using data from 'usage' and 'diff' to create the stacked bar. I can't find a good example of how to do this on the ggplot2 site. Thanks in advance! See the help on barplot: ?barplot For example: df - data.frame(usage=c(4, 2, 5), capacity=c(10, 20, 10), diff=c(6, 18, 5)) barplot(t(as.matrix(df[, 1:2]))) Jean [[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.
Re: [R] Contour plot on a triangular mesh
I have two observed categorical variables X1 and X2, with X3=X1+X2, and a continuous response Y. I can interpolate the surface and construct an ordinary 2D square contour plot (with X1,X2 axes and X3 on the diagonal). However, I would like to change the orientation of the plot so that the axes fit a parallelogram shaped grid made up from triangles. This would place X3 on the same scale as X1 and X2 and allow for an easier interpretation of the data for my research question. I hope this makes more sense! Thanks, Roary. Uwe Ligges-3 wrote Not sure if I understand the question: If you have more data the grid produced by image() or contour() will be finer anyway... Perhaps we just need an example what you are actually asking for. Uwe Ligges On 20.01.2012 13:28, Roary wrote: Hi All, I have 3 variables which present a perfect linear dependency such that the third is the sum of the first two. I have an ordinary 2D contour plot on a square grid with the first two variables forming the axes and the third naturally being the diagonals. From an interpretive point of view it would be nice to plot these two variables on a finer grid such that the third can have the same scaling (i.e. a finer grid) as the first two and this would look better on a triangular mesh. Is this possible in R? Many thanks, Roary -- View this message in context: http://r.789695.n4.nabble.com/Contour-plot-on-a-triangular-mesh-tp4313098p4313098.html Sent from the R help mailing list archive at Nabble.com. __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/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@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Contour-plot-on-a-triangular-mesh-tp4313098p4314337.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.
Re: [R] Estimation of the mode
Thanks for your reply. The advantage of nonparametric statistics is that you do not need to specify the distribution because the estimator (e.g. kernel estimator) converges to the true density as the number of observations converges to infinite. The mode in this case is the maximum of this estimator as a *function*. Therefore it actually makes a lot of sense and it is an activate research area in statistics. Please check these concepts before replying. Date: Fri, 20 Jan 2012 12:05:10 -0800 Subject: Re: [R] Estimation of the mode From: gunter.ber...@gene.com To: chikwi...@hotmail.com CC: r-help@r-project.org You realize, I trust, that the mode of a continuous distribution has no meaning without prior specification of the distribution, which, for a fitted density estimate would mean specification of the fitting parameters (bandwidth, etc.) at a minimum. So perhaps you need to rethink what you are trying to do and/or perhaps get some advice from a local statistical resource. -- Bert On Fri, Jan 20, 2012 at 8:27 AM, Javier xyz chikwi...@hotmail.com wrote: Hi all, I am trying to estimate the mode of a 4-dimensional nonparametric density estimator (any) using a sample of size n=10,000. I have tried using the package 'ks' and 'np' but they are extremely slow; this is related to the estimation of the bandwidth matrix. I also checked the package 'modeest' but it contains only methods for univariate distributions. I am only interested in the mode. Any suggestion? Thanks in advance. Kind regards. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Incorrect DateTime using ISOdatetime in R
Hi Luke, Thank you for the answer. On 20/01/2012, at 6:11 , Luke Miller wrote: 666.1751 sure seems like it should return 2010-10-29 04:12:09 based on your example. 666.1751 days from 2009-01-01 is 2010-10-29 + some hours/min/seconds. 0.1751 days * 24 hrs/day = 4.2024 (i.e. 4:00AM + some minutes). 0.2024 hours * 60 min/hr = 12.144 (i.e. 12 minutes + some seconds). 0.144 minutes * 60 sec/min = 8.64 (i.e. 8.64 seconds). Put it all together and I get 2010-10-29 04:12:08.64 in the GMT time zone. What makes you think it should be 2010-10-29 06:12:09? The first fix of the original GPS data is at 06:12:09. So maybe the error is somewhere else? I'm calculating first passage time in R. To run FPT we had to transform DateTime. 1. #paste Date and Time into one column DateTime DT-paste(GPS$Date, GPS$Time, sep= ) GPS$DateTime-as.POSIXct(strptime(as.character(DT), %d/%m/%Y %H:%M: %S)) #paste it together so that it is in the right format for FPT analysis loc - GPS[GPS$Bird==bird,c(LON, LAT, DateTime, Bird)] colnames(loc) - c(Long, Lat, gmt, bird) 2. ##put date in format that FPT likes loc$Date - (unclass(loc$gmt) - unclass(ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)))/(24*3600) 3. After running FPT, the date time needs to be transformed back from 666.1751 into /mm/dd hh:mm:ss And I used this function: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d$Date*(24*3600) where d is the FPT output file (previously loc). THANKS, Julia Are you running into a time zone issue, such as your GPS adjusting its time zone and reported the time based on the time zone where a reading was taken? If you crossed between time zones for some of your readings it might explain the fluctuating difference between the answer you expect and the answer that ISOdatetime gives you. -Luke On Fri, Jan 20, 2012 at 6:59 AM, Sula2011 julia.so...@gmx.de wrote: Dear list, I need to transform the DateTime of my GPS data from: 666.1751 into /mm/dd hh:mm:ss I have the following code: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d $Date*(24*3600) This gives me: 2010-10-29 04:12:09, which is wrong. It should be 2010-10-29 06:12:09 Another example: 418.3219 corresponds to: 2010-02-23 07:43:30, but it should be 2010-02-23 08:43:30. However, not always is the difference + 2 h, it's sometimes less or more. There are a lot of postings here regarding ISOdatetime, but I'm still not able to solve this . Any ideas or suggestions will be very much appreciated. Best regards, Julia PS. I've tried to find the answer in all sorts of R help forums and also in my R books - no luck so far. Maybe I'm missunderstanding the entire ISOdatetime function? -- View this message in context: http://r.789695.n4.nabble.com/Incorrect-DateTime-using-ISOdatetime-in-R-tp4313470p4313470.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. Julia Sommerfeld - PhD Candidate Institute for Marine and Antarctic Studies University of Tasmania Private Bag 129, Hobart TAS 7001 Phone: +61 477 289 301 Email: julia.so...@gmx.de julia.sommerf...@utas.edu.au [[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] rbind()
Hello there, Much thanks in advance for any help. I have a few questions: 1) Why do I keep getting the following error: File1 - read.csv(../RawData/File1.csv,as.is=TRUE,row.names=1) Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file '../RawData/File1.csv': No such file or directory ? More specifically, my directories are set up in the following way: SampleProject RawData SampleCode The current script is in the SampleCode folder. File1.csv is in the RawData folder. I'm a bit confused why this error keeps occurring. I googled it and found many other people getting the same error, but was not sure why mine remained incorrect... 2) Ultimately what I want to do is take File1.csv, File2.csv and File3.csv (all in the RawData folder) and basically add them together such that it was as if they were all on one big csv file to begin with. I thought I knew how to do this but I'm using a mac now-- is there something different between the code to do this with R Studio and on a Mac and using Tinn R on Windows? In any case, I would really very much appreciate any help on both these issues. Thank you again. benjamin [[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] rbind()
Hi Fred, It seems you don't have an rbind() problem, but a path problem. The error you're getting means R can't find your file. When specifying a relative path, as you do with ../RawData/File1.csv it's relative to your current working directory, not necessarily the directory where your script is. You can check that with getwd() and change it with setwd(). The safest thing to do is to specify an absolute path instead, such as /home/user/whatever/RawData/File1.csv but if you want to use relative paths, for instance for repeatability, then just check your working directory carefully. Sarah On Fri, Jan 20, 2012 at 3:39 PM, Fred G bayespoker...@gmail.com wrote: Hello there, Much thanks in advance for any help. I have a few questions: 1) Why do I keep getting the following error: File1 - read.csv(../RawData/File1.csv,as.is=TRUE,row.names=1) Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file '../RawData/File1.csv': No such file or directory ? More specifically, my directories are set up in the following way: SampleProject RawData SampleCode The current script is in the SampleCode folder. File1.csv is in the RawData folder. I'm a bit confused why this error keeps occurring. I googled it and found many other people getting the same error, but was not sure why mine remained incorrect... 2) Ultimately what I want to do is take File1.csv, File2.csv and File3.csv (all in the RawData folder) and basically add them together such that it was as if they were all on one big csv file to begin with. I thought I knew how to do this but I'm using a mac now-- is there something different between the code to do this with R Studio and on a Mac and using Tinn R on Windows? In any case, I would really very much appreciate any help on both these issues. Thank you again. benjamin [[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. -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.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.
Re: [R] Date seq question
On 1/20/2012 9:12 AM, cameron wrote: Can anyone please help me with this? I have a list of business dates. What I want is to have last day of last month and paste them on next month. What i haveWhat i want 5725 2011-09-22 5726 2011-09-23 5727 2011-09-26 5728 2011-09-27 5729 2011-09-28 5730 2011-09-29 5731 2011-09-30 5742 2011-10-17 2011-09-30 5743 2011-10-18 2011-09-30 5744 2011-10-19 2011-09-30 5745 2011-10-20 2011-09-30 5746 2011-10-21 2011-09-30 5747 2011-10-24 2011-09-30 5748 2011-10-25 2011-09-30 *5749 2011-10-26* 2011-09-30 5765 2011-11-17 2011-10-26 5766 2011-11-18 2011-10-26 5767 2011-11-21 2011-10-26 5768 2011-11-22 2011-10-26 5769 2011-11-23 2011-10-26 5770 2011-11-25 2011-10-26 5771 2011-11-28 2011-10-26 5772 2011-11-29 2011-10-26 *5773 2011-11-30* 2011-10-26 5780 2011-12-09 2011-11-30 5781 2011-12-12 2011-11-30 5782 2011-12-13 2011-11-30 5783 2011-12-14 2011-11-30 5784 2011-12-15 2011-11-30 5785 2011-12-16 2011-11-30 5786 2011-12-19 2011-11-30 5787 2011-12-20 2011-11-30 5788 2011-12-21 2011-11-30 5789 2011-12-22 2011-11-30 Reformatting the data you gave: date- c(9/22/2011, 9/23/2011, 9/26/2011, 9/27/2011, 9/28/2011, 9/29/2011, 9/30/2011, 10/17/2011, 10/18/2011, 10/19/2011, 10/20/2011, 10/21/2011, 10/24/2011, 10/25/2011, 10/26/2011, 11/17/2011, 11/18/2011, 11/21/2011, 11/22/2011, 11/23/2011, 11/25/2011, 11/28/2011, 11/29/2011, 11/30/2011, 12/9/2011, 12/12/2011, 12/13/2011, 12/14/2011, 12/15/2011, 12/16/2011, 12/19/2011, 12/20/2011, 12/21/2011, 12/22/2011) Here is a solution using plyr and zoo: library(plyr) library(zoo) DF - data.frame(date) DF - mutate(DF, dt = as.Date(date, format=%m/%d/%Y), ym = as.yearmon(dt)) lastday - ddply(DF, .(ym), summarise, last=max(dt)) lastday - mutate(lastday, ym=ym+(1/12)) merge(DF, lastday, all.x=TRUE) I first turn the strings into dates, and then into yearmons (year-month) which is what I need zoo for. Use ddply to get the last date within each year-month group. Add one month to the yearmon summaries to go to the next month. Then merge these two back together, implicitly by the yearmon. You could then delete any of the intermediate result columns if you like. -- Brian S. Diggs, PhD Senior Research Associate, Department of Surgery Oregon Health Science University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Incorrect DateTime using ISOdatetime in R
You're running into time zone issues. If you're in a time zone that recognizes daylight savings time for part of the year, the difference in the value you calculate and the expected answer will vary. Check your current system timezone: Sys.timezone() If it doesn't return UTC (aka GMT), you're going to run into issues. For instance, if I set my system timezone to CET (for Germany), I can recreate your problem. Sys.setenv(TZ = CET) myTime = as.POSIXct(strptime('2010-10-29 6:12:09', format = '%Y-%m-%d %H:%M:%S')) myTime [1] 2010-10-29 06:12:09 CEST myTime2 = (unclass(myTime) - (unclass(ISOdatetime(2009,1,1,0,0,0, tz = GMT / (24*3600) myTime2 [1] 666.1751 attr(,tzone) [1] CET myTime3 = ISOdatetime(2009,1,1,0,0,0, tz = GMT) + (myTime2*24*3600) Warning message: In check_tzones(e1, e2) : 'tzone' attributes are inconsistent myTime3 [1] 2010-10-29 04:12:09 GMT Note that 'myTime' was created in the CEST timezone. However, myTime2 is created by subtracting myTime from an ISOdatetime set in the GMT timezone, resulting in the 666.1751 value. That value is almost certainly incorrect for use in your first pass analysis. When I then try to convert myTime2 back into a human-readable format, myTime3, the returned value is off by 2 hours, as you've found. If you change the tz option in the ISOdatetime function to CET, you should get the correct values back out. For example: myTime4 = (unclass(myTime) - (unclass(ISOdatetime(2009,1,1,0,0,0, tz = CET / (24*3600) myTime4 [1] 666.2168 attr(,tzone) [1] CET myTime5 = ISOdatetime(2009,1,1,0,0,0, tz = CET) + (myTime4*24*3600) myTime5 [1] 2010-10-29 06:12:09 CEST When I keep everything in CET/CEST timezone with myTime4 and myTime5, I get back the correct 6:12:09 time stamp. However, if you intend to only be working on time stamps that are in the GMT/UTC time zone, then the easiest solution may be to set your system timezone (for the current R session) to UTC: Sys.setenv(TZ='UTC') # This is only active for the current R session After doing that, I can great a time stamp, without an explicit time zone, and R automatically sticks it into the UTC time zone. myTime6 = as.POSIXct(strptime('2010-10-29 6:12:09', format = '%Y-%m-%d %H:%M:%S')) myTime6 [1] 2010-10-29 06:12:09 UTC myTime7 = (unclass(myTime6) - (unclass(ISOdatetime(2009,1,1,0,0,0, tz =UTC / (24*3600) myTime7 [1] 666.2584 attr(,tzone) [1] UTC myTime8 = ISOdatetime(2009,1,1,0,0,0, tz = UTC) + (myTime7*24*3600) myTime8 [1] 2010-10-29 06:12:09 UTC That should cure your problems. You should re-run all of your FPT analyses, since you may have been feeding them incorrect time values all along. -Luke On Fri, Jan 20, 2012 at 11:24 AM, Julia Sommerfeld julia.so...@gmx.de wrote: Hi Luke, Thank you for the answer. On 20/01/2012, at 6:11 , Luke Miller wrote: 666.1751 sure seems like it should return 2010-10-29 04:12:09 based on your example. 666.1751 days from 2009-01-01 is 2010-10-29 + some hours/min/seconds. 0.1751 days * 24 hrs/day = 4.2024 (i.e. 4:00AM + some minutes). 0.2024 hours * 60 min/hr = 12.144 (i.e. 12 minutes + some seconds). 0.144 minutes * 60 sec/min = 8.64 (i.e. 8.64 seconds). Put it all together and I get 2010-10-29 04:12:08.64 in the GMT time zone. What makes you think it should be 2010-10-29 06:12:09? The first fix of the original GPS data is at 06:12:09. So maybe the error is somewhere else? I'm calculating first passage time in R. To run FPT we had to transform DateTime. 1. #paste Date and Time into one column DateTime DT-paste(GPS$Date, GPS$Time, sep= ) GPS$DateTime-as.POSIXct(strptime(as.character(DT), %d/%m/%Y %H:%M:%S)) #paste it together so that it is in the right format for FPT analysis loc - GPS[GPS$Bird==bird,c(LON, LAT, DateTime, Bird)] colnames(loc) - c(Long, Lat, gmt, bird) 2. ##put date in format that FPT likes loc$Date - (unclass(loc$gmt) - unclass(ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)))/(24*3600) 3. After running FPT, the date time needs to be transformed back from 666.1751 into /mm/dd hh:mm:ss And I used this function: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d$Date*(24*3600) where d is the FPT output file (previously loc). THANKS, Julia Are you running into a time zone issue, such as your GPS adjusting its time zone and reported the time based on the time zone where a reading was taken? If you crossed between time zones for some of your readings it might explain the fluctuating difference between the answer you expect and the answer that ISOdatetime gives you. -Luke On Fri, Jan 20, 2012 at 6:59 AM, Sula2011 julia.so...@gmx.de wrote: Dear list, I need to transform the DateTime of my GPS data from: 666.1751 into /mm/dd hh:mm:ss I have the following code: d$Date - ISOdatetime(2009, 1, 1, 0, 0, 0, tz = GMT)+d$Date*(24*3600) This gives me: 2010-10-29 04:12:09, which is wrong. It should be 2010-10-29 06:12:09 Another example:
[R] Get default values of a function argument
Hi, a quick question: Is there a way to retrieve the default value of a function argument - if it exists? (I know I can see it if I type the function name, but I would like get the value programaticaly.) Thanks, -- Helios de Rosario Martínez Researcher INSTITUTO DE BIOMECÁNICA DE VALENCIA Universidad Politécnica de Valencia • Edificio 9C Camino de Vera s/n • 46022 VALENCIA (ESPAÑA) Tel. +34 96 387 91 60 • Fax +34 96 387 91 69 www.ibv.org Antes de imprimir este e-mail piense bien si es necesario hacerlo. En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección de Datos de Carácter Personal, le informamos de que el presente mensaje contiene información confidencial, siendo para uso exclusivo del destinatario arriba indicado. En caso de no ser usted el destinatario del mismo le informamos que su recepción no le autoriza a su divulgación o reproducción por cualquier medio, debiendo destruirlo de inmediato, rogándole lo notifique al remitente. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Get default values of a function argument
On Jan 20, 2012, at 6:26 PM, Helios de Rosario wrote: Hi, a quick question: Is there a way to retrieve the default value of a function argument - if it exists? (I know I can see it if I type the function name, but I would like get the value programaticaly.) ?formals -- 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.
Re: [R] Get default values of a function argument
That's exactly what I wanted. Thanks! Helios El día 21/01/2012 a las 0:33, David Winsemius dwinsem...@comcast.net escribió: On Jan 20, 2012, at 6:26 PM, Helios de Rosario wrote: Hi, a quick question: Is there a way to retrieve the default value of a function argument - if it exists? (I know I can see it if I type the function name, but I would like get the value programaticaly.) ?formals INSTITUTO DE BIOMECÁNICA DE VALENCIA Universidad Politécnica de Valencia • Edificio 9C Camino de Vera s/n • 46022 VALENCIA (ESPAÑA) Tel. +34 96 387 91 60 • Fax +34 96 387 91 69 www.ibv.org Antes de imprimir este e-mail piense bien si es necesario hacerlo. En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección de Datos de Carácter Personal, le informamos de que el presente mensaje contiene información confidencial, siendo para uso exclusivo del destinatario arriba indicado. En caso de no ser usted el destinatario del mismo le informamos que su recepción no le autoriza a su divulgación o reproducción por cualquier medio, debiendo destruirlo de inmediato, rogándole lo notifique al remitente. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] rbind()
As Sarah said, you have a path problem. Are you saying that RawData is a sub-folder (sub-directory) of SampleProject? And you are running the script with the working directory set to SampleProject? [check using getwd() as Sarah suggested] If so, it looks like it would work if you use './RawData/File1.csv'. The .. causes it back up one directory (folder) above the working directory before looking for RawData. You can also use file.choose() to find the file, and that will tell you what the correct path is. There's nothing special about how R on the Mac finds input files, or how it uses rbind(). It does it in the standard R way. (I have no idea how much different it might be using R Studio or Tinn R on Windows.) -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/20/12 12:39 PM, Fred G bayespoker...@gmail.com wrote: Hello there, Much thanks in advance for any help. I have a few questions: 1) Why do I keep getting the following error: File1 - read.csv(../RawData/File1.csv,as.is=TRUE,row.names=1) Error in file(file, rt) : cannot open the connection In addition: Warning message: In file(file, rt) : cannot open file '../RawData/File1.csv': No such file or directory ? More specifically, my directories are set up in the following way: SampleProject RawData SampleCode The current script is in the SampleCode folder. File1.csv is in the RawData folder. I'm a bit confused why this error keeps occurring. I googled it and found many other people getting the same error, but was not sure why mine remained incorrect... 2) Ultimately what I want to do is take File1.csv, File2.csv and File3.csv (all in the RawData folder) and basically add them together such that it was as if they were all on one big csv file to begin with. I thought I knew how to do this but I'm using a mac now-- is there something different between the code to do this with R Studio and on a Mac and using Tinn R on Windows? In any case, I would really very much appreciate any help on both these issues. Thank you again. benjamin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building R on RHEL 5
Why not use the pre-compiled RPM's from EPEL ( http://fedoraproject.org/wiki/EPEL )? Version 2.14 of R is still in the testing folder here: http://download.fedora.redhat.com/pub/epel/testing/5/ Jason On 01/20/2012 02:34 PM, Erik Wright wrote: Hello, I am trying to upgrade to the latest R release on a machine running Red Hat el5. Previously I was successful at building R 2.11, but now I am having troubles with R 2.14. Configure goes fine, but then make throws a lot of errors (output below). Any idea what I am doing wrong this time around? Thanks in advance, Erik make output: ... gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../src/extra/pcre -I../../src/extra -I../../src/extra/xz/api -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c vfonts.c -o vfonts.o gfortran-g -O2 -c xxxpr.f -o xxxpr.o ar cr libR.a CConverters.o CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o arithmetic.o array.o attrib.o base.o bind.o builtin.o character.o coerce.o colors.o complex.o connections.o context.o cov.o cum.o dcf.o datetime.o debug.o deparse.o deriv.o devices.o dotcode.o dounzip.o dstruct.o duplicate.o engine.o envir.o errors.o eval.o format.o fourier.o gevents.o gram.o gram-ex.o gramLatex.o gramRd.o graphics.o grep.o identical.o inlined.o inspect.o internet.o iosupport.o lapack.o list.o localecharset.o logic.o main.o mapply.o match.o memory.o model.o names.o objects.o optim.o optimize.o options.o par.o paste.o platform.o plot.o plot3d.o plotmath.o print.o printarray.o printvector.o printutils.o qsort.o random.o raw.o registration.o relop.o rlocale.o saveload.o scan.o seq.o serialize.o size.o sort.o source.o split.o sprintf.o startup.o subassign.o subscript.o subset.o summary.o sysutils.o unique.o util.o version.o vfonts.o xxxpr.o libs/*o ranlib libR.a gcc -std=gnu99 -Wl,--export-dynamic -L/usr/local/lib64 -o R.bin Rmain.o libR.a -L../../lib -lRblas -lgfortran -lm -lreadline -lncurses -lrt -ldl -lm libR.a(main.o): In function `feof_unlocked': /usr/include/bits/stdio.h:123: multiple definition of `feof_unlocked' Rmain.o:/usr/include/bits/stdio.h:123: first defined here libR.a(main.o): In function `ferror_unlocked': /usr/include/bits/stdio.h:130: multiple definition of `ferror_unlocked' Rmain.o:/usr/include/bits/stdio.h:130: first defined here libR.a(main.o): In function `putchar_unlocked': /usr/include/bits/stdio.h:104: multiple definition of `putchar_unlocked' Rmain.o:/usr/include/bits/stdio.h:104: first defined here libR.a(main.o): In function `putc_unlocked': /usr/include/bits/stdio.h:97: multiple definition of `putc_unlocked' Rmain.o:/usr/include/bits/stdio.h:97: first defined here libR.a(main.o): In function `fputc_unlocked': ... several thousand similar errors... ... /usr/include/stdlib.h:330: multiple definition of `atof' libR.a(main.o):/usr/include/stdlib.h:330: first defined here collect2: ld returned 1 exit status make[3]: *** [R.bin] Error 1 make[3]: Leaving directory ... __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Contour plot on a triangular mesh
I'm not sure if this is appropriate. If the sum of your variables is always the same constant, then you might try a Ternary plot ( http://en.wikipedia.org/wiki/Ternary_plot ). The vcd package can make ternary plots. On 01/20/2012 02:56 PM, Roary wrote: I have two observed categorical variables X1 and X2, with X3=X1+X2, and a continuous response Y. I can interpolate the surface and construct an ordinary 2D square contour plot (with X1,X2 axes and X3 on the diagonal). However, I would like to change the orientation of the plot so that the axes fit a parallelogram shaped grid made up from triangles. This would place X3 on the same scale as X1 and X2 and allow for an easier interpretation of the data for my research question. I hope this makes more sense! Thanks, Roary. Uwe Ligges-3 wrote Not sure if I understand the question: If you have more data the grid produced by image() or contour() will be finer anyway... Perhaps we just need an example what you are actually asking for. Uwe Ligges On 20.01.2012 13:28, Roary wrote: Hi All, I have 3 variables which present a perfect linear dependency such that the third is the sum of the first two. I have an ordinary 2D contour plot on a square grid with the first two variables forming the axes and the third naturally being the diagonals. From an interpretive point of view it would be nice to plot these two variables on a finer grid such that the third can have the same scaling (i.e. a finer grid) as the first two and this would look better on a triangular mesh. Is this possible in R? Many thanks, Roary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Date seq question
Thanks Michael and Brian Thanks for your time. -- View this message in context: http://r.789695.n4.nabble.com/Date-seq-question-tp4313861p4314793.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.
Re: [R] Bayesian data analysis recommendations
Even if you're not doing medical research, I like a lot about Spiegelhalter's book: http://www.amazon.com/Bayesian-Approaches-Health-Care-Evaluation-Statistics/dp/0471499757/ref=sr_1_1?ie=UTF8qid=1327112075sr=8-1 For interacting with R and JAGS/BUGS my two favorite books that cover theory are Carlin Louis and the 2nd half of Gelman Hill. http://www.amazon.com/Bayesian-Methods-Analysis-Chapman-Statistical/dp/1584886978 http://www.amazon.com/Analysis-Regression-Multilevel-Hierarchical-Models/dp/052168689X If you have a handle on the theory, Jim Ablert's book (previously mentioned by Rich Shepard) is fun. -- View this message in context: http://r.789695.n4.nabble.com/Bayesian-data-analysis-recommendations-tp4311905p4315237.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Announce: Summer Program in Data Analysis (SPIDA) 2012
The Institute for Social Research (ISR) and its Statistical Consulting Service (SCS) at York University are pleased to announce our Summer Program In Data Analysis (SPIDA) for 2012. The Program runs from May 24th to June 1st, 2012.This year’s Program focuses on the theory and practice of linear models and mixed [or multilevel] models, as they are applied to hierarchical and longitudinal data. Please see the description below for more information. Please note that the deadline for applications for this year is February 6, and applications should be made online at http://www.isr.yorku.ca/spida2012/index.html -Michael Summer Program In Data Analysis (SPIDA): May 24th – June 1st, 2012 In its thirteenth season this year, ISR's Summer Program in Data Analysis focuses on linear models, beginning with “standard” regression, through generalized linear models and extending to mixed models, which incorporate two or more hierarchical levels of data or longitudinal data structures. Linear models and their extension to generalized linear models (which unify linear models with other commonly employed statistical models, such as logistic and Poisson regression) are the workhorses of quantitative social research. Linear and generalized linear models additionally provide the basis for other, more advanced statistical techniques, including the mixed-effects models that are the focus of this year's SPIDA. The first part of SPIDA will introduce participants to the R statistical computing environment; review linear models, including their implementation in R, diagnostic methods for checking models fit to data, and the elliptical geometry of least-squares regression; and introduce the generalized linear models framework and its implementation in R. This part of the Program will be taught by Professor John Fox of McMaster University. Linear models provide the basis for multilevel or mixed models, the topic of the second half of SPIDA 2012. Mixed models are useful for a wide range of data structures and research questions. They can be used for the analysis of hierarchical data, for example when students are nested in classes, which in turn are nested in schools, or when workers are nested within workplaces. The models provide simultaneous estimates of the differences between individuals, between higher-level units and of the way that those units affect individual differences. Mixed models can also be used for the analysis of longitudinal data. Applying multilevel models, temporal trajectories, for example a sequence of health measurements over time, are conceptualized as “nested” within individual survey respondents. The shape of the trajectory reveals how an individual's health changes over time, in relation to her or his personal characteristics, such as age, income and family characteristics. Also it is possible to incorporate an additional level of “community” effects. This part of SPIDA will be taught by Professor Georges Monette of York University. For the lectures and the daily computer lab sessions in SPIDA, we will be using R, an independent open source (i.e., free) statistical software package with wide-ranging pre-programmed statistical procedures and capacity for programming tailored statistical analyses. In addition, R is invaluable for generating informative high-quality graphics. SPIDA begins with a one-day Introduction to R by Professor Fox. No previous knowledge of R is expected of participants. A non-profit enterprise based in the research community, R is rapidly becoming an alternative to the major commercial statistical packages for serious data analysis. Further details about the Program, including a complete timetable and course descriptions, as well as information about program fees, residence accommodations, and the application process are provided at our web-site: http://www.isr.yorku.ca/spida2012/index.html The DEADLINE for applications is February 6th, 2012. Because of high demand and the limited space available in the Program, it is necessary to select among applicants. Selection will be based on applicants' previous experience in data analysis, as well as their statements of interest, but an effort will be made to represent all geographic regions and social science research interests. Applicants will be informed whether they have secured a place in the Program by February 20th, 2012. SPIDA is intended primarily for faculty, researchers and graduate and undergraduate students at Canadian universities, researchers and policy analysts in both public and not-for-profit organizations, and data librarians. Under the new funding arrangements for 2012, however, applications are invited from interested persons outside Canada. Full-time students are eligible for a modest fee bursary. For further inquiries about the Program, please contact Dr. Bryn Greer-Wootten via sp...@yorku.ca. -- Michael Friendly Email: frien...@yorku.ca Professor, Psychology Dept. York University Voice: 416
[R] 4th corner analysis ade4 - what do the colors mean
I have used the fourthcorner function as suggest by dray and legendre (model 2 and 4 then combine). I plot the combined value with plot(four.comb, type=G). What do the colors mean? I have both grey and black bars. many thanks, Stephen -- Stephen Sefick ** Auburn University Biological Sciences 331 Funchess Hall Auburn, Alabama 36849 ** sas0...@auburn.edu http://www.auburn.edu/~sas0025 ** Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis A big computer, a complex algorithm and a long time does not equal science. -Robert Gentleman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] question re. package playwith not able to run command getting error message that I'm attempting to use non function
I can't replicate the problem on my system (OS X) and I don't know enough about the Gtk + tcltk frameworks to help diagnose it outside of R -- it might be worth working up a minimal (non-)working example along the lines of: michaelweylandt$ R --vanilla library(playwith) playwith(plot(1:10)) and sending it to the maintainer (use the maintainer()) function to get contact info. Michael On Fri, Jan 20, 2012 at 12:56 PM, Farhat Maha mar...@gmail.com wrote: Thanks for your reply Michael, gwindow() command does work. and here is my sessionInfo gwindow() guiWidget of type: gWindowRGtk for toolkit: guiWidgetsToolkitRGtk2 (opens a window) sessionInfo() R version 2.14.1 (2011-12-22) Platform: i486-pc-linux-gnu (32-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=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] tcltk grid stats graphics grDevices utils [7] datasets methods base other attached packages: [1] RGtk2_2.20.21gridBase_0.4-4 [3] gWidgetstcltk_0.0-48 digest_0.5.1 [5] tcltk2_1.1-5 playwith_0.9-53 [7] gWidgetsRGtk2_0.0-78 gWidgets_0.0-47 [9] cairoDevice_2.19 lattice_0.20-0 loaded via a namespace (and not attached): [1] tools_2.14.1 again any advice appreciated. Maha On Fri, Jan 20, 2012 at 3:05 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Hcan you give session info (after loading playwith)? I'm able to get that code to work...also -- can you get the basic RGtk functions (like gwindow() ) to work? Michael On Thu, Jan 19, 2012 at 5:28 PM, Farhat Maha mar...@gmail.com wrote: Hello, I managed to install playwith package and all its prerequisites. My R version is R 2.14: R version 2.14.1 (2011-12-22) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) All my packages were updated, and recently installed. When I attempt to use the command playwith I get the following error message: library(playwith) Loading required package: lattice Loading required package: cairoDevice Loading required package: gWidgetsRGtk2 Loading required package: gWidgets Loading required package: grid playwith(plot(1:10)) Error in playwith(plot(1:10)) : attempt to apply non-function playwith(xyplot(Income ~ log(Population / Area), + data = data.frame(state.x77), groups = state.region, + type = c(p, smooth), span = 1, auto.key = TRUE, + xlab = Population density, 1974 (log scale), + ylab = Income per capita, 1974) + ) Error in playwith(xyplot(Income ~ log(Population/Area), data = data.frame(state.x77), : attempt to apply non-function interactive() [1] TRUE autoplay(on = TRUE, lattice.on = TRUE, base.on = TRUE, grid.on = TRUE, ask = FALSE) Automatic `playwith` for Lattice graphics is now ON. Automatic `playwith` for base graphics is now ON. Automatic `playwith` for grid graphics is now ON. plot(1:10) Error in playwith(plot(1:10), envir = environment) : attempt to apply non-function Error in plot.xy(xy, type, ...) : plot.new has not been called yet Any advice about why it is not working. thanks Maha [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Split values in vector
Hello, Maybe it's no longer needed but, another way would be the function below. It's more complicated because you don't need to know that there are only for categories. Only the original form and the wanted output. fun - function(x, var.to.transform){ f - function(x, nm){ if(is.na(x[1])){ result - rep(NA, length(nm)) }else{ result - rep(0, length(nm)) names(result) - nm tmp - unlist(strsplit(x, split=-)) if(length(tmp) == 1){ result[tmp] - 1 }else{ tmp - matrix(tmp, nrow=2) result[tmp[1, ]] - as.numeric(tmp[2, ]) } } result } if(is.character(var.to.transform)) inx.names.x - which(var.to.transform == names(x)) else{ inx.names.x - var.to.transform var.to.transform - names(x)[inx.names.x] } X - strsplit(as.character(x[, inx.names.x]), split = ;, fixed = TRUE) X.suf - strsplit(unlist(X), split = -, fixed = TRUE) X.suf - sapply(X.suf, function(x) x[1]) X.suf - unique(X.suf[!is.na(X.suf)]) X.names - paste(var.to.transform, X.suf, sep=_) res - x[, -inx.names.x] res[, X.names] - t(sapply(X, f, X.suf)) res } tc - textConnection( var1 var2 var3_00 var3_01 var3_02 var3_04 1 A 1 0 0 0 2 B 0 1 3 1 3 C 0 2 1 0 4 D 0 0 0 12 5 E NANANANA ) wanted - read.table(tc, header=TRUE) close(tc) (res1 - fun(x, var3)) (res2 - fun(x, 3)) all.equal(wanted, res1) all.equal(wanted, res2) Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Split-values-in-vector-tp4309651p4315357.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.
Re: [R] 4th corner analysis ade4 - what do the colors mean
On Jan 21, 2012; 7:39am stephen sefick wrote: I plot the combined value with plot(four.comb, type=G). What do the colors mean? I have both grey and black bars. The help file for fourthcorner plainly tells you (sub Details). You can also work out the meaning by looking at the summary statistics: The function plot produces a graphical representation of the results (white for non siginficant, light grey for negative sgnificant and dark grey for positive suignficant relationships). Regards, Mark. - Mark Difford (Ph.D.) Research Associate Botany Department Nelson Mandela Metropolitan University Port Elizabeth, South Africa -- View this message in context: http://r.789695.n4.nabble.com/4th-corner-analysis-ade4-what-do-the-colors-mean-tp4315476p4315508.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.