[R] cluster analysis

2015-06-16 Thread Venky
Hi friends, I have data like this Group Employee size WOE Employee size2 Weight of Evidence 1081680995 0 0.12875537 0.128755 -0.30761 1007079896 1 0.48380133 -0.46544 -0.70464 1000507407 2 0.26029825 -0.46544 0.070221 1006400720 3 0.12875537 0.128755 0.151385 1006916029 4 0.12875537 -0.05955

[R] Restricting Decimal Places in the Output

2015-06-16 Thread Shivi82
Good Morning All, I have working on a data set where I am finding mean and median for weight variable on a daily basis. The code: aggr<-aggregate(retail$weight,list(retail$ship.date),mean) This is giving me an accurate result however with 4 decimal places for the mean weight. In order to restric

Re: [R] Exporting from R to Excel or .csv

2015-06-16 Thread Jeff Newmiller
A CSV with multiple data frames would not conform to the standard definition of a CSV file. The XLConnect package can be used to generate Excel workbooks. There are other packages also, but they are mostly either too simplified to allow filling multiple sheets or too finicky for my taste. That

[R] Exporting from R to Excel or .csv

2015-06-16 Thread Kevin Kowitski
Hello,    Does anyone have some insight on how to; or where I can find better information on how to, export multiple data.frames of different dimensions to the same .csv or excel file? -Kevin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and

[R] hash::hash(...) assignment & clearing

2015-06-16 Thread Murat Tasan
The hash package implements hashmaps which must be cleared prior to removal to free memory, e.g.: > x <- hash(some_long_list_of_keys_and_values_here) > clear(x) > rm(x) I first assumed this held for re-assignment, too... e.g. one should: > x <- hash(some_long_list_of_keys_and_values_here) > clea

Re: [R] problem with nlme, environments, and packages

2015-06-16 Thread Greg Hather
Thank you, Duncan! Your suggestion worked! Greg On Tue, Jun 16, 2015 at 12:20 PM, Duncan Murdoch wrote: > On 16/06/2015 10:34 AM, Greg Hather wrote: > > Hi Duncan, > > > > I checked the global environment, and it was empty, so I think that > > rules out the second possibility. I posted a tarb

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Bert Gunter
Yes, indeed. Thanks, David. But if you check, tapply, aggregate(), by(), etc. are all basically wrappers to lapply() .So it's all a question of what syntax one feels most comfortable with. However note that data.table, plyR stuff and perhaps others are different in that they re-implement the under

Re: [R] reading daily snow depth data

2015-06-16 Thread Alemu Tadesse
Thank you Jim and Bob. This is really big help for me. Jim, this is your second time to help me out. Best Alemu On Tue, Jun 16, 2015 at 1:50 PM, boB Rudis wrote: > This look similar to snow data I used last year: > https://github.com/hrbrmstr/snowfirst/blob/master/R/snowfirst.R > > All the da

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread David Winsemius
On Jun 16, 2015, at 11:18 AM, Clint Bowman wrote: > Thanks, Dimitri. Burt is the real wizard here--I'll bet he can conjure up an > elegant solution. This would be base method: > by( md[-4]==5, md[4], colSums) device: 1 a b c 1 2 0 - devic

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread David L Carlson
Not in base, but in stats: > aggregate(md[,-4]==5, list(device=md$device), sum, na.rm=TRUE) device a b c 1 1 1 2 0 2 2 0 1 0 3 3 1 0 2 - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Origin

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Bert Gunter
... my bad! -- I filed to read carefully. A base syntax version is: dat <- data.frame (a=sample(1:5,10,rep=TRUE), b=sample(3:7,10,rep=TRUE), g = sample(7:9,10,rep=TRUE)) dev <- sample(1:3,10,rep=TRUE) sapply(dat,function(x) tapply(x,dev,function(x)sum(x==

[R] rdde : DDE connections on R

2015-06-16 Thread Juan Manuel Truppia
Hi all, I'm building a new package for DDE connections on R. It's called rdde and lives in https://bitbucket.org/juancentro/rdde. It's in alpha stage, but operational. It has a very simple vignette which explains the main reason you should try rdde vs tcltk2 (the only other option available) : perf

[R] mlogit error

2015-06-16 Thread mikebarr
Hello, I am trying to run a mixed logit model (panel form) with the mlogit package. I am running into the following error: "Error in random.nb[, sel, drop = F] : subscript out of bounds". I have searched the R Help forum (and online) and see no instances of this error. Below is the coding that I

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Dimitri Liakhovitski
Thank you guys - it's a great learning: 'summarise_each' and 'funs' On Tue, Jun 16, 2015 at 3:47 PM, Hadley Wickham wrote: > On Tue, Jun 16, 2015 at 12:24 PM, Dimitri Liakhovitski > wrote: >> Hello! >> >> I have a data frame: >> >> md <- data.frame(a = c(3,5,4,5,3,5), b = c(5,5,5,4,4,1), c = c(1

Re: [R] reading daily snow depth data

2015-06-16 Thread boB Rudis
This look similar to snow data I used last year: https://github.com/hrbrmstr/snowfirst/blob/master/R/snowfirst.R All the data worked pretty well. On Tue, Jun 16, 2015 at 3:21 PM, jim holtman wrote: > Here is an example of reading in the data. After that it is a data frame > and should be able t

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Hadley Wickham
On Tue, Jun 16, 2015 at 12:24 PM, Dimitri Liakhovitski wrote: > Hello! > > I have a data frame: > > md <- data.frame(a = c(3,5,4,5,3,5), b = c(5,5,5,4,4,1), c = c(1,3,4,3,5,5), > device = c(1,1,2,2,3,3)) > myvars = c("a", "b", "c") > md[2,3] <- NA > md[4,1] <- NA > md > > I want to count num

Re: [R] reading daily snow depth data

2015-06-16 Thread jim holtman
Here is an example of reading in the data. After that it is a data frame and should be able to process it with dplyr/data.table without much trouble: > x <- readLines(" http://www1.ncdc.noaa.gov/pub/data/snowmonitoring/fema/06-2015-dlysndpth.txt ") > writeLines(x, '/temp/snow.txt') # save for te

[R] Polysomnographic data analysis with R?

2015-06-16 Thread Charles Novaes de Santana
Dear all, Do you know if there is any R package or function we can use to analyze polysomnographic data? For example, something that can import an EDF file (or in a different format) and can give some properties of the polysomnographic records like periods of different sleep phases, etc. I looke

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Dimitri Liakhovitski
Thank you, Clint. That's the thing: it's relatively easy to do it in base, but the resulting code is not THAT simple. I thought dplyr would make it easy... On Tue, Jun 16, 2015 at 2:06 PM, Clint Bowman wrote: > May want to add headers but the following provides the device number with > each set f

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Clint Bowman
Thanks, Dimitri. Burt is the real wizard here--I'll bet he can conjure up an elegant solution. For me, just reaching a desired endpoint is enough. Clint Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Departm

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Clint Bowman
May want to add headers but the following provides the device number with each set fo sums: for (dev in (unique(md$device))) {cat(colSums(subset(md,md$device==dev)==5,na.rm=T),dev,"\n")} Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET:

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Dimitri Liakhovitski
Except, of course, Bert, that you forgot that it had to be done by device. Your solution ignores the device. md <- data.frame(a = c(3,5,4,5,3,5), b = c(5,5,5,4,4,1), c = c(1,3,4,3,5,5), device = c(1,1,2,2,3,3)) myvars = c("a", "b", "c") md[2,3] <- NA md[4,1] <- NA md vapply(md[myvars], funct

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Dimitri Liakhovitski
Thank you, Bert. I'll be honest - I am just learning dplyr and was wondering if one could do it in dplyr. But of course your solution is perfect... On Tue, Jun 16, 2015 at 1:50 PM, Bert Gunter wrote: > Well, dplyr seems a bit of overkill as it's so simple with plain old > vapply() in base R : > >

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Bert Gunter
Well, dplyr seems a bit of overkill as it's so simple with plain old vapply() in base R : > dat <- data.frame (a=sample(1:5,10,rep=TRUE), +b=sample(3:7,10,rep=TRUE), +g = sample(7:9,10,rep=TRUE)) > vapply(dat,function(x)sum(x==5,na.rm=TRUE),1L) a b g 5 4

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Clint Bowman
It would help if I could see beyond my allergy meds. A start could be: colSums(subset(md,md$device==1)==5,na.rm=T) colSums(subset(md,md$device==2)==5,na.rm=T) colSums(subset(md,md$device==3)==5,na.rm=T) Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Dimitri Liakhovitski
No problem at all, Clint. I was just trying to figure out of dplyr can do it. On Tue, Jun 16, 2015 at 1:40 PM, Clint Bowman wrote: > Any problem with > > colSums(md==5, na.rm=T) > > Clint BowmanINTERNET: cl...@ecy.wa.gov > Air Quality Modeler INTERNET:

Re: [R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Clint Bowman
Any problem with colSums(md==5, na.rm=T) Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7

[R] dplyr - counting a number of specific values in each column - for all columns at once

2015-06-16 Thread Dimitri Liakhovitski
Hello! I have a data frame: md <- data.frame(a = c(3,5,4,5,3,5), b = c(5,5,5,4,4,1), c = c(1,3,4,3,5,5), device = c(1,1,2,2,3,3)) myvars = c("a", "b", "c") md[2,3] <- NA md[4,1] <- NA md I want to count number of 5s in each column - by device. I can do it like this: library(dplyr) group_b

Re: [R] Question about XML package (accurately access one attribute in an multi-attribution node on the web page)

2015-06-16 Thread Boris Steipe
Humphrey - Any "correct" method requires you to specify _uniquely_ what you are looking for. If the bookmark keyword is necessary and unique, it appears you have a working solution. Or what else where you trying to accomplish? Cheers, Boris On Jun 16, 2015, at 9:01 AM, Humphrey Zhao wrote:

Re: [R] Error in local package install

2015-06-16 Thread Duncan Murdoch
On 16/06/2015 1:27 PM, Uwe Ligges wrote: > > > On 16.06.2015 16:33, Axel Urbiz wrote: >> Thanks again Uwe. I haven't renamed the file, only in the text sent to >> R-help. Here's the error again I'm getting. Sorry, this s a bit >> frustrating... > > No idea. Perhaps the down load failed? Can you

Re: [R] Error in local package install

2015-06-16 Thread Uwe Ligges
On 16.06.2015 16:33, Axel Urbiz wrote: Thanks again Uwe. I haven't renamed the file, only in the text sent to R-help. Here's the error again I'm getting. Sorry, this s a bit frustrating... No idea. Perhaps the down load failed? Can you open the file using some zip software and extract the DE

Re: [R] problem with nlme, environments, and packages

2015-06-16 Thread Duncan Murdoch
On 16/06/2015 10:34 AM, Greg Hather wrote: > Hi Duncan, > > I checked the global environment, and it was empty, so I think that > rules out the second possibility. I posted a tarball at > > https://drive.google.com/file/d/0B8hBX90jtuLcaGtOUktqV2V4UUU/view?usp=sharing > > Thank you for your help

[R] reading daily snow depth data

2015-06-16 Thread Alemu Tadesse
Dear All, I was going to read daily snow data for each state and station/city from the following link. I was not able to separate a given state's data from the rest of the contents of the file, read the data to a data frame and save it to file. http://www1.ncdc.noaa.gov/pub/data/snowmonitoring/f

Re: [R] Boxplot using a shapefile

2015-06-16 Thread Preethi Balaji
Dear all, Thanks very much for your help! I will keep your suggestions in mind and will get back to you if I get stuck! On Tue, Jun 16, 2015 at 1:28 PM, Roger Bivand wrote: > Boris Steipe utoronto.ca> writes: > >> >> Your workflow in principle is: >> >> - read the image into an object for whi

[R] Question about XML package (accurately access one attribute in an multi-attribution node on the web page)

2015-06-16 Thread Humphrey Zhao
Dear Sir/Madam: Thank you for your attention to my question. I have downloaded the source code of some web pages by RCurl, and I am trying to extract the URL from them. In  these web pages, there are many nodes contains the same URL, such like the  followings: http://cos.name/2015/05/the-data-wi

[R] Error working dsm: Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

2015-06-16 Thread Milagros Antun
Hello, I`m trying to use dsm package, *(library(Distance); library(dsm)*) , following Miller`s Appendix ( http://onlinelibrary.wiley.com/store/10./2041-210X.12105/asset/supinfo/mee312105-sup-0001-AppendixS1.pdf?v=1&s=ced953b57365e5eb5753f0ad76dcc02c26918736 ). I work with three dataframes, wh

Re: [R] problem with nlme, environments, and packages

2015-06-16 Thread Bert Gunter
An aside... Just wanted to point out that: fun <- function(x)log(x) can be more simply replaced by: fun <- log Functions in R a full first class objects and can be treated as such. In your example, this is still silly of course, but becomes relevant in function calls where you can do things li

Re: [R] model selection

2015-06-16 Thread Bert Gunter
Wrong list! This is about R. Post on a statistics list like stats.stackexchange.com for statistics questions. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Mon, Jun 15, 2015 at 3:55 PM, bruno cid

Re: [R] Error in local package install

2015-06-16 Thread Axel Urbiz
Thanks again Uwe. I haven't renamed the file, only in the text sent to R-help. Here's the error again I'm getting. Sorry, this s a bit frustrating... Thanks, Axel Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open the connection In addition: Warning messag

Re: [R] Error in local package install

2015-06-16 Thread Uwe Ligges
On 16.06.2015 15:16, Axel Urbiz wrote: Thanks Uwe. Actually, the problem persists in R-3.2.1. If it helps, the .zip file is here: http://win-builder.r-project.org/yC8eUu09w3Ui/ Works for me, but your error message is: "cannot open compressed file 'mypackage/DESCRIPTION'" which suggests

Re: [R] problem with nlme, environments, and packages

2015-06-16 Thread Greg Hather
Hi Duncan, I checked the global environment, and it was empty, so I think that rules out the second possibility. I posted a tarball at https://drive.google.com/file/d/0B8hBX90jtuLcaGtOUktqV2V4UUU/view?usp=sharing Thank you for your help! Greg [[alternative HTML version deleted]]

Re: [R] Error in local package install

2015-06-16 Thread Axel Urbiz
Thanks Uwe. Actually, the problem persists in R-3.2.1. If it helps, the .zip file is here: http://win-builder.r-project.org/yC8eUu09w3Ui/ Thank you, Axel. On Mon, Jun 15, 2015 at 5:41 PM, Uwe Ligges wrote: > > > On 15.06.2015 22:32, Axel Urbiz wrote: > >> Hello, >> >> I've built a windows b

Re: [R] Boxplot using a shapefile

2015-06-16 Thread Roger Bivand
Boris Steipe utoronto.ca> writes: > > Your workflow in principle is: > > - read the image into an object for which you can obtain values-per-pixel in a 2D structure; > - read the shapefile and convert into a polygon; > - determine the bounding box of the polygon; > - use the inout() function of

Re: [R] problem with nlme, environments, and packages

2015-06-16 Thread Duncan Murdoch
On 15/06/2015 8:32 PM, Greg Hather wrote: > Hello R users, > > I encountered a strange problem while writing a package that uses the > nlme function. First, I wrote some code that uses the nlme function, > and it ran without errors. However, when I tried to put the code into > a package, the nlm

Re: [R] Missing Values in Table Statement

2015-06-16 Thread PIKAL Petr
Hi actually output from dput is the most user friendly way of supplying data. try just copy this part below - temp <- structure(list(dusik = c(1814L, 2844L, 3121L, 3286L, 3515L, 2478L, 1891L), kyslik = c(5224L, 8632L, 9214L, 9765L, 10428L, 7403L, 5469L), co2 = c(20188L, 32118L, 35299L, 3678