Re: [R] Regarding Savitzky-Golay Smoothing Filter
On 02/22/2011 10:34 AM, reynolds pravindev wrote: > Hi > When we use the sav_gol command in R , it shows an error which says: " > error in as.matrix". We've downloaded the necessary packages. Kindly > help us with this issue. If there is any other function to perform > Savitzky-Golay smoothing in R, please let me know. > > With Regards > Reynolds > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Paul Hiemstra, MSc Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] parallel bootstrap linear model on multicore mac (re-post)
On 03/02/2011 11:38 PM, Anthony Dick wrote: > Hello all, > > I am re-posting my previous question with a simpler, more transparent, > commented code. > > I have been ramming my head against this problem, and I wondered if > anyone could lend a hand. I want to make parallel a bootstrap of a > linear mixed model on my 8-core mac. Below is the process that I want to > make parallel (namely, the boot.out<-boot(dat.res,boot.fun, R = nboot) > command). This is an extension to lmer of the bootstrapping linear > models example in Venables and Ripley. Please excuse my rather terrible > programming skills. I am always open to suggestions. Below the example I > describe what methods I have tried. > > library(boot) > library(lme4) > dat<-read.table("http://www2.fiu.edu/~adick/downloads/toy2.dat > <http://www2.fiu.edu/%7Eadick/downloads/toy2.dat>", header = T) > nboot<-1000 # number of bootstraps > attach(dat) > x<-dat[,2] # IV number 1 > y<-dat[,4] # DV > z<-dat[,3] # IV number 2 > subj<-dat[,1] # random factor > boot.fun<-function(data,i) { # function to resample residuals >d<-data >d$y<- d$fitted+d$res[i] # populate new y values based on > resampled residuals >as.numeric(coef(update(m2.fit,data=d))[1][[1]][1,c(1:4)]) > # update the linear model and output the coefficients >} > fit<-lmer(y~x*z + (1|(subj))) # the linear model > dat.res<-data.frame(y,x,z,subj, res=resid(fit), fitted=fitted(fit)) # > add residuals and fitted values to dat > boot.out<-boot(dat.res,boot.fun, R = nboot) # run the bootstrap using > the boot.fun > boot.out > > Methods attempted: > > Using the multicore package, I tried > boot.out<-collect(parallel(boot(dat.res,boot.fun, R = nboot))). This > returned a correct result, but did not speed things up. Not sure why... Hi Anthony, When the individual calls passed on to the cluster are very short (which might be the case for your bootstrap), the overhead of running them parallel becomes very large, negating the positive effect of running the processes parallel. This could be an explanation for the lack of speed improvement. A solution could be to not send individual bootstrap calls to the cluster, but sets of calls. This decrease the overhead for parallel running. cheers, Paul > I also tried snowfall and snow. While I can create a cluster and run > simple processes (e.g., provided example from literature), I can't get > the bootstrap to run. For example, using snow: > > cl<- makeCluster(8) > clusterSetupRNG(cl) > clusterEvalQ(cl,library(boot)) > clusterEvalQ(cl,library(lme4)) > boot.out<-clusterCall(cl,boot(dat.res,boot.fun, R = nboot)) > stopCluster() > > returns the following error: > > Error in checkForRemoteErrors(lapply(cl, recvResult)) : > 8 nodes produced errors; first error: could not find function "fun" > > I am stuck and at the limit of my programming knowledge and am punting > to the R-help list. I need to run this process thousands of times, which > is the reason to make it parallel. Any suggestions are much appreciated. > > > Anthony > -- Paul Hiemstra, MSc Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Howto view function's source code of an installed package
Gundala Viswanath wrote: Hi, Is there a way I can view the functions source code of a package I installed in my PC. For example I downloaded the great "mixtools" package. I want to see the source code of one of its function "normalmixEM" Is there a way to do it? Presumably from R command prompt? I tried to take a look at the zip file, but somehow I can't seem to find the file on which I can find the source code. Please advice. - Gundala Viswanath Jakarta - Indonesia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, You can see the R-source code of a function if you give the command without the brackets. For example: > sort function (x, decreasing = FALSE, ...) { if (!is.logical(decreasing) || length(decreasing) != 1) stop("'decreasing' must be a length-1 logical vector.\nDid you intend to set 'partial'?") UseMethod("sort") } Another option is to download the .tar.gz source package from CRAN, unpack it and the R source code is available in the "R" subdirectory. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +31302535773 Fax:+31302531145 http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-sig-Geo] Spatial Sample
Hi, One option is: ?spsample cheers, Paul Raphael Saldanha schreef: Hi! How can I make a spatial sample? Can someone recommend theorical books and materials for this? -- Raphael Saldanha UFJF - Brazil [[alternative HTML version deleted]] ___ R-sig-Geo mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-sig-geo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installing R in Ubuntu
Hi, If you download a package to your harddrive for installation you need to use the dpkg command like: 1) Download pacakge (foo.deb) 2) Go to the directory 3) dpkg -i foo.deb But I would advise against this because it is better to use repositories so R get updated automatically. The standard ubuntu repositories have old versions of R, see http://cran.r-project.org/bin/linux/ubuntu/ for a description of how to add the CRAN repositories for the latest version of R. You can also install a lot of R packages from this repository, doing this also ensures that they are automatically updated. cheers and hth, Paul Shreyasee Pradhan wrote: Hi, Thanks for that. the way I tried is as follows: 1) Downloaded the r-base package 2) went in that directory where the r-base package was downloaded from command line 3) entered the command sudo apt-get install r-base But got the error, that Couldn't find r-base command. I don't understand where I went I wrong. I will definitely try the following commands. Thanks, Shreyasee On Wed, Aug 13, 2008 at 12:02 PM, Senthil Kumar M <[EMAIL PROTECTED]>wrote: On Tue, Aug 12, 2008 at 9:24 PM, Shreyasee Pradhan <[EMAIL PROTECTED]> wrote: Hi, I am running Ubuntu on my Windows OS through VMware. I am trying to install R in Ubuntu, but not getting with those commands, which are there on the site. Can anyone please tell me how to install it, stepwise, with commands to be used. As I m new to Ubuntu as well, I am not aware of the commands very well. Hi, What commands did you try ? What worked and what didn't ? Which site did you refer ? Please read the posting guidelines here: http://www.r-project.org/posting-guide.html In the Ubuntu command line, try: sudo aptitude install r-base And for a list of R packages that you can install from the Ubuntu repositories: aptitude search r- | grep [^A-Za-z0-9] r- Install them like this: sudo aptitude install r-cran-package-name HTH, Senthil -/ "You see, but you do not observe. The distinction is clear." Sir Arthur Conan Doyle in, "The Memoirs of Sherlock Holmes" [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +31302535773 Fax:+31302531145 http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Coordinate systems for geostatistics in R
imicola schreef: Hi, I read somewhere that when carrying out geostatistical analysis in R you should not use latitude and longitude...can anyone expand on this a little for me, and what would be the best coordinate system to use? I have my data in a geographic coordinate system, WGS84, decimal degreesis this the wrong format for such analyses? I have also converted my data in the UTM projection and so have it in metres(ranging from 480,000 to 550,000 E and 170,000 to 230,000 N). If I was to use the UTM coordinates, should I be using the actual coordinates in metres, or should I convert this into an arbitrary coordinate system (i.e. from 0 - 1) somehow? I have noticed that running an analysis on the data gives different results depending on which type of system you use, so I want to make sure I have the correct system. I should also probably note that I am a geostatistical novice! Thanks, Hi, I use the gstat package for geostatistics. For doing the analysis I don't think it is necessary to convert to UTM. But maybe just do it to be on the safe side. If you use the spatial objects provided by the sp-package (http://cran.r-project.org/web/packages/sp/vignettes/sp.pdf) you transform your data to other projections using the spTransform package. Questions regarding geostatistics and spatial data will result in more answers on the r-sig-geo list. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +31302535773 Fax:+31302531145 http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] printing a dataframe summary to disk
Philip A. Viton wrote: I'd like to write the summary of a dataframe to disk, so that it looks essentially the same as what you'd see on screen; but I can't seem to do it. Can someone tell me how? Thanks! Philip A. Viton City Planning, Ohio State University 275 West Woodruff Avenue, Columbus OH 43210 vito...@osu.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, Does: write.table(summary(your_df), "yourfile") give you something you like? What is the reason that you want to write the summary to a file? cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Remove columns
Hi, This line of code does the trick: a[,which(apply(a, 2, sum) != 0)] cheers, Paul Alberto Lora M wrote: Hi Everbody Could somebody help me.? I need to remove the columns where the sum of it components is equal to zero. For example a<-matrix(c(0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0), ncol=4) a [,1] [,2] [,3] [,4] [1,]0001 [2,]0101 [3,]0000 [4,]0100 [5,]0001 [6,]0000 Columns 1 and 3 should be removed the result should be the dollowing matrix [,2] [,4] [1,]01 [2,]11 [3,]00 [4,]10 [5,]01 [6,]00 Thanks again __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] open txt
Stela Valenti Raupp wrote: Não consigo abrir a pasta txt no R, dá a mensagem: Warning message: In file(file, "r") : cannot open file 'plantula.txt': No such file or directory O arquivo está na mesma página do Scrip. Não sei qual é o problema [[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. I've got no clue what you say apart from the warning message. But the message suggests that there is "No such file or directory". Use list.files() to see which files are in your current working directory. Use setwd() to change to the correct working directory, which is probably the problem. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Several simple but hard tasks to do with R
Rakknar wrote: Hello everybody. I've been learning R for about a month to do a econometric study and now i'm stuck with some problems to make R do the things I want. Here I give the list of things I wanna do from the most simple to the more complex (for me of course): 1. Make a log. I've been using Stata and there i have a great tool to register what the program do: the log file, wich it's a simple .txt file where Stata writes every output it makes (not graphics of course). When I wanted to make the same thing with R I started to use the function sink() but it only register the results of the commands (summaries for example) and not the commands itself, witch it's really uncomfortable because it's harder to find out to witch command that results come from. Hi, I would recommend not using the command line as such too much. Making a script on your harddrive and always working from that seems a better to me. If you have some data on your harddrive (csv for example) you can write a script that takes that data and produces your results (graphs, lm's etc). This ensures that you can always later see how you have done your analysis, and redo if necessary. See also this e-mail on R-help http://www.nabble.com/PowerCut-Killed-R---is-my-code-retrievable--td25052662.html#a25052662. cheers and hope this helps, Paul 2. Saving objects in a .Rdata step by step. I want to save several regressions of interest in one .Rdata file. I want to save this results one by one. For example: make regression 1, save the result in the .Rdata file; then make the regression 2 and save the results in the same .Rdata file. I know I could make all the regressions and save the results all at once but for the kind of study I want to make It would be much useful this way. I've been using function save() but I only could save one result or all. 3. Conditional reading. I want to run regressions conditional to the existence of a .Rdata file (the one I would be making in step two). The condition would be something like If "you find X.Rdata file" run regression with X.Rdata data else run regression from the 0. I hope I can find help here. Thanks!! -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] print selected variables
rajclinasia wrote: Hi every one, I read one excel external file into R, in that R dataset i have 20 variables. now my querry is i want to print only selected variables (eg:10 variables) with complete data. pls send me the code it will be very helpful for us. Thanks in Advance. Hi, Please read the posting guide. It is very hard for us to give good advice right now. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Hello
dimple thyagarajan wrote: Hello! I am trying to merge two xy-plot with different ylimits. It seems that you are using lattice graphics (which you do not mention), if so, look at the documentation of xyplot, specifically to the panel argument. cheers, Paul Can someone please give me possible way of achieving it.. Thank you Regards Dimple [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] creating gantt chart
rajclinasia wrote: Hi every one, I have a R dataset like this. labels starts ends first task 2004-01-01 2004-03-03 second task 2004-02-02 2004-05-05 third task 2004-03-03 2004-06-06 fourth task 2004-04-04 2004-08-08 fifth task 2004-05-05 2004-09-09 now i want to create gantt chart for this data. can any body help us in code, it will be very helpful for us. Thanks in Advance. Hi, RSiteSearch("gantt chart") type "R-help gantt chart" in to google cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] When factor is better than other types, such as vector and frame?
Peng Yu schreef: Hi, It is easy to understand the types vector and frame. But I am wondering why the type factor is designed in R. What is the advantage of factor compare with other data types in R? Can somebody give an example in which case the type factor is much better than other data types? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Hi, Hi, Factor is better when the variable is categorical, such as 'Forest', 'Woodland' etc. When performing for example an lm() the categorical variables have to be a factor in order for R to recognize it in that way. cheers, Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] image plot
ogbos okike schreef: Hi, I am trying to use the image function to do a color plot. My matrix columns are labeled y and x. I tried >image(y, x) but I had error message ("Error in image.default(y, x) : increasing 'x' and 'y' values expected"). Could anybody please tell me how to add these increasing 'x' and 'y' values. Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, Please provide a reproducible example. An example that works with image: x = 1:10 y = seq(1,100,by =10) z = matrix(runif(100), 10, 10) image(x,y,z) x = sort(runif(10)) y = sort(runif(10)) image(x,y,z) So z is a matrix with the values and x and y tell the dimensions of each cell, often with equal interval. cheers, Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 set crontab for updating the repositories?
Sukhbir Rattan wrote: Hi, I have downloaded around 60GB package repositories of bioconductor to use it locally and to set up mirror at my university site. I have installed the mirror with rsync command and able to access also. Now I have to set a cron job for its daily updating from bioconductor website. How should I do it? I know rsync have to be used but I don't know the proper syntax. I request to send proper syntax. Thanks, Sukhbir Singh Rattan. [[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. Hi, Typing: crontab -e Will open the crontab file for the current user, here you can add commands that are to executed at certain times. The crontab will look something like: # m h dom mon dow command 0 0 * * * /foo/bar where the command /foo/bar will be executed every day (dom, mon and dow are a *, meaning 'for all') at 12 pm. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Trying to rename spatial pts data frame slot that isn't a slot()
Hi Tim, I don't know the answer to your problem, but I do know that you might consider reposting this question to the r-sig-geo mailing list. There you will find a geographically oriented audience, which will probably lead to better and faster answers. cheers, Paul Tim Clark wrote: Dear List, I am analyzing the home range area of fish and seem to have lost the individuals ID names during my manipulations, and can't find out how to rename them. I calculated the MCP of the fish using mcp() in Adehabitat. MCP's were converted to spatial points data frame and exported to qGIS for manipulations. At this point the ID names were lost. I brought the manipulated shapefiles back into qGIS, but can't figure out how to rename the individuals. #Calculate MCP and save as a shapefile my.mcp<-mcp(xy, id=id, percent=100) spol<-area2spol(my.mcp) spdf <- SpatialPolygonsDataFrame(spol, data=data.frame +(getSpPPolygonsLabptSlots(spol), +row.names=getSpPPolygonsIDSlots(spol)), match.ID = TRUE) writeOGR(spdf,dsn=mcp.dir,layer="All Mantas MCP", driver="ESRI +Shapefile") #Read shapefile manipulated in qGIS mymcp<-readOGR(dsn=mcp.dir,layer="All mantas MCP land differenc") My spatial points data frame has a number of "Slot"s, including one that contained the original names called Slot "ID". However, I can not access this slot using slot() or slotNames(). slotNames(mymcp) [1] "data""polygons""plotOrder" "bbox" "proj4string" What am I missing here? Is Slot "ID" not a slot? Can I export the ID's with the shapefiles to qGIS? Can I rename the ID's when I bring them back into R? When is a slot not a slot()? Thanks, TIm Tim Clark Department of Zoology University of Hawaii __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sppolot: fill below minimum legend value
emorway wrote: In the plot below, there are some grid cells that have values below 10, which is the lowest "cut" value I have specified. Is there a way, without adjusting the number of cuts, to tell R to fill in those cells with the lowest possible color (in this case greeen)? There is a white "hole" in the image about a quarter of the way in from the left side, this is what I would like to correct. Thanks...Eric The code: pts<-list("sp.points",K.dat,pch=3,col="black") cuts<-c(10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000) spplot(lzm.krige.dir["var1.pred"],at=cuts,colorkey=list(at=log10(cuts),at=log10(cuts),labels=as.character(cuts)),scales=list(draw=TRUE), xlab="Easting",ylab="Northing",key.space="right",cex=1.1,col.regions=terrain.colors(30),main="Hydraulic Conductivity of Layer 2",sp.layout=list(pts)) The image: http://www.nabble.com/file/p25392472/Image3.jpeg Hi Eric, As far as I know you need to set the lower value of cuts to the minimum of the dataset to prevent this white space from occuring. If you don't want to see this in the colorbar, you need to adjust it using the colorkey argument. And a non-technical note, you e-mail doesn't give a lot of background regarding your problem. spplot is a function that is only used by people working with geographic data, which is probably a small subset of the total community. See the posting guide for some hints about what kind of information is necessary in an e-mail to r-help, for example a reproducible example. In addition, there is a mailing list specifically meant for geographic data, r-sig-geo, where you are more likely to get the answers you are looking for. cheers and good luck, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] setting plotting device
utkarshsinghal wrote: Hi All, I have recently *re*-installed R-2.9.1 in my Linux machine. Hi, Did you use the package manager of you linux distro, or did you compile from source. cheers, Paul Since then, I am unable to plot using the usual interactive device. > plot(1:10) This plots in a pdf file "Rplots.pdf" in my working directory. > sessionInfo() R version 2.9.1 (2009-06-26) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base > dev.cur() null device 1 > capabilities(what = NULL) jpeg png tifftcltk X11 aqua http/ftp sockets FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE libxml fifo clediticonv NLS profmemcairo TRUE TRUE TRUE TRUE TRUEFALSEFALSE > dev.interactive() [1] FALSE Before re-installation, everything was working perfectly. Please suggest, how do I set the interactive device as default? Thank in advance, Regards, Utkarsh [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 set default plotting colors by treatment?
Remko Duursma wrote: col=c("blue","red")mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... The problem is that the info in 'treatment' is non-constant, and you need to either pass on the info into the scope of the function, or you need to calculate the values in 'treatment' inside the function. Could you provide us with a reproducible example (as suggested in the posting guide), that would make it much easier for us to answer you question veel succes! Paul remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) wrote: # I tried defining a function like this myplot <- function(...)plot(..., pch=19, col=c("blue","red")[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot <- function(...) { plot(..., pch=19, col=c("blue","red")mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 set default plotting colors by treatment?
I offer my sincere apologies for not reading the e-mail carefully, your example is indeed reproducible. When you stop using the 'with' function, this is I think what you would like: myplot2 = function(formula, data, ...) { plot(formula, data = data, ..., pch = 19, col = c("blue","red")[data$treatment]) } myplot2(Ymeas~Xmeas, mydfr) A possible problem occurs when you want to redefine 'pch' or 'col', e.g.: myplot2(Ymeas~Xmeas, mydfr, pch = 20) Error in localWindow(xlim, ylim, log, asp, ...) : formal argument "pch" matched by multiple actual arguments cheers and hope this helps, Paul Remko Duursma wrote: The example is reproducible! Did you see the first post? remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 9:19 PM, Paul Hiemstra wrote: Remko Duursma wrote: col=c("blue","red")mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... The problem is that the info in 'treatment' is non-constant, and you need to either pass on the info into the scope of the function, or you need to calculate the values in 'treatment' inside the function. Could you provide us with a reproducible example (as suggested in the posting guide), that would make it much easier for us to answer you question veel succes! Paul remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) wrote: # I tried defining a function like this myplot <- function(...)plot(..., pch=19, col=c("blue","red")[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot <- function(...) { plot(..., pch=19, col=c("blue","red")mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] installation problem
wesley mathew wrote: Hello All I have some problem for installing XML_2.6-0.tar . I am working in widows and R version is R-2.9.1 >*install.packages("XML")* After selecting a CRAN mirror ** *Error :-* Warning: unable to access index for repository http://cran.pt.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning messages: 1: In open.connection(con, "r") : unable to connect to 'cran.r-project.org' on port 80. 2: In getDependencies(pkgs, dependencies, available, lib) : package ‘XML’ is not available ** Hi, Sounds like either: - The mirror is broken, try a few others - You are behind a proxy server, configure you machine to use the proxy server >*install.packages( "c:/program files/R/XML_2.6-0.tar.gz", type="source", repos=NULL)* *Error :-* 'sh' is not recognized as an internal or external command, operable program or batch file. This doesn't work in windows if you have not installed the Rtools (http://www.murdoch-sutherland.com/Rtools/). Try to install those first, or download and install the windows binary version. cheers, Paul Thanks in advance for your help Kind Regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] call for input
Martin Batholdy wrote: Hi, is there a way to make a call for an input at some point of a process ..? I don't know how to describe it well ... like; please enter your first name: > and then, what is typed in should be saved into a variable. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, Look at the readline() function. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] releasing memory when using the ncdf package
Hi, Try the gc() command. cheers, Paul eric lee wrote: Hello, I'm running R 2.7.2 in a windows XP environment and I run the following in an R console: library(ncdf) nc <-open.ncdf('c:/file.nc') aa <- get.var.ncdf(nc,'var1') This works fine, but 'aa' takes up about 100mb and I want to release the memory after using it. I try: rm(aa) close.ncdf(nc) and look at Windows Task Manager, but the memory hasn't been released. Do you know what I should do to release the memory? Thanks in advance. eric __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 can we check file empty or not
deepak m r wrote: Hi All, I need to check whether the file is empty or not, Please help me in this regards. Best regards, Deepak.M.R __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, file.info("your_file")$size == 0 cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 repeat the names?
Hi, Take a look at rep(), specifically the each = parameter. cheers, Paul Madhavi Bhave wrote: Dear R helpers I have a city.csv file as given below. 'city.csv' city_name1city_name2 New York CityBuffallo So I define city_name = read.csv('city.csv') city1 = city_name$city_name1 city2 = city_name$city_name2 My problem is how do I repeat the names one after other say 10 times i.e. my output should be like New York City Buffallo New York City Buffallo New York City Buffallo New York City ... ... ... ... I have tried the following commands rep(c(city1,city2), 5) and I got the output something like this [1] 1 1 1 1 1 1 ... If I try rep((city1,city2), 5) Error: unexpected ',' in "rep((city1," Please guide Regards MAdhavi Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/ [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Total least squares linear regression
Hi, The wikipedia shows the matrix algebra that calculates Total regression, you could put this into R code to solve your problem. Also take a look at the pcrcomp or svd function for singular value decmoposition implementation. This would probably not be generic, but that is not a problem for you. groet, Paul Gnewbee wrote: Dear all, After a thorough research, I still find myself unable to find a function that does linear regression of 2 vectors of data using the "total least squares", also called "orthogonal regression" (see : http://en.wikipedia.org/wiki/Total_least_squares) instead of the "ordinary least squares" method. Indeed, the "lm" function has a "method" argument but the manual says that there is only one option so far. However, since the samples I am studying have the type of relationship that requires orthogonal regression, I am bound to use it. The only thing I've found so far is the "tlsce" function in the "BCE" package (see : http://cran.r-project.org/web/packages/BCE/index.html) but I'm not sure it's of general use or designed for the particular application of taxonomy, since its arguments are supposed to be matrices. If any of you knew a function that does this or had a personnal script to do this kind of regression, I'd be very grateful. Thanks a lot in advance Gnewbee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 can I associate a list of defined names with the dataframes to be downloaded
Alex Levitchi wrote: Hello I am very thankful for the reply from Jim Holtman and David Winsemius, especially for the understandable explanations. it really works. Now I get another problem I cannot figure out. That is the situation: I work in biology. I need to download several files according to an experiment, which can be find out in NCBI GEO, and store them. For this I use GEOquery package and getGEO function. Each experiment (named GSE) contains several Samples (GSM), which names I extract by names(GSMList()). So now I want to make association between the defined names, which represents lowercases names of GSM, having them from names(GSMList()) as class(names(GSMList(gse))) [1] "character" I wrote something like this lapply=(i=1:length(names(GSMList(gse))), lgsms[i]=getGEO(names(GSMList(gse))[i])) Hi Alex, please read the lapply documentation carefully, don't guess the correct syntax. But after looking at the docs of lapply, the examples aren't very clear. The correct syntax is somewhere along the lines of this: geo_list = lapply(names(GSMList), function(name) { return(getGEO(name) ) }) you can read this piece code aloud like, "for all names in GSMList do the function getGEO and return the results in a list". cheers, Paul but "Error: unexpected ',' " or anything else if I try to make it directly by associating a name from the list to correspondent GEO file I get this lgsms[1]=getGEO(names(GSMList(gse))[1]) #lgsms - list of lowercases names from names(GSMList()) File stored at: /tmp/RtmpgnMuHv/GSM296650.soft # so it downloaded the file but didn't make the association with the name so I cannot use it. Error in lgsms[1] = getGEO(names(GSMList(gse))[1]) : incompatible types (from S4 to character) in subassignment type fix Generally, working with GEOquery should be done very careful, as previously I also have some problems regarding the characteristics of data extracted from it and the way to convert them in an affordable way. It is a pity, that authors don't give more explanations on it. So I suppose it is also here. Kind regards Alex Levitchi [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extending data frame with longer columns
Ralf B wrote: Hi, I am a beginner in R and have only read a few chapters in the R book, I was not able to find a solution for this simple problem. I have an empty data frame: a=data.frame(name="test") which I would like to extend in a for-loop (with data extracted from a database). Ideally I would like to extend the data frame like this: a["new_1"] = 1:10 a["new_1"] = 1:12 a["new_1"] = 1:14 I would first read all the data into a list (maybe using lapply), where the columns are the parts of the list. Then you can find out which one is longest, and add NA's at the end of the other columns, and than use do.call("cbind", list_of_columns) to get the resulting data.frame: note that I use apply type of constructs a lot, it is sort of one line for loop. # Create a mockup list for this particular example column_list = lapply(round(runif(5, 1, 10)), function(len_column) { rep(len_column, times = len_column) }) # Find the length of the columns in the list len_columns = sapply(column_list, length) # add the NA's dum = lapply(column_list, function(col) { c(col, rep(NA, max(len_columns) - length(col))) }) # Make the dataframe dat = data.frame(do.call("cbind", dum)) it is quite a manual way of doing it, maybe someone else knows of an available R function to do it. But this is how I would do it. cheers, Paul R now obviously complains about the changing length of the new columns. However, I would like to have missing values being added whenever columns are shorter than a newer (longer) column. How can I do that? Thanks, Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bayesian Block Kriging?
Hi Candan, As a more general remark, there is a mailing list for spatial data, including interpolation, r-sig-geo. This question would be more appropriate there. I gave some answers in-line below from what I could come up with. Reposting on r-sig-geo would be a good idea to get more response. cheers, Paul Candan Soykan wrote: Hello, I'm interested in doing Bayesian kriging using R. I see that the package geoR has a function that will allow one to do this (krige.bayes). However, my data are not in the form of points, but rather they are blocks that represent spatial averages (i.e., the number of fishing hooks per month in a given lat x long square). I am therefore interested in treating the data as spatial blocks, rather than points. I see that package gstat has a function that will allow one to do block kriging (krige). However, I cannot find a function that will allow me to do both, Bayesian and block kriging at the same time. My questions are: 1) Can the function "krige.bayes" be made to accommodate data in areal form (rather than point data)? or possibly, I've never used krige.bayes 2) Does the function "krige" allow for Bayesian inference (i.e., priors, posteriors)? or to my knowledge, no 3) Is there another package that can do both? or I think not 4) Is there a method for combining functions to do what I would like to do? write a new function that combines both things you want (you question is a bit vague) A response to any and/or all of these questions would be greatly appreciated. Thank you in advance. Candan Soykan candan.soy...@noaa.gov __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting values from a list
chipmaney schreef: I have run a kruskal.test() using the by() function, which returns a list of results like the following (subset of results): Herb.df$ID: 4-2 Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841 Herb.df$ID: 44-1 Kruskal-Wallis chi-squared = 4.43, df = 6, p-value = 0.6187 So then, how do extract a vector of p-values (i.e., result$p.value) for every element in the list? If result$p.value normally returns the p value from a kruskal.test result you can probably do something like: vector_pvalues = sapply(result_from_by_list, function(x) x$p.value) cheers, Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting multiple table automatically
KennyL wrote: Hi All, I have a slight issue getting R to plot a series of tables automatically. Essentially I have a series of tables that I wish to plot. They are named on_2, on_3 etc. based on the file name when they were read in. I have filelist <- list.files() to give me list of the table names. I wish to plot each table, so I was thinking along some kind of for loop as below: for (i in 1:Number_Files) { plot(filelist[1]) } With a few other bits a pieces, however obviously this tries to plot the character string in filelist, any ideas on how to get R to read the identically named table and plot that? Thanks, Kenny Hi Kenny, Take a look at parse() if you want it do your way, but consider the following much better way. Read the files into a list first not in seperate R objects, something like: list_tables = lapply(list.files(), read.table) ?lapply and plot: for(tab %in% list_tables) plot(tab) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dot-dot-dot as an actual argument
Jyotirmoy Bhattacharya wrote: I could not find any documentation of how dot-dot-dot works when used as an argument in a function call (rather than as a formal argument in a definition). I would appreciate some references to the rules governing situations like: f1<-function(x,y,...){ print(x) } it would print(x), probably complain that y is missing f2<-function(...){ f1(...) } f2(1,2,3) Hi! print the .. and see what happens: f2<-function(...){ f1(...) print(list(...)) } f2(1,2,3) In the call above how are the three numbers bound to the individual formal arguments x and y of f1 rather than f1 being called with a single pairlist, which is what the documentation says ... is. And while the example above succeeds, why does the following fail, library(lattice) f.barchart <- function(...) { barchart(...) } x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), d = c(1,2,2,1)) print(f.barchart(a ~ b, data = x, groups = d)) This gives the error: Error in eval(expr, envir, enclos) : ..3 used in an incorrect context, no ... to look in The problem is that d is a column in x and not a seperate R object. This is solved in barchart because the function knows that it needs to look in x for d. The problem only is that when the third (group = d) is taken from the ... (..3) it doesn't find any R object called d. So it crashes with the above error. cheers, Paul Jyotirmoy Bhattacharya __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting values from a list
chipmaney wrote: Thanks, as a follow-up, how do i extract the list element name (ie, 4-2 or 44-1) Look at names(your_list) cheers, Paul thanks, chipper Date: Thu, 18 Feb 2010 11:56:45 -0800 From: ml-node+1560750-540257540-69...@n4.nabble.com To: chipma...@hotmail.com Subject: Re: Extracting values from a list Try this: sapply(x, '[', 'p.value') On Thu, Feb 18, 2010 at 5:21 PM, chipmaney <[hidden email]> wrote: I have run a kruskal.test() using the by() function, which returns a list of results like the following (subset of results): Herb.df$ID: 4-2 Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841 Herb.df$ID: 44-1 Kruskal-Wallis chi-squared = 4.43, df = 6, p-value = 0.6187 So then, how do extract a vector of p-values (i.e., result$p.value) for every element in the list? -- View this message in context: http://n4.nabble.com/Extracting-values-from-a-list-tp1560701p1560701.html Sent from the R help mailing list archive at Nabble.com. __ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 generate graph from dataframe?
chinna wrote: I connected to database and i am accessing the tables but i dont know how to generate graphs from the database tables. can anyone please help me i am new to R project Hi, Take a look at the plot() command. Or you can have a look at the lattice or ggplot2 packages. The book R graphics by Paul Murrel is a good book on R graphics. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] (Somewhat) broken EPS files produced
Hi Wartan, Not really an answer to your specific problem, but you could try to use pdf instead of eps, in combination ofcourse with pdflatex. I've never had problems with pdf nad Sweave. If you need to use eps, than my reply is of no help to you :). cheers, Paul Wartan Hachaturow wrote: Hello. I'm writing some simple text using sweave, and faced a strange problem with eps files produced for my plots (one example attached). Individual eps files are interpreted by ghostscript just fine, and show up without errors. But once I try to include them into main LaTeX/Sweave document (using regular \includegraphics, produced by Sweave), ghostscript gives me this error on those files: Error: /undefinedresult in --stringwidth-- Operand stack: (600) 0.5 Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1878 1 3 %oparray_pop 1877 1 3 %oparray_pop 1861 1 3 %oparray_pop 1755 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- Dictionary stack: --dict:1157/1684(ro)(G)-- --dict:0/20(G)-- --dict:82/200(L)-- --dict:178/300(L)-- --dict:91/200(L)-- Current allocation mode is local Current file position is 207944 GPL Ghostscript 8.71: Unrecoverable error, exit code 1 What might be the problem? P.S. I get exactly the same behavior on Debian/sid and OS X. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generating reports from database through R
durga chennu wrote: Hi, after some research now i am connecting to the database .but i am not getting any reports can u please tell me any suggestions or ideas. Regards chinna. [[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. Hi Chinna, Please be much more specific as to what you want, both in terms of the analysis and the report. Please read the posting guide carefully, sticking to it will get you much better responses from the mailing list. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] export graphics for editing in Illustrator
Ivan Calandra wrote: Dear R users, I would like to edit my graphics in Illustrator. I know that I can set up almost every graph parameter in R, but the time I will spend searching for the correct settings might not be worth since I'm quite used to Illustrator and since I will in any case use Illustrator to prepare for publication. Up to now, I've used savePlot() with type=("eps") but I'm unable to dissociate every part of the plot in Illustrator. Is there a better way to do it? Another function, another package, or a completely different approach? I'm of course open to all suggestions. For info, I run R2.10 on Windows XP Thanks in advance Ivan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, I mostly use pdf to store my results from R. In R code it would look like: pdf("bla.pdf") plot commands... dev.off() I can read these pds into Inkscape (opensource vector drawing program) and edit all the indvidual lines and such. I can imagine Illustrator should also be able to read these pdfs. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boot R
Cassiano wrote: Hello, This is my first post, and my english is not very good, but I will try... I have a problem with boot the R. After that I install ubuntu 9.10 the R don't run. When I open the terminal and digit R, appear the message: */usr/lib/R/bin/exec/R: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory* Hi, R tries to find libgfortran.so.3, which it cannot find. Either it's not on your computer, or it's the wrong version. Check if it is installed: dpkg -l | grep libgfortran If this last command does not return anything, you need to install using: sudo apt-get update sudo apt-get install libgfortran3 probably it is not installed by default and this will solve the problem. cheers, Paul What's happening? Can anyone help me? Thank you __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two questions for R beginners
Ivan Calandra wrote: Since you want input from beginners, here are some thoughts I had and still have two big problems with R: - this vectorization thing. I've read many manuals (including R inferno), but I'm still not completely clear about it. In simple examples, it's fine. But when it gets a bit more complex, then... Related to it, the *apply functions are still a bit difficult to understand. When I have to use them, I just try one and see what happens. I don't understand them well enough to know which one I need. - the second problem is where to find the functions/packages I need. There are many options, and that's actually the problem. R Wiki, Rseek, RSiteSearch, Crantastic, etc... When you start with R, you discover that the capabilities of R are almost unlimited and you don't really know where to start, where to find what you need. As noted in earlier posts, the mailing list is really great, but some people are really hard with beginners. It was noted in a discussion a few days ago, but it looks like some don't realize how difficult it is at the beginning to formulate a good question, clear, with self-contained example and so on. Moreover, not everybody speaks English natively. I don't mean that you must help, even when the question is really vague and not clear and whatever. I'm just saying that if you don't want to help (whatever the reason), you don't have to say it badly. But in any cases, the mailing list is still really helpful. As someone noted (sorry I erased the email so I don't remember who), it might be a good idea to split it. Hi everyone, My 2ct about the mailing list :). I understand that beginners have a hard time formulating a good question. But the problem is that we can't answer the question when it is unclear. So either I: - Don't bother answering - Try do discuss with the author of the question, taking lots of time to find out what exactly is the question. - Send a "read the posting guide" answer I mostly do the first, as I have to get things done during my PhD :). So this leaves us with kind of a problem, the person mailing the list doesn't have the knowledge to ask the right question, the list can't answer properly and consequently, the person mailing the list still doesn't get the information he/she needs. We could start an R-beginner mailing list, but this would also suffer from this problem. What do you guys think? Maybe the mailing list is not the right medium for really basic stuff. For that I would recommend a good R-book or (better) a course in R or (even better) some colleagues who work with R that you can ask questions to. cheers, Paul Hope that's what you wanted Ivan Le 2/26/2010 08:39, Dieter Menne a écrit : Patrick Burns wrote: * What were your biggest misconceptions or stumbling blocks to getting up and running with R? (This derives partly from teaching) The fact that this xapply-stuff was not idempotent (worse: not always) and that you need a monster like do.call() to straighten this out. Nowadays, plyr comes close. The concept of environment. With S it was worse, though. That you cannot change values "passed by reference". I noted that the latter is no problem for students who have not worked with c(++/#) before. That there is only one return-result in functions. "[" and the likes as an operator. 10 years ago, when I started, the message was: S4 is the future, S3 is legacy. So I learned S4. Only to never use is in self-written code later. Might be different for BioConductor people. That sometimes you can use vectors not in data= (lattice), and sometimes not (ggplot2). Still a VERY confusing inconsistency. The "why-does-this-not-print" FAQ. Why does par(oma..) not work with lattice? Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two questions for R beginners
Ivan Calandra wrote: You are definitely right... What to do with bad beginner's questions is not a simple issue. If a "beginner's mailing list" is created, who will answer to such questions? And moreover, the beginners won't take advantage of the other questions (I've personally learned a lot trying to understand the questions and answers to other's problems). And also, as you said, the problems might persist. The beginner's mailing list might be good in one aspect though: the "experts" who subscribe to it would be willing to help the beginners to get started with R, knowing that the questions might not be clearly stated. As you pointed out, the mailing list is not the best for basic stuff (the question is of course "what is basic?"). Not everybody knows some colleagues who work with R (I'm personally the 1st one to use R in my lab). I think, somehow and I have no idea how, documentation and guidance to search for help should be more accessible as soon as you start with R. Maybe a _*clear*_ section on the R homepage or in the "introduction to R" manual like "where to find help", including all of the most common and useful resources available (from "?" and RSiteSearch() to R Wiki and Crantastic). Hi Ivan (and list), I think the main problem is not as much that there isn't structure in the way R provides documentation / tutorials, but that people have a hard time finding the structure. There are task views for certain specific fields, but I think a lot of beginners do not know that they exist. There are separate mailing lists for specific fields, but I often see geographical (my field of expertise) oriented questions on R-help that would fit much better on R-sig-geo. So I think a "O my God, I've downloaded R and what now" tutorial might be a good idea to put very close to the download button of R on CRAN. This tutorial would focus not on how to do things in R, but would provide guidance to the most obvious sources of information such as Task views, specific mailing lists, ways to search list archives, information for beginners how to write a good e-mail etc. I think for a lot of beginners it is not as much the answer to a specific question that they need, but more guidance how to look for answers themselves. But at the end of the day, R is still not very easy to learn when coming from GUI oriented stats programs. In addition, to become reasonably fluent in R, you need spend at least a few hours a week on it. SO I think we can ease the pain for beginners, but not take away that it takes quite some time to become fluent in R. cheers, Paul I hope that this whole discussion might help to make the R world better. Thank you Patrick for initiating it! Regards, Ivan Le 2/26/2010 15:09, Paul Hiemstra a écrit : Ivan Calandra wrote: Since you want input from beginners, here are some thoughts I had and still have two big problems with R: - this vectorization thing. I've read many manuals (including R inferno), but I'm still not completely clear about it. In simple examples, it's fine. But when it gets a bit more complex, then... Related to it, the *apply functions are still a bit difficult to understand. When I have to use them, I just try one and see what happens. I don't understand them well enough to know which one I need. - the second problem is where to find the functions/packages I need. There are many options, and that's actually the problem. R Wiki, Rseek, RSiteSearch, Crantastic, etc... When you start with R, you discover that the capabilities of R are almost unlimited and you don't really know where to start, where to find what you need. As noted in earlier posts, the mailing list is really great, but some people are really hard with beginners. It was noted in a discussion a few days ago, but it looks like some don't realize how difficult it is at the beginning to formulate a good question, clear, with self-contained example and so on. Moreover, not everybody speaks English natively. I don't mean that you must help, even when the question is really vague and not clear and whatever. I'm just saying that if you don't want to help (whatever the reason), you don't have to say it badly. But in any cases, the mailing list is still really helpful. As someone noted (sorry I erased the email so I don't remember who), it might be a good idea to split it. Hi everyone, My 2ct about the mailing list :). I understand that beginners have a hard time formulating a good question. But the problem is that we can't answer the question when it is unclear. So either I: - Don't bother answering - Try do discuss with the author of the question, taking lots of time to find out what exactly is the question. - Send a "read the posting guide" answer
Re: [R] two questions for R beginners
Thomas Adams wrote: Paul, I think your point "you need [to] spend at least a few hours a week on it" is key. Since I am not doing statistics daily, more in fits & starts as my latest project -may- require, my approach has been more task oriented. A less-than-ideal approach. So, I think your suggestion is on-the-mark. Tom I also see co-workers who would like to work with R, see the benefit of R etc, but don't have the time to learn and maintain R. But I'm not really sure how to fix this, it seems impossible to have both easy, intuitive to use and power and flexibility. cheers, Paul Paul Hiemstra wrote: Ivan Calandra wrote: You are definitely right... What to do with bad beginner's questions is not a simple issue. If a "beginner's mailing list" is created, who will answer to such questions? And moreover, the beginners won't take advantage of the other questions (I've personally learned a lot trying to understand the questions and answers to other's problems). And also, as you said, the problems might persist. The beginner's mailing list might be good in one aspect though: the "experts" who subscribe to it would be willing to help the beginners to get started with R, knowing that the questions might not be clearly stated. As you pointed out, the mailing list is not the best for basic stuff (the question is of course "what is basic?"). Not everybody knows some colleagues who work with R (I'm personally the 1st one to use R in my lab). I think, somehow and I have no idea how, documentation and guidance to search for help should be more accessible as soon as you start with R. Maybe a _*clear*_ section on the R homepage or in the "introduction to R" manual like "where to find help", including all of the most common and useful resources available (from "?" and RSiteSearch() to R Wiki and Crantastic). Hi Ivan (and list), I think the main problem is not as much that there isn't structure in the way R provides documentation / tutorials, but that people have a hard time finding the structure. There are task views for certain specific fields, but I think a lot of beginners do not know that they exist. There are separate mailing lists for specific fields, but I often see geographical (my field of expertise) oriented questions on R-help that would fit much better on R-sig-geo. So I think a "O my God, I've downloaded R and what now" tutorial might be a good idea to put very close to the download button of R on CRAN. This tutorial would focus not on how to do things in R, but would provide guidance to the most obvious sources of information such as Task views, specific mailing lists, ways to search list archives, information for beginners how to write a good e-mail etc. I think for a lot of beginners it is not as much the answer to a specific question that they need, but more guidance how to look for answers themselves. But at the end of the day, R is still not very easy to learn when coming from GUI oriented stats programs. In addition, to become reasonably fluent in R, you need spend at least a few hours a week on it. SO I think we can ease the pain for beginners, but not take away that it takes quite some time to become fluent in R. cheers, Paul I hope that this whole discussion might help to make the R world better. Thank you Patrick for initiating it! Regards, Ivan Le 2/26/2010 15:09, Paul Hiemstra a écrit : Ivan Calandra wrote: Since you want input from beginners, here are some thoughts I had and still have two big problems with R: - this vectorization thing. I've read many manuals (including R inferno), but I'm still not completely clear about it. In simple examples, it's fine. But when it gets a bit more complex, then... Related to it, the *apply functions are still a bit difficult to understand. When I have to use them, I just try one and see what happens. I don't understand them well enough to know which one I need. - the second problem is where to find the functions/packages I need. There are many options, and that's actually the problem. R Wiki, Rseek, RSiteSearch, Crantastic, etc... When you start with R, you discover that the capabilities of R are almost unlimited and you don't really know where to start, where to find what you need. As noted in earlier posts, the mailing list is really great, but some people are really hard with beginners. It was noted in a discussion a few days ago, but it looks like some don't realize how difficult it is at the beginning to formulate a good question, clear, with self-contained example and so on. Moreover, not everybody speaks English natively. I don't mean that you must help, even when the question is really vague and not clear and whatever. I'm just saying that if you don't want to help
Re: [R] Boot R
Cassiano wrote: I think I have 'libgfortran'. After that I digit 'dpkg -l | grep libgfortran' in terminal, I got this message: ii libgfortran2 4.2.4-5ubuntu1 Runtime library for GNU Fortran applications ii libgfortran2-dbg 4.2.4-5ubuntu1 Runtime library for GNU Fortran applications ii libgfortran3 4.4.1-4ubuntu9 Runtime library for GNU Fortran applications ii libgfortran3-dbg 4.4.1-4ubuntu9 Runtime library for GNU Fortran applications And the error continue: /usr/lib/R/bin/exec/R: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory if you do: sudo updatedb locate libgfortran | grep so does it find the file? And in which path? cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Boot R
Cassiano wrote: I think I have 'libgfortran'. After that I digit 'dpkg -l | grep libgfortran' in terminal, I got this message: ii libgfortran2 4.2.4-5ubuntu1 Runtime library for GNU Fortran applications ii libgfortran2-dbg 4.2.4-5ubuntu1 Runtime library for GNU Fortran applications ii libgfortran3 4.4.1-4ubuntu9 Runtime library for GNU Fortran applications ii libgfortran3-dbg 4.4.1-4ubuntu9 Runtime library for GNU Fortran applications And the error continue: /usr/lib/R/bin/exec/R: error while loading shared libraries: libgfortran.so.3: cannot open shared object file: No such file or directory Cassiano wrote: After sudo updatedb - nothing after locate libgfortran | grep so //usr/lib/libgfortran.so.2 /usr/lib/libgfortran.so.2.0.0 /usr/lib/libgfortran.so.3.0.0 /usr/lib/debug/usr/lib/libgfortran.so.2.0.0 /usr/lib/debug/usr/lib/libgfortran.so.3.0.0 /usr/lib/gcc/i486-linux-gnu/4.4/libgfortran.so / My reply: The point is that R is expecting /usr/lib/libgfortran.so.3 but your computer has /usr/lib/libgfortran.so.3.0.0. A trick is to make a symbolic link from /usr/lib/libgfortran.so.3 to /usr/lib/libgfortran.so.3.0.0. /usr/lib/libgfortran.so only points to /usr/lib/libgfortran.so.3.0.0 in that case: sudo ln -s /usr/lib/libgfortran.so.3.0.0 /usr/lib/libgfortran.so.3 This should fix the problem. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Experts
Hi, Maybe the R version Ryan is using is very old? cheers, Paul Erik Iverson wrote: Ryan Kinzer wrote: Erik Thanks for helping. Both of them are factors. That's the problem, they need to be of class Date. See the R NEWS article about Date classes in Volume 4/1. http://cran.r-project.org/doc/Rnews/ I don't see how they could be factors though, since you shouldn't be able to subtract two factors from each other without a warning at least? e.g., when I make up factors f1 and f2 >f1 - f2 Warning message: In Ops.factor(f1, f2) : - not meaningful for factors We would have to have a small, reproducible example to know for sure what's going on... Best Regards, Erik __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two questions for R beginners
Jack Siegrist wrote: My biggest impediment, as a scientist without previous programming experience, is that the R help is not beginner-friendly. I think it is probably great for experienced programmers and for the people who helped to create the software, to help them remember what they did, but I think it is very difficult for a newcomer without a strong programming background to learn about a new function or to discover the name of a function that you are pretty sure should already exist. Maybe this wouldn’t matter for most programming languages, but as free statistics software R is obviously going to attract many scientists who want to get an analysis done and have varying levels of experience with programming. Hi Jack, A problem more or less is that the R community consists primarily of volunteers. People who answer questions to the help list in their spare time or during company time. This also holds for many of the online material. A program like Mathematica has a company providing the online material, they hire people to do this work. I don't use this as an excuse for R, but it might explain why the R community is what it is. In reply to the 'bashing' of new users. I agree that sometimes the experts answering the questions can be blunt, but most often it is in response to questions that are very hard to answer. As I said earlier in this mail thread, asking the right question already involves some of the knowledge to answer the question. So to get good, informative responses a user needs some level already. I do want to point out that there is a posting guide for the mailing list that gives a quite detailed instructions, like give the exact error (don't just say, R crashes). Provide traceback() and sessionInfo() etc, etc. And a lot of posters do not adhere to these rules. cheers, Paul I found it much easier to learn how to use Mathematica, using only the online help. With R I had to buy several books to get a handle on it, which is fine, but even the books that I have found to be most useful tend to be didactically lacking—either too cursory or mired in unexplained programming jargon. They are OK just not great. What I think would be very helpful is an introduction to programming using R, preferably a big thick college textbook that takes at least a semester to go through, which should be a prerequisite for going through the Introduction to R available on CRAN. Also to do any analysis on real data you have to use the apply family of functions to perform different functions by groups. A long introduction to these functions, with lots of comparisons and contrasts between them would be very helpful. A few random examples concerning the R help: In my version of R (2.7.0 on Windows XP) typing ?+ doesn’t do anything, but then if you type in the next line + ?sum you get the “Arithmetic Operators” help page. If you had just typed ?sum in the first place you get the “Sum of Vector Elements” help page. Most examples in the R help pages use way to many other functions to be useful to a beginner. If an example uses 10 other functions besides the one being described, chances are a beginner won’t know what one of them does, which can set off a chain of having to look up other irrelevant functions. Some function names in the base package are goofy, such as “rowsum” which is used to “compute column sums across rows”, not to be confused with “rowSums” which computes row sums. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple Linear Autoregressive Model with R Language
Emil Davtyan wrote: Hello - I need to do simple linear autoregressive model with R software for my thesis. I looked into all your documentation and I am not able to find anything too helpful. Can someone help me with the codes? Thanks Emil [[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. Hi, Google "R ar model", the first hit gives: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/ar.html cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two questions for R beginner
Brandon Zicha wrote: What were your biggest misconceptions or stumbling blocks to getting up and running with R? Easy. I terms of materials I have been unable to find good books that introduce users to R from the perspective of someone familiar only with packages like SPSS or STATA, or not familiar with statistics packages at all. Even introduction texts use jargon without introducing it. I think that R-help files should be more thorough than they are, and contain more examples. I thought that STATA help files were sparse! The notion that 'R is a user community and thus they do this in their spare time' is no excuse for those creating new tools for R not developing complete help files. It doesn't take that much time relative to actually creating the new function. Hi Brandon, I would disagree with your point that documentation doesn't take much time. Writing documentation that is suitable for both the advanced user (being a reference, and thus preferably short) and the beginning user (being sort of a tutorial, and thus prefererably longer) is quite a challenge, comparable to writing a good paper. Apart from the fact that it takes quite a while, it is also not much fun. Often people develop packages for their own research and put the software online so others can benefit, they don;t need the documentation themselves and don't get paid to write the documentation. So saying 'it's no excuse' really goes too far in my view. R is free, you did not pay several thousands of euros giving you the right for good support. Even the support is free through the mailing list. You can get a paid version of R at Revelution Computing. Then you can call them if there are problems. I'm not meaning to offend anybody, but I didn't agree with "is no excuse for those creating new tools for R not developing complete help files". Partly the strength of R is in the open source, but sometimes, as with documentation, this can bite you. But I think the R docs aren't that bad, I've seen proprietary software that a worse job than R. my 2euro on the subject :), Cheers, Paul In terms of actual R use - creating, using, and manipulating data are the biggest frustration for those of the 'spreadsheet generation'. I get the impression that one needs to not merely understand, but be fully fluent in the jargon of matrix mathematics to even know what is going on half the time. I find myself - even now - using 'rules of thumb' that 'seemed to work' rather than fully understanding what I am doing. It is particularly discouraging when many of those 'intro books' suggest using something besides R for data manipulation - how clumsy is that!? I find the actual programming syntax itself is the easiest part to master. It is certainly more flexible - but without a particularly sufficient increase in complexity - than trying to write script in SPSS and STATA. Brandon Zicha __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two questions for R beginner
nity is much looser, much more open source. Probably the R core team would be the closest thing we have. What do you think? Best, Brandon Z On Mar 2, 2010, at 1:16 PM, Paul Hiemstra wrote: Brandon Zicha wrote: What were your biggest misconceptions or stumbling blocks to getting up and running with R? Easy. I terms of materials I have been unable to find good books that introduce users to R from the perspective of someone familiar only with packages like SPSS or STATA, or not familiar with statistics packages at all. Even introduction texts use jargon without introducing it. I think that R-help files should be more thorough than they are, and contain more examples. I thought that STATA help files were sparse! The notion that 'R is a user community and thus they do this in their spare time' is no excuse for those creating new tools for R not developing complete help files. It doesn't take that much time relative to actually creating the new function. Hi Brandon, I would disagree with your point that documentation doesn't take much time. Writing documentation that is suitable for both the advanced user (being a reference, and thus preferably short) and the beginning user (being sort of a tutorial, and thus prefererably longer) is quite a challenge, comparable to writing a good paper. Apart from the fact that it takes quite a while, it is also not much fun. Often people develop packages for their own research and put the software online so others can benefit, they don;t need the documentation themselves and don't get paid to write the documentation. So saying 'it's no excuse' really goes too far in my view. R is free, you did not pay several thousands of euros giving you the right for good support. Even the support is free through the mailing list. You can get a paid version of R at Revelution Computing. Then you can call them if there are problems. I'm not meaning to offend anybody, but I didn't agree with "is no excuse for those creating new tools for R not developing complete help files". Partly the strength of R is in the open source, but sometimes, as with documentation, this can bite you. But I think the R docs aren't that bad, I've seen proprietary software that a worse job than R. my 2euro on the subject :), Cheers, Paul In terms of actual R use - creating, using, and manipulating data are the biggest frustration for those of the 'spreadsheet generation'. I get the impression that one needs to not merely understand, but be fully fluent in the jargon of matrix mathematics to even know what is going on half the time. I find myself - even now - using 'rules of thumb' that 'seemed to work' rather than fully understanding what I am doing. It is particularly discouraging when many of those 'intro books' suggest using something besides R for data manipulation - how clumsy is that!? I find the actual programming syntax itself is the easiest part to master. It is certainly more flexible - but without a particularly sufficient increase in complexity - than trying to write script in SPSS and STATA. Brandon Zicha __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Random real numbers
frederik vanhaelst wrote: Hi, How could i generate random real numbers between 0 en 2*pi? Thanks, Frederik [[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. Googeling for "R generate random number" gave this as a second hit (on my machine): http://blog.revolution-computing.com/2009/02/how-to-choose-a-random-number-in-r.html cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 in R
Hi Frederik, There is no need for the double for loop: b[,5] <- sin(runif(5,0,2*pi)) As to your question, check the values i and k take. In the first iteration of the second loop k == 0, and R does not support an index equal to 0. The problem is in 1:n-1, this gives 0- 4, in stead do 1:(n-1). Better is to skip the double for loop altogether and vectorization. cheers, Paul frederik vanhaelst wrote: Hi, I want put some values in the last column of a matrix b. But every time again there comes the same error on the screen... b <- array(0, c(5,5)) m<-matrix(runif(20,0,2*pi),5) # the sinus of this kind of values i want put in the last column of b, m is a 5*4 matrix n<-5 for(i in 1:n){ + a2<-1 + for(k in 1: n-1){ + a2<-a2*sin(m[i,k]) + } + b[i,n]<-a2 + } Error in b[i, n] <- a2 : replacement has length zero Is there someone who see the problem? Thanks a lot, Frederik [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Redhat Linux Install
Marc Schwartz wrote: On Mar 5, 2010, at 3:45 PM, Ryan Garner wrote: I just installed R on Redhat Linux at work for the first time and have two questions. 1. I tried to install R to have png and cairo capabilities and was unsuccessful. Before running make, I ran ./configure --with-libpng=yes --with-x=no --with-cairo=yes --with-readline-yes . R installed fine, but when I run R and type capabilities() capabilities() jpeg pngtiff tcltk X11 aqua http/ftp sockets TRUE TRUE TRUE TRUEFALSEFALSE TRUE TRUE l ibxmlfifo cledit iconv NLS profmemcairo TRUEFALSE TRUE TRUE TRUE TRUEFALSE Why are png and cairo still FALSE? 2. I would also like to have X11 enabled. From reading the message board, the consesus seems to be to install xorg-dev. I'm unable to do this because I don't have root or super user priveleges. But if I'm able to log into my work servers with PuTTY and Xming and run xemacs or xvim, does this mean that X11 is already installed somewhere? If so, how do I specify this when doing ./configure? There is conflicting information here. You specified --with-x=no, yet you want X. You indicate that you "installed R", yet you do not have root access. In order to compile R from source and have the functionality that you seem to want, you will need either have root access to install the required libraries or have the SysAdmin do so. In order to install R using the defaults, you need to have root access or have your SysAdmin do so. The required libraries are the 'dev' or development versions of the RPMs for each of the components such as libpng, cairo, readline and X. These contain the header files (.h) that are required to compile R from source and support these features. These issues are described in the R Installation and Administration manual: http://cran.r-project.org/doc/manuals/R-admin.html The easier option would be to have the SysAdmin simply use the available RPMs for R rather than compiling from source. I presume that by Red Hat Linux, you mean RHEL. You can point your SysAdmin to the EPEL (http://fedoraproject.org/wiki/EPEL) which provides pre-built RPMs for R, installable by using 'yum'. In addition to Marc, CRAN also provides .rpm version of R [1]. It could be that these are newer than the ones on EPEL, but I'm not sure. cheers, Paul [1] http://cran.r-project.org/bin/linux/redhat/ If you can use ssh to login to the server using PuTTY and that supports X as you indicate, then it means that the server has been configured to support 'X forwarding' and that your ssh login is using the '-X' option to request it on your end of the connection. This means that the server supports X, but may or may not have the X related development RPMs installed, which as I note, are required to compile R from source and support X. Xming, on the other hand, I believe provides its own X server implementation, which potentially brings other issues into play. I have not used it, so would defer to others on the details. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Removing Zeros from matrix
Dimitris Rizopoulos wrote: one approach is the following: mat <- matrix(rnorm(100*45), 100, 45) mat[sample(100*45, 50)] <- 0 index <- rowMeans(mat == 0) == 0 mat[index, ] Dimitris, You use quite a complicated syntax to get the index. I think the following syntax using apply is more easy to understand: # Note, MARGIN equal to 1 means loop over rows # If any member of a row is zero index = apply(mat == 0, MARGIN = 1, any) # If all members of a row are zero index = apply(mat == 0, MARGIN = 1, all) cheers and hope it helps, Paul I hope it helps. Best, Dimitris On 3/9/2010 11:05 AM, ogbos okike wrote: Hi Everybody, I have a matrix of about 45 columns. Some of the rows contain zeros. Using data1<-data[complete.cases(data),], I can remove the "NA" rows. But I am unable to tackle that of zeros. Can anybody give me an idea of how to remove rows containing zeros in a matrix. Thanks so much Best Ogbos [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] IMPORTANT - To remove the null elements from a vector
barbara.r...@uniroma1.it wrote: I have a vector that have null elements. How to remove these elements? For example: x=[10 0 30 40 0 0] I want the vector y=[10 30 40] Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. and, to add to the options already posted: subset(x, x != 0) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Removing Zeros from matrix
Dimitris Rizopoulos wrote: On 3/9/2010 1:36 PM, Paul Hiemstra wrote: Dimitris Rizopoulos wrote: one approach is the following: mat <- matrix(rnorm(100*45), 100, 45) mat[sample(100*45, 50)] <- 0 index <- rowMeans(mat == 0) == 0 mat[index, ] Dimitris, You use quite a complicated syntax to get the index. I think the following syntax using apply is more easy to understand: well, this way is much more efficient to compute, especially if you have many rows. Compare the following to see the difference: mat <- matrix(rnorm(2*1e06), 1e06, 2) mat[sample(2*1e06, 50)] <- 0 system.time(index1 <- !apply(mat == 0, MARGIN = 1, any)) system.time(index2 <- rowMeans(mat == 0) == 0 ) all.equal(index1, index2) Point taken, I totally agree that for large matrices you should use your approach. Didn't know that it made such a difference, great to learn something new :). But I still like the other syntax more ;). cheers, Paul Best, Dimitris # Note, MARGIN equal to 1 means loop over rows # If any member of a row is zero index = apply(mat == 0, MARGIN = 1, any) # If all members of a row are zero index = apply(mat == 0, MARGIN = 1, all) cheers and hope it helps, Paul I hope it helps. Best, Dimitris On 3/9/2010 11:05 AM, ogbos okike wrote: Hi Everybody, I have a matrix of about 45 columns. Some of the rows contain zeros. Using data1<-data[complete.cases(data),], I can remove the "NA" rows. But I am unable to tackle that of zeros. Can anybody give me an idea of how to remove rows containing zeros in a matrix. Thanks so much Best Ogbos [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 select partially (not completely) unique rows?
Hi Mark, If you convert the data.frame to a Spatial class (see the sp-package documentation) you can use the function zerodist to find spatial locations that are at the same locations. cheers, Paul Mark Na wrote: Dear R-helpers, I know how to use unique to select unique rows, e.g. unique.rows<-unique(dataframe) but I would like to select those rows that are unique only only TWO of my dataframe's columns (so, two rows with the same value on these two columns would not be kept, even if they had different values in other columns). For example, I have a dataframe with 10 columns, two of which are LATITUDE and LONGITUDE. I wish to keep only one row per unique combination of these two columns, so I've tried: unique.latlong<-extracted[unique(paste(extracted$latitude,extracted$longitude)),] but this is returning a dataframe of missing values (NAs). Could anyone point me in the right direction? Thanks! Mark Na [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] mapping states with colors
Hi, You could have a look at the sp-package, it provides R-classes for spatial data. In addition, it also provides very nice plotting facilities. To read your data into these sp classes you can use the rgdal package. There is also an R mailing list specifically for geographic data (r-sig-geo) which might be a more suitable place to get good replies. cheers, Paul Donald Braman wrote: Hi folks, I'm just learning how to use maps. As an initial foray, I'm mapping the states that have "duty to retreat" (blue) and "stand your ground" (red) self-defense standards. Here is my extremely naive script: dtr <- c('alabama', 'arizona', 'conneticut', 'delaware', 'dist of columbia' , 'hawaii', 'maryland', 'massachusetts', 'minnesota', 'missouri', 'nebraska' , 'new hampshire', 'new jersey', 'new mexico', 'new york', 'north carolina' , 'north dakota', 'ohio', 'pennsylvania', 'rhode island', 'virginia', 'wyoming', 'arkansas', 'vermont') syg <- c( 'alaska', 'california', 'colorado', 'florida', 'georgia', 'idaho' , 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine' , 'michigan', 'mississippi', 'montana', 'nevada', 'oklahoma', 'oregon', 'south carolina', 'south dakota', 'tennessee', 'texas', 'utah', 'washington', 'west va', 'wisconsin') map('state', proj='bonne', param=50, region = c(syg, dtr), fill=TRUE, col=c('red', 'blue')) Obviously that doesn't work. A couple questions: 1. How do I get Alaska & Hawaii on the map? 2. How to I set the col atttribute for a subset of the states I'm mapping? Many thanks in advance for any help! Don Donald Braman http://www.culturalcognition.net http://ssrn.com/author=286206 http://www.law.gwu.edu/Faculty/profile.aspx?id=10123 [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Mathematical annotation axis in lattice
Hi Albart, This bugged me also for quite some time. After some experiments the following syntax worked best: library(lattice) a = 0.11 xyplot(1:10~10:11, xlab = as.expression(bquote(R^2~" equals "~.(a With the combination of as.expression and bquote you can mix text, math expression and the content of objects (in the case here of a). Read the documentation of bquote for more details. cheers, Paul Coster, Albart wrote: Dear list, making mathematical expressions in plots is not difficult: expression(phi[1]) for example. At this moment I am stuck in creating a vector of expressions: pos <- 1:10 lab <- letters[pos] Now, I would like to create a vector of expressions which I could use for labeling the x-axis of a lattice plot. ll <- as.expression(paste(pos," phi[",lab,"]",sep = "") xyplot(1:10~11:10,scales = list(x = list(labels = ll,at = 1:10))) does not work. I read about the function substitute, but that did not solve it. Could you recommend me how I should do this? Thanks in advance, Albart Coster Wageningen Universiteit Netherlands __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] changing point style in xyplots depending on groups
Thomas von Känel wrote: hi, i've got the following and would like to set the point style for A, B and C myself (eg pch=1, 6 and 16) library(lattice) df <- data.frame(x = log(c(1, 0.5 ,0.2 ,0.12 ,0.06, 1, 0.5 ,0.2, 0.12,0.06, 1, 0.5 ,0.2 ,0.12,0.06)), y = c(1, 2, 5, 14, 24, 51, 50, 50, 49, 54, 100, 101, 103, 97, 95), gr = c('A','A','A','A','A','B','B','B','B','B','C','C','C','C','C')) xyplot(df$y~df$x,groups=df$gr) thanks in advance for any help Tom von Känel Human Genetics Uni Berne __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Making pch not one value but a list of numbers should work, in this case do not use the groups variable: xyplot(x~y, df, pch = c(1,1,1,1,1,3,3,3,3,3,5,5,5,5,5)) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problems generating image from tiff file
Hi Mehdi, PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. I don't mean to rude, but you seem to lack basic knowledge regarding the use of spatial data in R. Starting to use R is hard, but please ask your supervisor to help you or try and read more information on the internet. Some hints: The Spatial taskview: http://cran.r-project.org/web/views/Spatial.html The R tips wiki: http://wiki.r-project.org/rwiki/doku.php?id=tips:spatial-data Or read the sp-documentation: ?sp vignette("sp") In addition, there is a mailing list specifically for geographic data and analysis in R, r-sig-geo. This is a much better place for your type of questions. I also have some comments inline below. cheers and good luck with your R adventures! Paul Mehdi Khan wrote: I imported the attached tiff file and converted the coordinate system to long lat and graphed it: californiatiff<- readGDAL("california1.tif") proj4string(californiatiff) What is the outcome of this command? rasterprojection <- spTransform(californiatiff, CRS("+proj=longlat") It seems that you reproject a grid here. Remember that when reprojecting a grid, the grid structure is lost. The squares in the grid in the new projection aren't squares anymore. So the output of spTransform is no longer a grid (SpatialGrid or SpatialPixels) but a point dataset (SpatialPoints). however, when using the plot command for rasterprojection, The sp-objects are plotted not using the plot command, but using the spplot command. If you are using this, this is not obvious from your e-mail. I get a blob. I can see the outline of the state of california and nevada, but rather than being able to see the geographic features, it is just a monocolor blob. My suspicion is that since it is a list of coordinates and another column that contains attributes, I need to turn it into a polygon. I've tried the following codes but none work: rasterprojection2<-SpatialPolygons(rasterprojection) You are trying to convert a grid to a polygon, this is not possible. Error in is.vector(X) : trying to get slot "Polygons" from an object of a basic class ("integer") with no slots rasterprojection2<- Polygons(rasterprojection) Error in as.vector(x, "list") : cannot coerce type 'S4' to vector of type 'list' Essentially, all I need to do is to connect the coordinates into polygons. What am I doing wrong? You used readgdal to read the tif file. If you want polygons, get a shapefile and read it using readOGR or readShapeLines or readShapePoly. Thank you! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problems generating image from tiff file
Hi Mehdi, No problem, we all have to start somewhere! Glad to have helped. If you take a look at http://wiki.r-project.org/rwiki/doku.php?id=tips:spatial-data:spatial_data_visualization you will find some tips on how to plot spatial data using spplot. Including how to plot a grid together with a polygon. good luck and cheers, Paul Mehdi Khan schreef: Paul, Thank you very much for your explanation. I have only been using R for GIS purposes for about a week, so my expertise in the field is shallow. Your explanation helped me out and I was able to plot the tif file simply by using the spplot command. The reason I was projecting it was that I am trying to project a separate shape file on top of the tif--and the coordinates of the two files are different. What I ended up doing was using spTransform to change the coordinate system of the shape file into that of the tif file, and used the image () and plot commands to graph them on top of one another. I'm definately a novice when it comes to R, but I am learning. Thanks a lot! On Fri, Jul 17, 2009 at 12:25 AM, Paul Hiemstra <mailto:p.hiems...@geo.uu.nl>> wrote: Hi Mehdi, PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. I don't mean to rude, but you seem to lack basic knowledge regarding the use of spatial data in R. Starting to use R is hard, but please ask your supervisor to help you or try and read more information on the internet. Some hints: The Spatial taskview: http://cran.r-project.org/web/views/Spatial.html The R tips wiki: http://wiki.r-project.org/rwiki/doku.php?id=tips:spatial-data Or read the sp-documentation: ?sp vignette("sp") In addition, there is a mailing list specifically for geographic data and analysis in R, r-sig-geo. This is a much better place for your type of questions. I also have some comments inline below. cheers and good luck with your R adventures! Paul Mehdi Khan wrote: I imported the attached tiff file and converted the coordinate system to long lat and graphed it: californiatiff<- readGDAL("california1.tif") proj4string(californiatiff) What is the outcome of this command? rasterprojection <- spTransform(californiatiff, CRS("+proj=longlat") It seems that you reproject a grid here. Remember that when reprojecting a grid, the grid structure is lost. The squares in the grid in the new projection aren't squares anymore. So the output of spTransform is no longer a grid (SpatialGrid or SpatialPixels) but a point dataset (SpatialPoints). however, when using the plot command for rasterprojection, The sp-objects are plotted not using the plot command, but using the spplot command. If you are using this, this is not obvious from your e-mail. I get a blob. I can see the outline of the state of california and nevada, but rather than being able to see the geographic features, it is just a monocolor blob. My suspicion is that since it is a list of coordinates and another column that contains attributes, I need to turn it into a polygon. I've tried the following codes but none work: rasterprojection2<-SpatialPolygons(rasterprojection) You are trying to convert a grid to a polygon, this is not possible. Error in is.vector(X) : trying to get slot "Polygons" from an object of a basic class ("integer") with no slots rasterprojection2<- Polygons(rasterprojection) Error in as.vector(x, "list") : cannot coerce type 'S4' to vector of type 'list' Essentially, all I need to do is to connect the coordinates into polygons. What am I doing wrong? You used readgdal to read the tif file. If you want polygons, get a shapefile and read it using readOGR or readShapeLines or readShapePoly. Thank you! __ R-help@r-project.org <mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone:
Re: [R] Show representation of a data structure
bwgoudey schreef: I'm currently working with some large complex data structures eg list of lists of data_frames containing lots more variables and lists etc. Sometimes, I'd like to be able to bring up a simple representation of the structure I'm working with, minus all of the values it contains (so simply printing the variable doesn't work as its too hard to see structure when there are 1000s of values being printed). I know there is a function in R that allows you to do something like this but I cannot remember what it is and my searching has turned up nothing. Does anyone know the function I'm talking about or have any other useful suggestions as to what I can do? Thanks Hi, Try summary() or str() on the object. cheers, Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] animated grid graphics
Hi, Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. This movie is also much more compatible with all kinds of machines. It might be that you can get your grid animation working on your own computer, but if another user has a less powerfull machine he might not have a smooth animation. Good luck! Paul Unternährer Thomas schreef: I need to make a fairly complex animated graphic and decided to use grid for it. A very simple example of what I need: ##== library(grid) grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() rectNames <- paste("r", 1:100, sep = "") for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), "native"), y = unit(sample(0:100, 1), "native"), width = 0.1, height = 0.1, name = rectNames[i]) } for (i in 1:100) { grid.remove(rectNames[i]) } ##== The problem here is that removing grid objects is very slow, at least in the way I use it. Is it possible to remove all objects at once (or to use some technique similar to double buffering)? A second way to do it would be to remove a viewport and all its children from the current viewport tree. Is this possible? Example: ##== grid.newpage() pushViewport(plotViewport()) pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100 grid.xaxis() grid.yaxis() pushViewport(viewport(xscale = extendrange(c(0, 100)), yscale = extendrange(c(0, 100)), name = "plotVP")) for (i in 1:100) { grid.rect(x = unit(sample(0:100, 1), "native"), y = unit(sample(0:100, 1), "native"), width = 0.1, height = 0.1, name = paste("r", i, sep = "")) } *remove("plotVP")*?? ##== Another approach would be to save every single plot as an image and use something like imagemagick to produce an animated gif, but I was just wondering if it's possible by using grid only (no need to use it outside of R). Thanks in advance Thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] animated grid graphics
Allan Engelhardt wrote: On 21/07/09 14:00, Paul Hiemstra wrote: Hi, Drawing grid graphics always takes long, I would write the images to png's and make the animation. If you use Linux I can suggest some nice tools to do this. Please do suggest! I was thinking about a similar problem. Allan. Hi Allan and Jeremy, I use the jpeg2yuv and mpg2enc commands to create an mpg movie from a series of jpeg's, in this case created using R. The command to produce the mpg movie looks something like: ls *.jpg | jpeg2yuv -f 25 -I p | mpg2enc -q3 -M2 2048 -o animation.mpg These tools are part of the ffmpeg project (http://ffmpeg.org/) an I think they are part of the debian (and maybe ubuntu) repositories. Another cool tool is yuvmotionfps, it allows you to interpolation between frame, see http://jcornet.free.fr/linux/yuvmotionfps.html. cheers and good luck, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Multi-line comments?
Mark Knecht wrote: Hi, I looked in the language definition and was surprised. Is there really no multi-line/block comment defined in R? I wanted to comment out 20 lines that I'm moving to a function but didn't want to delete them. Is there no defined way to get around using a # on each of the 20 lines? Thanks, Mark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, This issue has come up before, and as far as I know there is no multiline comment. However, there are a few ways of commenting out larges pieces of code. - Use a good text editor, Kate (KDE) allows you to select the 20 lines and press Ctrl-D to comment them all at once. - Use a setup like: if(FALSE) { line1 ... line20 } And set FALSE to TRUE if you want to let the code be executed. These are probably not the only ones, but this is what I could think of right now. cheers and good luck, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] All possible linear models given multiple explaining variables
Thomas A. Groen wrote: Hi, I would like to have a script/function (or write one) that can calculate the linear models for all possible combinations of explaining variables. Eventually I would like to end up with a data base (or data frame) giving for each model the R2, R2adj, AIC etc. Currently I'm a bit stuck while writing my own script using the lm() function from the base package. Also, I haven't fund any function (yet) that can do this as well. Perhaps these functions/scripts already exist? I would be very grateful to any suggestions and thoughts. kind regards, 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. Hi, Take a look at the step() command. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Multi-line comments?
Erik Iverson schreef: What editor are you all using to write R code? Many will have ways of doing what you want, e.g., comment-region (bound by default to M-; through comment-dwim) in Emacs. I use Kate, the advanced text editor in KDE. Paul -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Knudsen Sent: Wednesday, July 22, 2009 9:55 AM To: Mark Knecht Cc: r-help Subject: Re: [R] Multi-line comments? On Wed, Jul 22, 2009 at 4:30 PM, Mark Knecht wrote: I wanted to comment out 20 lines that I'm moving to a function but didn't want to delete them. Is there no defined way to get around using a # on each of the 20 lines? Just like you, I have been longing for that myself. It seems that the answer is negative, so I have ended up using if (1==0) { # code goes here } although is not really nice to look at. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re ading Image Files
cotixan wrote: Hello, I'm rather new to R and I want to do some image analysis. Is there a way to read jpeg files into a matrix like matlab's imread? http://cran.r-project.org/web/packages/rimage/index.html -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PDF Compression
Hi, You could have a look at exporting the pdfs using the Cairo package. cheers, Paul David Keegan schreef: Hi, I am generating a large number of graphs with pdf() and incorporating them in pdf document using pdflatex. According to the pdf() help: 'pdf' writes uncompressed PDF. It is primarily intended for producing PDF graphics for inclusion in other documents, and PDF-includers such as 'pdftex' are usually able to handle .compression. But pdflatex incorporates the R graphs without compressing them. They appear in the final document in cleartext, almost but not identical to what was generated by R. I tried the latex settings "\\pdfcompresslevel=9", "\\pdfobjcompresslevel=3". They reduced the overall size of the final document slightly, but didn't cause the embedded R graphs to be compressed. Can anyone suggest how I can get pdflatex to compress the R graphs while embedding them? My output files are very big, and I know they would be substantially smaller if the R graphs were compressed. Regards, David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-installation regarding.
Hi Frederick, The development files for readline are not available. Install them to get this working. For debian/ubuntu the package to install is called libreadline-dev or something. SUSE's package manager might have a similar package. Alternatively you can skip installing R from source and use binary packages that are available in .dev, .rpm etc from CRAN [1]. This ensures you have the latest version of R and that upgrading is done through the package manager of SUSE, minimizing your work. cheers, Paul [1] http://cran.r-project.org/bin/linux/suse/ fredrick devadoss wrote: Hello All, I am new to R and tried to install R in Linux system (OS: Open SUSE). After untar the source code, changed the directory, and typed the command ./configure, it was checking a list...finally it gave an error message. Here with i have enclosed the error message. Check-list goes like this: checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/usr/i586-suse-linux/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking for gfortran option to produce PIC... -fPIC checking if gfortran PIC flag -fPIC works... yes checking if gfortran static flag -static works... yes checking if gfortran supports -c -o file.o... yes checking if gfortran supports -c -o file.o... (cached) yes checking whether the gfortran linker (/usr/i586-suse-linux/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking for cos in -lm... yes checking for sin in -lm... yes checking for dlopen in -ldl... yes checking readline/history.h usability... no checking readline/history.h presence... no checking for readline/history.h... no checking readline/readline.h usability... no checking readline/readline.h presence... no checking for readline/readline.h... no checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... yes checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available Can anyone help me in this regard? Expecting your reply and thanks in advance. Warm regards Fredrick. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] pdf files in loops
James Rome wrote: On 3/31/2010 10:01 PM, Berwin A Turlach wrote: G'day James, On Wed, 31 Mar 2010 21:44:31 -0400 James Rome wrote: I need to make a bunch of PDF files of histograms. [...] What am I doing wrong? http://cran.ms.unimelb.edu.au/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f HTH. Cheers, Berwin -- I got it. Thanks. I forgot to assign the graph to a variable. :-( for( gate in gatelist) { outfile = paste("../", airport, "/", airport, "taxiHistogram", gate, ".pdf", sep="") pdf(file = outfile, width = 10, height=8, par(lwd=1)) title=paste("Taxi time for Arrival Gate", gate, "by Runway at", airport) gdf = mdf[mdf$ArrivalGate == gate, ] gdf$tt= gdf$TaxiTime/60 g = histogram(~(gdf$tt) | gdf$Runway, data=gdf, type="count", ylab="Count",breaks=20, main=title, xlab="taxi time (min)", par.strip.text=list(cex=0.7)) print(g) dev.off() } works. Is there a way to make all the plots pages in one pdf file? Hi, Put the pdf() and the dev.off() outside the loop and the plots will be on separate pages in the same pdf file. pdf() loop dev.off() cheers, Paul Thanks, Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] interpolating between lat/long position data with time
cbarcelo wrote: Hello, I am currently working with satellite tracking data for an organism with irregularly spaced location data in space and time (point data is occasionally spaced by 1-10 days). I have 4 columns of data, Lat, Long, Date, Time. I would like to linearly interpolate my data set so that I have one position per day with attached time stamps. I am fairly new to R, any pointers on code for this would be most helpful! Thanks! Hi, Take a look at the Spatial Task view, this provides an introduction to all kinds spatial data processing in R. In addition, the R-sig-geo mailing list is a more suitable list to ask this question, you will probably get more response there. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding country boundaries on field map plots
zow...@ncst.go.ke wrote: Hi R users, What is the command for adding (or how do we add) country boundaries on r-spatial plots. Thanks ZABLONE OWITI GRADUATE STUDENT Nanjing University of Information, Science and Technology College of International Education Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China Website: www.nuist.edu.cn [[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. Hi, You have to be more specific, in particular you need to provide some code that takes us to the step where you would want to add the country boundaries. In addition, the r-sig-geo mailing list might be a better place to ask this question. If you use spplot, look at the sp.layout argument. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 BLAT in r
Fahim wrote: I am trying to use blat in R. I couldn't find any package in CRAN or bioconductor. I downloaded the windows executable from Jim Kent's (from ucsc) webpage. I was wondering how to use/call these executables or functions embedded in these executables. I am seeking for some direction or some material that addresses such problem. Help appreciated. Thanks -Fahim Mohammad cecs, univ of Louisville Hi Fahim, The easiest way I can see is to use system() to call the executable. Probably BLAT uses some text parameter files to specify what it needs to do. Write an R function that generates the BLAT parameters files, run BLAT and process the result using another function, something like this: writeParameterfile() system(blat) getOutcomes() Another option, a hard one though, is to link the source code of BLAT directly into R. But I think using system is a good alternative. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] histogram
Santosh wrote: Dear R gurus... How do I control "smoothing" of a density plot in panel.densityplot when using histogram? Thanks much, Santosh [[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. Hi, From ?panel.densityplot, argument darg, I was referred to ?density. I think the 'bw' argument is what you need. Pass it to panel.densityplot in the darg argument. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 interactive input like C++
余舟 wrote: Huhu, Thank you for all you guys. readline works. I hope R can be more and more powerful to deal with strings. Strings and power come from regular expressions, check out ?regexpr. cheers, Paul Thank you so much; Zhou 2010/4/14 Erik Iverson David Scott wrote: Erik Iverson wrote: ?? wrote: Thank you for your reply. My objective is simple. Assume I have a constant vector, say Vector. in C++ code, I want to do: int index; cout<<"Please enter the index of the element you want to look at Vector :"; cin>>index cout< Isn't that what the file argument of ?scan says? I think? file: the name of a file to read data values from. If the specified file is ‘""’, then input is taken from the keyboard (or whatever ‘stdin()’ reads if input is redirected or R is embedded). I think the required function is readline which prompts for user input. ?readline Great, didn't know that one. The example in ?readline is hilarious. [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 R mode
djack...@miners.utep.edu wrote: Hello all, I am using R to perform certain calculations on huge amounts of data. In short I need a function that does the mode function, ie returns the most common element. I looked at the mode function in R but it seems to return the type of the data element you give it. Does such a method exist? I have tried googling this to no avail as all the results lead me back to the mode function I do not want. I googled for "R calculate mode", the first hit was this result: http://www.mail-archive.com/r-help@r-project.org/msg30197.html this is probably what you want. cheers, Paul Thanks, Don [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] histogram
Santosh wrote: Thanks for your email... yes, I had tried that "bw" thing.. for some reason it does not seem to work.. could not figure out where I am wrong... Below is an example for your convenience.. you might notice that the density plots appear to be a curve of connected segments. Changing breaks, nint or bw didn't seem to help. library(reshape) set.seed(13454) aa <- data.frame(a1=rnorm(500),b1=rnorm(500,0.8),c1=rnorm(500,0.5),cat1=rep(1:5,each=100)) ab <- melt(aa,measure.vars=c("a1","b1","c1")) histogram(~ value|variable,ab,breaks=NULL,nint=10,type="density",layout=c(2,2),as.table=T,scales=list(relation='free'), panel=function(x,lqp=c(0.05,0.975),...) { panel.histogram(x,col='lightblue',...) panel.densityplot(x,col.line='blue',lwd=1.75,bw=2,...) replace bw = 2 by darg = list(bw = 2), then it works for me. Read the documentation of panel.densityplot carefully, it says that you need to use darg = list(). cheers, Paul panel.abline(v=c(quantile(as.vector(x),prob=lqp,na.rm = T)), col="dark green",lwd=2,lty=2) }, strip=strip.custom( strip.names=F, strip.levels=T, par.strip.text=list(cex=0.75)), ) Thanks again, Santosh On Thu, Apr 15, 2010 at 12:41 AM, Paul Hiemstra <mailto:p.hiems...@geo.uu.nl>> wrote: Santosh wrote: Dear R gurus... How do I control "smoothing" of a density plot in panel.densityplot when using histogram? Thanks much, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org <mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, From ?panel.densityplot, argument darg, I was referred to ?density. I think the 'bw' argument is what you need. Pass it to panel.densityplot in the darg argument. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul <http://intamap.geo.uu.nl/%7Epaul> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 and S-Plus: Two programs separated by a common language?
Hi Paul, Paul Miller wrote: Hello Everyone, My company purchased S-Plus before it was bought out by Tibco. My understanding is that we own version 7.0 outright. So far, I've been learning in R but thought I might also try working in S-Plus. My understanding is that S-Plus has some useful extra features. Such as? Are these features so important for you work that you need s-plus? Another potential benefit would be the ability to purchase technical support, which I thought might help me to learn the S language. You can also get technical support for R, REvolution Computing for example. I was just wondering if anyone could give me some advice about the wisdom or folly of trying to use both products. For example, how well do the two play together? If I learn to do something using a package in R, is their some way to bring that into S-Plus? I've noticed that some R packages, such as MASS and Hmisc are in S-Plus but are unsupported. Others, such as reshape, appear not to be in the program but I thought maybe they could be imported. I would say, if it is not necessary, use one product and not two. Problems like the one below can be avoided in that case. cheers and good luck, Paul I know that R and S-Plus code are supposed to be very similar. I was just wondering how similar. Yesterday, I ran some code from the MASS package in S-Plus but the program didn't produce the graph I exepected to see. I've been able to use windows() in R to correct this, but S-Plus doesn't recognize that. So I was wondering how often code written in one program would fail to work in the other. Any insights you can offer will be most appreciated. Thanks, Paul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 read contents of a text file into a single string?
Dimitri Shvorob wrote: ... Both readLines() and scan() produce a number_of_lines x 1 vector; trying paste(s, collapse = NULL) leaves it unaffected. How can I concatenate vector elements (lines) into a single string? Thank you. try collapse = '' cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 get and paste in a loop to return objects for object names listed a strings
Nevil Amos wrote: I am trying to create a heap of boxplots, by looping though a series of factors and variables in a large data.frame suing paste to constrcut the facto and response names from the colnames I thought I could do this using get() however it is not working what am I doing wrong? You don't give a reproducible example, this makes it hard to answer your question. But not really in response to your question, take a look at histogram from the lattice package or geom_boxplot from the ggplot2 package. These functions can do all the work for you of drawing boxplots for a series of factors and variables in a large data.frame. This saves you a lot of time. cheers, Paul thanks Nevil Amos sp.codes=levels(data.all$CODE_LETTERS) for(spp in sp.codes) { data.sp=subset(data.all,CODE_LETTERS==spp) responses = colnames(data.all)[c(20,28,29,19)] #if (spp=="BT") responses = colnames(data.all)[c(19,20,26:29)] groups=colnames (data.all)[c(9,10,13,16,30)] data.sp=subset(data.all,CODE_LETTERS==spp) for (response in responses){ for (group in groups){ r<-get(paste("data.sp$",response,sep="")) g<-get(paste("data.sp$",group, sep="")) print (r) print(g) boxplot(r ~g) }}} Error in get(paste("data.sp$", response, sep = "")) : object 'data.sp$Hb' not found __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Statistical analysis
Chris Li wrote: Hi all, I have got two datasets, one of them is rainfall data and the other one is groundwater level data. I would like to see whether there is a correlation between these two datasets and if there is, to what extent they are correlated. My stats background is limited, therefore any advice on which command I should use in R would be greatly appreciated. Thanks in advance. Chris Hi, My advice would be to get an introductory statistics book and start with that. There is an Introductory stats book by Dalgaard that uses R. Strikes two birds with one blow. http://www.amazon.com/Introductory-Statistics-R-Peter-Dalgaard/dp/0387954759 cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem on SUSE Linux Enterprise Server 10 (ia64)
Hi, You need to install the headers/libs for readline. Probably using your package manager, look for something like readline-devel. cheers, Paul Yuan Zhidong wrote: Dear Sir, When I install R on SUSE Linux Enterprise Server 10 (ia64) (Linux a450 2.6.16.21-0.8-default #1 SMP Mon Jul 3 18:25:39 UTC 2006 ia64 ia64 ia64 GNU/Linux) it reported the wrong messages at the end: # ./configure checking build system type... ia64-unknown-linux-gnu checking host system type... ia64-unknown-linux-gnu loading site script './config.site' loading build specific script './config.site'checking for pwd... /bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... found checking for working autoconf... found . checking for readline/readline.h... no checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... yes checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available Could you tell me how to fix the problem? Thank you! Best wishes, Yuan Zhidong __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SAS user now converting to R - Help with Transpose
Hi, Also take a look at cast(), melt() and recast() from the reshape package. Great and very flexible functions. cheers, Paul Daniel Malter schreef: ?reshape hth, Daniel baxterj wrote: I am just starting to code in R and need some help as I am used to doing this in SAS. I have a dataset that looks like this: Chemical Well1 Well2 Well3 Well4 BOD 13.2 14.2 15.5 14.2 O2 7.8 2.6 3.5 2.4 TURB 10.2 14.6 18.5 17.3 and so on with more chemicals I would like to transpose my data so that it looks like this: Chemical WellID Value BOD Well1 13.2 BOD Well2 14.2 BOD Well3 15.5 BOD Well4 14.2 O2 Well1 7.8 O2 Well2 2.6 and so on In sas I would code it like this: proc sort data=ds1; by chemical; run; Proc Transpose data=ds1 out=ds2; by chemical; var Well1 Well2 Well3 Well4; run; data ds3; set ds2; rename _name_ = WellID; rename col1 = value; run; How can I do this in R?? Any help is much appreciated. Thanks! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Something wrong with my function Please Help
Chunhao Tu wrote: Hi R users, I try to build a function to compute odds ratio and relative risk however something wrong. I stuck for many hours but I really don't know how to solve it. Would someone please give me a hint? OR.RR<-function(x){ + x <- as.matrix(any(dim(x)==2)) + OR<-(x[1,1]*x[2,2])/(x[1,2]*x[2,1]) + RR<-(x[1,1]/(sum(x[1,])))/(x[2,1]/(sum(x[2,]))) + return(OR);return(RR) + } tt<-matrix(data=1:4,nrow=2,ncol=2) OR.RR(tt) Error in OR.RR(tt) : subscript out of bounds Many Thanks Tu In addition to Barry Rowlingson: You can insert the browser() command at any point in the code to drop into that environment. In you case you can use: x = function(arg1, arg2) { browser() do_stuff(arg1, arg2) } Running this will drop you into the environment of function x, allowing you to run the function line by line, and allowing you to inspect the content of all objects. An alternative to browser() is to use the following command: options(error=recover) When a program generates an error, you drop into that environment, allowing you to better diagnose the problem. Also look at the traceback() command, this show you which chain of commands led to the error. cheers and good luck, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Change directory to implement same programes
Hi, You can use list.files() of Sys.glob to get a listing of all the files in a certain directory, e.g. to get all ".R" files and source them: for(f in Sys.glob("C:/Documents and Settings/lma/*.R")) source(f) cheers, Paul Tammy Ma wrote: How do I source a bunch of files in different directories in R? From: metal_lical...@live.com To: r-help@r-project.org Date: Wed, 30 Sep 2009 13:45:34 +0300 Subject: [R] Change directory to implement same programes HI, R-Users, I have one problem: I have written the the programs which process all file in one directory: for example: setwd("C:/Documents and Settings/lma/My Documents/Vappu-saved/Log") as the start. .. But I have many folders like "Vappu-saved" and there are a lot of files in each directory. What I want is using the same program what I write for the above directory to autimatically change directory address to implement the above programs what I wrote. How do I realize it? Thanks a lot. Regards, Lingyi _ Windows Live™: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009 [[alternative HTML version deleted]] _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Missing functions
Kenny Shen wrote: Hi all, I'm new to R and have been working hard to get familiarized with it. A problem I'm facing now is that having installed some packages (psych, doBy), I can't seem to access the functions even through there was no error messages when I load them using library(). I get an error telling me the function doesn't exist. But when I ran e.g. library(help = psych), the function I want was missing. I did find that when I load other packages, there will be some initialisation messages, but loading psych and doBy just brings up the prompt again with no output. Any help is greatly appreciated. Thanks, Kenny Hi, Try psych:::theFunctionIWant, does this find the function? cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Missing functions
Hi, Look at remove.packages(). Paul Kenny Shen wrote: hi paul, i tried loading the package psych again and: > library(psych) Warning messages: 1: Display list redraw incomplete 2: Display list redraw incomplete 3: Display list redraw incomplete typing library(psych) after that just brings me to an empty > then with psych:::function, Error: package 'psych' does not have a name space is there a way to perhaps clean up and reinstall the packages? thanks, kenny On Thu, Oct 1, 2009 at 3:54 PM, Paul Hiemstra <mailto:p.hiems...@geo.uu.nl>> wrote: Kenny Shen wrote: Hi all, I'm new to R and have been working hard to get familiarized with it. A problem I'm facing now is that having installed some packages (psych, doBy), I can't seem to access the functions even through there was no error messages when I load them using library(). I get an error telling me the function doesn't exist. But when I ran e.g. library(help = psych), the function I want was missing. I did find that when I load other packages, there will be some initialisation messages, but loading psych and doBy just brings up the prompt again with no output. Any help is greatly appreciated. Thanks, Kenny Hi, Try psych:::theFunctionIWant, does this find the function? cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul <http://intamap.geo.uu.nl/%7Epaul> -- - "A mental model is good. I change mine all the time." -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] convert RData to txt
mykh...@gmail.com wrote: hello all, will you plz tell me how can i convert RData files to txt,,, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, Depends on what is in the RData files, which can be any R object. So there is no single answer as long as you don't provide more information. So please read the posting guide for more information. In general you can use the load() command to the RData file, and if it is for example a csv file you can use write.csv to write it to ascii. cheers Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Viewing specific data from a dataframe
Hi, I'm not sure I understand what you want. This would have been easier if you had provided a reproducible example. See the following code: bla = matrix(runif(1), 10, 10) cor_bla = cor(bla, method = "spearman") Now what do you want to select. All the variables that have a correlation higher than 0.8 with any of the other variables, excluding themselves? Or a correlation higher than 0.8 in contrast to one of the variables, e.g. the third variable? cheers, Paul Krystyna Golabek wrote: Dear R users, Simple question. Can anyone help with the code that would allow me to view only the variables who's correlation output is >0.8? This is the code I'm using to date cor(data, method="spearman") Kind regards Krys _ Save time by using Hotmail to access your other email accounts. [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Viewing specific data from a dataframe
Hi Krys, Please also cc all you responses to the list, keeping the conversation in the archives. The following code might be of help to you: set.seed(1) bla = matrix(runif(1), 10, 10) colnames(bla) = LETTERS[1:ncol(bla)] cor_bla = cor(bla, method = "spearman") # Assign NA to all values below 0.7 or equal to 1 cor_bla[cor_bla < 0.7 | cor_bla == 1] = NA # Are there any variables that have a correlation with another variable # that is not NA, those are the ones you want apply(cor_bla, 2, function(x) any(!is.na(x))) # Show the names of the columns that fit the conditions rownames(cor_bla)[apply(cor_bla, 2, function(x) any(!is.na(x)))] cheers, Paul Paul Hiemstra wrote: Hi, I'm not sure I understand what you want. This would have been easier if you had provided a reproducible example. See the following code: bla = matrix(runif(1), 10, 10) cor_bla = cor(bla, method = "spearman") Now what do you want to select. All the variables that have a correlation higher than 0.8 with any of the other variables, excluding themselves? Or a correlation higher than 0.8 in contrast to one of the variables, e.g. the third variable? cheers, Paul Krystyna Golabek wrote: Dear R users, Simple question. Can anyone help with the code that would allow me to view only the variables who's correlation output is >0.8? This is the code I'm using to date cor(data, method="spearman") Kind regards Krys _ Save time by using Hotmail to access your other email accounts. [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Is there a recent book on Q-Q plot and data visualization in general?
Hi Peng Yu, Chapter 13 of the following book provides a good description of the assumption done when using regression and other techniques. It also discusses the QQplot. @BOOK{Christensen1996, title = {Plane Answers to Complex Questions: The Theory of Linear Models}, publisher = {Springer, New York}, year = {1996}, author = {Ronald Christensen}, edition = {Second}, note = {496p}, } cheers, Paul Peng Yu wrote: Hi, I want to look for some detailed explanation on the properties of Q-Q plot and how the properties are derived. In R, there is the following reference. Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. Somebody also mentioned the following book chapter to me. Chambers et al., Graphical methods for Data Analysis, Ch.6. But both books are old. I'm wondering if there is any more recent (therefore, maybe better) books for Q-Q plot, and data visualization in general. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Is there a recent book on Q-Q plot and data visualization in general?
Hi, See page 335 for a qq plot in the third edition of the book. cheers, Paul Peng Yu wrote: Hi, I checked the 3rd edition of this book. But I don't find Q-Q plot. Would you please take a look of the table of content below and let me know if the same section is available in the 3rd edition? http://www.amazon.com/Plane-Answers-Complex-Questions-Theory/dp/0387953612/ref=sr_1_1?ie=UTF8&s=books&qid=1254856526&sr=8-1#reader Regards, Peng On Tue, Oct 6, 2009 at 9:50 AM, Paul Hiemstra wrote: Hi Peng Yu, Chapter 13 of the following book provides a good description of the assumption done when using regression and other techniques. It also discusses the QQplot. @BOOK{Christensen1996, title = {Plane Answers to Complex Questions: The Theory of Linear Models}, publisher = {Springer, New York}, year = {1996}, author = {Ronald Christensen}, edition = {Second}, note = {496p}, } cheers, Paul Peng Yu wrote: Hi, I want to look for some detailed explanation on the properties of Q-Q plot and how the properties are derived. In R, there is the following reference. Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole. Somebody also mentioned the following book chapter to me. Chambers et al., Graphical methods for Data Analysis, Ch.6. But both books are old. I'm wondering if there is any more recent (therefore, maybe better) books for Q-Q plot, and data visualization in general. Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem with CPU usage
Hi, If you work on Windows you can reduce the priority of the Rgui.exe process. You can do this in the task manager, right click > Priority. cheers, Paul venkata kirankumar wrote: Hi all, I have a problem with CPU usage while running the Rgui.exe problem is while I am running scripts on Rgui its taking 100% of CPU is there any posibility to reduce the cpu consumption are any package I can use to reduce CPU consumption can any one help me out from this problem because while running these scripts I am not able to do any other work and there is no recursive functions and all loops are ending properly Thanks in advance kiran [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 read plain text documents into a vector?
Richard Liu wrote: I'm new to R. I'm working with the text mining package tm. I have several plain text documents in a directory, and I would like to read all the files with extension .txt in that directory into a vector, one text document per vector element. That is, v[1] would be the first document, v[2] the second, etc. I know how to read the documents into a tm Corpus, but that's not what I want to do. I would think that this kind of operation should be elementary and the first step in any text mining. Thanks, Richard Hi Richard, Try somthing along these lines: file_list = list.files("/where/are/the/files") obj_list = lapply(file_list, FUN = yourfunction) yourfunction is probably either read.table or some read function from the tm package. So obj_list will become a list of either data.frame's or tm objects. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] two graphs 1 x-axis
Hi Naomi, Take a look at the lattice package for plotting. An example using your data: library(lattice) library(reshape) a<-c(1,2,3,4,5,6) b<-c(3,5,4,6,1,1) c<-c(1,1,1,1,1,1) bla = data.frame(a,b,c) # melt is from reshape bla2 = melt(bla, id.vars = "a") xyplot(value~a | variable, bla2, layout = c(1,2), strip = strip.custom(factor.levels = c("a vs b", "a vs c"))) ?melt ?xyplot xyplot takes care that the axis are equal, no need to set it yourself. Lattice is a bit harder to get to know than the 'normal' plotting system in R, but is great for multivariate data. cheers and good luck, Paul Duijvesteijn, Naomi wrote: Dear R-people I have a question concerning plotting graphs. Here an example dataset a<-c(1,2,3,4,5,6) b<-c(3,5,4,6,1,1) c<-c(1,1,1,1,1,1) d<-as.data.frame(cbind(a,b,c)) plot.new() plot(d$a, d$b, col="red") par(new=TRUE) plot(d$a,d$c, col="red", pch="|") What I would want is to plot de second plot under the first plot. So not in the the first plot. There is a way to divide your graph in 2 or 3 parts and use the same x-axis but I do not seem to get it right. Could somebody help me out? Thanks in advance! Regards, Naomi Disclaimer: De informatie opgenomen in dit bericht (en bijlagen) kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde(n). Indien u dit bericht ten onrechte ontvangt, wordt u geacht de inhoud niet te gebruiken, de afzender direct te informeren en het bericht te vernietigen. Aan dit bericht kunnen geen rechten of plichten worden ontleend. -- Disclaimer: The information contained in this message may be confidential and is intended to be exclusively for the addressee. Should you receive this message unintentionally, you are expected not to use the contents herein, to notify the sender immediately and to destroy the message. No rights can be derived from this message. Please consider the environment before printing this email __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] system() or shell() with python script
Remko Duursma wrote: Hi all, I am having some problems calling a python script from R that resides in a folder that is in the path (WindowsXP): Hi Remko, Some suggestions: 1. Try to see if the path that R has from a call to system is correct (i.e. the same as from cmd): system("path") 2. Try calling it with python added in front: system("python script.py") 3. Add a shebang line to the top of your script like: #! c:/Program Files/Python/python.exe This tells the OS which program you want to use to run the script. cheers, Paul ps maybe superfluous, but try the python getopt package for reading commandline arguments. system("quickPadTool.py") Warning message: In system("quickPadTool.py") : quickPadTool.py not found # I also tried 'shell' (and shell.exec as well). shell("quickPadTool.py") 'quickPadTool.py' is not recognized as an internal or external command, operable program or batch file. Warning message: In shell("quickPadTool.py") : 'quickPadTool.py' execution failed with error code 1 I can run the script fine from a command window just fine, from the same directory. Any pointers? thanks, Remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 exclude certain columns by column names?
Linlin Yan wrote: Try this: x[, colnames(x) != 'a'] And more general: x[, !colnames(x) %in% c('a','b')] Paul [1] 3 4 On Tue, Nov 3, 2009 at 9:31 AM, Peng Yu wrote: I can exclude columns by column number using '-'. But I wondering if there is an easy way to exclude some columns by column names. x=cbind(c(1,2),c(3,4)) x [,1] [,2] [1,]13 [2,]24 colnames(x)=c('a','b') x a b [1,] 1 3 [2,] 2 4 x[,-'a'] Error in -"a" : invalid argument to unary operator x[,-1] [1] 3 4 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] turn off function output
Ning Ma wrote: Hi, everybody Is there any way to turn off the output message of a function, maybe a result of cat() or print() command in that function. I only expected it to be executed quite and return a value. Any intermediate messages can be omitted. Thanks! Ma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi, have a look at this e-mail from the R-help archives: http://tolstoy.newcastle.edu.au/R/e4/help/08/01/0841.html cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Antw: Re: compiling R-2.9.2 or R-2.10.0 on ubuntu 9.04 (powerpc)
Laurin Müller wrote: i installed: libreadline-dev libcnf-dev but configure with no readline brings the same error. regards, laurin >>> Paul Hiemstra 05.11.2009 12:38 >>> sudo apt-get install libreadline-dev Try running with readline turned on (the default). In regard to your problem, check the value of the LDFLAGS and have a look at the following e-mail from the archive (found by googling your error message): http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg20344.html cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.