Re: [R] dates by week multiple years

2019-02-05 Thread Jim Lemon
Hi Keith, Perhaps you do not want to go with calendar weeks: 365/7 = 52.14 as there are not an even number of weeks in a year, you may want to plot by week from your initial observation. As you are using as.Date, you could simply calculate weeks as: data$Week<-1+as.numeric(data$Date - data$Date[

[R] dates by week multiple years

2019-02-05 Thread Marlin Keith Cox
Hello all, I did not attach data as this is probably simple answer that I cannot find. I am collecting daily data and would like to plot the data by week but now that we are into the new year, my plots started over with 01 after the last week of the year. How can I continuously keep adding weeks

Re: [R] problems when merging two data sets

2019-02-05 Thread Francois COLLIN
Quite agree with Jeff Newmiller and Bert Gunter. The error you get (" 'by' must specify a uniquely valid column") is a very common mistake when the function merge is misused. Although, the function merge is the good choice. Have you read the manual of the function sending the command `?merge`.

Re: [R] data.frame() versus as.data.frame() applied to a matrix.

2019-02-05 Thread William Dunlap via R-help
I think of the methods of as.data.frame as a helper functions for data.frame and don't usually call as.data.frame directly. data.frame() will call as.data.frame for each of its arguments and then put together the the results into one big data.frame. > for(method in c("as.data.frame.list","as.data

Re: [R] data.frame() versus as.data.frame() applied to a matrix.

2019-02-05 Thread Richard M. Heiberger
To me the interesting difference between matrix() and as.matrix() is that as.matrix() retains the argument names as the rows names of the result. > tmp <- structure(1:3, names=letters[1:3]) > tmp a b c 1 2 3 > matrix(tmp) [,1] [1,]1 [2,]2 [3,]3 > as.matrix(tmp) [,1] a1 b2

Re: [R] problems when merging two data sets

2019-02-05 Thread Jim Lemon
Hi Sasha, I'll take a wild guess that your column names have periods (.) replacing the spaces in the names you use: species occurrence -> species.occurrence The error message means that R can't find the variable name you have used in the "by" argument. The second wild guess is that your column na

Re: [R] data.frame() versus as.data.frame() applied to a matrix.

2019-02-05 Thread Rolf Turner
On 2/6/19 12:27 PM, Jeff Newmiller wrote: I have no idea about "why it is this way" but there are many cases where I would rather have to use backticks around syntactically-invalid names than deal with arbitrary rules for mapping column names as they were supplied to column names as R wants th

Re: [R] data.frame() versus as.data.frame() applied to a matrix.

2019-02-05 Thread Jeff Newmiller
I have no idea about "why it is this way" but there are many cases where I would rather have to use backticks around syntactically-invalid names than deal with arbitrary rules for mapping column names as they were supplied to column names as R wants them to be. From that perspective, making the

[R] Calendar Heat Map

2019-02-05 Thread reichmanj
r-Help Form I'm working on a "Time-Series Calendar Heatmap" using the following code. ggplot(myData, aes(monthweek, weekdayf, fill = myData $adjusted)) + geom_tile(colour = "white") + facet_grid(year(myData $date)~monthf) + scale_fill_gradient(low="red", high="green") + xlab("Week of

[R] data.frame() versus as.data.frame() applied to a matrix.

2019-02-05 Thread Rolf Turner
Consider the following: set.seed(42) X <- matrix(runif(40),10,4) colnames(X) <- c("a","b","a:x","b:x") # Imitating the output # of model.matrix(). D1 <- as.data.frame(X) D2 <- data.frame(X) names(D1) [1] "a" "b" "a:x" "b:x" names(D2) [1] "a" "b" "a.

Re: [R] problems when merging two data sets

2019-02-05 Thread Bert Gunter
Show us your code! (as the posting guide below requests. Please read the posting guide). 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 Tue, Feb 5, 2019 at 10

Re: [R] problems when merging two data sets

2019-02-05 Thread Jeff Newmiller
There are many examples of how to do this properly on the web, and many ways you could have failed to follow those examples. You need to be much more specific (using actual R code) about what you did in order for us to help you get past your specific error. [1][2][3] You will also avoid the wha

Re: [R] Help converting file to XTS

2019-02-05 Thread Jeff Newmiller
One thing about POSIXct or POSIXlt... you always need to address the issue of timezone. If your timestamp data are simple (no daylight savings) you may be able to get away with a simple Sys.setenv( TZ="GMT" ) sometime in each R session prior to converting anything to this type (e.g at the begi

[R] problems when merging two data sets

2019-02-05 Thread sasa kosanic
Dear All, I would like to merge two data sets however I am doing something wrong... 1 data set contains 2 columns of 'species occurrence'(1 column) in Germany and 'species names' (2 column). and the second one names of 'Red list species'(1 column) and 'species status' (2 column). so I would like

Re: [R] Help converting file to XTS

2019-02-05 Thread David Winsemius
On 2/5/19 6:06 AM, Johannes Møllerhagen wrote: Hello there! I am a master student working on my master thesis, and I am trying to convert some data to xts so I can apply a highfrequency package to it. At the moment I am trying to use a POSIXct function. I am quite new at this program and I a

Re: [R] Help converting file to XTS

2019-02-05 Thread Bert Gunter
Hard to say without knowing what dat looks like. Can you show us a small sample, perhaps via dput( head( dat)) ? See ?dput, ?head for details. A guess would be that dat is a data frame and not a character string, but Bert Gunter "The trouble with having an open mind is that people keep c

[R] Help converting file to XTS

2019-02-05 Thread Johannes Møllerhagen
Hello there! I am a master student working on my master thesis, and I am trying to convert some data to xts so I can apply a highfrequency package to it. At the moment I am trying to use a POSIXct function. I am quite new at this program and I am having some issue. The file is attached. The c

Re: [R] list with list function

2019-02-05 Thread Andras Farkas via R-help
Thanks Rui and Ivan, works perfectly... Andras On Monday, February 4, 2019, 4:18:39 PM EST, Rui Barradas wrote: Hello, Like this? Map('[', listA, lapply(listB, '*', -1)) Hope this helps, Rui Barradas Às 21:01 de 04/02/2019, Andras Farkas via R-help escreveu: > Hello everyone, > >

[R] [R-pkgs] Major Update to asciiSetupReader Package

2019-02-05 Thread Jacob
The latest version of the package asciiSetupReader includes a number of major improvements and bug fixes. This package lets you read in .dat+.sps and .dat+.sas pair files. See the following for an overview of the package: https://jacobkap.github.io/asciiSetupReader/ For a list of changes please