From riyasmjgeo at gmail.com Sat Feb 4 08:28:44 2017 From: riyasmjgeo at gmail.com (riyasmjgeo) Date: Fri, 3 Feb 2017 23:28:44 -0800 (PST) Subject: [datatable-help] Gradient colours in line graph Message-ID: <1486193324897-4728623.post@n4.nabble.com> Hi all, I am a new user of R. I just did my first real program. I would like to know how to put a gradient (like rainbow() or topo.colors, etc) to a* line* graph. Example: ar1=array(data=1:10,dim=9) ar2=array(data=11:20,dim=9) plot(ar1,ar2,type="l",col="red",lwd=3) Instead of a red color, I would like to make it in rainbow colors. Tried to do my own and tried searching but everywhere its about giving gradient to point graph, not to a line graph. Please help, it is needed for my work. -- View this message in context: http://r.789695.n4.nabble.com/Gradient-colours-in-line-graph-tp4728623.html Sent from the datatable-help mailing list archive at Nabble.com. From Pierrelouis.stenger at gmail.com Wed Feb 8 00:19:54 2017 From: Pierrelouis.stenger at gmail.com (Pierrel) Date: Tue, 7 Feb 2017 15:19:54 -0800 (PST) Subject: [datatable-help] Color extraction, quantification and analysis from image in R Message-ID: <1486509594220-4728690.post@n4.nabble.com> Dear R-help Team, I would like to `quantifying colors in an image`. I work on the iridescence of nacre (mother of pearl), and I want to quantifying three colors (**red, yellow and green**) on this shell (for example on the right picture on the link above). So, I had test some packages (`imager`, `ImageMagick`, `EBImage`...), but I don't really find something that help me. Well, I would like to make color quantification on R, with circles. The area of ??the primitive in pixel may be expressed as that of a circle of equivalent surface area. The primitive is a contiguous area of neighboring pixels of similar color. The center of the circle can be the anchor pixel. So, there is the equation which I think it's ok to do this: > DeltaI = square root[(Ranchor - Ri)? - (Ganchor - Gi)? - (Banchor -Bi)?] Where R,G and B are color components of a pixel, ranging from 0 to 255, anchor is the anchor pixel and i is any pixel around the anchor pixel which are the same equivalent color. There is a image link to the expectation results (from Al?i?ek & Balaban 2012): So there is my (bootable worked) code, but I have really no idea how to continue.. May be try to create a package ? library(png) nacre <- readPNG("test.png") nacre dim(nacre) # show the full RGB image grid.raster(nacre) # show the 3 channels in separate images nacre.R = nacre nacre.G = nacre nacre.B = nacre # zero out the non-contributing channels for each image copy nacre.R[,,2:3] = 0 nacre.G[,,1]=0 nacre.G[,,3]=0 nacre.B[,,1:2]=0 # build the image grid img1 = rasterGrob(nacre.R) img2 = rasterGrob(nacre.G) img3 = rasterGrob(nacre.B) grid.arrange(img1, img2, img3, nrow=1) # Now let?s segment this image. First, we need to reshape the array into a data frame with one row for each pixel and three columns for the RGB channels: # reshape image into a data frame df = data.frame( red = matrix(nacre[,,1], ncol=1), green = matrix(nacre[,,2], ncol=1), blue = matrix(nacre[,,3], ncol=1) ) ### compute the k-means clustering K = kmeans(df,4) df$label = K$cluster ### Replace the color of each pixel in the image with the mean ### R,G, and B values of the cluster in which the pixel resides: # get the coloring colors = data.frame( label = 1:nrow(K$centers), R = K$centers[,"red"], G = K$centers[,"green"], B = K$centers[,"blue"] ) # merge color codes on to df df$order = 1:nrow(df) df = merge(df, colors) df = df[order(df$order),] df$order = NULL # get mean color channel values for each row of the df. R = matrix(df$R, nrow=dim(nacre)[1]) G = matrix(df$G, nrow=dim(nacre)[1]) B = matrix(df$B, nrow=dim(nacre)[1]) # reconstitute the segmented image in the same shape as the input image nacre.segmented = array(dim=dim(nacre)) nacre.segmented[,,1] = R nacre.segmented[,,2] = G nacre.segmented[,,3] = B # View the result grid.raster(nacre.segmented) Someone have a track or any idea ? Thanks for any help.. Link to the article: http://s3.amazonaws.com/academia.edu.documents/41113722/tiger_prawn.pdf?AWSAccessKeyId=AKIAIWOWYYGZ2Y53UL3A&Expires=1486502777&Signature=ZcX1eV8nqS1%2BYRSgvJZyAURvCwo%3D&response-content-disposition=inline%3B%20filename%3DVisual_Attributes_of_Hot_Smoked_King_Sal.pdf -- View this message in context: http://r.789695.n4.nabble.com/Color-extraction-quantification-and-analysis-from-image-in-R-tp4728690.html Sent from the datatable-help mailing list archive at Nabble.com. From elxxg9 at 163.com Sun Feb 19 08:46:41 2017 From: elxxg9 at 163.com (nabblegirl) Date: Sat, 18 Feb 2017 23:46:41 -0800 (PST) Subject: [datatable-help] How to unserialize php-serialized data in R? Message-ID: <1487490401577-4728943.post@n4.nabble.com> In mysql database, have data serialized by php as below: "a:564:{s:13:\"caltime\";s:6:\"65.26\"; I use Rmysql to query these data, but donot know how to unserialize them in R. -- View this message in context: http://r.789695.n4.nabble.com/How-to-unserialize-php-serialized-data-in-R-tp4728943.html Sent from the datatable-help mailing list archive at Nabble.com. From serdar.akin at paylevo.com Sun Feb 19 10:20:12 2017 From: serdar.akin at paylevo.com (Serdar Akin) Date: Sun, 19 Feb 2017 09:20:12 +0000 Subject: [datatable-help] How to unserialize php-serialized data in R? In-Reply-To: <1487490401577-4728943.post@n4.nabble.com> References: <1487490401577-4728943.post@n4.nabble.com> Message-ID: It looks like jsonlite::fromJSON function should do the trick. s?n 19 feb. 2017 kl. 08:51 skrev nabblegirl : > In mysql database, have data serialized by php as below: > > "a:564:{s:13:\"caltime\";s:6:\"65.26\"; > I use Rmysql to query these data, but donot know how to unserialize them in > R. > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/How-to-unserialize-php-serialized-data-in-R-tp4728943.html > Sent from the datatable-help mailing list archive at Nabble.com. > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zkokia at 163.com Mon Feb 20 03:26:26 2017 From: zkokia at 163.com (Kokia Z) Date: Mon, 20 Feb 2017 10:26:26 +0800 (CST) Subject: [datatable-help] splm/spgm : How to specify the instrumental variables for certain dependent variable ? Message-ID: <1aefe205.3068.15a59576d0d.Coremail.zkokia@163.com> spgm(formula, data=list(), index=NULL, listw =NULL, listw2 = NULL, model=c("within","random"), lag = FALSE, spatial.error=TRUE, moments = c("initial", "weights", "fullweights"), endog = NULL, instruments= ~ X1 + X2, lag.instruments = FALSE, verbose = FALSE, method = c("w2sls", "b2sls", "g2sls", "ec2sls"), control = list(), optim.method = "nlminb", pars = NULL) Here's where I'm stuck in R: I need to use the instruments= ~ X1 + X2 as only one of my dependent variable, in stata, the code can be written as : ivreg2 Y x1 x2 x3 ...( xn = IV_1 + IV_2 ),gmm2s robust now in R, how can I specify the instrumental variables for my certain dependent variable? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: