[R] package.skeleton from within function: objects not found
Hi all, I ran into a strange error: I am trying to create a package skeleton for a new source package from within a function. Objects that are created in this function are to be included in my package, but for some reason, I get an error message saying that these objects cannot be found. Here is the code: ## myfun - function(pkgName,x){ myenv - new.env() apply(x, 1, function(row){ assign(row[1], row[2], envir=myenv) }) f - function(x,y) x+y e - rnorm(1000) # browser() package.skeleton(name = pkgName, list=c(f,e, myenv)) return(myenv) } x - data.frame(keys = LETTERS[1:5], values = 1:5) myfun(test, x) ## And my sessionInfo: sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base I did not find anything referring to this problem in the help page, on the R mailing list or wiki. Has anyone noticed this or can someone explain to me why my objects cannot be found? Many thanks in advance, best wishes, Tine [[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] formula for nls
Christian Ritz pisze: Hi Jarek, an alternative approach is to provide more precise starting values! It pays off to realise that it's possible to find quite good guesses for some of the parameters in your model function: t ~ tr+(ts-tr)/((1+(a*h)^n)^(1-(1/n))) The parameters tr and ts correspond to the response t for h equal to infinity and h=0. Therefore by looking at the plot of your data I would set: tr = 0 ts = 15000 The parameter n must be above 1 in order to achieve a decreasing function. We will not think more about this at the moment. For n somewhat larger than 1 (in which case I would approximate the exponent 1-(1/n) by 1) the parameter a is approximately equal to the reciprocal of the h value resulting in a response halfway between tr and ts. Therefore (again from looking at the plot) I would set a=10. Using the above starting values and simply increasing n in steps of 1 eventually results in a useful model fit: ## Fails tmp.m1-nls(t ~tr+(ts-tr)/((1+(a*h)^n)^(1-(1/n))), data = tmp, start = list(a=10, n=1, tr=0, ts=15000)) ## Fails tmp.m1-nls(t ~tr+(ts-tr)/((1+(a*h)^n)^(1-(1/n))), data = tmp, start = list(a=10, n=2, tr=0, ts=15000)) ## Works!! tmp.m1-nls(t ~tr+(ts-tr)/((1+(a*h)^n)^(1-(1/n))), data = tmp, start = list(a=10, n=3, tr=0, ts=15000)) summary(tmp.m1) plot(t ~ h, data = tmp) lines(tmp$h, predict(tmp.m1)) I hope you can use this explanation?! Christian yes, I must only check if coefs are expected but... fortunalty I found that my problem is solved by package HydroMe thanks again Jarek __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] package.skeleton from within function: objects not found
Indeed, this works. Thanks! On Jan 28, 2008 9:30 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: You need to set the 'environment' argument (the help file is incomplete). e.g. env - sys.frames()[[sys.nframe()]] package.skeleton(name = pkgName, list=c(f,e, myenv), env=env) On Mon, 28 Jan 2008, Tineke Casneuf wrote: Hi all, I ran into a strange error: I am trying to create a package skeleton for a new source package from within a function. Objects that are created in this function are to be included in my package, but for some reason, I get an error message saying that these objects cannot be found. Here is the code: ## myfun - function(pkgName,x){ myenv - new.env() apply(x, 1, function(row){ assign(row[1], row[2], envir=myenv) }) f - function(x,y) x+y e - rnorm(1000) # browser() package.skeleton(name = pkgName, list=c(f,e, myenv)) return(myenv) } x - data.frame(keys = LETTERS[1:5], values = 1:5) myfun(test, x) ## And my sessionInfo: sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base I did not find anything referring to this problem in the help page, on the R mailing list or wiki. Has anyone noticed this or can someone explain to me why my objects cannot be found? Many thanks in advance, best wishes, Tine [[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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 [[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] How to fill bar plot with textile rather than color
If you type example(barplot) you will find an example. Ciao, domenico CHENYS wrote: Hi, I'm looking for a tool which can fill bar chart with dash, skewed line, or grids, rather than pure color. Any one have the idea how to do that in R? Or maybe in Matlab will also be helpful. Thanks very much. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using facet_grid() from ggplot2 with additional text in labels
Dear Rainer, I think you'll have to recode the labels of the levels to get the output that you want. levels(ssq$gi) - c(gi = 1, gi = 2, gi = 3) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Rainer M Krug Verzonden: zaterdag 26 januari 2008 14:15 Aan: r-help; hadley wickham Onderwerp: [R] using facet_grid() from ggplot2 with additional text in labels Hi I am using ggplot2 at the moment and I must say it is definitely better then ggplot - good work. My problem is that I am using facet_grid() in the following way: p - ggplot(ssq, aes(x=year, y=-log(ssq))) p + geom_point() + facet_grid(me*gi~cs*rz) and it works nicely, except that I would like to have, in naddition to the values of me, gi, cs and rz the name of the variable. I.e: if gi is 1, 2 and 3 I would like to have gi = 1:, gi = 2 and gi = 3 as labels of the p[anels. I did it with ggplot, but I don't remember and I have lost the code ... Just a small comment on the package: as I am using emacs with ess, I have to press _ twice to get the underscore in the commands (as the first one is replaced with - and then reverted to _) - would it be possible to change these in the next release with . (but still provide an alias with _)? Thanks a lot Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in levels() function?
Groot, Philip de wrote: Hello all, I am not sure whether it actually is a bug, but it is not the behaviour I would expect. Please consider this: Sibships [1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901 [6] Patient_8901 Patient_4008 Patient_4008 Patient_7991 Patient_7991 [11] Patient_8353 Patient_8353 Patient_1212 Patient_1212 Patient_2168 [16] Patient_2168 Patient_2760 Patient_2760 Patient_4726 Patient_4726 [21] Patient_6699 Patient_6699 Patient_7641 Patient_7641 Patient_8263 [26] Patient_8263 Patient_1389 Patient_1389 Patient_1618 Patient_1618 [31] Patient_2410 Patient_2410 Patient_2612 Patient_2612 Patient_2721 [36] Patient_2721 Patient_5053 Patient_5053 Patient_8458 Patient_8458 [41] Patient_211 Patient_211 Patient_9004 Patient_9004 Patient_3423 [46] Patient_3423 Patient_7413 Patient_7413 Patient_7815 Patient_7815 [51] Patient_9232 Patient_9232 Patient_2267 Patient_2267 Patient_468 [56] Patient_468 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232 Comparison_Indices [1] TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE [49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE Sibships[Comparison_Indices] [1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901 [6] Patient_8901 Patient_7413 Patient_7413 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232 The problem with this last command is that I would expect 4 levels (because only 8 Comparison_Indices are true, which is equal to 4 sibships. So: levels() does not take array indices into account or stated otherwise: if you use a subset in an array (vector), the levels() are not properly updated (to my opinion). What I additionally found is the following: small_test - factor(x=c(a, b, c)) typeof(small_test) [1] integer The same happens to the Sibships that I defined as a factor? Why is it of type integer? This is the version() output: version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 6.1 year 2007 month 11 day26 svn rev43537 language R version.string R version 2.6.1 (2007-11-26) So: should I submit a Bug report? No. This is all completely as designed. Factors are internally integers (group codes), with a levels attribute that says what the codes mean. If you want the full story, use dput(small_test) or class(small_test) or str(small_test). And subsetting a factor retains the original factor levels. To drop unused levels, just use factor(f[index]) or f[index, drop=TRUE]. The opposite behaviour can be even more annoying/dangerous because it leads to empty cells dropping out of tables and bars disappearing from barplots. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to skip last lines while reading the data in R
hey all greetings hey all am an engineering student...and am trying to learn R i am trying to automate reading a specific type of file...and perform certain functions...but i want to omit lines in the end of the file.. there is an option for skiping the lines before begining...but how can i ask R to read till n-2th or n-3th row...or skip the last 2 or 3 rows while reading... i have files of diff. number of lines...!! i wd be grateful to u if u can help me out of this..!!! thanks in advance Rafi...!! -- View this message in context: http://www.nabble.com/how-to-skip-last-lines-while-reading-the-data-in-R-tp15132030p15132030.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] Bug in levels() function?
Hello all, I am not sure whether it actually is a bug, but it is not the behaviour I would expect. Please consider this: Sibships [1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901 [6] Patient_8901 Patient_4008 Patient_4008 Patient_7991 Patient_7991 [11] Patient_8353 Patient_8353 Patient_1212 Patient_1212 Patient_2168 [16] Patient_2168 Patient_2760 Patient_2760 Patient_4726 Patient_4726 [21] Patient_6699 Patient_6699 Patient_7641 Patient_7641 Patient_8263 [26] Patient_8263 Patient_1389 Patient_1389 Patient_1618 Patient_1618 [31] Patient_2410 Patient_2410 Patient_2612 Patient_2612 Patient_2721 [36] Patient_2721 Patient_5053 Patient_5053 Patient_8458 Patient_8458 [41] Patient_211 Patient_211 Patient_9004 Patient_9004 Patient_3423 [46] Patient_3423 Patient_7413 Patient_7413 Patient_7815 Patient_7815 [51] Patient_9232 Patient_9232 Patient_2267 Patient_2267 Patient_468 [56] Patient_468 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232 Comparison_Indices [1] TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE [49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE Sibships[Comparison_Indices] [1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901 [6] Patient_8901 Patient_7413 Patient_7413 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232 The problem with this last command is that I would expect 4 levels (because only 8 Comparison_Indices are true, which is equal to 4 sibships. So: levels() does not take array indices into account or stated otherwise: if you use a subset in an array (vector), the levels() are not properly updated (to my opinion). What I additionally found is the following: small_test - factor(x=c(a, b, c)) typeof(small_test) [1] integer The same happens to the Sibships that I defined as a factor? Why is it of type integer? This is the version() output: version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 6.1 year 2007 month 11 day26 svn rev43537 language R version.string R version 2.6.1 (2007-11-26) So: should I submit a Bug report? Regards, Dr. Philip de Groot Wageningen University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] basic spatial query
Hello; Please coud you advise me of a simple way to select points (x,y coordinates) that fall within a polygon. I've got a set of polygons, each one defined by an arbitrary number of points, and several points inside each polygon. I know this is simple with a GIS, but I'd rather do it inside R. Thanks and best regards, Javier - __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [R-pkgs] dynlm: new version 0.2-0
Dear useRs, I've release a new version of the dynlm package to CRAN which adds two new features: o instrumental variables regression (two-stage least squares) via formulas like dynlm(y ~ x1 + x2 | z1 + z2 + z3, data = mydata) where z1, z2, z3 are the instruments which can again contain lags/differences/season via the d()/L()/season() operators. o specification of multiple lags via formulas like dynlm(y ~ L(x, 0:4), data = mydata) where y is regressed on x and lags 1 through 4 of x. Furthermore, I've enhanced some convenience funcitonality such as printing and fixed a bug in the time alignment when there were leading NAs in the underlying data. Z ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to skip last lines while reading the data in R
Perhaps: data - read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) will skip the last two lines '-(1:2)' On 28/01/2008, mrafi [EMAIL PROTECTED] wrote: hey all greetings hey all am an engineering student...and am trying to learn R i am trying to automate reading a specific type of file...and perform certain functions...but i want to omit lines in the end of the file.. there is an option for skiping the lines before begining...but how can i ask R to read till n-2th or n-3th row...or skip the last 2 or 3 rows while reading... i have files of diff. number of lines...!! i wd be grateful to u if u can help me out of this..!!! thanks in advance Rafi...!! -- View this message in context: http://www.nabble.com/how-to-skip-last-lines-while-reading-the-data-in-R-tp15132030p15132030.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] basic spatial query
jgarcia at ija.csic.es writes: Hello; Please coud you advise me of a simple way to select points (x,y coordinates) that fall within a polygon. I've got a set of polygons, each one defined by an arbitrary number of points, and several points inside each polygon. I know this is simple with a GIS, but I'd rather do it inside R. If your data are geographical, please see ?overlay-methods in the sp package. You may also choose to follow up this question on the R-sig-geo list. There are also ways of doing this at a lower level (without creating sp objects first) in at least the splancs package, say if the data are not geographical. Roger Thanks and best regards, Javier - __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] maptools no such file
pieterprovoost at gmail.com writes: No, I get the same error message there... Please do not needlesly delete the thread content. Your original question was: I'm having problems reading a shapefile with read.shape (maptools). I'm absolutely sure my file is there, but I get no such file. The wd is ok, since read.table for example does find the file. getwd() [1] D:/somedirectory/R scripts read.table(cities.shp) Error in read.table(cities.shp) : empty beginning of file In addition: Warning message: In read.table(cities.shp) : incomplete final line found by readTableHeader on 'cities.shp' which is self-explanatory, because you were not using read.shape() anyway. You continued: read.shape(cities.shp) Error in getinfo.shape(filen) : No such file but did not respond to the suggestion from an R-helper with the output from: readShapePoly(cities.shp) Try list.files(pattern=shp$) to see whether your assumption that the files are where you think they are, is justified. Then get back with the output of getinfo.shape(cities.shp) If you want to, you can use file.choose() to choose the file interactively. If you haven't solved this yourself by then (found the files youself), do remember to include the verbatim output of sessionInfo() too. Roger Bivand -- This message was sent on behalf of pieterprovoost at gmail.com at openSubscriber.com http://www.opensubscriber.com/message/r-help at r-project.org/8476734.html __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] package.skeleton from within function: objects not found
Professor Ripley, do you have an idea why it works for me to save different types of objects, but not for the environment object I construct in the function: ### Example of a function that works without error: fun2 - function(myname){ f - function(x,y) x+y g - function(x,y) x-y d - data.frame(a=1, b=2) e - hello env - sys.frames()[[sys.nframe()]] package.skeleton(list=c(f,g,d,e), name=myname,env=env) } fun2(mypkg) fun3 - function(myname){ myenv - new.env() apply(x, 1, function(row){ assign(row[1], row[2], envir=myenv) }) f - function(x,y) x+y g - function(x,y) x-y d - data.frame(a=1, b=2) e - hello env - sys.frames()[[sys.nframe()]] package.skeleton(list=c(f,g,d,e,myenv), name=myname,env=env) } fun3(mypkg) ### For the second example, 'fun3', I get this error message: Error in save(list = item, file = file.path(data_dir, sprintf(%s.rda, : object 'myenv' not found Thanks in advance! On Jan 28, 2008 9:30 AM, Prof Brian Ripley [EMAIL PROTECTED] wrote: You need to set the 'environment' argument (the help file is incomplete). e.g. env - sys.frames()[[sys.nframe()]] package.skeleton(name = pkgName, list=c(f,e, myenv), env=env) On Mon, 28 Jan 2008, Tineke Casneuf wrote: Hi all, I ran into a strange error: I am trying to create a package skeleton for a new source package from within a function. Objects that are created in this function are to be included in my package, but for some reason, I get an error message saying that these objects cannot be found. Here is the code: ## myfun - function(pkgName,x){ myenv - new.env() apply(x, 1, function(row){ assign(row[1], row[2], envir=myenv) }) f - function(x,y) x+y e - rnorm(1000) # browser() package.skeleton(name = pkgName, list=c(f,e, myenv)) return(myenv) } x - data.frame(keys = LETTERS[1:5], values = 1:5) myfun(test, x) ## And my sessionInfo: sessionInfo() R version 2.6.1 (2007-11-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base I did not find anything referring to this problem in the help page, on the R mailing list or wiki. Has anyone noticed this or can someone explain to me why my objects cannot be found? Many thanks in advance, best wishes, Tine [[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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] maptools no such file
Roger Bivand Roger.Bivand at nhh.no writes: pieterprovoost at gmail.com writes: No, I get the same error message there... Your original question was: I'm having problems reading a shapefile with read.shape (maptools). I'm absolutely sure my file is there, but I get no such file. The wd is ok, since read.table for example does find the file. getwd() [1] D:/somedirectory/R scripts read.table(cities.shp) which is self-explanatory, because you were not using read.shape() anyway. OK - this was your test that the file existed. read.dbf(cities.dbf) might have been more helpful. To check that there is no spaces in path names problem here, I tried: library(maptools) getwd() [1] /home/rsb/tmp/bigshape/R scripts list.files(pattern=shp$) [1] co37_d90.shp getinfo.shape(co37_d90.shp) Shapefile type: Polygon, (5), # of Shapes: 104 shp - read.shape(co37_d90.shp) Shapefile type: Polygon, (5), # of Shapes: 104 admittedly on Linux and with an up-to-date package. I have also checked on Windows XP, also with current maptools and R 2.6.1, with the same result. Seeing your sessionInfo() would show both your platform and package version. Roger If you want to, you can use file.choose() to choose the file interactively. If you haven't solved this yourself by then (found the files youself), do remember to include the verbatim output of sessionInfo() too. Roger Bivand -- This message was sent on behalf of pieterprovoost at gmail.com at openSubscriber.com http://www.opensubscriber.com/message/r-help at r-project.org/8476734.html __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] double-click in RData file versus load( file )
hello Duncan, Gabor Many thanks for your help! I think that the line: if( chartr(/,\\,getwd() )==R.home() ) setwd(C:\\) can solve my problem in this moment!! :-) Thanks again Cleber On 26/01/2008 9:03 PM, Cleber Nogueira Borges wrote: hi Gabor and Duncan, I make a test and I find that the key of problem is the setwd() command in my Rprofile.site I don't understand this behaviour yet! :-( I understand it now. It's a small bug in the startup code. When you specify a file to restore on the command line, it has two effects: it changes the working directory to the directory of that file, and it loads the file. Unfortunately, the code that loaded the file assumed it was in the current directory and used a relative filename, not an absolute path. (I think this was due to workarounds for behaviour of old Windows versions that are no longer supported.) When your Rprofile.site file changed the working directory, R tried to load the test.RData file from there, and failed. So you didn't get what you wanted. I'll fix this in R-devel and R-patched, and it should make it into the next release. Duncan Murdoch ___ Experimente já e veja as novidades. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] KM estimation for interval censoring?
gallon li [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Does anybody know if there is such a function to estimate the distribution for interval censored data? survfit doesn't work for this type of data as I tried various references. My reading of R-help posts by Therneau and Lumley is that interval censoring is only available for parametric estimates in the survival package. It's not KM, but perhaps this will be of interest: Turnbull's Nonparametric Estimator for Interval-Censored Data Suely Ruiz Giolo http://www.est.ufpr.br/rt/suely04a.pdf Giolo cites KLEIN, J. P, MOESCHBERGER, M. Survival Analysis. New York: Springer Verlag, 1997, for the algorithm. This MIT-CSAIL report says they have an available R package that handles interval censoring and time-dependent covariates: http://dspace.mit.edu/bitstream/1721.1/33957/1/MIT-CSAIL-TR-2006-055.pdf -- David Winsemius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] x-axis
Hi, I want to plot a graph and here is my code: ec-rep(0,length(e)) fc-rep(0,length(f)) plot(e,ec,type=p,col=1,pch=19) points(f,fc,col=2,pch=20) legend(1.0e+08,1.0,c(dog, human),text.col=green4,pch=c(19,20),col=c(1,2)) my major problem here is the x-axis is too large in scale and its very hard for me to read the x-points from my graph. Can I change the x-label too?? Please help me figure out my problem!! Thanks in advance e: [1] 17358865 17966995 21306539 27880531 34166504 36111044 36266288 [8] 36854306 43786190 44322336 45529444 46302360 53479132 58567262 [15] 60564442 72637088 79875476 93155112 94372260 96643396 103123936 [22] 116908456 131781664 132968364 135945080 141788832 149924864 156539568 [29] 157817896 162399496 168344072 173146584 176302744 182878168 183946152 [36] 185068720 190791232NA f-[1] 17906353 21295547 27880531 34118702 35395488 36132622 37916920 [8] 43786190 44322336 46302360 53494622 62105336 63817440 72637088 [15] 79875476 94545992 96506368 103123936 116908456 126190072 127446552 [22] 131781664 154658264 176302744 181670472 182625272 182878168 183946152 [29]NA cheers, Anisah - [[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] Bug in levels() function?
And subsetting a factor retains the original factor levels. To drop unused levels, just use factor(f[index]) or f[index, drop=TRUE]. The opposite behaviour can be even more annoying/dangerous because it leads to empty cells dropping out of tables and bars disappearing from barplots. Of course you can apply the same reasoning to continuous variables too. I've always thought it would be interesting to have a continuous analogue of a factor that preserved its original range by default. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using facet_grid() from ggplot2 with additional text in labels
ggopt(strip.text = function(variable, value) paste(variable, value, sep== )) That's exactly what I was looking for - thanks. One thing that I should mention is that this is likely to change at some point in the future. Eventually it will become: + facet_grid(strip.text = function(variable, value) paste(variable, value, sep= )) but that's probably a few versions down the line. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 with checking out-of-range values in each column in data frame
Dear list, I have following data, where I want to check if any value in each column is out of range. For example, column f1 can only take values 1-5, so if any values less than 1 or 5 will be defined as missing value (i.e. NA), column f4 can only take values of 1-3 and any values that are outside this interval will be considered as missing values. The below data is a subset of a big survey sample and I want to create an automatic procedure to check if all particpants gave a reasonable answer. How can I do this in R and also replace the empty values with NA? dat id f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 1 1 5 3 1 1 1 1 2 1 1 1 2 2 5 5 1 1 1 1 2 1 1 2 3 3 3 4 1 1 1 1 2 1 1 1 4 4 5 5 1 1 1 1 1 1 1 1 5 5 4 3 2 1 2 2 1 2 3 6 6 4 4 1 2 2 1 2 1 1 1 7 7 4 4 1 1 1 2 3 2 2 2 8 8 4 5 2 2 2 2 2 2 2 2 9 9 4 4 2 3 3 3 3 3 3 3 10 10 4 3 1 2 3 1 2 1 2 3 11 11 2 5 1 1 2 1 3 1 1 2 12 12 4 3 1 2 3 3 3 3 2 3 13 13 5 5 1 1 1 1 2 1 1 2 14 14 5 3 3 3 3 2 1 3 1 1 15 15 4 3 1 1 1 2 2 2 1 2 16 16 3 2 2 3 2 3 3 2 2 3 17 17 4 5 1 1 1 1 2 1 1 1 18 18 3 3 2 2 3 2 3 2 3 3 19 19 4 4 1 2 2 2 3 2 3 3 20 20 4 4 1 2 3 3 3 2 3 3 Thanks in advance, Tom - Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling. [[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] how to skip last lines while reading the data in R
On Mon, 28 Jan 2008, Barry Rowlingson wrote: Henrique Dallazuanna wrote: Perhaps: data - read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) Euurgh! Am I the only one whose sense of aesthetics is enraged by this? To get rid of the last two items you reverse the vector, remove the first two items, then reverse the vector again? One liners are fine for R Golf games, but in the real world, I'd get the length of the vector and cut directly off the end. Consider these: # reverse/trim/reverse: rev1 - function(x,n=100,m=5){ for(i in 1:n){ y=rev(rev(x)[-(1:m)]) } return(y) } # get length, trim rev2 - function(x,n=100,m=5){ for(i in 1:n){ y=x[1:(length(x)-m)] } return(y) } system.time(rev1(1:1000,1,5)) [1] 1.864 0.008 2.044 0.000 0.000 system.time(rev2(1:1000,1,5)) [1] 0.384 0.008 0.421 0.000 0.000 Result: faster, more directly readable code. And if you know the file size, just use read.table('data.txt', nrows=#file_rows-2) (and wc -l will tell you the number of rows more efficiently that using a text connection: if you must use a temporary home use file(), no arguments, as that is much more efficient). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Grouping data via an index
Hello r-help, I have a lengthy vector of data (with values anywhere from 1-200), and another index vector of 'groups' representing values 0-2, 3-5, 6-8, ... of length 67. The index vector has the structure (1, 4, 7, ... , 196, 199), where each value is the midpoint of each respective group. I'm trying to convert the data vector such that values falling into each group are changed to the 'number' of that group. That is, the position of the midpoint of that group in the index vector. For example, 4 or 5 would become a 2; 6 would become 3; 9 or 10 would become 4, and so on. Haven't had any success thus far -- does anyone know of a simple method offhand? I've started by converting the data vector to a vector of the midpoints of each group, via round(data.vector/3)*3 + 1 But haven't been able to accomplish much past that. I'm guessing it can be accomplished via a simple loop or otherwise. Thanks, -- jared tobin, student research assistant fisheries and oceans canada [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R on an eeePC
Dear list, I wonder if somebody has succeeded in installing R on an eeePC (Xandros desktop). Searching via Rseek (term eeePC) and in eeePC forums (term Cran) left me without proper hits. Best wishes, Walter. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R loops
I'm a new user and am having trouble with loops. In the following, I'm trying to add the results of test and the loops are not working. I've simplified the loop. What am I doing wrong? Thanks! test-numeric(20) tot-numeric(20) for(i in 1:20){test[i]-1} for (i in 1:20){tot[i]-(test[i]+tot[i])} tot [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -- View this message in context: http://www.nabble.com/R-loops-tp15135671p15135671.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] help with checking out-of-range values in each column in data frame
Try: transform(data, f1 = factor(f1, levels = 1:5), f4 = factor(f4, 1:3)) On Jan 28, 2008 8:12 AM, Tom Cohen [EMAIL PROTECTED] wrote: Dear list, I have following data, where I want to check if any value in each column is out of range. For example, column f1 can only take values 1-5, so if any values less than 1 or 5 will be defined as missing value (i.e. NA), column f4 can only take values of 1-3 and any values that are outside this interval will be considered as missing values. The below data is a subset of a big survey sample and I want to create an automatic procedure to check if all particpants gave a reasonable answer. How can I do this in R and also replace the empty values with NA? dat id f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 1 1 5 3 1 1 1 1 2 1 1 1 2 2 5 5 1 1 1 1 2 1 1 2 3 3 3 4 1 1 1 1 2 1 1 1 4 4 5 5 1 1 1 1 1 1 1 1 5 5 4 3 2 1 2 2 1 2 3 6 6 4 4 1 2 2 1 2 1 1 1 7 7 4 4 1 1 1 2 3 2 2 2 8 8 4 5 2 2 2 2 2 2 2 2 9 9 4 4 2 3 3 3 3 3 3 3 10 10 4 3 1 2 3 1 2 1 2 3 11 11 2 5 1 1 2 1 3 1 1 2 12 12 4 3 1 2 3 3 3 3 2 3 13 13 5 5 1 1 1 1 2 1 1 2 14 14 5 3 3 3 3 2 1 3 1 1 15 15 4 3 1 1 1 2 2 2 1 2 16 16 3 2 2 3 2 3 3 2 2 3 17 17 4 5 1 1 1 1 2 1 1 1 18 18 3 3 2 2 3 2 3 2 3 3 19 19 4 4 1 2 2 2 3 2 3 3 20 20 4 4 1 2 3 3 3 2 3 3 Thanks in advance, Tom - Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling. [[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] how to skip last lines while reading the data in R
If you don't mind reading it in twice its just: DF - read.table(xy.dat, header = TRUE, nrow = length(readLines(xy.dat)) - 3) tail(DF) # or DF - read.table(xy.dat, header = TRUE, nrow = length(count.fields(xy.dat)) - 3) tail(DF) # or DF - read.table(xy.dat, header = TRUE, nrow = nrow(read.table(xy.dat, header = TRUE)) - 2) tail(DF) On Jan 28, 2008 5:10 AM, mrafi [EMAIL PROTECTED] wrote: hey all greetings hey all am an engineering student...and am trying to learn R i am trying to automate reading a specific type of file...and perform certain functions...but i want to omit lines in the end of the file.. there is an option for skiping the lines before begining...but how can i ask R to read till n-2th or n-3th row...or skip the last 2 or 3 rows while reading... i have files of diff. number of lines...!! i wd be grateful to u if u can help me out of this..!!! thanks in advance Rafi...!! -- View this message in context: http://www.nabble.com/how-to-skip-last-lines-while-reading-the-data-in-R-tp15132030p15132030.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] Odp: x-axis
Hi [EMAIL PROTECTED] napsal dne 28.01.2008 13:06:16: Hi, I want to plot a graph and here is my code: ec-rep(0,length(e)) fc-rep(0,length(f)) Strange. If I understand correctly, you repeat zero length(e) or length(f) times and then you plot those zeroes at x axis = e values and another set of zero points at different x points based on f values. Why? BTW, didnt you want to do dotchart? Or maybe to can consider logaritmic x axis? Regards Petr plot(e,ec,type=p,col=1,pch=19) points(f,fc,col=2,pch=20) legend(1.0e+08,1.0,c(dog, human),text.col=green4,pch=c(19,20),col=c(1,2)) my major problem here is the x-axis is too large in scale and its very hard for me to read the x-points from my graph. Can I change the x-label too?? Please help me figure out my problem!! Thanks in advance e: [1] 17358865 17966995 21306539 27880531 34166504 36111044 36266288 [8] 36854306 43786190 44322336 45529444 46302360 53479132 58567262 [15] 60564442 72637088 79875476 93155112 94372260 96643396 103123936 [22] 116908456 131781664 132968364 135945080 141788832 149924864 156539568 [29] 157817896 162399496 168344072 173146584 176302744 182878168 183946152 [36] 185068720 190791232NA f-[1] 17906353 21295547 27880531 34118702 35395488 36132622 37916920 [8] 43786190 44322336 46302360 53494622 62105336 63817440 72637088 [15] 79875476 94545992 96506368 103123936 116908456 126190072 127446552 [22] 131781664 154658264 176302744 181670472 182625272 182878168 183946152 [29]NA cheers, Anisah - [[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] how to skip last lines while reading the data in R
On Mon, 28 Jan 2008, mrafi wrote: but then the number of levels would reamain the same...!! Please explain: the levels of factors are taken from the data which is actually read. Prof Brian Ripley wrote: On Mon, 28 Jan 2008, Barry Rowlingson wrote: Henrique Dallazuanna wrote: Perhaps: data - read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) Euurgh! Am I the only one whose sense of aesthetics is enraged by this? To get rid of the last two items you reverse the vector, remove the first two items, then reverse the vector again? One liners are fine for R Golf games, but in the real world, I'd get the length of the vector and cut directly off the end. Consider these: # reverse/trim/reverse: rev1 - function(x,n=100,m=5){ for(i in 1:n){ y=rev(rev(x)[-(1:m)]) } return(y) } # get length, trim rev2 - function(x,n=100,m=5){ for(i in 1:n){ y=x[1:(length(x)-m)] } return(y) } system.time(rev1(1:1000,1,5)) [1] 1.864 0.008 2.044 0.000 0.000 system.time(rev2(1:1000,1,5)) [1] 0.384 0.008 0.421 0.000 0.000 Result: faster, more directly readable code. And if you know the file size, just use read.table('data.txt', nrows=#file_rows-2) (and wc -l will tell you the number of rows more efficiently that using a text connection: if you must use a temporary home use file(), no arguments, as that is much more efficient). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/how-to-skip-last-lines-while-reading-the-data-in-R-tp15132030p15136013.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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to fill bar plot with textile rather than color
Thank you, and also thanks to John Kane. I did some tests last night, if you plot something like height - t(t(c(1,-1,1))) bardensity - t(t(c(10,10,0))) barangle - t(t(c(45,135,0))) barplot(height, density = bardensity, angle = barangle) You can get grids. Otherwise, only slanted lines or colors. I thought filling with dots or grids is quite common in traditional bar chart. But most softwares, including Matlab, SAS, Excel2k7, and gunplot, as I know, don't have such options. Anyway, thank you again. Let me know if you find any package which can fill bar plot with dots On Jan 28, 2008 4:13 AM, Domenico Vistocco [EMAIL PROTECTED] wrote: If you type example(barplot) you will find an example. Ciao, domenico CHENYS wrote: Hi, I'm looking for a tool which can fill bar chart with dash, skewed line, or grids, rather than pure color. Any one have the idea how to do that in R? Or maybe in Matlab will also be helpful. Thanks very much. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to fill bar plot with textile rather than color
density ?barplot aa - c(4,5,6) barplot(aa, density=2, col='red', border=blue) --- CHENYS [EMAIL PROTECTED] wrote: Hi, I'm looking for a tool which can fill bar chart with dash, skewed line, or grids, rather than pure color. Any one have the idea how to do that in R? Or maybe in Matlab will also be helpful. Thanks very much. -- View this message in context: http://www.nabble.com/How-to-fill-bar-plot-with-textile-rather-than-color-tp15127737p15127737.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] how to skip last lines while reading the data in R
but then the number of levels would reamain the same...!! Prof Brian Ripley wrote: On Mon, 28 Jan 2008, Barry Rowlingson wrote: Henrique Dallazuanna wrote: Perhaps: data - read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) Euurgh! Am I the only one whose sense of aesthetics is enraged by this? To get rid of the last two items you reverse the vector, remove the first two items, then reverse the vector again? One liners are fine for R Golf games, but in the real world, I'd get the length of the vector and cut directly off the end. Consider these: # reverse/trim/reverse: rev1 - function(x,n=100,m=5){ for(i in 1:n){ y=rev(rev(x)[-(1:m)]) } return(y) } # get length, trim rev2 - function(x,n=100,m=5){ for(i in 1:n){ y=x[1:(length(x)-m)] } return(y) } system.time(rev1(1:1000,1,5)) [1] 1.864 0.008 2.044 0.000 0.000 system.time(rev2(1:1000,1,5)) [1] 0.384 0.008 0.421 0.000 0.000 Result: faster, more directly readable code. And if you know the file size, just use read.table('data.txt', nrows=#file_rows-2) (and wc -l will tell you the number of rows more efficiently that using a text connection: if you must use a temporary home use file(), no arguments, as that is much more efficient). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/how-to-skip-last-lines-while-reading-the-data-in-R-tp15132030p15136013.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] KM estimation for interval censoring?
The Icens package implements a number of different estimation paradigms. Briefly, for interval censored data, the KM does not apply, but Turnbull's method does. Relevant citations for Icens are in it. For a Cox model approach, there was at one time a package, not at CRAN, by Commenges (and a Biometrics paper, I believe), Google suggests that Dr. Commenges is pretty active in this area. David Winsemius wrote: gallon li [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Does anybody know if there is such a function to estimate the distribution for interval censored data? survfit doesn't work for this type of data as I tried various references. My reading of R-help posts by Therneau and Lumley is that interval censoring is only available for parametric estimates in the survival package. It's not KM, but perhaps this will be of interest: Turnbull's Nonparametric Estimator for Interval-Censored Data Suely Ruiz Giolo http://www.est.ufpr.br/rt/suely04a.pdf Giolo cites KLEIN, J. P, MOESCHBERGER, M. Survival Analysis. New York: Springer Verlag, 1997, for the algorithm. This MIT-CSAIL report says they have an available R package that handles interval censoring and time-dependent covariates: http://dspace.mit.edu/bitstream/1721.1/33957/1/MIT-CSAIL-TR-2006-055.pdf -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to skip last lines while reading the data in R
Ok, I agree, but I assume that her don't know the number of rows of file. In your example: rev2 - function(x,n=100,m=5){ for(i in 1:n){ y=x[1:(length(x)-m)] } return(y) } is needed that open other textConnection - if use the example posted by me. Is there other option? On 28/01/2008, Barry Rowlingson [EMAIL PROTECTED] wrote: Henrique Dallazuanna wrote: Perhaps: data - read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) Euurgh! Am I the only one whose sense of aesthetics is enraged by this? To get rid of the last two items you reverse the vector, remove the first two items, then reverse the vector again? One liners are fine for R Golf games, but in the real world, I'd get the length of the vector and cut directly off the end. Consider these: # reverse/trim/reverse: rev1 - function(x,n=100,m=5){ for(i in 1:n){ y=rev(rev(x)[-(1:m)]) } return(y) } # get length, trim rev2 - function(x,n=100,m=5){ for(i in 1:n){ y=x[1:(length(x)-m)] } return(y) } system.time(rev1(1:1000,1,5)) [1] 1.864 0.008 2.044 0.000 0.000 system.time(rev2(1:1000,1,5)) [1] 0.384 0.008 0.421 0.000 0.000 Result: faster, more directly readable code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Grouping data via an index
Tobin, Jared wrote: Hello r-help, I have a lengthy vector of data (with values anywhere from 1-200), and another index vector of 'groups' representing values 0-2, 3-5, 6-8, ... of length 67. The index vector has the structure (1, 4, 7, ... , 196, 199), where each value is the midpoint of each respective group. I'm trying to convert the data vector such that values falling into each group are changed to the 'number' of that group. That is, the position of the midpoint of that group in the index vector. For example, 4 or 5 would become a 2; 6 would become 3; 9 or 10 would become 4, and so on. Haven't had any success thus far -- does anyone know of a simple method offhand? I've started by converting the data vector to a vector of the midpoints of each group, via round(data.vector/3)*3 + 1 But haven't been able to accomplish much past that. I'm guessing it can be accomplished via a simple loop or otherwise. You could convert midpoints to breakpoints and use cut(). Do you know that each group contains 3 consecutive values? Otherwise it gets a bit sticky. If it does, use as.integer(cut(data.vector, breaks=seq(-.5,200.5,3))) (which also works for other sets of breakpoints) or just use integer division data.vector %/% 3 + 1 Thanks, -- jared tobin, student research assistant fisheries and oceans canada [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on an eeePC
Doing 'RSiteSearch(eee)' yields some hits. I knew that the ASUS eeePC had come up on r-help. -kevin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dr. Walter H. Schreiber Sent: Monday, January 28, 2008 9:32 AM To: r-help@r-project.org Subject: [R] R on an eeePC Dear list, I wonder if somebody has succeeded in installing R on an eeePC (Xandros desktop). Searching via Rseek (term eeePC) and in eeePC forums (term Cran) left me without proper hits. Best wishes, Walter. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 loops
On 1/28/2008 8:48 AM, cvandy wrote: I'm a new user and am having trouble with loops. In the following, I'm trying to add the results of test and the loops are not working. I've simplified the loop. What am I doing wrong? Thanks! test-numeric(20) tot-numeric(20) for(i in 1:20){test[i]-1} for (i in 1:20){tot[i]-(test[i]+tot[i])} tot [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 At the start numeric(20) gives you a vector of 20 zeros. Your first loop changes all the values of test to 1. Your second loop adds a one from test to each of the zeros in tot. Simulating something like this by hand is a good way to spot the errors: reduce the length of vector to some small number (e.g. 5), then write down on a piece of paper 5 slots for test, 5 for tot, and run through the commands as though you are R. If you don't get what R gives at the end, then look at all the variables in your simulation, and identify where it went wrong. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to get out the t-test value matrix for a linear regression ?
Hi, all I've written some R script to calculate the linear regression of a matrix. Here below is my script: x-matrix(scan(h:/data/xxx.dat,0),nrow=46,ncol=561,byrow=TRUE) year - NULL year - cbind(year,as.matrix(x[,1])) lm.sol-lm(x~year) xtrend-coef(lm.sol)[2,]# get the matrix of regression coefficient t.test- ? # also want to get a similar matrix of t-test value for the regression coefficient class(summary(lm.sol)) listof class(summary(lm.sol)) listof# the t-test values are in the obj summary(lm.sol), but how to get them out as a matrix similar as the abovextrend? Anyone can help me? Thanks ! Regards Leo 2008-01-28 leo_aries [[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] double-click in RData file versus load( file )
hi Duncan, I can't access file greater than 3 mb in my work! :-( :-( ((( unfortunately, is not a joke! I need a new job :-D ))) When I return home, I will do download the patch and report the results to you! :-( Thanks for your attention! Cleber It is now fixed in the version available from http://www.stats.uwo.ca/faculty/murdoch/CRAN/bin/windows/base/rpatched.html and will be on CRAN within a few hours. Could you please try it and confirm that it works? Duncan Murdoch ___ Experimente já e veja as novidades. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] KM estimation for interval censoring?
RobG == Robert Gentleman [EMAIL PROTECTED] on Mon, 28 Jan 2008 08:18:06 -0800 writes: RobG The Icens package implements a number of different estimation paradigms. RobG Briefly, for interval censored data, the KM does not apply, but RobG Turnbull's method does. Relevant citations for Icens are in it. RobG For a Cox model approach, there was at one time a package, not at CRAN, RobG by Commenges (and a Biometrics paper, I believe), Google suggests that RobG Dr. Commenges is pretty active in this area. Further, Marloes Maathuis is active in this field, too. Her (CRAN) R package is 'MLEcens' which computes the (nonparametric!) MLE for (bivariate or univariate) interval censored data, which -- I think -- is what the KM estimator is for the one-sided censoring. Martin Maechler, ETH Zurich RobG David Winsemius wrote: gallon li [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Does anybody know if there is such a function to estimate the distribution for interval censored data? survfit doesn't work for this type of data as I tried various references. My reading of R-help posts by Therneau and Lumley is that interval censoring is only available for parametric estimates in the survival package. It's not KM, but perhaps this will be of interest: Turnbull's Nonparametric Estimator for Interval-Censored Data Suely Ruiz Giolo http://www.est.ufpr.br/rt/suely04a.pdf Giolo cites KLEIN, J. P, MOESCHBERGER, M. Survival Analysis. New York: Springer Verlag, 1997, for the algorithm. This MIT-CSAIL report says they have an available R package that handles interval censoring and time-dependent covariates: http://dspace.mit.edu/bitstream/1721.1/33957/1/MIT-CSAIL-TR-2006-055.pdf RobG -- RobG Robert Gentleman, PhD RobG Program in Computational Biology RobG Division of Public Health Sciences RobG Fred Hutchinson Cancer Research Center RobG 1100 Fairview Ave. N, M2-B876 RobG PO Box 19024 RobG Seattle, Washington 98109-1024 RobG 206-667-7700 RobG [EMAIL PROTECTED] RobG __ RobG R-help@r-project.org mailing list RobG https://stat.ethz.ch/mailman/listinfo/r-help RobG PLEASE do read the posting guide http://www.R-project.org/posting-guide.html RobG 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] matrix creation
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO Hi Michelle, You don't show your read.csv or read.table call, nor the output of str(obj) where obj is the name of the object you read the data into. I notice that you have explicit 0 and NA. Is there a chance that you have entered NA into the cells that you want to be missing in Excel? (I know this may be a silly question but a user I know did this once.) If you have, delete the NA's from the spreadsheet and leave those cells blank and try again - R knows what to do in those cases and codes the missingness as NA. Also, remember that you can have text only in row 1 and/or column 1 for the rownames and colnames. Check out the R Data Import/Export that came with your R, which is also on the web: http://cran.r-project.org/doc/manuals/R-data.html HTH G On Mon, 2008-01-28 at 11:35 -0700, Michelle DePrenger-Levin wrote: Hello, I am trying to create multiple matrices (to run a PVA) but can't import all of them from a .csv without the numbers treated as labels and not factors. I can enter the matrix slowly: Site05_96 - matrix(c(0.07,0,0.03,0.00,NA,0.00, 0.09,0.16667,0.31,0.42,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.26,0.16667,0.19,0.00,NA,0.00, 0.58,0.7,0.47,0.58,0,0.00), nrow = 6, ncol = 6, dimnames = list(c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead), c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead))) I would like to list all matrices (for all 12 years and all 4 sites) in one Excel sheet (.csv) and then read each matrix as chucks of 6 rows. However, when I try this I either get all the values (the %) in quotes (not as factors) and if I try to force them with as.factor, it no longer seems to be a matrix. AsMi0598test2 - as.matrix(AsMi05test[1:6,1:6]) X Vegetative Vegetative.with.Herbivory Reproductive Reproductive.with.Herbivory Dormant 1 Vegetative 0.25 0.130 0 0.08 2 Vegetative with Herbivory 0.50 0.500 0 0.00 3 Reproductive0.17 0.330 0 0.33 4 Reproductive with Herbivory 0.08 0.670 0 0.08 5 Dormant 0.00 0.000 0 1.00 6 Dead0.00 0.000 0 0.00 When I add AsMi0598test2 - as.factor(as.matrix(AsMi05test[1:6,1:6])) I get this: [1] Vegetative Vegetative with Herbivory Reproductive Reproductive with Herbivory [5] Dormant Dead0.25 0.50 [9] 0.170.080.00 0.00 [13] 0.130.500.33 0.67 [17] 0.000.000 0 [21] 0 0 0 0 [25] 0 0 0 0 [29] 0 0 0.08 0.00 [33] 0.330.081.00 0.00 16 Levels: 0 0.00 0.08 0.13 0.17 0.25 0.33 0.50 0.67 1.00 Dead Dormant Reproductive ... Vegetative with Herbivory I want to read all matrices into stoch.projection( ) {popbio} Thanks for any suggestions. I could enter them all in the .txt document if I can't read them from the Excel sheet. Michelle DePrenger-Levin [[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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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
[R] matrix creation
Hello, I am trying to create multiple matrices (to run a PVA) but can't import all of them from a .csv without the numbers treated as labels and not factors. I can enter the matrix slowly: Site05_96 - matrix(c(0.07,0,0.03,0.00,NA,0.00, 0.09,0.16667,0.31,0.42,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.26,0.16667,0.19,0.00,NA,0.00, 0.58,0.7,0.47,0.58,0,0.00), nrow = 6, ncol = 6, dimnames = list(c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead), c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead))) I would like to list all matrices (for all 12 years and all 4 sites) in one Excel sheet (.csv) and then read each matrix as chucks of 6 rows. However, when I try this I either get all the values (the %) in quotes (not as factors) and if I try to force them with as.factor, it no longer seems to be a matrix. AsMi0598test2 - as.matrix(AsMi05test[1:6,1:6]) X Vegetative Vegetative.with.Herbivory Reproductive Reproductive.with.Herbivory Dormant 1 Vegetative 0.25 0.130 0 0.08 2 Vegetative with Herbivory 0.50 0.500 0 0.00 3 Reproductive0.17 0.330 0 0.33 4 Reproductive with Herbivory 0.08 0.670 0 0.08 5 Dormant 0.00 0.000 0 1.00 6 Dead0.00 0.000 0 0.00 When I add AsMi0598test2 - as.factor(as.matrix(AsMi05test[1:6,1:6])) I get this: [1] Vegetative Vegetative with Herbivory Reproductive Reproductive with Herbivory [5] Dormant Dead0.25 0.50 [9] 0.170.080.00 0.00 [13] 0.130.500.33 0.67 [17] 0.000.000 0 [21] 0 0 0 0 [25] 0 0 0 0 [29] 0 0 0.08 0.00 [33] 0.330.081.00 0.00 16 Levels: 0 0.00 0.08 0.13 0.17 0.25 0.33 0.50 0.67 1.00 Dead Dormant Reproductive ... Vegetative with Herbivory I want to read all matrices into stoch.projection( ) {popbio} Thanks for any suggestions. I could enter them all in the .txt document if I can't read them from the Excel sheet. Michelle DePrenger-Levin [[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] sub-plot in a plot
See 'fig' argument in ?par example: x - rnorm(100) plot(x) par(fig=c(2/3,1,2/3,1), new=T) hist(x, main=) On 28/01/2008, lamack lamack [EMAIL PROTECTED] wrote: From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: sub-plot in a plotDate: Mon, 28 Jan 2008 15:43:40 + Dear all, how can I do these sub-plots in a plot (see file attached) in R. Best regards. Receba GRÁTIS as mensagens do Messenger no seu celular quando você estiver offline. Conheça o MSN Mobile! Crie já o seu! _ [[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: How to get out the t-test value matrix for a linear regression ?
Hi [EMAIL PROTECTED] napsal dne 28.01.2008 17:16:37: Hi, all I've written some R script to calculate the linear regression of a matrix. Here below is my script: x-matrix(scan(h:/data/xxx.dat,0),nrow=46,ncol=561,byrow=TRUE) year - NULL year - cbind(year,as.matrix(x[,1])) lm.sol-lm(x~year) xtrend-coef(lm.sol)[2,]# get the matrix of regression coefficient t.test- ? # also want to get a similar matrix of t- test value for the regression coefficient class(summary(lm.sol)) listof class(summary(lm.sol)) listof# the t-test values are in the obj summary(lm.sol), but how to get them out as a matrix similar as the abovextrend? str is your friend. Try, str(summary(lm.sol)) and you will find a structure of summary object. From it it is quite easy to find that summary(lm.sol)$coef gives you a table with t.test values. Regards Petr Anyone can help me? Thanks ! Regards Leo 2008-01-28 leo_aries [[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] how to skip last lines while reading the data in R
or even: head(read.table(xy.dat, header = TRUE), -2) On Jan 28, 2008 10:52 AM, Gabor Grothendieck [EMAIL PROTECTED] wrote: If you don't mind reading it in twice its just: DF - read.table(xy.dat, header = TRUE, nrow = length(readLines(xy.dat)) - 3) tail(DF) # or DF - read.table(xy.dat, header = TRUE, nrow = length(count.fields(xy.dat)) - 3) tail(DF) # or DF - read.table(xy.dat, header = TRUE, nrow = nrow(read.table(xy.dat, header = TRUE)) - 2) tail(DF) On Jan 28, 2008 5:10 AM, mrafi [EMAIL PROTECTED] wrote: hey all greetings hey all am an engineering student...and am trying to learn R i am trying to automate reading a specific type of file...and perform certain functions...but i want to omit lines in the end of the file.. there is an option for skiping the lines before begining...but how can i ask R to read till n-2th or n-3th row...or skip the last 2 or 3 rows while reading... i have files of diff. number of lines...!! i wd be grateful to u if u can help me out of this..!!! thanks in advance Rafi...!! -- View this message in context: http://www.nabble.com/how-to-skip-last-lines-while-reading-the-data-in-R-tp15132030p15132030.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] using facet_grid() from ggplot2 with additional text in labels
Dear Thierry On 28/01/2008, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Dear Rainer, I think you'll have to recode the labels of the levels to get the output that you want. I haven't thought about using levels - that was probably the reason why it threw the sorting out. Thanks Rainer levels(ssq$gi) - c(gi = 1, gi = 2, gi = 3) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Rainer M Krug Verzonden: zaterdag 26 januari 2008 14:15 Aan: r-help; hadley wickham Onderwerp: [R] using facet_grid() from ggplot2 with additional text in labels Hi I am using ggplot2 at the moment and I must say it is definitely better then ggplot - good work. My problem is that I am using facet_grid() in the following way: p - ggplot(ssq, aes(x=year, y=-log(ssq))) p + geom_point() + facet_grid(me*gi~cs*rz) and it works nicely, except that I would like to have, in naddition to the values of me, gi, cs and rz the name of the variable. I.e: if gi is 1, 2 and 3 I would like to have gi = 1:, gi = 2 and gi = 3 as labels of the p[anels. I did it with ggplot, but I don't remember and I have lost the code ... Just a small comment on the package: as I am using emacs with ess, I have to press _ twice to get the underscore in the commands (as the first one is replaced with - and then reverted to _) - would it be possible to change these in the next release with . (but still provide an alias with _)? Thanks a lot Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Come join me on MaLaYsiaN BesT…
Come join me on MaLaYsiaN BesT! Mari kita berkongsi cerita mengenai apa sahaja mengenai malaysia. cth: gambar lucu, gambar aneh, gambar hantu, artis malaysia, info bola sepak malaysia, sejarah bola sepak, berita sukan bola sepak terkini dan arena bola sepak . Click here to join: http://malaysianbest.ning.com/?xgi=3hLsp9Y Thanks, khai __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sub-plot in a plot
See the subplot function in the TeachingDemos package. Hope this helps, From: [EMAIL PROTECTED] on behalf of lamack lamack Sent: Mon 1/28/2008 8:51 AM To: r-help@r-project.org Subject: [R] sub-plot in a plot From: [EMAIL PROTECTED]: [EMAIL PROTECTED]: sub-plot in a plotDate: Mon, 28 Jan 2008 15:43:40 + Dear all, how can I do these sub-plots in a plot (see file attached) in R. Best regards. Receba GRÁTIS as mensagens do Messenger no seu celular quando você estiver offline. Conheça o MSN Mobile! Crie já o seu! _ [[elided Hotmail spam]] [[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] Function for translation of a list into a matrix as used by ordination?
Thanks for all who commented on this question. It turns out that there is a nice set of functions in library BiodiversityR that translate a stack or list input data file to a community matrix: import.from.Excel(file = file.choose(), sheet = community, sitenames = sites, column = species, value = abundance, factor = , level = ) import.from.Access(file = file.choose(), table = community, sitenames = sites, column = species, value = abundance, factor = , level = ) I believe the other contributions set to the list worked to varying degrees as well. billy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bug in levels() function?
This is not a bug; it is deliberately designed this way. There are circumstances when you want to drop levels on subsetting and other circumstances where you don't, so the default behaviour can't make everyone happy. However, there is an option to get the behaviour you want x-as.factor(LETTERS) levels(x[1]) [1] A B C D E F G H I J K L M N O P Q R S [20] T U V W X Y Z levels(x[1,drop=TRUE]) [1] A On Mon, 28 Jan 2008, Groot, Philip de wrote: Hello all, I am not sure whether it actually is a bug, but it is not the behaviour I would expect. Please consider this: Sibships [1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901 [6] Patient_8901 Patient_4008 Patient_4008 Patient_7991 Patient_7991 [11] Patient_8353 Patient_8353 Patient_1212 Patient_1212 Patient_2168 [16] Patient_2168 Patient_2760 Patient_2760 Patient_4726 Patient_4726 [21] Patient_6699 Patient_6699 Patient_7641 Patient_7641 Patient_8263 [26] Patient_8263 Patient_1389 Patient_1389 Patient_1618 Patient_1618 [31] Patient_2410 Patient_2410 Patient_2612 Patient_2612 Patient_2721 [36] Patient_2721 Patient_5053 Patient_5053 Patient_8458 Patient_8458 [41] Patient_211 Patient_211 Patient_9004 Patient_9004 Patient_3423 [46] Patient_3423 Patient_7413 Patient_7413 Patient_7815 Patient_7815 [51] Patient_9232 Patient_9232 Patient_2267 Patient_2267 Patient_468 [56] Patient_468 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232 Comparison_Indices [1] TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE [49] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE Sibships[Comparison_Indices] [1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901 [6] Patient_8901 Patient_7413 Patient_7413 28 Levels: Patient_1212 Patient_1389 Patient_1618 Patient_211 ... Patient_9232 The problem with this last command is that I would expect 4 levels (because only 8 Comparison_Indices are true, which is equal to 4 sibships. So: levels() does not take array indices into account or stated otherwise: if you use a subset in an array (vector), the levels() are not properly updated (to my opinion). What I additionally found is the following: small_test - factor(x=c(a, b, c)) typeof(small_test) [1] integer The same happens to the Sibships that I defined as a factor? Why is it of type integer? This is the version() output: version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 6.1 year 2007 month 11 day26 svn rev43537 language R version.string R version 2.6.1 (2007-11-26) So: should I submit a Bug report? Regards, Dr. Philip de Groot Wageningen 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. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] vernacular names for circular diagrams
Thanks very much for the enlightenment. Very interesting indeed, and I am glad to find Nightingale exonerated of her purported crime. cheers, Rolf On 29/01/2008, at 8:25 AM, Greg Snow wrote: I had heard the same thing about Florence Nightingale, but it seems that this is a confusion of different graphs. Nightingale developed a graph based on a circle, but all the angles were equal and the different values were encoded by using different radii of the slices (and she did the right thing by having the radius proportional to the square root of the value). She never named this plot, but I have seen coxcomb (Nightingale refered to the document in which this graph first appeared as the coxcomb) or rotogram used as names. At first glance this may be confused for a pie chart, hence the credit, but in truth I think Nightingale is innocent of the crime of creating the first pie chart. From: [EMAIL PROTECTED] on behalf of Rolf Turner Sent: Mon 1/28/2008 12:10 PM To: r-help Subject: Re: [R] [OT] vernacular names for circular diagrams On 28/01/2008, at 12:07 AM, Peter Dalgaard wrote: Jean lobry wrote: snip about an hour North of Paris. Her father inquired - coincidentally during the cheese course - what work I was doing in Paris; I replied that I was researching the activities of a Scot, William Playfair, during the revolutionary period. I told him that Playfair had invented several statistical graphs, including the pie chart snip I have been for many years under the impression that the pie chart was invented by Florence Nightingale. Am I misinformed? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid... {{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] vernacular names for circular diagrams
Thank you! cheers, Rolf On 29/01/2008, at 8:38 AM, roger koenker wrote: Howard Wainer (Graphical Discovery, PUP, 2005, p 20) gives this dubious honor to Playfair (1759- 1823). Nightingale (1820- 1910) was far too enlightened for this sort of thing, see for example her letter to Galton about endowing an Oxford professorship in social statistics (reprinted in Karl Pearson's bio of Galton: http://galton.org/cgi-bin/searchImages/search/pearson/vol2/pages/ vol2_0482.htm It sets a very ambitious agenda that we have not yet made much progress on... url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Jan 28, 2008, at 1:10 PM, Rolf Turner wrote: On 28/01/2008, at 12:07 AM, Peter Dalgaard wrote: Jean lobry wrote: snip about an hour North of Paris. Her father inquired - coincidentally during the cheese course - what work I was doing in Paris; I replied that I was researching the activities of a Scot, William Playfair, during the revolutionary period. I told him that Playfair had invented several statistical graphs, including the pie chart snip I have been for many years under the impression that the pie chart was invented by Florence Nightingale. Am I misinformed? cheers, Rolf Turner # # Attention:\ This e-mail message is privileged and confid... {{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Integer vs numeric
Christophe Genolini wrote: Hi the list. I do not understand the philosophy behind numeric and integer. - 1 is numeric (which I find surprising) - 2 is numeric. - 1:2 is integer. Why is that ? I hope I can answer your question at least partly: Numeric means double, i.e. internally stored as a double precision floating point number. As far as I know this is the default. You can, however, force an object to be, e.g. an integer, a single prevision float or a double precision float. as.integer(12) as.single(12) as.double(12) So far I only needed this if I wanted to call some C or Fortran code. Maybe there are other applications when you need to force the type? I hope this helps at least a bit further? Roland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] vernacular names for circular diagrams
If anyone is interested in seeing Nightingale's Coxcomb a.k.a. Nightingale's Rose, it can be seen at http://www.economist.com/world/europe/displaystory.cfm?story_id=10278643. Best regards, Peter. -Oprindelig meddelelse- Fra: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] På vegne af Rolf Turner Sendt: 28. januar 2008 20:54 Til: roger koenker Cc: r-help Emne: Re: [R] [OT] vernacular names for circular diagrams Thank you! cheers, Rolf On 29/01/2008, at 8:38 AM, roger koenker wrote: Howard Wainer (Graphical Discovery, PUP, 2005, p 20) gives this dubious honor to Playfair (1759- 1823). Nightingale (1820- 1910) was far too enlightened for this sort of thing, see for example her letter to Galton about endowing an Oxford professorship in social statistics (reprinted in Karl Pearson's bio of Galton: http://galton.org/cgi-bin/searchImages/search/pearson/vol2/pages/ vol2_0482.htm It sets a very ambitious agenda that we have not yet made much progress on... url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Jan 28, 2008, at 1:10 PM, Rolf Turner wrote: On 28/01/2008, at 12:07 AM, Peter Dalgaard wrote: Jean lobry wrote: snip about an hour North of Paris. Her father inquired - coincidentally during the cheese course - what work I was doing in Paris; I replied that I was researching the activities of a Scot, William Playfair, during the revolutionary period. I told him that Playfair had invented several statistical graphs, including the pie chart snip I have been for many years under the impression that the pie chart was invented by Florence Nightingale. Am I misinformed? cheers, Rolf Turner # # Attention:\ This e-mail message is privileged and confid... {{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] survey: estimating a covariance matrix
Thomas and David, Thanks for your answers. The svyvar() function does the trick. It does not provide a vcov() method for the variance-covariance matrix of these estimates themselves. But I guess I can bootstrap them using library(boot)... Thanks again, daniel On Jan 25, 2008 6:13 PM, Thomas Lumley [EMAIL PROTECTED] wrote: On Wed, 23 Jan 2008, Daniel Oberski wrote: Hello Does anybody happen to know if it is possible to use the survey package to estimate a covariance matrix from a complex survey? Yes. svyvar() in the survey package estimates a population covariance matrix. It doesn't give standard errors for this estimate, though. -thomas [[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] Grid search: avoid for loops thanks to applyco?
Hello I'm trying to implement a grid search for a threshold autoregressive model, it is a model in which the regression coefficients are different according to the regimes (under the lower threshold, between lower and upper, over the upper threshold). Estimation of the threshold is made with Conditional least squares: once the threshold is given, the usual parameters are computed with usual OLS, the thresholds values are those which minimise the Sum of squares. In order to find the threshold values one has to compute the sum of squares of all models, which takes n x n/2 operations for a model with two regimes (for my case: 300x150=45'000). Transcription of the Matlab code into R is inefficient because of the loops (very slow), a schema of the actual code gives: for(in in 1:length(thres1)) firstThresh-tresh1[i] for(j in 1:length(thres1)) if(ji) secondThresh-tresh1[j] regime1-ifelse(xthresh1)*x regime2-ifelse(xthresh2)*x ...(some matrix algebra in order to obtain the Sum of Squares of cbind(x, regime1, regime2) I'm trying to implement it into R with applyco instead, but don't succeed. Many packages use grid search but all with for loops and small number of values. To use applyco, I saw these solutions: -write the matrix building and estimation function estim(X,thresh1, thresh2) and then with mapply mapply(estim, tresh1, thresh2) The problem is that I have to compute all combinations of thresh 1 and thresh 2 (with the condition thresh 2thresh1) and not only the combinations arg1[i] with arg2[i] -create a big array with all possible matrices cbind(y, regime1, regime2) and then use apply with only an estimation function. But I would need to create an array of 300 x 300 matrices... What do you think? Do you see other solutions? Is is possible to evaluate other combinations within the mapply function? Thanks for your help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on an eeePC
Dr. Walter H. Schreiber wrote: Dear list, I wonder if somebody has succeeded in installing R on an eeePC (Xandros desktop). Searching via Rseek (term eeePC) and in eeePC forums (term Cran) left me without proper hits. Try just looking for 'eee' at http://tolstoy.newcastle.edu.au/~rking/R/ -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to fill bar plot with textile rather than color
Filling bars with lines/grids/points is legacy back to the days when the only way to get high quality plots was to use a pen plotter (on the screen you would see bars made of '*' or similar). The pen plotter would use a mechanical arm to draw the lines using a pen/marker. it was easy to have the pen draw lines in a rectangle, but filling the rectangle with color just meant drawing the lines so close together that there was not space between them (and getting everyone else mad at you because it took so long, used up all the ink, and usually made holes in your paper). With modern graphics devices, filling the rectangle with a solid color is simpler than the lines. Using lines/grids can also lead to various optical illusions of colors or movement (called a Moire effect), see Tufte's book on displaying quantitative information for some detail on this. Some patterns can also make some bars appear longer or shorter (the gradient patterns that are popular in some areas). Using shading lines, patterns should be used carefully because of this (it is best to do a simple graph to compare to your more fancy version to compare and see if there are any visual distortions due to fills). If you really want to try the different fills, there are a couple of options. You can create the barplot with a unique color as the fill and save this to a graphics file. Then create (or find) the fill you want and save that to a graphics file. Use an external graphics manipulation program such as Imagemagick or gimp2 to then replace the bar fills with the pattern. If you want a pure R solution then you can do something like this (replace tmpfun with any function that adds the fill pattern of interest to an existing plot): library(TeachingDemos) tmp.dat - table( sample( letters[1:4], 1000, replace=TRUE) ) tmp1 - barplot(tmp.dat, col=NA, width=1, ylim=c(-5,max(tmp.dat)+5)) tmp2 - par('usr') tmpfun - function(){ tmp.x - seq(tmp2[1], tmp2[2], length=50) tmp.y - seq(tmp2[3], tmp2[4], length=50) points( expand.grid(x=tmp.x, y=tmp.y), pch='.' ) } for (i in seq(along=tmp1) ){ clipplot( tmpfun(), xlim=tmp1[i] + c(-0.5,0.5), ylim=c(0,tmp.dat[i]) ) } Again, always compare such plots to one without fill (or solid fill), to make sure that you are not distorting/distracting/etc. Hope this helps, From: [EMAIL PROTECTED] on behalf of yaosheng CHEN Sent: Mon 1/28/2008 8:08 AM To: Domenico Vistocco Cc: r-help@r-project.org Subject: Re: [R] How to fill bar plot with textile rather than color Thank you, and also thanks to John Kane. I did some tests last night, if you plot something like height - t(t(c(1,-1,1))) bardensity - t(t(c(10,10,0))) barangle - t(t(c(45,135,0))) barplot(height, density = bardensity, angle = barangle) You can get grids. Otherwise, only slanted lines or colors. I thought filling with dots or grids is quite common in traditional bar chart. But most softwares, including Matlab, SAS, Excel2k7, and gunplot, as I know, don't have such options. Anyway, thank you again. Let me know if you find any package which can fill bar plot with dots On Jan 28, 2008 4:13 AM, Domenico Vistocco [EMAIL PROTECTED] wrote: If you type example(barplot) you will find an example. Ciao, domenico CHENYS wrote: Hi, I'm looking for a tool which can fill bar chart with dash, skewed line, or grids, rather than pure color. Any one have the idea how to do that in R? Or maybe in Matlab will also be helpful. Thanks very much. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] basic spatial query
On 28/01/2008, at 11:14 PM, [EMAIL PROTECTED] wrote: Hello; Please coud you advise me of a simple way to select points (x,y coordinates) that fall within a polygon. I've got a set of polygons, each one defined by an arbitrary number of points, and several points inside each polygon. I know this is simple with a GIS, but I'd rather do it inside R. You could convert the polygon to an owin object and use inside.owin() in the spatstat package. You could also use the undocumented spatstat function inside.xypolygon (). cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to get out the t-test value matrix for a linear regression ?
leo_aries wrote: Hi, all I've written some R script to calculate the linear regression of a matrix. Here below is my script: x-matrix(scan(h:/data/xxx.dat,0),nrow=46,ncol=561,byrow=TRUE) year - NULL year - cbind(year,as.matrix(x[,1])) lm.sol-lm(x~year) xtrend-coef(lm.sol)[2,]# get the matrix of regression coefficient t.test- ? # also want to get a similar matrix of t-test value for the regression coefficient class(summary(lm.sol)) listof class(summary(lm.sol)) listof# the t-test values are in the obj summary(lm.sol), but how to get them out as a matrix similar as the abovextrend? Anyone can help me? Thanks ! This seems to do it: Y - matrix(rnorm(10),5) x - rnorm(5) sapply(coef(summary(lm(Y~x))),[, TRUE, t value) Response Y1 Response Y2 (Intercept) 0.54854882.021065 x-0.5175011 -2.225623 Or, a bit less sneaky sapply(coef(summary(lm(Y~x))), function(X) X[,t value]) Response Y1 Response Y2 (Intercept) 0.54854882.021065 x-0.5175011 -2.225623 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] matrix creation
I was asked for the following information and hope it might help those who could answer my question... To import the table I used: AsMi05test=read.csv(C:/AsMi_Site05_1998.csv) str(AsMi05test) `data.frame': 12 obs. of 8 variables: $ X : Factor w/ 6 levels Dead,Dormant,..: 5 6 3 4 2 1 5 6 3 4 ... $ Vegetative : num 0.25 0.50 0.17 0.08 0.00 ... $ Vegetative.with.Herbivory : num 0.13 0.5 0.33 0.67 0 0 0.41 0.5 0 0 ... $ Reproductive : num 0 0 0 0 0 0 0 0 0 0 ... $ Reproductive.with.Herbivory: num 0 0 0 0 0 ... $ Dormant: num 0.08 0 0.33 0.08 1 0 0.06 0 0 0 ... $ Dead : num 0.42 0.00 0.33 0.17 0.00 ... $ End.Date : int 1998 1998 1998 1998 1998 1998 1999 1999 1999 1999 ... From: Michelle DePrenger-Levin Sent: Monday, January 28, 2008 11:35 AM To: 'r-help@r-project.org' Subject: matrix creation Hello, I am trying to create multiple matrices (to run a PVA) but can't import all of them from a .csv without the numbers treated as labels and not factors. I can enter the matrix slowly: Site05_96 - matrix(c(0.07,0,0.03,0.00,NA,0.00, 0.09,0.16667,0.31,0.42,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.26,0.16667,0.19,0.00,NA,0.00, 0.58,0.7,0.47,0.58,0,0.00), nrow = 6, ncol = 6, dimnames = list(c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead), c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead))) I would like to list all matrices (for all 12 years and all 4 sites) in one Excel sheet (.csv) and then read each matrix as chucks of 6 rows. However, when I try this I either get all the values (the %) in quotes (not as factors) and if I try to force them with as.factor, it no longer seems to be a matrix. AsMi0598test2 - as.matrix(AsMi05test[1:6,1:6]) X Vegetative Vegetative.with.Herbivory Reproductive Reproductive.with.Herbivory Dormant 1 Vegetative 0.25 0.130 0 0.08 2 Vegetative with Herbivory 0.50 0.500 0 0.00 3 Reproductive0.17 0.330 0 0.33 4 Reproductive with Herbivory 0.08 0.670 0 0.08 5 Dormant 0.00 0.000 0 1.00 6 Dead0.00 0.000 0 0.00 When I add AsMi0598test2 - as.factor(as.matrix(AsMi05test[1:6,1:6])) I get this: [1] Vegetative Vegetative with Herbivory Reproductive Reproductive with Herbivory [5] Dormant Dead0.25 0.50 [9] 0.170.080.00 0.00 [13] 0.130.500.33 0.67 [17] 0.000.000 0 [21] 0 0 0 0 [25] 0 0 0 0 [29] 0 0 0.08 0.00 [33] 0.330.081.00 0.00 16 Levels: 0 0.00 0.08 0.13 0.17 0.25 0.33 0.50 0.67 1.00 Dead Dormant Reproductive ... Vegetative with Herbivory I want to read all matrices into stoch.projection( ) {popbio} Thanks for any suggestions. I could enter them all in the .txt document if I can't read them from the Excel sheet. Michelle DePrenger-Levin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] vernacular names for circular diagrams
On 28/01/2008, at 12:07 AM, Peter Dalgaard wrote: Jean lobry wrote: snip about an hour North of Paris. Her father inquired - coincidentally during the cheese course - what work I was doing in Paris; I replied that I was researching the activities of a Scot, William Playfair, during the revolutionary period. I told him that Playfair had invented several statistical graphs, including the pie chart snip I have been for many years under the impression that the pie chart was invented by Florence Nightingale. Am I misinformed? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Integer vs numeric
On 28-Jan-08 21:23:12, Roland Rau wrote: Christophe Genolini wrote: Hi the list. I do not understand the philosophy behind numeric and integer. - 1 is numeric (which I find surprising) - 2 is numeric. - 1:2 is integer. Why is that ? I hope I can answer your question at least partly: Numeric means double, i.e. internally stored as a double precision floating point number. As far as I know this is the default. You can, however, force an object to be, e.g. an integer, a single prevision float or a double precision float. as.integer(12) as.single(12) as.double(12) So far I only needed this if I wanted to call some C or Fortran code. Maybe there are other applications when you need to force the type? I hope this helps at least a bit further? Roland Further to the above: The help ?: says: Value: For numeric arguments [as opposed to factors], a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer type, otherwise of type 'numeric'. By if 'from' and 'to' are both integers I understand it to mean if the values of 'from' and 'to' are integers (in the mathematical realm), i.e. this does not refer to the R type. Thus: a-1; b-2 str(a) # num 1 str(b) # num 2 str((a:b)) # int [1:2] 1 2 so a and b were numeric when created, but since their values are integers (etc.) (a:b) has integer type. Presumably this is for computational efficiency. Integer arithmetic on a computer is faster than floating-point arithmetic; and if the computation can be done in the CPU registers (register arithmetic) then it is faster still (as I presume is the case here). Mind you. I'm guessing here. I have had nothing to do with the implementation of arithmetic in R, so cannot answer authoritatively for the motivations of those who did! Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 28-Jan-08 Time: 21:46:28 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [OT] vernacular names for circular diagrams
I had heard the same thing about Florence Nightingale, but it seems that this is a confusion of different graphs. Nightingale developed a graph based on a circle, but all the angles were equal and the different values were encoded by using different radii of the slices (and she did the right thing by having the radius proportional to the square root of the value). She never named this plot, but I have seen coxcomb (Nightingale refered to the document in which this graph first appeared as the coxcomb) or rotogram used as names. At first glance this may be confused for a pie chart, hence the credit, but in truth I think Nightingale is innocent of the crime of creating the first pie chart. From: [EMAIL PROTECTED] on behalf of Rolf Turner Sent: Mon 1/28/2008 12:10 PM To: r-help Subject: Re: [R] [OT] vernacular names for circular diagrams On 28/01/2008, at 12:07 AM, Peter Dalgaard wrote: Jean lobry wrote: snip about an hour North of Paris. Her father inquired - coincidentally during the cheese course - what work I was doing in Paris; I replied that I was researching the activities of a Scot, William Playfair, during the revolutionary period. I told him that Playfair had invented several statistical graphs, including the pie chart snip I have been for many years under the impression that the pie chart was invented by Florence Nightingale. Am I misinformed? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [OT] vernacular names for circular diagrams
Howard Wainer (Graphical Discovery, PUP, 2005, p 20) gives this dubious honor to Playfair (1759- 1823). Nightingale (1820- 1910) was far too enlightened for this sort of thing, see for example her letter to Galton about endowing an Oxford professorship in social statistics (reprinted in Karl Pearson's bio of Galton: http://galton.org/cgi-bin/searchImages/search/pearson/vol2/pages/vol2_0482.htm It sets a very ambitious agenda that we have not yet made much progress on... url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Jan 28, 2008, at 1:10 PM, Rolf Turner wrote: On 28/01/2008, at 12:07 AM, Peter Dalgaard wrote: Jean lobry wrote: snip about an hour North of Paris. Her father inquired - coincidentally during the cheese course - what work I was doing in Paris; I replied that I was researching the activities of a Scot, William Playfair, during the revolutionary period. I told him that Playfair had invented several statistical graphs, including the pie chart snip I have been for many years under the impression that the pie chart was invented by Florence Nightingale. Am I misinformed? cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped: 9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] maptools no such file
Roger, I tried your suggestions and ran into same problems as Pieter did before. On 28.01.2008 12:35 (UTC+1), Roger Bivand wrote: pieterprovoost at gmail.com writes: No, I get the same error message there... Please do not needlesly delete the thread content. Your original question was: I'm having problems reading a shapefile with read.shape (maptools). I'm absolutely sure my file is there, but I get no such file. The wd is ok, since read.table for example does find the file. For testing I copied /usr/local/lib/R/library/rgdal/vectors/cities.shp into /usr/home/rhurlin/TEMP/Rscripts/ getwd() [1] D:/somedirectory/R scripts [1] /usr/home/rhurlin/TEMP/Rscripts read.table(cities.shp) Error in read.table(cities.shp) : empty beginning of file In addition: Warning message: In read.table(cities.shp) : incomplete final line found by readTableHeader on 'cities.shp' which is self-explanatory, because you were not using read.shape() anyway. You continued: read.shape(cities.shp) Error in getinfo.shape(filen) : No such file Fehler in getinfo.shape(filen) : No such file but did not respond to the suggestion from an R-helper with the output from: readShapePoly(cities.shp) Fehler in getinfo.shape(filen) : No such file Try list.files(pattern=shp$) to see whether your assumption that the files are where you think they are, is justified. [1] cities.shp Then get back with the output of getinfo.shape(cities.shp) Fehler in getinfo.shape(cities.shp) : No such file If you want to, you can use file.choose() to choose the file interactively. If you haven't solved this yourself by then (found the files youself), do remember to include the verbatim output of sessionInfo() too. R version 2.6.1 (2007-11-26) i386-unknown-freebsd8.0 # This is 8.0-CURRENT from yesterday locale: de_DE.ISO8859-15/de_DE.ISO8859-15/de_DE.ISO8859-15/C/de_DE.ISO8859-15/de_DE.ISO8859-15 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] maptools_0.7-4 sp_0.9-19 foreign_0.8-23 proto_0.3-8 loaded via a namespace (and not attached): [1] ggplot2_0.5.7 lattice_0.17-4 rcompgen_0.1-17 Roger Bivand It seems, that the C call of 'Rshapeinfo' makes trouble on my system. Rshapeinfo.c tries to open the shapefile with the following code: hSHP = SHPOpen( shpnm[0], rb ); If I did not misunderstood, this returns NULL on my system. I have almost no C programming skills, so I am not able to understand the code enough. Could something be wrong in using 'gettext'? (GNU gettext-runtime 0.16.1) Hope this helps a bit, Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R for Mac 10.3.9
http://cran.fhcrc.org/bin/macosx/old/powerpc/R-2.2.0.dmg But that is sooo old. Maybe he could compile from the source (he'd need to install XCode and a fortran compiler). I assume that once these requirements are installed, the compilation would be as simple as: ./configure make Maybe the experts have something to add. And [EMAIL PROTECTED] seems more appropriate for mac- specific questions. kindest regards, b On Jan 28, 2008, at 6:12 PM, Paul Johnson wrote: I know nothing of Macintosh, so please be patient. My student has a Macintosh with OSX 10.3.9. The R for Mac says it is for 10.4.4 or higher. Aside from saying get a new Mac, what can be said to my student? Can you point me at the newest version of R that did work on 10.3 ? pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Very Important Message
Hello, I am Mr. Ellis David by name and I?m the CEO/OWNER of Davidellis Textiles company Inc. in West Africa. We supply textiles to over hundred of customers spread all over the world.We need someone that will be representing my company as a Manager/Representative, who will attend to customers in receiving payments. I need honesty in this business because you will be handling money for the company. This is due to the poor facilities here in Africa to recieve funds through bank to bank transfer. My customers will pay in money for the products they bought from the company to you through your EQUITY LINE OF CREDIT ACCOUNT. You will be receiving the payment through your Equity Line of Credit to maintain trust on both ends. With your line of credit, it will show that you received some funds and also that you don?t get away with the company fund. After you receive the funds, you withdraw it and send the money to the Branch which will be provided to you. We will discuss the payment of your services immediately we here from you. Efficiency and honesty is required in this business. Your remuneration(s) can still be discussed on your response to this proposal, please mail to my direct mail box: [EMAIL PROTECTED] Awaiting your response. Sincerely, Ellis David. Follow this link to sign up: http://audubonaction.org/audubon/join.html?rk=K1x5Jw4zf3jT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on an eeePC
RSiteSearch(R asus) G. On Mon, Jan 28, 2008 at 03:31:45PM +0100, Dr. Walter H. Schreiber wrote: Dear list, I wonder if somebody has succeeded in installing R on an eeePC (Xandros desktop). Searching via Rseek (term eeePC) and in eeePC forums (term Cran) left me without proper hits. Best wishes, Walter. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor [EMAIL PROTECTED]UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fourier Analysis and Curve Fitting in R
Rolf Turner wrote: On 26/01/2008, at 10:54 AM, Carson Farmer wrote: Dear List, I am attempting to perform a harmonic analysis on a time series of snow depth, in which the annual curve is essentially asymmetric (i.e. snow accumulates slowly over time, and the subsequent melt occurs relatively rapidly). I am trying to fit a curve to the data, however, the actual frequency is unknown. In general the actual frequency of the curve will indeed be close to 1/(1 year). However, because I intend to perform this analysis on many regions, this will not always be the case. This is perhaps an acceptable assumption however... Obviously there is something I am not understanding here. I would have thought that the ``actual frequency'' would be 1/(1 year) (period = 1 year) --- modulo the fact that the length of the year is constantly changing a tiny bit. (But I would've thought that this would have no practical impact in respect of any observed series.) My sampling interval is daily. What is your sampling interval, BTW? Day? Week? Month? I have been trying to follow the methods in Peter Bloomfields text Fourier Analysis of Time Series, but am having trouble implementing this in R. Yes it certainly would. Note that even though the ``actual frequency'' is (???) 1/(1 year), the representation of the mean function in terms of sinusoids will involve in theory infinitely many terms/frequencies since the mean function is clearly (!) not a sinusoid. Does anyone have any suggestions, or perhaps directions on how this might be done properly? Am I using the right methods for fitting an asymmetric curve? What I am really trying to do is fit a relatively smooth line to my data which will preferentially weight the larger values. This method needs to be able to fit through data gaps however, which is why I was originally looking to fit sinusoids. A jpg of a single year of the data is available here: http://www.geog.uvic.ca/spar/carson/snowDepth.jpg to give you an idea of the shape of my curve. Thank you again for your help, Carson I would have to know more about what you are *really* trying to do, and what the data are like, before I could make any useful suggestions. Many modelling issues could come into play, and many modelling strategies are potentially applicable. cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] (no subject)
Hi all I am trying to generate a normal unbalanced data to estimate the coefficients of LM, LMM, GLM, and GLMM and their standard errors. Also, I am trying to estimate the variance components and their standard errors. Further, I am trying to use the likelihood ratio test to test H0: sigma^2_b = 0 (random effects variance component), and the t-test to test H0:mu=0 (intercept of the model Yij = mu + Bi + Eij). I am using the following program all.fix.coef.lme - rep(NA,R) all.fix.coef.lm - rep(NA,R) all.fix.coef.glm - rep(NA,R) all.se.fix.coef - rep(NA,R) all.fix.coef.glmm - rep(NA,R) all.se.fix.coef.glmm - rep(NA,R) all.varcomp.g - rep(NA,R) all.se.varcomp.g2 - rep(NA,R) all.se.varcomp.gD - rep(NA,R) all.se.fix.coef.adapt - rep(NA,R) vb-rep(NA,R) yb-rep(NA,R) va-rep(NA,R) mse-rep(NA,R) msa-rep(NA,R) maxH0-rep(NA,R) maxH1-rep(NA,R) tstat1 - rep(NA,R) tstat2 - rep(NA,R) tstatD- rep(NA,R) tstatad - rep(NA,R) tstatlme - rep(NA,R) tstatlm - rep(NA,R) sigmahatesq - rep(NA,R) sigmahatbsq - rep(NA,R) est.ICC - rep(NA,R) all.fix.coef.lm - rep(NA,R) all.se.fix.coef.lm - rep(NA,R) all.se.fix.coef.glm - rep(NA,R) all.se.fix.coef.adapt.lm - rep(NA,R) F- rep(NA,R) F1- rep(NA,R) lrt - rep(NA,R) lrtest - rep(NA,R) yb - rep(NA,R) varyb - rep(NA,R) var - rep(NA,R) var1 - rep(NA,R) D- rep(NA,R) Lrt - function(k, R=250,m, c, stop=FALSE){ if(stop) browser() set.seed(421) options(digits = 3) for(case in 1:3){ if(case==1) c - 1:3 if(case==2) c - 5:15 if(case==3) c - 25:150 for(r in(1:R)){ n - c*m y - rep(rnorm(m),each=c)+ rnorm(m*c) g - as.factor(rep(1:m,each=c)) test - data.frame(cbind(g,y)) #test$h - 1:3 test.lme1 - lme (y~1, test, random = ~1|g) #test.lme2 - lme (y~1, test) glm - glm(y~1) test.lm - lm (y~1) glmm - glmmPQL (y~1, test, random = ~1|g, family=gaussian) all.se.fix.coef.lm[r] - as.vector(sqrt(vcov(test.lm))) all.fix.coef.lme [r] - as.vector(fixef(test.lme1)) all.fix.coef.lm [r] - as.vector(coef(test.lm)) all.fix.coef.glm [r] - as.vector(coef(glm)) all.se.fix.coef [r] - as.vector(sqrt(vcov(test.lme1))) all.fix.coef.glmm[r] - as.vector(fixef(glmm)) all.se.fix.coef.glmm[r] - as.vector(sqrt(vcov(glmm))) lrtest[r]- -2* (logLik(test.lme1, REML = TRUE))#- logLik(test.lme2, REML = TRUE)) if (lrtest[r] 1.64) all.se.fix.coef.adapt[r]-sqrt(vcov(test.lme1)) else all.se.fix.coef.adapt[r]-sqrt(vcov(glm)) est.ICC[r] - as.numeric(VarCorr(test.lme1)[1,1])/( as.numeric(VarCorr(test.lme1)[1,1])+test.lme1$sigma^2) all.varcomp.g [r] -as.vector(as.numeric(VarCorr(test.lme1)[1,1])) if (test.lme1$apVar[1] == Non-positive definite approximate variance-covariance) { all.se.varcomp.g2[r] - NA tstat2[r] - 0 } else { all.se.varcomp.g2[r] - sqrt(test.lme1$apVar[2,2]) tstat2[r]- all.varcomp.g[r]/all.se.varcomp.g2[r] } all.se.varcomp.gD[r] - sqrt(2/c*( c*as.numeric(VarCorr(test.lme1)[1,1]) + as.numeric(VarCorr(test.lme1)[2,1]))^2/(n+c)+(2/(c^2*(n-m+2))* as.numeric(VarCorr(test.lme1)[2,1])^2)) tstatD[r] - all.varcomp.g[r]/all.se.varcomp.gD[r] tstatlme[r]- abs(all.fix.coef.lme[r]/all.se.fix.coef[r]) tstatlm[r]-abs(all.fix.coef.lm[r]/all.se.fix.coef.lm[r]) tstatad [r]-abs(all.fix.coef.lme[r]/all.se.fix.coef.adapt[r]) } } list(m, c, round(mean(all.se.fix.coef.adapt, na.rm = T), 3), round(mean(all.se.fix.coef.lm, na.rm = T ),3), round(mean(all.se.fix.coef, na.rm = T ), 3), round(sqrt(var(all.fix.coef.lme, na.rm = T)),3), round(mean(all.se.fix.coef.glmm), 3), #round(mean(all.fix.coef.glmm), 3), length(lrtest[lrtest1.64])/2.50, length(tstatlm[tstatlm1.64])/2.5, length(tstatlme[tstatlme1.64] )/2.5, length(tstatad[tstatad1.64] )/2.5, round(mean(lrtest[lrtest0]),3), #round(var(lrtest[lrtest0]), 3), #length(lrtest[lrtest0])/2.5, length(tstatD[tstatD1.64])/2.5, length(lrtest[lrtest1.64])/2.5, lrtest ) } for (i in m) { for(j in c) { m = i c = j A.i- Lrt(0, ,m,c) se.table - rbind(se.table, A.i) } } write.table(se.table, sep=””) == But I couldn't find all values in the list, I just found 10 out of 14. The results were as follows V1V2V3V4V5V6V7V8V9V10 220.4890.4570.5140.53210.834.42832.8 250.3230.3020.3030.3556.841.233.639.2 2100.2350.2190.2240.2566.456.447.251.6 2500.1080.0990.0990.1186.899.694.897.6 21000.0740.0710.0730.0823.210099.299.2 520.3160.3030.3070.3341240.833.238 550.2010.1970.2030.2154.469.262.468.4 5100.1470.140.1420.1567.2868082.8 5500.0660.0630.0670.076100100100 51000.0470.0450.0440.056.4100100100 1020.2240.2190.2280.2328.462.459.662 1050.1440.140.1390.158.488.484.486.8 10100.1030.0990.10.1078.898.897.698 10500.0460.0450.0460.0487.2100100100
Re: [R] Integer vs numeric
On 28-Jan-08 22:40:02, Peter Dalgaard wrote: [...] AFAIR, space is/was more of an issue. If you do something like for i in 1:1e7 some.silly.simulation() then you have 40 MB sitting there doing nothing, and 80 MB if it had been floating point. Hmmm ... there's something to be said for good old for(i=1,i=1e7,i++){} As pointed out in ?for, when you do for(i in X){...} #(e.g. X=(1:1e7)) the object X is created (or is already there) in full at the start and sits there, as you say doing nothing, until you end the loop. Whereas the C code just keeps track of i and of the condition. At least on a couple of my machines (64MB and 184MB RAM) knocking out 40MB would inflict severe trauma! Let alone 80MB. Mind you, the little one is no longer allowed to play with big boys like R, though the other one is still used for moderate-sized games. Would there be much of a time penalty in implementing a 'for' loop, C-style, as i-1 while(i=1e7){ ... i-i+1 } ?? It looks as though there might be: system.time(for(i in (1:1e7)) x-cos(3) ) #[1] 13.521 0.132 13.355 0.000 0.000 system.time({i-1;while(i=1e7){x-cos(3);i-i+1}}) #[1] 38.270 0.076 37.629 0.000 0.000 which suggests that the latter is about 3 times as slow. (And no, this wasn't done on either of my puny babes). (And this isn't the first time I've wished for an R implementation of ++ as a CPU-level incrementation, as opposed to the R-arithmetic implementation which treats adding 1 to a variable as a full-dress arithmetic parade! Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 28-Jan-08 Time: 23:34:52 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maptools no such file
On Mon, 28 Jan 2008, Rainer Hurling wrote: Roger, I tried your suggestions and ran into same problems as Pieter did before. Rainer: I don't think that we know what platform Pieter was using, apart from the working directory that looked like Windows, and where the problem could not be reproduced. I note that yours is FreeBSD 8, and I agree, the .C() interface to the small helper function should most likely be replaced by a .Call() to make handling the file name more robust. Can I send a modified version off-list tomorrow, since I have no access to your platform otherwise? Is readOGR() in rgdal working, by the way? Roger On 28.01.2008 12:35 (UTC+1), Roger Bivand wrote: pieterprovoost at gmail.com writes: No, I get the same error message there... Please do not needlesly delete the thread content. Your original question was: I'm having problems reading a shapefile with read.shape (maptools). I'm absolutely sure my file is there, but I get no such file. The wd is ok, since read.table for example does find the file. For testing I copied /usr/local/lib/R/library/rgdal/vectors/cities.shp into /usr/home/rhurlin/TEMP/Rscripts/ getwd() [1] D:/somedirectory/R scripts [1] /usr/home/rhurlin/TEMP/Rscripts read.table(cities.shp) Error in read.table(cities.shp) : empty beginning of file In addition: Warning message: In read.table(cities.shp) : incomplete final line found by readTableHeader on 'cities.shp' which is self-explanatory, because you were not using read.shape() anyway. You continued: read.shape(cities.shp) Error in getinfo.shape(filen) : No such file Fehler in getinfo.shape(filen) : No such file but did not respond to the suggestion from an R-helper with the output from: readShapePoly(cities.shp) Fehler in getinfo.shape(filen) : No such file Try list.files(pattern=shp$) to see whether your assumption that the files are where you think they are, is justified. [1] cities.shp Then get back with the output of getinfo.shape(cities.shp) Fehler in getinfo.shape(cities.shp) : No such file If you want to, you can use file.choose() to choose the file interactively. If you haven't solved this yourself by then (found the files youself), do remember to include the verbatim output of sessionInfo() too. R version 2.6.1 (2007-11-26) i386-unknown-freebsd8.0 # This is 8.0-CURRENT from yesterday locale: de_DE.ISO8859-15/de_DE.ISO8859-15/de_DE.ISO8859-15/C/de_DE.ISO8859-15/de_DE.ISO8859-15 attached base packages: [1] stats graphics grDevices utils datasets grid methods [8] base other attached packages: [1] maptools_0.7-4 sp_0.9-19 foreign_0.8-23 proto_0.3-8 loaded via a namespace (and not attached): [1] ggplot2_0.5.7 lattice_0.17-4 rcompgen_0.1-17 Roger Bivand It seems, that the C call of 'Rshapeinfo' makes trouble on my system. Rshapeinfo.c tries to open the shapefile with the following code: hSHP = SHPOpen( shpnm[0], rb ); If I did not misunderstood, this returns NULL on my system. I have almost no C programming skills, so I am not able to understand the code enough. Could something be wrong in using 'gettext'? (GNU gettext-runtime 0.16.1) Hope this helps a bit, Rainer -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Integer vs numeric
(Ted Harding) wrote: Further to the above: The help ?: says: Value: For numeric arguments [as opposed to factors], a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer type, otherwise of type 'numeric'. By if 'from' and 'to' are both integers I understand it to mean if the values of 'from' and 'to' are integers (in the mathematical realm), i.e. this does not refer to the R type. In the realm of floating point arithmetic to be precise. Fractional part zero is one way of putting it. Representable in integer type refers to the fact that double precision has 53 bits for the mantissa and integers have 32, so some floating point integers won't fit. The point is of course that 1.3:9.3 is _not_ an integer vector. Thus: a-1; b-2 str(a) # num 1 str(b) # num 2 str((a:b)) # int [1:2] 1 2 so a and b were numeric when created, but since their values are integers (etc.) (a:b) has integer type. Presumably this is for computational efficiency. Integer arithmetic on a computer is faster than floating-point arithmetic; and if the computation can be done in the CPU registers (register arithmetic) then it is faster still (as I presume is the case here). AFAIR, space is/was more of an issue. If you do something like for i in 1:1e7 some.silly.simulation() then you have 40 MB sitting there doing nothing, and 80 MB if it had been floating point. Also AFAIR, the reason 1 is not integer is that then every operation like x-1 would involve a coercion to double. Mind you. I'm guessing here. I have had nothing to do with the implementation of arithmetic in R, so cannot answer authoritatively for the motivations of those who did! -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] trouble installing quantreg packages
I am trying to install the quantreg Package on MacOSX. When I choose CRAN mirror, it gives me the error: Error in read.dcf(file = tmpf) : Line longer than buffer size In addition: There were 44 warnings (use warnings() to see them) Is there any known current problem with this package? Sincerely Arjun Adhikari -- Doctoral Instructional Assistant Texas State University Department of Biology 601 University Dr. San Marcos, TX, 78666, USA Executive Editor Himalayan Journal of Sciences www.himjsci.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] Integer vs numeric
Further to the above: The help ?: says: Value: For numeric arguments [as opposed to factors], a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer type, otherwise of type 'numeric' ??? This is very surprising since with a to numeric, the result is integer : str(1:4.5) int [1:4] 1 2 3 4 Anyway, if I understand, 'integer' in R is not realy the math type integer. I am a bit confuse... Christophe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R for Mac 10.3.9
I know nothing of Macintosh, so please be patient. My student has a Macintosh with OSX 10.3.9. The R for Mac says it is for 10.4.4 or higher. Aside from saying get a new Mac, what can be said to my student? Can you point me at the newest version of R that did work on 10.3 ? pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems compiling shogun 0.4.4
Hello, I'm trying to compile Shogun 0.4.4 from source on Redhat Enterprise Linux 4 (update 5). I've compiled and installed R-2.6.1 already and that seems to work fine. I had some initial problems finding R development files, which were fixed by setting CFLAGS='-I/tmp/R-2.6.1/ include' and CXXFLAGS='-I/tmp/R-2.6.1/include' in my shell before running ./configure --interface=R. After configuring and then running make I get the following error: ... ./gui/R.cpp.o(.text+0xc19):gui/R.cpp:317: undefined reference to `R_CHAR' ./gui/R.cpp.o(.text+0xd39): In function `R_init_sg(_DllInfo*)': gui/R.cpp:439: undefined reference to `R_registerRoutines' collect2: ld returned 1 exit status make: *** [sg.so] Error 1 Any ideas? I looked for some configure option that might disable GUI features but didn't find anything relevant. Thanks, -- Brian McNally __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [OT] - standard errors for parameter estimates under ridge regression and lasso?
Dear R community, I'm curious to know how people go about estimating standard errors for parameter estimates after model selection by ridge regression and the lasso. Do you have any practical or theoretical advice? Warmly, Andrew -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] matrix creation
hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO On Mon, 2008-01-28 at 12:17 -0700, Michelle DePrenger-Levin wrote: I was asked for the following information and hope it might help those who could answer my question... That looks fine to me Michelle. You will have problems with as.matrix on this though as a matrix in R has to contain *all* elements of the same kind, text or numeric. As $X is a factor, the matrix ends up as a character matrix, as this example shows: my.dat - data.frame(X = gl(4,5), Vegetative = runif(20), Dormant = runif(20)) str(my.dat) as.matrix(my.dat) I'm not familiar with popbio, but a brief look at the function you mentioned seems to need a list of matrices. You need to study what data requirements this function has. I doubt you can use the data you read in exactly as you have it, as you have found out you can't create a numeric matrix from it. This isn't an issue of how you are reading the data in, rather an inherent issue with how you are doing things with your data. You could convert the factor column to its numeric representation and then you can produce a matrix that is numeric my.dat$X - as.numeric(my.dat$X) str(my.dat) as.matrix(my.dat) *But* you should read the help for popbio to see what you are required to provide as what I show is only a workaround for the matrix issue - I have no idea what a projection matrix is in the sense of popbio or how to use the functions in that package. HTH G To import the table I used: AsMi05test=read.csv(C:/AsMi_Site05_1998.csv) str(AsMi05test) `data.frame': 12 obs. of 8 variables: $ X : Factor w/ 6 levels Dead,Dormant,..: 5 6 3 4 2 1 5 6 3 4 ... $ Vegetative : num 0.25 0.50 0.17 0.08 0.00 ... $ Vegetative.with.Herbivory : num 0.13 0.5 0.33 0.67 0 0 0.41 0.5 0 0 ... $ Reproductive : num 0 0 0 0 0 0 0 0 0 0 ... $ Reproductive.with.Herbivory: num 0 0 0 0 0 ... $ Dormant: num 0.08 0 0.33 0.08 1 0 0.06 0 0 0 ... $ Dead : num 0.42 0.00 0.33 0.17 0.00 ... $ End.Date : int 1998 1998 1998 1998 1998 1998 1999 1999 1999 1999 ... From: Michelle DePrenger-Levin Sent: Monday, January 28, 2008 11:35 AM To: 'r-help@r-project.org' Subject: matrix creation Hello, I am trying to create multiple matrices (to run a PVA) but can't import all of them from a .csv without the numbers treated as labels and not factors. I can enter the matrix slowly: Site05_96 - matrix(c(0.07,0,0.03,0.00,NA,0.00, 0.09,0.16667,0.31,0.42,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.00,0,0.00,0.00,NA,0.00, 0.26,0.16667,0.19,0.00,NA,0.00, 0.58,0.7,0.47,0.58,0,0.00), nrow = 6, ncol = 6, dimnames = list(c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead), c(Vegetative, Vegetative with herbivory, Reproductive, Reproductive with herbivory, Dormant, Dead))) I would like to list all matrices (for all 12 years and all 4 sites) in one Excel sheet (.csv) and then read each matrix as chucks of 6 rows. However, when I try this I either get all the values (the %) in quotes (not as factors) and if I try to force them with as.factor, it no longer seems to be a matrix. AsMi0598test2 - as.matrix(AsMi05test[1:6,1:6]) X Vegetative Vegetative.with.Herbivory Reproductive Reproductive.with.Herbivory Dormant 1 Vegetative 0.25 0.130 0 0.08 2 Vegetative with Herbivory 0.50 0.500 0 0.00 3 Reproductive0.17 0.330 0 0.33 4 Reproductive with Herbivory 0.08 0.670 0 0.08 5 Dormant 0.00 0.000 0 1.00 6 Dead0.00 0.000 0 0.00 When I add AsMi0598test2 - as.factor(as.matrix(AsMi05test[1:6,1:6])) I get this: [1] Vegetative Vegetative with Herbivory Reproductive Reproductive with Herbivory [5] Dormant Dead0.25 0.50 [9] 0.170.080.00 0.00 [13] 0.130.500.33 0.67 [17] 0.000.000 0 [21] 0 0 0 0 [25] 0 0
Re: [R] [OT] vernacular names for circular diagrams
On Jan 28, 2008 1:25 PM, Greg Snow [EMAIL PROTECTED] wrote: I had heard the same thing about Florence Nightingale, but it seems that this is a confusion of different graphs. Nightingale developed a graph based on a circle, but all the angles were equal and the different values were encoded by using different radii of the slices (and she did the right thing by having the radius proportional to the square root of the value). She never named this plot, but I have seen coxcomb (Nightingale refered to the document in which this graph first appeared as the coxcomb) or rotogram used as names. At first glance this may be confused for a pie chart, hence the credit, but in truth I think Nightingale is innocent of the crime of creating the first pie chart. An example of Stigler's Law of Eponomy (Stigler, 1980), Nightingale's Coxcomb chart did not orignate with her, though this should not detract from her credit. She likely got the idea from William Farr, a close friend and frequent correspondent, who used the same graphic principles in 1852. The earliest known inventor of polar area charts is Andre-Michel Guerry (1829). --- Michael Friendly via http://www.math.yorku.ca/SCS/Gallery/historical.html Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about order
I have a data vector as following: z [1] 183.1370 201.9610 113.7250 140.7840 156.2750 42.1569 42.1569 42.1569 [9] 240.1960 308.4310 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 [17] 42.1569 42.1569 42.1569 42.1569 279.8040 42.1569 42.1569 when I sort, it gave me the right order sort(z) [1] 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 [9] 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 113.7250 [17] 140.7840 156.2750 183.1370 201.9610 240.1960 279.8040 308.4310 BUT when I use the order, the returned index is strange and not right. You can check the first 4 values. order (z) [1] 6 7 8 11 12 13 14 15 16 17 18 19 20 22 23 3 4 5 1 2 9 21 10 I am not sure why R does not order it correctly when handling a vector with repetitive values. I use just the first 4 values of z, then it ordered correctly. order (z[1:4]) [1] 3 4 1 2 Can someone help? What is the problem here? Is this a R bug? How to order when handling a vector with repetitive values? -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 about order
that seems right order() gives you the indexes idx such that x[idx] == sort(x) set.seed(123) x - rnorm(10) idx - order(x) identical(x[idx], sort(x)) [1] TRUE best b On Jan 28, 2008, at 8:19 PM, Waverley wrote: I have a data vector as following: z [1] 183.1370 201.9610 113.7250 140.7840 156.2750 42.1569 42.1569 42.1569 [9] 240.1960 308.4310 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 [17] 42.1569 42.1569 42.1569 42.1569 279.8040 42.1569 42.1569 when I sort, it gave me the right order sort(z) [1] 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 [9] 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 113.7250 [17] 140.7840 156.2750 183.1370 201.9610 240.1960 279.8040 308.4310 BUT when I use the order, the returned index is strange and not right. You can check the first 4 values. order (z) [1] 6 7 8 11 12 13 14 15 16 17 18 19 20 22 23 3 4 5 1 2 9 21 10 I am not sure why R does not order it correctly when handling a vector with repetitive values. I use just the first 4 values of z, then it ordered correctly. order (z[1:4]) [1] 3 4 1 2 Can someone help? What is the problem here? Is this a R bug? How to order when handling a vector with repetitive values? -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 about order
On Mon, 28 Jan 2008, Waverley wrote: I have a data vector as following: z [1] 183.1370 201.9610 113.7250 140.7840 156.2750 42.1569 42.1569 42.1569 [9] 240.1960 308.4310 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 [17] 42.1569 42.1569 42.1569 42.1569 279.8040 42.1569 42.1569 when I sort, it gave me the right order sort(z) [1] 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 [9] 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 42.1569 113.7250 [17] 140.7840 156.2750 183.1370 201.9610 240.1960 279.8040 308.4310 BUT when I use the order, the returned index is strange and not right. You can check the first 4 values. order (z) [1] 6 7 8 11 12 13 14 15 16 17 18 19 20 22 23 3 4 5 1 2 9 21 10 Seems ok to me. Maybe you are looking for rank()? Order gives the ordering permutation, rank the inverse, i.e.: R z2 - sort(z) R identical(z2, z[order(z)]) [1] TRUE R identical(z, z2[rank(z)]) [1] TRUE hth, Z I am not sure why R does not order it correctly when handling a vector with repetitive values. I use just the first 4 values of z, then it ordered correctly. order (z[1:4]) [1] 3 4 1 2 Can someone help? What is the problem here? Is this a R bug? How to order when handling a vector with repetitive values? -- Waverley @ Palo Alto __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fourier Analysis and Curve Fitting in R
well if you want to find the spectral density aka what frequencies explain most of the variance then I would suggest the spectral density. This can be implemented with spec.pgram(). This is conducted with the fast fourier transform algorithm. a-ts(data, frequency = 1) #make the time series with 365readings/365days ?spec.pgram and you should be able to take it from here This will give you the raw periodogram and the dominant frequencies after you smooth the periodogram. If your intention is to just fit a curve to your data there are many types of cuve fitting options moving average etc. What are you trying to do find the dominant periodicy? make a prediction equation? fit a smooth line? or... give us some more information and maybe we can help On 1/28/08, Carson Farmer [EMAIL PROTECTED] wrote: Rolf Turner wrote: On 26/01/2008, at 10:54 AM, Carson Farmer wrote: Dear List, I am attempting to perform a harmonic analysis on a time series of snow depth, in which the annual curve is essentially asymmetric (i.e. snow accumulates slowly over time, and the subsequent melt occurs relatively rapidly). I am trying to fit a curve to the data, however, the actual frequency is unknown. In general the actual frequency of the curve will indeed be close to 1/(1 year). However, because I intend to perform this analysis on many regions, this will not always be the case. This is perhaps an acceptable assumption however... Obviously there is something I am not understanding here. I would have thought that the ``actual frequency'' would be 1/(1 year) (period = 1 year) --- modulo the fact that the length of the year is constantly changing a tiny bit. (But I would've thought that this would have no practical impact in respect of any observed series.) My sampling interval is daily. What is your sampling interval, BTW? Day? Week? Month? I have been trying to follow the methods in Peter Bloomfields text Fourier Analysis of Time Series, but am having trouble implementing this in R. Yes it certainly would. Note that even though the ``actual frequency'' is (???) 1/(1 year), the representation of the mean function in terms of sinusoids will involve in theory infinitely many terms/frequencies since the mean function is clearly (!) not a sinusoid. Does anyone have any suggestions, or perhaps directions on how this might be done properly? Am I using the right methods for fitting an asymmetric curve? What I am really trying to do is fit a relatively smooth line to my data which will preferentially weight the larger values. This method needs to be able to fit through data gaps however, which is why I was originally looking to fit sinusoids. A jpg of a single year of the data is available here: http://www.geog.uvic.ca/spar/carson/snowDepth.jpg to give you an idea of the shape of my curve. Thank you again for your help, Carson I would have to know more about what you are *really* trying to do, and what the data are like, before I could make any useful suggestions. Many modelling issues could come into play, and many modelling strategies are potentially applicable. cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Package simex
On Jan 28, 2008, at 11:30 AM, Liaw, Andy wrote: The original paper is: Cook, J. R. Stefanski L. A. (1994) Simulation--extrapolation estimation in parametric measurement error models. Journal of the American Statistical Association, 89, 1314-1328. From: Michael Kubovy Dear R-helpers, It is not clear to me how you get measurement.error SD when you have a single dataset, and it is not clear to me how sensitive SIMEX is to errors in the estimates of measurement error. Could someone please point me to the relevant literature? Indeed, the article is cited in the package help. Unfortunately it ends with my question: Among the limitations of SIMEX estimation … the two most notable are the requirement that the measurement error variance be known … (p. 1327). The study I'm dealing with does not have a history of similar studies that would allow me to estimate the measurement error variance. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] add/subtract matrices, ignoring NA or missing values
Hi, For example, given two 2x2 matrices m1 and m2. I would like to add/subtract element by element m1 [,1] [,2] [1,] NA NA [2,]12 m2 [,1] [,2] [1,]1 NA [2,] NA2 m1 + m2 [,1] [,2] [1,] NA NA [2,] NA4 How can I ignore the NA, and get this ? Hope the solution can be extended to subtract and modulo also. [,1] [,2] [1,] 1 NA [2,] 14 [[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] how to simulate seasonal cointegrated series
Hi, does anyone know how to simulate two seasonal data series that are cointegrated? Thanks! -- Tom [[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] add/subtract matrices, ignoring NA or missing values
Perhaps you could explain the motivation behind this. At any rate here are three different solutions: ifelse(is.na(m1), ifelse(is.na(m2), NA, m2), ifelse(is.na(m2), m1, m1 + m2)) apply(array(c(m1, m2), c(2,2,2)), 1:2, function(x) sum(c(na.omit(x), NA)[1])) na.m1 - is.na(m1) na.m2 - is.na(m2) ifelse(na.m1 na.m2, NA, ifelse(na.m1, 0, m1) + ifelse(na.m2, 0, m2)) On Jan 28, 2008 9:34 PM, Ng Stanley [EMAIL PROTECTED] wrote: Hi, For example, given two 2x2 matrices m1 and m2. I would like to add/subtract element by element m1 [,1] [,2] [1,] NA NA [2,]12 m2 [,1] [,2] [1,]1 NA [2,] NA2 m1 + m2 [,1] [,2] [1,] NA NA [2,] NA4 How can I ignore the NA, and get this ? Hope the solution can be extended to subtract and modulo also. [,1] [,2] [1,] 1 NA [2,] 14 [[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] Using Predict and GLM
Your problem is that your newdata data frame only specifies what the value for A is in the predictions. The values for W1 and W2 are unspecified. To predict from fitted models, you need to specify the values you wish to use for *all* the predictor variables, not just the one (I presume) is different from the estimation set. Assuming that is what you want to do, here is a version of your script that you may care to look at fairly closely. I have omitted all the unnecessary bits, (I could find), put the variables in a data frame instead of leaving them strewn around the global environment, and done a couple of predictions just to show it works. _ set.seed(644) n0 - 200 # number of observations myData - data.frame(W1 = rnorm(n0, mean = 2, sd = 2), W2 = rnorm(n0, mean = 3, sd = 8)) myData - transform(myData, # add A A = rbinom(n0, 1, ifelse(W1 1.5, 0.4, 0.2))) myData - transform(myData, # add Y Y = rbinom(n0, 1, 1/(1+exp(-(10*A-5*(W1)^2+2*W2) Q - glm(Y ~ A + W1 + W2, family = binomial, data = myData) pData - transform(myData, A = 0) # keep W1 and W2 as they were QA - predict(Q, newdata = pData) # linear predictors QR - predict(Q, newdata = pData, type = response) # probs plot(QA, QR) _ Bill Venables. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sherri Rose Sent: Tuesday, 29 January 2008 1:27 PM To: r-help@r-project.org Subject: [R] Using Predict and GLM Dear R Help, I read through the archives pretty extensively before sending this email, as it seemed there were several threads on using predict with GLM. However, while my issue is similar to previous posts (cannot get it to predict using new data), none of the suggested fixes are working. The important bits of my code: set.seed(644) n0=200 #number of observations W1=rnorm(n0,mean=2,sd=2) #Use rnorm to generate W1 W2=rnorm(n0,mean=3,sd=8) #Use rnorm to generate W1 Aprob=matrix(.2, nrow=n0, ncol=1) #generating the probability of A #generating probability of A dependant on W1 for(i in 1:n0){ if (W1[i]1.5) {Aprob[i]=0.4} } A=matrix(rbinom(n0, 1, Aprob), nrow=n0, ncol=1) #generating the 0/1 exposure Yprob=1/(1+exp(-(10*A-5*(W1)^2+2*W2))) Y=matrix(rbinom(n0, 1, Yprob), nrow=n0, ncol=1) #generating the 0/1 exposure zero=data.frame(rep(0, n0)) Q=glm(cbind(Y, 1-Y) ~ A + W1 + W2, family='binomial') QA=predict(Q, newdata=as.data.frame(A)) Q0=predict(Q,newdata=(A=zero)) I've tried many variations of the last line (Q0) to get the predicted values when A=0 with no luck. With this code, I get errors that my A=zero is a list even though I made it into a data frame. This is the version of the code (after my reading) that *should* work for predict once I can get it to accept that it is not a list. With other variants of the line that will run but are not syntactically correct, my QA and Q0 are the same. Any guidance would be appreciated! Sherri [[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] NLMINB convergence codes
According to the R documentation for NLMINB, the returned value of convergence is 0 for successful convergence. When I got another code (1), I looked up the PDF that linked from the documentation (http://netlib.bell-labs.com/cm/cs/cstr/153.pdf), which said that a return code under 3 was impossible. Is there other documentation that gives the correct meanings of the NLMINB convergence codes in the R implementation? Thanks! Rebecca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] error message + boot library
Dear all; What can be wrong with this simple example? library(boot) d1-c(rnorm(10,mean=10)) fm-function(d,i) mean(d[i]) bd1-boot(d1,fm,1) Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Thanks for any idea __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 message + boot library
I wonder what your sessionInfo() is... I copied and pasted your example and could not reproduce the problem (ie, worked just fine). b On Jan 29, 2008, at 12:27 AM, Pedro Mardones wrote: Dear all; What can be wrong with this simple example? library(boot) d1-c(rnorm(10,mean=10)) fm-function(d,i) mean(d[i]) bd1-boot(d1,fm,1) Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Thanks for any idea __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] error bar ploting problem with 'arrows' function
Hello, I used 'arrows' function to plot the error bar but it dosen't work always. For example: Similar commands on two different data sets gives first result OK and second result NOT (attached plot1 is OK and plot2 is NOT). Plots as well as data file is attached here. Below is the script which I used for arrow ploting. Kindly help, Yogesh *Script for error bar plot1:* plot(file3$lat,file3$STotwoKm,pch=21,cex=2.5,ylim=c(-4,10),xlim=c(-50,50),xlab=NA,ylab=NA, col=1, xaxs=i,yaxs=i) arrows(file3$lat,file3$STotwoKm,file3$lat,file3$STotwoKm+sqrt(file3$var1), col=1, code=2, angle=90,length=0.1) arrows(file3$lat,file3$STotwoKm,file3$lat,file3$STotwoKm-sqrt(file3$var1), col=1, code=2, angle=90,length= 0.1) ** ** ** *Script for error bar plot2:* ** *##* ** plot(file3$lat,file3$twoTOfive,pch=22,cex=2.5,ylim=c(-4,10),xlim=c(-50,50),xlab=NA,ylab=NA, col=2,xaxs=i,yaxs=i) arrows(file3$lat, file3$var2, file3$lat,file3$twoTOfive+sqrt(file3$var2), col=2, code=2, angle=90, length=0.1) arrows(file3$lat, file3$var2, file3$lat,file3$twoTOfive-sqrt(file3$var2), col=2, code=2, angle=90, length=0.1) ### -- Yogesh K. Tiwari (Dr.rer.nat), Scientist, Indian Institute of Tropical Meteorology, Homi Bhabha Road, Pashan, Pune-411008 INDIA Phone: 0091-99 2273 9513 (Cell) : 0091-20-258 93 600 (O) (Ext.250) Fax: 0091-20-258 93 825 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.