Re: [Rd] Problem using raw vectors with inline cfunction
Hello, That is a bug in inline indeed. I just commited a fix in r-forge. The fix is to obviously replace this as.character by an as.raw. Thanks for teh report. Romain Le 01/02/13 10:25, Karl Forner a écrit : Hello, From what I understood from the documentation I found, when using the inline cfunction with convention=".C", R raw vectors should be given as unsigned char* to the C function. But consider the following script: library(inline) testRaw <- cfunction(signature(raw='raw', len='integer') , body=' int l = *len; int i = 0; Rprintf("sizeof(raw[0])=%i\\n", sizeof(raw[0])); for (i = 0; i < l; ++i) Rprintf("%i, ", (int)raw[i]); for (i = 0; i < l; ++i) raw[i] = i*10; ' , convention=".C", language='C', verbose=TRUE ) tt <- as.raw(1:10) testRaw(tt, length(tt)) When I execute it: $ R --vanilla --quiet < work/inline_cfunction_raw_bug.R sizeof(raw[0])=1 192, 216, 223, 0, 0, 0, 0, 0, 224, 214, *** caught segfault *** address (nil), cause 'unknown' Traceback: 1: .Primitive(".C")(, raw = as.character(raw), len = as.integer(len)) 2: testRaw(tt, length(tt)) aborting ... Segmentation fault (core dumped) I was expecting to get in the C function a pointer on a byte array of values (1,2,3,4,5,6,7,8,9,10). Apparently that is not the case. I guess that the "raw = as.character(raw)," printed in the traceback is responsible for the observed behavior. If it is expected behavior, how can I get a pointer on my array of bytes ? Thanks. Karl -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 R Graph Gallery: http://gallery.r-enthusiasts.com blog:http://romainfrancois.blog.free.fr |- http://bit.ly/RE6sYH : OOP with Rcpp modules `- http://bit.ly/Thw7IK : Rcpp modules more flexible __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Problem using raw vectors with inline cfunction
Hello, >From what I understood from the documentation I found, when using the inline cfunction with convention=".C", R raw vectors should be given as unsigned char* to the C function. But consider the following script: library(inline) testRaw <- cfunction(signature(raw='raw', len='integer') , body=' int l = *len; int i = 0; Rprintf("sizeof(raw[0])=%i\\n", sizeof(raw[0])); for (i = 0; i < l; ++i) Rprintf("%i, ", (int)raw[i]); for (i = 0; i < l; ++i) raw[i] = i*10; ' , convention=".C", language='C', verbose=TRUE ) tt <- as.raw(1:10) testRaw(tt, length(tt)) When I execute it: $ R --vanilla --quiet < work/inline_cfunction_raw_bug.R sizeof(raw[0])=1 192, 216, 223, 0, 0, 0, 0, 0, 224, 214, *** caught segfault *** address (nil), cause 'unknown' Traceback: 1: .Primitive(".C")(, raw = as.character(raw), len = as.integer(len)) 2: testRaw(tt, length(tt)) aborting ... Segmentation fault (core dumped) I was expecting to get in the C function a pointer on a byte array of values (1,2,3,4,5,6,7,8,9,10). Apparently that is not the case. I guess that the "raw = as.character(raw)," printed in the traceback is responsible for the observed behavior. If it is expected behavior, how can I get a pointer on my array of bytes ? Thanks. Karl __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] CRAN task views: markdown? better .CSS?
On Thu, 31 Jan 2013, Michael Friendly wrote: On 1/31/2013 12:01 PM, Achim Zeileis wrote: Michael: CRAN task views are useful, but they seem difficult to write and maintain because the XML format is rather limited (no sectioning) What type of sectioning would you like to have? In the HTML part, you can use the usual structuring tools like , , etc. It's not OK. I think you mean the ... section, where I failed to read the vignette sufficiently closely, which talks about using HTML. and the must be maintained manually. Yes, but I recently started adding tools to help checking this. Hopefully I'll also get round to add some more convenience features for this. Something simple might be a tool to scan the ... section for ... mentions and just print a new section to the console. This would avoid having to remember what you added recently and manually add to the This is (almost) possible with the latest version of "ctv" (0.7-6). You can do: pkg <- check_ctv_packages("MyView.ctv") pkg This shows mismatches between the and sections and with CRAN. And then you can do: writeLines(paste(" ", pkg[[1]], "")) possibly altering the indentation. As I wrote in my previous post: I would like to better integrate these tools with read.ctv() but didn't get round to it, yet. Best, Z -Michael -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel