Re: [R] create multiple categorical variables in a data frame using a loop

2018-04-19 Thread David Winsemius
> On Apr 19, 2018, at 1:22 PM, David Winsemius wrote: > > >> On Apr 19, 2018, at 11:20 AM, Ding, Yuan Chun wrote: >> >> Hi All, >> >> I want to create a categorical variable, cat.pfoa, in the file of pfas.pheno >> (a data frame) based on log2pfoa values. I can do it using the following >>

Re: [R] create multiple categorical variables in a data frame using a loop

2018-04-19 Thread David Winsemius
> On Apr 19, 2018, at 11:20 AM, Ding, Yuan Chun wrote: > > Hi All, > > I want to create a categorical variable, cat.pfoa, in the file of pfas.pheno > (a data frame) based on log2pfoa values. I can do it using the following code. > > pfas.pheno <-within(pfas.pheno, {cat.pfoa<-NA > cat.pfoa[pf

Re: [R] create multiple categorical variables in a data frame using a loop

2018-04-19 Thread Ding, Yuan Chun
Hi Rui, Thank you very much for your help!! It works very well, I got it. Ding -Original Message- From: Rui Barradas [mailto:ruipbarra...@sapo.pt] Sent: Thursday, April 19, 2018 11:35 AM To: Ding, Yuan Chun ; r-help@r-project.org Subject: Re: [R] create multiple categorical variable

Re: [R] create multiple categorical variables in a data frame using a loop

2018-04-19 Thread Rui Barradas
Hello, When programming it is better to use dat[["variable"]] than dat$variable. So your code could be pfas.pheno[[cat.var]] <- NA pfas.pheno[[cat.var]][pfas.pheno[,i] <= quantile(pfas.pheno[,i],0.25, na.rm =T)] <- 0 etc. Untested. Hope this helps, Rui Barradas On 4/19/2018 7:20 PM, Ding

[R] create multiple categorical variables in a data frame using a loop

2018-04-19 Thread Ding, Yuan Chun
Hi All, I want to create a categorical variable, cat.pfoa, in the file of pfas.pheno (a data frame) based on log2pfoa values. I can do it using the following code. pfas.pheno <-within(pfas.pheno, {cat.pfoa<-NA cat.pfoa[pfas.pheno$log2pfoa <=quantile(pfas.pheno$log2pfoa,0.25, na.rm =T)]<-0 c

Re: [R] Reasons to Use R in a Public Administrations and Ideas for a Short Training

2018-04-19 Thread Christopher W Ryan
A few years ago I gave two 5-hour workshops about R to a class of US high school students in a somewhat-accelerated science research class (so these were already science-motivated kids). They had been using mainly Excel, and some SPSS for which the school had a license. Overall they seemed to lik

Re: [R] Question

2018-04-19 Thread Olivier Crouzet
Hi, I think he's talking about how much a statistical estimator is influenced by extreme datapoints, e.g. https://en.m.wikipedia.org/wiki/Robust_statistics#Breakdown_point Olivier -- Olivier Crouzet Assistant Professor @LLING UMR6310 - Université de Nantes / CNRS Guest Scientist @UMCG - Uni

Re: [R] Syntax for capturing and writing file names

2018-04-19 Thread Rui Barradas
Hello, You can process several files at a time with repeated use of *appy functions. Something like the following (not tested). # This first instruction may not be needed old_dir <- setwd("path/to/txt/files") # Get the filenames in a vector and read them in txt_files <- list.files(pattern =

Re: [R] Reasons to Use R in a Public Administrations and Ideas for a Short Training

2018-04-19 Thread Thierry Onkelinx
Dear Lorenzo, First of all I would focus on topics which immediately usable by your audience. E.g. making figures and tables based on preprocessed data files (txt, Excel, GoogleSheets, data base query, ...). And pick examples in which the definition of the figures and tables remains more or less s

[R] calculates the standard error with the delta method

2018-04-19 Thread A. Tafsir DIALLO via R-help
I need your help because I am having difficulties to finalize an econometric model.By the way, I want to calculate the standard error with delta method in a 2sls model with interactions under R.I want to determine the total effect of the institutions (Institutions + D_MinMond * Institutions) on

Re: [R] Event-triggered change in value with a time-delay

2018-04-19 Thread Hannah Meredith
Hi David, Thank you for your suggestion- I will look into it some more. Thanks again, Hannah On Wed, Apr 18, 2018 at 5:09 PM, David Winsemius wrote: > > > On Apr 18, 2018, at 1:04 AM, Hannah Meredith > wrote: > > > > Hello, > > > > I am solving a set of ODEs using deSolve and have run into a

Re: [R] Question

2018-04-19 Thread Keith Jewell
On 15/04/2018 17:26, Marc Girondot via R-help wrote: Le 15/04/2018 à 17:56, alireza daneshvar a écrit : break-down point Can you explain more what you plan to do and give an example of what you have tried to do until now to do a "break down point" in R. Perhaps a "break down point" is common

Re: [R] R Identifying columns with specific character

2018-04-19 Thread Julia Cabrera via R-help
Farnoosh I want to start by appreciating your reply. Thank you so much. I am waiting to know your plan why not give me pic [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.e

[R] Syntax for capturing and writing file names

2018-04-19 Thread Neotropical bat risk assessments
Hi all, I am looking for syntax to read a list of *txt files, (loop through?) each with a different data content but same fields, then run lines of code to produce summary stats (I have working code for this) and add the matching data file name when writing the results of a line of R code.   S