[R] Fastest way to calculate quantile in large data.table

2015-02-05 Thread Camilo Mora
In total I found 8 different way to calculate quantile in very a large data.table. I share below their performances for future reference. Tests 1, 7 and 8 were the fastest I found. Best, Camilo library(data.table) v - data.table(x=runif(1),x2 = runif(1),

[R] Fastest way to calculate quantile in large data.table

2015-02-04 Thread Camilo Mora
Hi everyone, I have a data.table with 200 columns and few million rows and am trying to calculate the .1 and .9 quantiles for each row across all 200 columns. I have found different ways to do this, all with different performances. The examples I used are below. I wonder whether there is a

[R] Operations with dates just as Month and Day and not Year

2015-01-23 Thread Camilo Mora
Hi everyone, I am trying to calculate the number of days between any two dates in a year regardless of the year. Specifically, image two dates: MonDay1 - 01-30 #January 30 MonDay2 - 12-31 #December 31 I want the difference of those two dates to be MonDay1- MonDay2=30 days

[R] inahull? from package alphahull not working when used with lapply

2014-10-27 Thread Camilo Mora
Hi Bart, Even after putting the variables in the apply function, the results come not right: library (alphahull) DT=data.frame(x=c(0.25,0.25,0.75,0.75),y=c(0.25,0.75,0.75,0.25)) Hull - ahull(DT, alpha = 0.5) TEST- data.frame(x=c(0.25,0.5),y=c(0.5,0.5)) plot(Hull) points(TEST) InHul2D -

Re: [R] inahull? from package alphahull not working when used with lapply

2014-10-27 Thread Camilo Mora
Yes, that works. curiously, I tried that initially but it did not work because of the around x. Thank you very much for your help for future readers inhull can be used with apply using: library (alphahull)

[R] Using a function for rows over a subset of columns in data.table

2014-10-27 Thread Camilo Mora
Hi everyone, This may be a trivial solution but I have not been able to figure what is wrong with this code. The basic premise of the code is to use data.table to append a new column to a data.table that indicates if the values per row at two other columns are within a 2d hull generated with

[R] inahull” from package alphahull not working when used with apply

2014-10-26 Thread Camilo Mora
Hi everyone, I have a two column (x,y) database with say 20 million rows. I want to check the points that are inside of a hull created with the package alphahull. The function that does this is call �inahull�, and it runs well when I use it for one point at a time. But when I try to optimize

[R] Plotting sum rather than count in hexbin

2014-10-19 Thread Camilo Mora
Hi everyone, This may be a trivial solution but I would appreciate any help. I have a database with three variables. I would like to plot the first two variables in a xy plot making the color of points proportional to the values in the third variable. Given that many points overlap, I decided

Re: [R] Plotting sum rather than count in hexbin

2014-10-19 Thread Camilo Mora
. Thanks again, Camilo From: Jim Lemon j...@bitwrit.com.au Sent: Sunday, October 19, 2014 10:27 AM To: r-help@r-project.org Cc: Camilo Mora Subject: Re: [R] Plotting sum rather than count in hexbin On Sun, 19 Oct 2014 08:09:28 AM Camilo Mora wrote: Hi

Re: [R] Plotting sum rather than count in hexbin

2014-10-19 Thread Camilo Mora
I figure out a way to display the hexbins color coded proportional to a third attribute of the points falling on a given hexbin. I share it for future reference or in case anyone has a way to improve it. Cheers C library(plotrix) library(hexbin) #creates

[R] Is xyz point inside 3d convex hull?

2014-10-12 Thread Camilo Mora
Hi everyone, I wonder if there is a code in r that can generate a 3d convex hull from a data-frame containing 3 columns and then use another database with the same three columns and for each row determine if the xyz point is inside or not the convex hull generated with the first database? The

[R] Raster in parallel computing?

2014-01-07 Thread Camilo Mora
Hi everyone, I am using the package raster to interpolate a large number of rasters (~1million) of different resolutions to a unique 1degree resolution grid and wonder if you know if it is possible to do this in parallel computer?. My code (example below) works like a charm but it will

Re: [R] Runtime error using ncdf

2013-08-19 Thread Camilo Mora
Hi Dave, I run into this problem with windows 7 and 8. I used the latest versions of r and ncdf as taken from icran. I found my way around this problem breaking the files but it is a petty that ncdf has this bug as it is a quite useful package. Thanks, Camilo Camilo Mora, Ph.D

[R] Runtime error using ncdf

2013-08-17 Thread Camilo Mora
). If of interest to anyone, I ended up splitting my files (making them smaller than 2GB) using a software call NCO: http://www.ncl.ucar.edu/Support/talk_archives/2007/1053.html and then working in R at 64.. Cheers, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii

Re: [R] Runtime error in R

2013-08-15 Thread Camilo Mora
crashes within a millisecond from running the line that tries to open the file. Anyway, I wanted to provide this info in case you may know what could be causing this Runtime error in r. Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available

[R] Runtime error in R

2013-08-13 Thread Camilo Mora
that the code reaches the RAM limit. This makes me to suspect that the error in 64bit is related to a default value on how big the files could be. Anyway, any help will be highly appreciated. Cheers, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available

[R] get column index with match using apply

2013-06-08 Thread Camilo Mora
in setting max in match to be dynamic for each row. I have play around with different configurations and google it with no success. Any input will be greatly appreciated, best, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone

[R] error in rowSums in data.table

2013-05-30 Thread Camilo Mora
hi: I have a datatable with two columns (see below) and I want to create another column that adds the values of the rows in the first two columns. I am trying this: DT[ , col3 :=rowSums(.SD, na.rm = TRUE), .SDcols = c(col1,col2)] but I get this error: Error in inherits(x, data.frame) :

[R] Changing y-axis in ggplot to show proportions instead of density

2013-04-03 Thread Camilo Mora
if something like this possible? Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57 Provider code: 313 Phone 776 2282 From the USA or Canada you have to dial 011 57 313 776 2282

[R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
to the cell to the left. So the results for the example above should be something like: a b c d 0 0 0 0 1 2 3 0 1 0 1 2 I wonder if you may know?. Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57 Provider code: 313 Phone 776 2282 From the USA or Canada you have to dial 011 57 313 776 2282 http://www.soc.hawaii.edu/mora/ Quoting arun

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
NAs gets NAs in the output, which is what I am looking for. I guess a solution is to subset complete rows and then run your line of code. Unless there is an alternative, to tell cumsum to leave NAs as NAs? Thanks again, Camilo Camilo Mora, Ph.D. Department of Geography, University

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
Nice!. Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57 Provider code: 313 Phone 776 2282 From the USA or Canada you have to dial 011 57 313 776 2282 http://www.soc.hawaii.edu

[R] Error with custom function in apply: ”Error in FUN(newX[, i], ...) : unused argument(s) (newX[, i])”

2013-03-23 Thread Camilo Mora
is:### nrows=nrow(data) a=c() for(b in 1:nrows) { c= ColChange(data[b,1],data[b,2],data[b,3:6],2) a=rbind(a,c) } # Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57

[R] loop in a data.table

2013-03-13 Thread Camilo Mora
, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57 Provider code: 313 Phone 776 2282 From the USA or Canada you have to dial 011 57 313 776 2282 http://www.soc.hawaii.edu/mora

[R] loop in a data.table

2013-03-13 Thread Camilo Mora
Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57 Provider code: 313 Phone 776 2282 From the USA or Canada you have to dial 011 57 313 776 2282 http://www.soc.hawaii.edu/mora

[R] replace zeros for NA in a column based on values of another column

2013-03-02 Thread Camilo Mora
the reason of this error or is there an alternative to replace the values in one column based on the values of another? Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii http://www.soc.hawaii.edu/mora/ __ R-help@r

[R] Geographical Interpolation functions

2012-10-03 Thread Camilo Mora
Hi I am comparing different interpolation methods on climate data. I have found quite a few functions (e.g. spline and kriging) but I wonder if Nearest-neighbor interpolation and Natural neighbor function are available in an R package? Thanks, Camilo Camilo Mora, Ph.D. Department

[R] why variations in accuracy between R to ARCGIS for the same point reprojection?

2012-09-02 Thread Camilo Mora
. Unfortunately, the resulting output, although similar in shape to the outputs in R and Arcgis, is still not quite the same. Any thoughts why these differences in supposedly the same calculations? Any input will be greatly appreciated, Thanks, Camilo Camilo Mora, Ph.D. Department of Geography

Re: [R] why variations in accuracy between R to ARCGIS for the same point reprojection?

2012-09-02 Thread Camilo Mora
p.s. I always pride R. It is just hard to image academic life without it... Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently available in Colombia Phone: Country code: 57 Provider code: 313 Phone 776 2282 From the USA or Canada you have to dial

[R] is there colNA for a image? (i.e. How to set the color of NAs or background in an image)

2012-08-04 Thread Camilo Mora
is that that the plot does not work well in the layout with the other image. Any help very much appreciated. Again, my question is how to set the background color of an image in a layout?. Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii

[R] First value in a row

2012-07-24 Thread Camilo Mora
to x3. That is NewColumn .1 .2 .4 Any input greatly appreciated, Thanks, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] First value in a row

2012-07-24 Thread Camilo Mora
.6 0112 .2 .3 NA 0111 .1 NA NA 0110 NA NA NA ,sep=,header=TRUE) the last value (from left to right) should be: .6 .3 .1 NA NAs are always consecutive once they appear. Thanks again, Camilo Camilo Mora, Ph.D. Department of Geography, University of Hawaii Currently

[R] How to replace range of data in a dataframe

2012-02-15 Thread Camilo Mora
Hi: I wonder if anyone may know the answer to this question: COnsider the following data frame (DF): ColumnA ColumnB ColumnC a d d s s e e r e y w y t u i q e l What I need is to

[R] confidence Intervals for predictions in GLS

2010-08-14 Thread Camilo Mora
appreciated, Best, Camilo Camilo Mora, Ph.D. Department of Biology Dalhouisie University Halifax, Canada Phone: (902) 494-7720 http://as01.ucis.dal.ca/fmap/people.php?pid=53 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] Spatial ANCOVA in R

2008-11-15 Thread Camilo Mora
, Camilo Camilo Mora, Ph.D. SCRIPPS Institute of Oceanography University of California San Diego San Diego, USA Phone: (858) 822 1642 http://cmbc.ucsd.edu/People/Faculty_and_Researchers/mora/ And Department of Biology Dalhouisie University Halifax, Canada Phone: (902) 494 3910 http://as01.ucis.dal.ca