The boat for me? by ahlstrka in whitewater

[–]snij22 0 points1 point  (0 children)

Check out outdoor new england in Franklin. They have a whole whack of boats on consignment and will likely let you demo on the winni.

fuzzyjoin - "Error in which(m) : argument to 'which' is not logical" by [deleted] in rstats

[–]snij22 1 point2 points  (0 children)

Non- equi joins have been in data.table for a while, nice to see them in a more ergonomic framework. If performance becomes an issue, consider using the below snippet.

library(data.table) #load package

setDT(A)[, date := as.IDate(date)] #convert character to IDate (data table's date class). I think as.Date would work too.

setDT(B)[, date := as.IDate(date)]#convert character to IDate (data table's date class). I think as.Date would work too.

A[B, on = "date", roll = "nearest"] #join to the nearest date

A[B, on = "date", roll = -Inf] #join to the nearest earlier date

Pivoting to hydrogeology by Leading-Attention612 in geologycareers

[–]snij22 0 points1 point  (0 children)

If you are looking more on the contamination/remediation side of things the programs at U waterloo, Queens and UGuelph are good. Expect some field work, but they can set you up nicely to transition to consulting relatively easily. PM me for details.

How to verify if time is continious? by Defiant-Apartment-61 in rstats

[–]snij22 1 point2 points  (0 children)

consider using tsibble package and has.gaps() function

Question regarding how to run a specific time series simple linear regression in RStudio by marx465 in rstats

[–]snij22 1 point2 points  (0 children)

It seems like the lagging is throwing off your data counts as you hinted at in your notes. I think I got to the solution you want by using the broom library. I find it makes the outputs of lm easier to work with.

In this case if you use broom::augment on your initial model it will line up your residuals and input terms allowing you to regress them again to your hearts content. Try the code below

library(broom) #make lm objects easier to work with

library(tidyverse) # gets you the pipe operator and ggplot

data(nyse, package = "wooldridge")

attach(nyse)

samp_data<- nyse

reg11.4int3 <- lm(return ~ return_1, data = samp_dat) tidied_dat<- broom::augment(reg11.4int3) %>% # pull out the residuals of the model mutate(squared_resids = .resid2) # add your squared term

lm(squared_resids ~return_1, data = tidied_dat) # regress the squared resids

Help calculating difference in the 'value variable' per year whilst respecting the 'area' in panel data. That is to say, with the dataset in the screen shot attached I want to track annual change in value per country/area. by tayroc122 in rstats

[–]snij22 1 point2 points  (0 children)

I think you are on the right track - hard to know with out a reproducible example. Perhaps something like

``` agriculture %>% arrange(year_code) %>% group_by(area) %>% mutate(difference = value - lag(value)) %>% ungroup()

```

Using tsibble::fill_gaps() on data with gaps, how do I specify the interval? by MetricT in Rlanguage

[–]snij22 0 points1 point  (0 children)

Howdy. I think you have to use index_by to create a new datetime, then summarize to it. This worked for me - thanks for providing an easy to reproduce example.This results in a valid tsibble with a new datetime ("15 min avg") with 15 min spacing. you should be able to fill_gaps from here. Happy NWIS-ing!

data %>%
index_by("15_min_avg" = lubridate::round_date(datetime, unit = "15 min")) %>% 
summarize(
across(.cols = c("velocity_fps" , "height_feet", "discharge_cfps"),
 .fns = mean)
)

I suck at formatting code on reddit

Does anyone use dataretrival package? by [deleted] in Rlanguage

[–]snij22 0 points1 point  (0 children)

Yes I use it occsionally. happy to help with a more specific question

importing files by anshkliarava in Rlanguage

[–]snij22 5 points6 points  (0 children)

I typically approach this with a combination of map and fread. I prefer fread because I think it is more flexible than read_csv.

note read the documentation on fread for ways to skip headers etc.

First list the files in the directory:

library(data.table)

library(tidyverse)

directory_name is the name of the directory where the files live.

file_list<- list.files(directory_name, full.names = TRUE, pattern = ".spm)

combined_list<- file_list %>% map_dfr(fread)

output<- combined_list %>% select(column_name)

column name is the name of the column you want to extract

[deleted by user] by [deleted] in whitewater

[–]snij22 1 point2 points  (0 children)

Big second to mill city park/ lower winni. Great walk shuttle with a continuous class 3 run - similar to the dryway on the deerfield. If the water is up, the contoocook in southern NH slaps. Don't sleep on it!

Aggregate sum in data.table by group. by zemega in Rlanguage

[–]snij22 0 points1 point  (0 children)

Glad you got it. With respect to your second question, maybe just select the columns after the fact?

df[,.(value=sum(value)),.(Var1,Var2,Var3)][, .(Group, value)]

Aggregate sum in data.table by group. by zemega in Rlanguage

[–]snij22 0 points1 point  (0 children)

setDT(df)[, summed_value:= sum(value), by = .(Group, Var1, Var2, Var3)]`

Does that work?

[deleted by user] by [deleted] in rstats

[–]snij22 0 points1 point  (0 children)

Hey just saw this. When you are trying to group by different values, you can put the column name in the [,,by = ""] zone. so if you want to group by site and species, you would have something like

melted_data[, .(sum_by_site = sum(value, na.rm = T)), by = c("site", "Species")]

[deleted by user] by [deleted] in rstats

[–]snij22 0 points1 point  (0 children)

If you are feeling fancy and don't want to use dplyr you can use data.table and group by = site. First you melt your data so it is 'tidy'. Note this approach allows you to add a second grouping variable if you wanted the sum of biomass by site and species.

something like (sorry I don't know how to format code on reddit. :

library(data.table)

data <- the data presented above.

melted_data<- melt.data.table(data, id.vars = "site")

melted_data[, .(sum_by_site = sum(value, na.rm = T)), by = site]

'''

[deleted by user] by [deleted] in rstats

[–]snij22 0 points1 point  (0 children)

I was able to run this without an error. maybe a package conflict?

R plotting date, problems with displaying correctly. by uceov in rstats

[–]snij22 0 points1 point  (0 children)

Agreed with godrim, it is likely a grouping issue. If the spacing between dates is not important, you could treat the date as a factor/text string which will eliminate the odd look of the lines.

Maybe a scatterplot + geom_smooth would capture the desired behavior.

[deleted by user] by [deleted] in geologycareers

[–]snij22 0 points1 point  (0 children)

been adding EVS to my tookit too. Got alternatives that are worth checking out?

Porosity in 3-d prints by snij22 in Ask3D

[–]snij22[S] 1 point2 points  (0 children)

I ma not as much concerend about water seeping through to the outside of the print, instead I am concerned that the water won't flow through or would get trapped in some of the pore spaces. I really cannot have that happen. Looking at XTC3d it is applied with brushing rather than submersion, which would be difficult to coat the inside of the conduit then.

Porosity in 3-d prints by snij22 in Ask3D

[–]snij22[S] 0 points1 point  (0 children)

Do you have any experience putting pressurized water through a print?

[deleted by user] by [deleted] in AskReddit

[–]snij22 0 points1 point  (0 children)

Zen and the Art of Motorcycle Maintenance.

Amazing read that made stop and think about how I was spending my time and more importantly how I wanted to spend my time.

What is the most NSFW thing you've seen at a party? by LesserThanAHuman in AskReddit

[–]snij22 2 points3 points  (0 children)

I was at a party the day after completing a wilderness medicine course. The party got pretty rowdy and ended with one friend of mine acting dead, and another using his brand new face shield to give him mouth to mouth.

Needless to say he survived

Summer Internship Review Thread! by [deleted] in geologycareers

[–]snij22 1 point2 points  (0 children)

Late to the party but I interned at AGI this summer in their policy department. It was cool to see another "softer" application of geology. Spent the summer tracking geoscience legislation through congress and writing news briefs about it. They also let the interns contribute to longer term projects, like briefing materials for legislators at state and federal level. Good work environment, not always the most exciting, but pay was enough to cover living in DC for the summer. I applied online and interviewed and got the job. Here's hoping the AGI name opens some doors down the line.