Re: [R] year and week to date - before 1/1 and after 12/31

2018-10-17 Thread Jeff Newmiller
You cannot obtain a predictable result by sending invalid time representation data to strptime... you have to work with valid time representations. See sample approach below: weekEnds <- function( DF ) { d1_1 <- as.Date( sprintf( "%04d 1 1"

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-17 Thread Bert Gunter
If you wish to use R, you need to at least understand its basic data structures and functionality. Expecting that mimickry of code in special packages will suffice is, I believe, an illusion. If you haven't already done so, you should go through a basic R tutorial or two (there are many on the web;

Re: [R] Simulating data with nested random effects

2018-10-17 Thread Bert Gunter
This would almost certainly fit better on the r-sig-mixed-models list,rather than here. You are more likely to get authoritative responses about this specialized statistical topic there. Also -- these are **plain text** mailing lists. Please do not post in html. Cheers, Bert Bert Gunter "The t

[R] Simulating data with nested random effects

2018-10-17 Thread Peter Wijeratne
Hello, I would like to simulate nested data, where my mixed effects model fitted to real data has the form: y ~ time + (1 | site/subject) I then take the hyper-parameters from this model to simulate fake data, using this function: create_fake <- function(J,K,L,HP,t){

Re: [R] Matching multiple search criteria (Unlisting a nested dataset, take 2)

2018-10-17 Thread Nathan Parsons
I do not have your command of base r, Bert. That is a herculean effort! Here’s what I spent my night putting together: ## Create search terms ## dput(st) st <- structure(list(word1 = c("technique", "me", "me", "feel", "feel" ), word2 = c("olympic", "abused", "hurt", "hopeless", "alone" ), word3 =

[R] Random selection of points in SpatialPointsDataFrame with distance constraint

2018-10-17 Thread Nielson Pasqualotto
I'm trying to select points randomly (without replacement) from a SpatialPointsDataFrame (input object) with a minimum distance of 3,000 meters between them. I want to get random 50% of all points and create a vector object with lines index as result. I tried to use sample() function but I still di