Re: [R] How to aggregate values in corresponding dataframes

2019-03-25 Thread lily li
Each dataframe is a gridded file, so I want to add the values at corresponding grid cells from all the dataframes. On Mon, Mar 25, 2019 at 6:22 PM Rui Barradas wrote: > Sorry, I forgot to ask something. > > When you say you want to add the df's values, what exactly do you mean? > All of the valu

Re: [R] Monte Carlo simulation for ratio and its CI

2019-03-25 Thread Bert Gunter
> ratio1 <- with(dat, sum(v1,na.rm = TRUE)/sum(v3,na.rm=TRUE)) > ratio1 [1] 1.2 It looks like you should spend some more time with an R tutorial or two. This is basic stuff (if I understand what you wanted correctly). Also, this is not how a "confidence interval" should be calculated, but that is

Re: [R] creating a dataframe with full_join and looping over a list of lists.

2019-03-25 Thread Matthew
This is fantastic !  It was exactly what I was looking for. It is part of a larger Shiny app, so difficult to provide a working example as part of the post, and after figuring out how your code works ( I am an R novice), I made a couple of small tweaks and it works great !  Thank you very much,

[R] Monte Carlo simulation for ratio and its CI

2019-03-25 Thread Marna Wagley
Hi R User, I was trying to calculate ratios with confidence interval using Monte Carlo simulation but I could not figure it out. Here is the example of my data (see below), I want to calculate ratios (dat$v1/dat$v3 & dat$v2/dat$v3) and its confidence intervals using a 100 randomly selected data set

Re: [R] loop through columns in a data frame

2019-03-25 Thread Bert Gunter
"Does anyone know how to use loop (or other methods) to create new columns? In SAS, I can use array to get it done. But I don't know how to do it in R." Yup. Practically all users of R know how, as this is entirely elementary. You will too if you make the effort to go through a basic R tutorial, o

Re: [R] loop through columns in a data frame

2019-03-25 Thread jim holtman
R Notebook You forgot to provide what your test data looks like. For example, are all the columns a single letter followed by “_" as the name, or are there longer names? Are there always matched pairs (‘le’ and ‘me’) or can singles occur? Hide library(tidyverse)# create some data test <- tibble(a

[R] loop through columns in a data frame

2019-03-25 Thread Yuan, Keming (CDC/DDNID/NCIPC/DVP) via R-help
Hi All, I have a data frame with variable names like A_le, A_me, B_le, B_me, C_le, C_me if A_le=1 or A_me=1 then I need to create a new column A_new=1. Same operation to create columns B_new, C_new... Does anyone know how to use loop (or other methods) to create new columns? In SAS, I can

[R] [R-pkgs] New package feisr: Fixed effects individual slope models

2019-03-25 Thread Tobias Rüttenauer
Dear R users, Are you worried about the parallel trends assumption in your panel regression? Use fixed effects individual slope models, controlling for heterogeneous trends! I am very pleased to announce that the package feisr is now available on CRAN! CRAN: https://cran.r-project.org/package=fe

Re: [R] Just confirming (?): No way to "export" a (Quartz) plot...

2019-03-25 Thread David Goldsmith
Excellent, thanks! (It just goes to show how hard it can be to find something when you don't know precisely what to look for.) DLG On Mon, Mar 25, 2019 at 8:18 AM Ivan Krylov wrote: > On Sun, 24 Mar 2019 23:35:30 -0700 > David Goldsmith wrote: > > > No way to "export" a (Quartz) plot... > > .

Re: [R] How to create gridded data

2019-03-25 Thread David L Carlson
If the grid is not full you need to identify the missing cells. As an example we can remove rows 3 and 6 from DF1: > DF1miss <- DF1[-c(3, 6), ] > DF2miss <- xtabs(Precip~latitude+longitude, DF1miss) > DF2miss longitude latitude 110.5 111 111.5 112 45.5 3.2 5.0 0.0 2.0 46 6

Re: [R] Printing vectrix

2019-03-25 Thread David L Carlson
Here are a couple of other options. One changes the console width and the other pads the matrix before printing: > # Print rows of 10 values > x <- 1:25 > # Basically cheating and you don't get column numbers > # wd depends on the size of the values and the number > # of values > wd <- (floor(log

Re: [R] Just confirming (?): No way to "export" a (Quartz) plot...

2019-03-25 Thread Ivan Krylov
On Sun, 24 Mar 2019 23:35:30 -0700 David Goldsmith wrote: > No way to "export" a (Quartz) plot... > ...once I've got it the way I want it, (e.g., to a PNG) Well, there seems to be a quartz.save() function, but I cannot attest to its well-behavedness, not having a Mac to test it on. -- Best reg

Re: [R] simulation of PowerGARCH,Threshold GARCH,and GJR GARCH

2019-03-25 Thread Eric Berger
Doing a web search on R CRAN GJR GARCH brought up the rugarch package. The models you mentioned are discussed in the documentation to that package https://cran.r-project.org/web/packages/rugarch/vignettes/Introduction_to_the_rugarch_package.pdf On Mon, Mar 25, 2019 at 2:06 PM Amon kiregu wrot

[R] simulation of PowerGARCH,Threshold GARCH,and GJR GARCH

2019-03-25 Thread Amon kiregu
what is the r code for simulating PowerGARCH,Threshold GARCH,and GJR GARCH in order to capture heteroscedasticity,volatility clustering,etc,,so that i can have simulation of mean part and simulation on innovation part. thanks [[alternative HTML version deleted]] _

[R] Just confirming (?): No way to "export" a (Quartz) plot...

2019-03-25 Thread David Goldsmith
...once I've got it the way I want it, (e.g., to a PNG)? I.e., I either have to create a PNG device and then plot to that, or use Mac's (screen) "Grab" app? Thanks. DLG > sessionInfo() R version 3.5.2 (2018-12-20) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.

Re: [R] How to aggregate values in corresponding dataframes

2019-03-25 Thread Rui Barradas
Sorry, I forgot to ask something. When you say you want to add the df's values, what exactly do you mean? All of the values, by row, by column, what? Rui Barradas Às 10:20 de 25/03/2019, Rui Barradas escreveu: Hello, Maybe something like this? Note that you *never* need to set header = FALS

Re: [R] How to aggregate values in corresponding dataframes

2019-03-25 Thread Rui Barradas
Hello, Maybe something like this? Note that you *never* need to set header = FALSE, it already is the default of read.table. You would have to with read.csv. old_dir <- setwd("~/directory") f1990 <- list.files(pattern = "^199.*\\.txt$") r1990 <- lapply(f1990, read.table) setwd(old_dir) Hope

[R] How to aggregate values in corresponding dataframes

2019-03-25 Thread lily li
Hi R users, I have multiple dataframes in a directory, and with the same postfix ".txt". Each dataframe is a gridded file with just values, but each value represents one grid cell. There are many years, and each year has 12 months, so there are many such files. For each year, I want to read the co

Re: [R] lag function row name with

2019-03-25 Thread Eric Berger
Hi John, dplyr::lag expects a vector. The following should work dplyr::lag(temp[,1],2) HTH, Eric On Mon, Mar 25, 2019 at 9:45 AM John wrote: > Hi, > >I have a dataset whose row names corresponds to months. When I apply lag > function (dplyr package) on this dataset, I get NAs with warning

[R] lag function row name with

2019-03-25 Thread John
Hi, I have a dataset whose row names corresponds to months. When I apply lag function (dplyr package) on this dataset, I get NAs with warning messages. Is there any lag function that carries out the lag but keep the row names? I will have two datasets. The dates of the datasets are not exact

Re: [R] Printing vectrix

2019-03-25 Thread K. Elo
Hi! 2019-03-25 kello 09:30 +0800, Steven Yen wrote: > The second command is ugly. How can I print the 25 numbers into 2 > rows > of ten plus a helf row of 5? Thanks. Something like this? x<-1:25; for (i in seq(1,length(x),10)) print(x[i:ifelse((i+9)>length(x),length(x),i+9)]) HTH, Kimmo _