Re: [R] Help with creating subset of a data frame

2018-07-09 Thread Bert Gunter
%in% instead of == ?"%in%" Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jul 9, 2018 at 3:35 PM, Bhaskar Mitra wrote: > Hello Everyone

[R] Help with creating subset of a data frame

2018-07-09 Thread Bhaskar Mitra
Hello Everyone, I am trying to create a subset of a data frame (df1) based on the first three unique values in the first column (v1). Here are my codes: b <- unique(df1$v1)[1:3] df2 <- subset(df1,df1$v1==b) df1: v1 v2v3 1 ab 1 a1 b1 2 a2 b2 2 a3 b3 3 a4 b4

Re: [R] Something simple not working in group_by

2018-07-09 Thread Bert Gunter
Dunno. But if I understand correctly, here's a base R way to do it: (## using your m) > m$total <- with(m,ave(score,id,FUN = cumsum)) > m id score total 1 1 6 6 2 1 612 3 2 6 6 4 2 3 9 5 3 3 3 6 3 3 6 Cheers, Bert Bert Gunter "The tro

Re: [R] (no subject)

2018-07-09 Thread Jim Lemon
Hi Laura, Here's a basic method: lsdf<-read.table(text="Bird Date Latitude Longitude eb80976 16/07/2012 50.99 -5.85 eb80976 17/07/2012 52.09 -4.58 eb80976 18/07/2012 49.72 -5.56 eb80976 19/07/2012 51.59 -3.17 eb80976 20/07/2012 52.45 -2.03 eb80976 21/07/2012

Re: [R] Something simple not working in group_by

2018-07-09 Thread Sariya, Sanjeev
Strange. Worked fine on: R version 3.4.2 (2017-09-28) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 9 (stretch) Commands: m <- data.frame( id = rep(1:3, each=2), score = rep(c(6,3), each=3) ) as.data.frame(m %>% group_by(id) %>% mutate(total = cumsum(score))) id scor

[R] Something simple not working in group_by

2018-07-09 Thread Sumitrajit Dhar
Hi Folks, I am trying to get a group_by cumsum using: R version 3.5.0 (2018-04-23) -- "Joy in Playing" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin15.6.0 (64-bit) Here is an example of a simple construct that is not working. m <- data.frame( id = r

Re: [R] (no subject)

2018-07-09 Thread Jeff Newmiller
perhaps geom_path rather than geom_line? On July 9, 2018 12:40:15 PM PDT, Hasan Diwan wrote: >https://imgur.com/a/0f72Fsz results from the following code: > >ggplot()+borders("world", colour="gray50", >fill="gray50")+geom_line(aes(x=Longitude, y=Latitude), birds) > >It's ugly, but it will give yo

[R] (no subject)

2018-07-09 Thread Werning, Jan-Philipp
Dear all, In the end I try to run a system dynamics simulation in R using the package deSolve. Therefore I need an auxiliary list (auxs) the model can refer to when it the functions need an auxiliary value. I used a manual list: auxs <- c( aSplitSN=0.4 , aSplitLN=0.6, aSplitSR1=0 , aSplitLR1=

Re: [R] (no subject)

2018-07-09 Thread Hasan Diwan
https://imgur.com/a/0f72Fsz results from the following code: ggplot()+borders("world", colour="gray50", fill="gray50")+geom_line(aes(x=Longitude, y=Latitude), birds) It's ugly, but it will give you a starting point. -- H On Mon, 9 Jul 2018 at 10:53, Laura Steel wrote: > > I am a beginner to R an

Re: [R] (no subject)

2018-07-09 Thread Bert Gunter
Laura: 1. We generally do not do code for you; we expect you to show your efforts first. 2. You might want to post this on the r-sig-geo list instead. They specialize in such issues, so that you are more likely to find helpful advice there. 3. There are many good R tutorials on the web. e.g. see

Re: [R] (no subject)

2018-07-09 Thread Dylan Distasio
You'll probably get a more detailed reply from someone with more expertise, but have you looked at something like what this article proposes: https://medium.com/fastah-project/a-quick-start-to-maps-in-r-b9f221f44ff3 On Mon, Jul 9, 2018 at 1:53 PM Laura Steel wrote: > I am a beginner to R and I

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread William Poling, Ph.D., MPH via R-help
Hi Kevin. Maybe? setwd("C:/RPractice") write_csv(yourfile, path = "yourfile.csv") yourfile <- read.csv("yourfile.csv") HTH WHP On Monday, July 9, 2018, 10:42:24 AM EDT, Kevin Thorpe wrote: Hi. I have some data frames I created previously that seem to not be working correctly anymore.

[R] (no subject)

2018-07-09 Thread Laura Steel
I am a beginner to R and I need to map some Atlantic puffin migration routes onto a map of the Northern Hemisphere. I have a latitude and longitude point per bird, per day. I would like to be able to plot the routes of all my birds on one map and ideally so that I can see at which date they are at

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
Thanks Jeff and all others. I will need to use the tempfile route I guess (I'm running in a Linux OS) for the time-being. After I re-loaded the data frames that were broken before and they seemed fine, after using them for awhile they broke again. I am trying to build my analysis with rmarkd

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Jeff Newmiller
TL;DR: If you want to do this, go ahead and use a temporary file or text connection. Others have pointed out that write.csv returns NULL rather than a file connection, but I haven't seen comments on your impulse to avoid the use of files. *nix operating systems are admirably efficient with mul

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread William Dunlap via R-help
>I tried something like read.csv(write.csv(df,row.names=FALSE)) but got the error > > Error in read.table(file = file, header = header, sep = sep, quote = quote, : > 'file' must be a character string or connection To diagnose this without reading the help(write.csv) look at the return value of

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread David Winsemius
> On Jul 9, 2018, at 8:44 AM, Kevin Thorpe wrote: > > So, after I sent the initial email I quit that R session entirely. When I > started it again to try an provide the example data, the original (that I had > a problem with before) is now behaving itself. Grrr. > > Now no one is going to be

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
So, after I sent the initial email I quit that R session entirely. When I started it again to try an provide the example data, the original (that I had a problem with before) is now behaving itself. Grrr. Now no one is going to believe I ever had a problem with the data. :-) -- Kevin E. T

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Bert Gunter
Can you not anonymize column names, add random noise to some of the columns, etc. ? -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jul 9, 2018 a

Re: [R] R couldnt recognize US Pasific timezome

2018-07-09 Thread MacQueen, Don via R-help
Or (perhaps preferably) "US/Pacific" for daylight savings time support. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 On 7/9/18, 1:46 AM, "R-help on behalf of Jeff Newmiller" wrote: Several of the "c

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
Although your suggestion to provide the data is excellent and one I typically agree with, they data are currently unpublished and so should not be publicly available. I have tried to make a reproducible example in the past (when similar looking things happened), but was unable to. Maybe I'll try

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Eric Berger
Hi Kevin, It's good that you provided the background to the problem. Rather than asking this list to "debug" your proposed solution, I think you would be better off showing some of the "corrupted" data frame and ask for suggestions how to deal with it. (Suggestions may or may not match your initial

[R] Using write.csv as a connection for read.csv

2018-07-09 Thread Kevin Thorpe
Hi. I have some data frames I created previously that seem to not be working correctly anymore. I *think* the problem is that some of the variables in the data frame are of a type called labelled. There are other attributes in the data frame as well. I thought that the easiest way to fix this w

Re: [R] glmer won't allow quasi- distribution mixed models

2018-07-09 Thread Bert Gunter
You should probably post this on the r-sig-mixed-models list instead, where you are more likely to find the expertise to diagnose the problem and give you a helpful response. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things int

Re: [R] about ECDF display in ggplot2

2018-07-09 Thread Bogdan Tanasa
Dear Jeff, thank you for all your time, and very precious help. with best regards. -- bogdan On Mon, Jul 9, 2018 at 1:41 AM, Jeff Newmiller wrote: > Thank you for making the effort... but most attachments get stripped on > the mailing list. Using the reprex package as I suggested and putting

[R] glmer won't allow quasi- distribution mixed models

2018-07-09 Thread Luke Duncan
Dear R folk I am trying to run a series of models on distance data for three different species of animals. My data are not zero-inflated (distances were recorded for locomotion only and so if the animal didn't move, it wasn't recorded) and are Poisson distributed. However, all of the models that I

Re: [R] Zoo changing time-zone when I merge 2 zoo time series

2018-07-09 Thread Christofer Bogaso
My default is set as GMT. On Mon, Jul 9, 2018 at 4:01 PM David Wolfskill wrote: > On Mon, Jul 09, 2018 at 03:52:02PM +0530, Christofer Bogaso wrote: > > Hi, > > > > Below is my code : > > > > library(zoo) > > Dat1 = structure(c(17890, 17770.01, 17600, 17593, 17630.01), index = > > structure(c(15

Re: [R] Zoo changing time-zone when I merge 2 zoo time series

2018-07-09 Thread Eric Berger
I found the following at https://stackoverflow.com/questions/25269425/merge-zoo-removes-time-zone library(xts) merge2=function(x,y) { as.zoo(merge(as.xts(x), as.xts(y)))} If you define the function merge2() as above then merge2(Dat1,Dat2) should be ok HTH, Eric On Mon, Jul 9, 2018 at 1:22

Re: [R] Package installation

2018-07-09 Thread Duncan Murdoch
On 09/07/2018 6:18 AM, Steven Yen wrote: I have had trouble installing packages (e.g., car, aod) in some computers (such as computers in the student lab) but no problem in my own laptop. Installation typically goes through, but after I got out and back in R (and RStudios), the error message says

[R] Package installation

2018-07-09 Thread Steven Yen
I have had trouble installing packages (e.g., car, aod) in some computers (such as computers in the student lab) but no problem in my own laptop. Installation typically goes through, but after I got out and back in R (and RStudios), the error message says "packages xxx not available". That is,

[R] Zoo changing time-zone when I merge 2 zoo time series

2018-07-09 Thread Christofer Bogaso
Hi, Below is my code : library(zoo) Dat1 = structure(c(17890, 17770.01, 17600, 17593, 17630.01), index = structure(c(1512664740, 1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct", "POSIXt"), tzone = "America/Los_Angeles"), class = "zoo") Dat2 = structure(c(15804.28, 15720.61, 1

Re: [R] R couldnt recognize US Pasific timezome

2018-07-09 Thread Jeff Newmiller
Several of the "conventional" three letter timezone abbreviations actually get re-used in different parts of the world, and not all operating system support for timezones include the same shortcuts. The solution is to use the correct timezone string rather than your familiar shortcut... you can

Re: [R] about ECDF display in ggplot2

2018-07-09 Thread Jeff Newmiller
Thank you for making the effort... but most attachments get stripped on the mailing list. Using the reprex package as I suggested and putting the result into the email is by far the safest approach. Since I received your email directly, I did get the attachments. Below is my reproducible exampl

[R] R couldnt recognize US Pasific timezome

2018-07-09 Thread Christofer Bogaso
Hi, I wanted to convert Epoch time to readable time with US Pacific Time Zone using 'anytime' package, as below: > library(anytime) > anytime(1417411980, tz = 'PST') [1] "2014-12-01 05:33:00 GMT" Warning message: In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'PST' However it appears that R co