Re: [R] tried half-precision but size 2 is unknown on this machine

2015-01-04 Thread Uwe Ligges
Following the posting guide and hence reading the help page first helps: Possible sizes are 1, 2, 4 and possibly 8 for integer or logical vectors, and 4, 8 and possibly 12/16 for numeric vectors. Best, Uwe Ligges On 04.01.2015 08:03, Mike Miller wrote: Thanks for the pedantic insult, but

Re: [R] tried half-precision but size 2 is unknown on this machine

2015-01-04 Thread Duncan Murdoch
On 04/01/2015 12:31 AM, Mike Miller wrote: It's an IEEE standard format: http://en.wikipedia.org/wiki/Half-precision_floating-point_format#IEEE_754_half-precision_binary_floating-point_format:_binary16 This is what I see: writeBin(vec , con, size=2 ) Error in writeBin(vec, con, size =

Re: [R] Separating a Complicated String Vector

2015-01-04 Thread John Posner
I'm coming to R from Python, so I coded a Python3 solution: # data = alabama bates tuscaloosa smith arkansas fayette little rock alaska juneau nome .split() state_list = [alabama, arkansas, alaska] # etc. return_list = [] for word in data: if word in state_list:

Re: [R] sapply function and poisson distribution

2015-01-04 Thread dimnik
thank you for your answer.Yes,that sounds right.I thought the same thing but the problem is how can i generalize the command for every vector of numbers not only for the specific example?not only for c(1,2),c(0.1,0.8). 2015-01-04 0:45 GMT+00:00 Pete Brecknock [via R]

Re: [R] How to group by then count?

2015-01-04 Thread Christian Brandstätter
Dear Monnad, one possible way would be to use as.factor() and in the summary you would get counts for every level. Like this: x = c(1, 1, 2, 1, 5, 2) summary(as.factor(x)) Cheers, Christian Hi all, I thought this was a very naive problem but I have not found any solution which is

Re: [R] tried half-precision but size 2 is unknown on this machine

2015-01-04 Thread Jeff Newmiller
Sorry about the dead lead on the package... it is hexView. It does not support FP16 directly though... You would have to find another way to make that conversion. Some people have posted code that may be usable with Rcpp [1]. I believe your architecture may support hardware conversion of FP32

Re: [R-es] Ayuda identificación elementos en el cluster

2015-01-04 Thread Carlos J. Gil Bellosta
Hola, ¿qué tal? Tu problema es que lo que llamas nombre es un factor. Mira esto: cat(iris$Species[1]) 1 cat(as.character(iris$Species[1])) setosa Un saludo, Carlos J. Gil Bellosta http://www.datanalytics.com El día 4 de enero de 2015, 10:39, Jose Manuel Veiga del Baño chem...@um.es

Re: [R] problem with vegan function rda()

2015-01-04 Thread Jari Oksanen
Lukas, Lukas Kohl llukas.kkohl at gmail.com writes: Hello R-list Maybe someone knows what's going on here. I'm trying to re-run a script I wrote earlier this year using the function rda() in the vegan package. The script run fine back then, and I did not change the dataset, so I was

Re: [R] tried half-precision but size 2 is unknown on this machine

2015-01-04 Thread Prof Brian Ripley
On 04/01/2015 12:12, Duncan Murdoch wrote: On 04/01/2015 12:31 AM, Mike Miller wrote: It's an IEEE standard format: http://en.wikipedia.org/wiki/Half-precision_floating-point_format#IEEE_754_half-precision_binary_floating-point_format:_binary16 This is what I see: writeBin(vec , con, size=2

[R-es] Ayuda identificación elementos en el cluster

2015-01-04 Thread Jose Manuel Veiga del Baño
Hola a todos, Tengo un problema, que no consigo solucionar. En el análisis cluster de 280 elementos lo hago mediante la secuencia: library(cluster)  clusplot(mydata2, fit2$cluster, color=TRUE, shade=TRUE,       labels=2, lines=0) La representacion de los 280 elementos lo hace de forma

[R] How to group by then count?

2015-01-04 Thread Monnand
Hi all, I thought this was a very naive problem but I have not found any solution which is idiomatic to R. The problem is like this: Assuming we have vector of strings: x = c(1, 1, 2, 1, 5, 2) We want to count number of appearance of each string. i.e. in vector x, string 1 appears 3 times; 2

Re: [R] How to group by then count?

2015-01-04 Thread Berend Hasselman
On 04-01-2015, at 10:02, Monnand monn...@gmail.com wrote: Hi all, I thought this was a very naive problem but I have not found any solution which is idiomatic to R. The problem is like this: Assuming we have vector of strings: x = c(1, 1, 2, 1, 5, 2) We want to count number of

Re: [R] tried half-precision but size 2 is unknown on this machine

2015-01-04 Thread Mike Miller
Thanks! So it looks like I can say R writeBin/readBin does not support half-precision floats even though the error message size 2 is unknown on this machine seems to contradict that (for some machine). I tried to figure out from the source code (src/main/connections.c) how it decides what is

Re: [R] How to group by then count?

2015-01-04 Thread MacQueen, Don
This seems to me to be a case where thinking in terms of computer programming concepts is getting in the way a bit. Approach it as a data analysis task; the S language (upon which R is based) is designed in part for data analysis so there is a function that does most of the job for you. (I

[R] dealing with NA in readBin() and writeBin()

2015-01-04 Thread Mike Miller
The help doc for readBin writeBin tells me this: Handling R's missing and special (Inf, -Inf and NaN) values is discussed in the ‘R Data Import/Export’ manual. So I go here: http://cran.r-project.org/doc/manuals/r-release/R-data.html#Special-values Unfortunately, I don't really understand

Re: [R] dealing with NA in readBin() and writeBin()

2015-01-04 Thread Duncan Murdoch
On 04/01/2015 5:13 PM, Mike Miller wrote: The help doc for readBin writeBin tells me this: Handling R's missing and special (Inf, -Inf and NaN) values is discussed in the ‘R Data Import/Export’ manual. So I go here:

Re: [R] dealing with NA in readBin() and writeBin()

2015-01-04 Thread Mike Miller
On Sun, 4 Jan 2015, Duncan Murdoch wrote: On 04/01/2015 5:13 PM, Mike Miller wrote: The help doc for readBin writeBin tells me this: Handling R's missing and special (Inf, -Inf and NaN) values is discussed in the ‘R Data Import/Export’ manual. So I go here:

Re: [R] sapply function and poisson distribution

2015-01-04 Thread Pete Brecknock
dimnik wrote thank you for your answer.Yes,that sounds right.I thought the same thing but the problem is how can i generalize the command for every vector of numbers not only for the specific example?not only for c(1,2),c(0.1,0.8). 2015-01-04 0:45 GMT+00:00 Pete Brecknock [via R]

[R] counting sets of consecutive integers in a vector

2015-01-04 Thread Mike Miller
I have a vector of sorted positive integer values (e.g., postive integers after applying sort() and unique()). For example, this: c(1,2,5,6,7,8,25,30,31,32,33) I want to make a matrix from that vector that has two columns: (1) the first value in every run of consecutive integer values, and

Re: [R] counting sets of consecutive integers in a vector

2015-01-04 Thread Peter Alspach
Tena koe Mike An alternative, which is slightly fast: diffv - diff(v) starts - c(1, which(diffv!=1)+1) cbind(v[starts], c(diff(starts), length(v)-starts[length(starts)]+1)) Peter Alspach -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Mike

Re: [R] counting sets of consecutive integers in a vector

2015-01-04 Thread jim holtman
Here is another approach: v - c(1,2,5,6,7,8,25,30,31,32,33) # split by differences != 1 t(sapply(split(v, cumsum(c(1, diff(v)) != 1)), function(x){ + c(value = x[1L], length = length(x)) # output first value and length + })) value length 0 1 2 1 5 4 225 1 3

Re: [R] counting sets of consecutive integers in a vector

2015-01-04 Thread jim holtman
Here is a solution using data.table require(data.table) x - data.table(v, diff = cumsum(c(1, diff(v)) != 1)) x v diff 1: 10 2: 20 3: 51 4: 61 5: 71 6: 81 7: 252 8: 303 9: 313 10: 323 11: 333 x[, list(value = v[1L], length = .N),

Re: [R] Separating a Complicated String Vector

2015-01-04 Thread William Dunlap
f - function (x) { isState - is.element(tolower(x), tolower(state.name)) w - which(isState) data.frame(State = x[rep(w, diff(c(w, length(x) + 1)) - 1L)], City = x[!isState]) } E.g., V1 -c(alabama, bates, tuscaloosa, smith, arkansas, fayette, little rock, alaska, juneau, nome)

Re: [R] counting sets of consecutive integers in a vector

2015-01-04 Thread Mike Miller
Thanks, Peter. Why not cbind your idea for the first column with my idea for the second column and get it done in one line?: v - c(1,2,5,6,7,8,25,30,31,32,33) M - cbind( v[ c(1, which( diff(v) !=1 ) + 1 ) ] , rle( v - 1:length(v) )$lengths ) M [,1] [,2] [1,]12 [2,]54