Re: [R] Help_urgent_how to calculate mean and sd in biomod 2

2017-10-20 Thread Rui Barradas
it. Or see the class of those objects. class(myBiomodModelEval_55["ROC","Testing.data",,,]) class(myBiomodModelEval_55["TSS","Testing.data",,,]) You do not apply(), simply do mean(myBiomodModelEval_55["ROC","Testing.data",,,]) An

Re: [R] Add a vertical line and some values on a plot

2017-10-22 Thread Rui Barradas
Hello, After the plot just do abline(v = median(A)) As for how to plot points, see, well, ?points(). Hope this helps, Rui Barradas Em 22-10-2017 16:33, varin sacha via R-help escreveu: Dear R-experts, Here below is my code, I would like to add a vertical line on my plot, showing the

Re: [R] Linear regression with tranformed dependant variable

2017-10-23 Thread Rui Barradas
Hello, R-Help answers questions on R code, your question is about statistics. You should try posting the question to https://stats.stackexchange.com/ Hope this helps, Rui Barradas Em 23-10-2017 18:54, kende jan via R-help escreveu: Dear all, I am trying to fit a multiple linear regression

Re: [R] A list of data frames and a list of colnames.

2017-10-23 Thread Rui Barradas
Hello, I think that your code is simple enough to be considered "nice". If you are worried about the for loop, don't, were loops worrying they wouldn't exist. Hope this helps, Rui Barradas Em 23-10-2017 22:09, Ed Siefker escreveu: I have a list of file names, and a

Re: [R] Help_urgent_how to calculate mean and sd in biomod 2

2017-10-26 Thread Rui Barradas
ols_3.4.2 [13] stringr_1.2.0munsell_0.4.3compiler_3.4.2 colorspace_1.3-2 [17] tibble_1.3.4 Hope this helps, Rui Barradas Em 26-10-2017 21:09, Lara Dutra Silva escreveu: Boa noite, Não sei se português. Estou a ter algumas dificuldades na alteração do tamanho, letra de um plot, ou seja, as

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Rui Barradas
# total non zero totals # V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 # 6 8 8 8 8 7 7 8 6 10 grand_total #[1] 76 # another way prod(dim(data)) - sum(zero + na) #[1] 76 Hope this helps, Rui Barradas Em 29-10-2017 10:25, Engin YILMAZ escreveu: Dear R Staff You can see my data.csv

Re: [R] Help with Nesting

2017-10-31 Thread Rui Barradas
Hello, This is cross-posted from https://stackoverflow.com/questions/47042591/how-to-resolve-nested-variables-inside-a-loop-in-r And you already have the answer there. See my comment. Rui Barradas Em 31-10-2017 19:00, Edward Guda via R-help escreveu: How do i resolve this? symbol <-

Re: [R] Function to save results

2017-11-01 Thread Rui Barradas
Hello, If cat is giving you an error try print(attr <- ...etc...) Hope this helps, Rui Barradas Em 01-11-2017 17:21, Priya Arasu via R-help escreveu: Hi David,Thank you for the example.When I try to use the cat function, I get an error cat(attr<-getAttractors(net, type="a

Re: [R] Help in R

2017-11-05 Thread Rui Barradas
Hello, Also tail(test_df$Movie, 10) Hope this helps, Rui Barradas Em 05-11-2017 19:18, Ulrik Stervbo escreveu: R can have a bit of a learning curve... There are several ways to achieve your goal - depending on what you want: test_df <- data.frame(Movie = letters, some.value = rnorm

Re: [R] For each entry type in column?

2017-11-06 Thread Rui Barradas
that the column in question holds "levels" do you mean it's a factor? (factors are R's categorical variables.) Hope this helps, Rui Barradas Em 06-11-2017 19:26, Matti Viljamaa escreveu: It’s sometimes faster to ask from someone who has already learnt the syntax. In this ca

Re: [R] Missing information in source()

2017-11-07 Thread Rui Barradas
Hello, Try print(head(...)) Hope this helps, Rui Barradas Em 07-11-2017 20:01, Tom Backer Johnsen escreveu: Dear R-help, I am running a Mac under Sierra, with R version 3.4.2 and RStudio 1.1.383. When running head () or tail () on an object in a script using source (

Re: [R] weighted average grouped by variables

2017-11-09 Thread Rui Barradas
Hello, Using base R only, the following seems to do what you want. with(mydf, ave(speed, date_time, type, FUN = weighted.mean, w = n_vehicles)) Hope this helps, Rui Barradas Em 09-11-2017 13:16, Massimo Bressan escreveu: Hello an update about my question: I worked out the following

Re: [R] weighted average grouped by variables

2017-11-09 Thread Rui Barradas
Sorry, I messed up. Only checked the final result after sending the previous mail. The solution is wrong. Rui Barradas Em 09-11-2017 13:27, Rui Barradas escreveu: Hello, Using base R only, the following seems to do what you want. with(mydf, ave(speed, date_time, type, FUN = weighted.mean, w

Re: [R] assign NA to rows by test on multiple columns of a data frame

2017-11-22 Thread Rui Barradas
5 #5 5 2 0 NA Hope this helps, Rui Barradas On 11/22/2017 10:34 AM, Massimo Bressan wrote: Given this data frame (a simplified, essential reproducible example) A<-c(8,7,10,1,5) A_flag<-c(10,0,1,0,2) B<-c(5,6,2,1,0) B_flag<-c(12,9,0,5,0) mydf<-data.frame(A, A

Re: [R] assign NA to rows by test on multiple columns of a data frame

2017-11-22 Thread Rui Barradas
Hello, Sorry, I obviously read in a hurry. icol <- grepl("flag", names(mydf)) is.na(mydf[!icol]) <- mydf[icol] == 0 mydf # A A_flag B B_flag #1 8 10 5 12 #2 NA 0 6 9 #3 10 1 NA 0 #4 NA 0 1 5 #5 5 2 NA 0 Hope this help

Re: [R] Remove

2017-12-09 Thread Rui Barradas
21 #6 B 47 512 #9 C 61 521 #10 C 68 235 Hope this helps, Rui Barradas On 12/9/2017 12:48 AM, Ashta wrote: Hi David, Ista and all, I have one related question Within one group I want to keep records conditionally. example within group A I want keep rows that have " x" values ran

Re: [R] Confidence intervals around the MIC (Maximal information coefficient)

2017-12-10 Thread Rui Barradas
ex){ mine(data[index, ])$MIC } results=boot(data = cbind(C,D), statistic = myCor, R = 2000) boot.ci(results,type="all") Hope this helps, Rui Barradas On 12/10/2017 3:19 PM, varin sacha via R-help wrote: Dear R-Experts, Here below is my R code (reproducible example) to calculate the

Re: [R] match and new columns

2017-12-13 Thread Rui Barradas
Hello, Here is one way. tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0) tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0) Hope this helps, Rui Barradas On 12/13/2017 9:36 PM, Val wrote: Hi all, I have a data frame tdat <- read.table(textConnection("A B C Y A1

Re: [R] Help with script

2017-12-28 Thread Rui Barradas
Example , sum) Happy holidays, Rui Barradas On 12/29/2017 12:03 AM, PABLO ORTIZ PINEDA wrote: Hello there. Happy new year for everyone! I need help with a table. This table contains 300 rows and 192 columns. Being the first column the ID of my samples that can have several observations. I nee

Re: [R] Writing text files out of a dataset

2017-12-29 Thread Rui Barradas
Hello, You have to create the vector 'd' outside the loop before using it. d <- numeric(nrow(data)) Only then comes the loop. Hope this helps, Rui Barradas On 12/29/2017 2:31 PM, Luca Meyer wrote: Hello, I am trying to run the following syntax for all cases within the datafra

Re: [R] Help with Regular expression

2018-01-03 Thread Rui Barradas
Hello, I believe the following regex will do it. x <- "\":\"03-JAN-2018 16:00:00\"" sub('^.*(\\d{2}-\\w{3}-\\d{4} \\d{2}:\\d{2}:\\d{2})[:"]', '\\1', x) Hope this helps, Rui Barradas On 1/3/2018 2:26 PM, Christofer Bogaso wrote: Hi,

Re: [R] HOW TO FILTER DATA

2018-01-03 Thread Rui Barradas
- "H04Q007/32" select_many <- c("H04Q007/32", "H04M001/275") oecd2 <- subset(oecd, IPC == select_one) oecd3 <- subset(oecd, IPC %in% select_many) Hope this helps, Rui Barradas On 1/3/2018 7:53 PM, Saptorshee Kanto Chakraborty wrote: Hello, I have a data of P

Re: [R] help needed on quantmod....

2018-01-07 Thread Rui Barradas
IBM&f=d1t1l1c1p2ohgv' In addition: Warning message: In download.file(paste("https://finance.yahoo.com/d/quotes.csv?s=";, : InternetOpenUrl failed: 'Não foi possível processar o nome ou o endereço do servidor' So it's a server error. Note that getSymbols(&quo

Re: [R] [FORGED] RE: [FORGED] Re: Revolutions blog: December 2017 roundup

2018-01-09 Thread Rui Barradas
Hello, I didn't like the video but that has nothing to do with the language, I just happen to prefer other type(s) of music. Rui Barradas On 1/9/2018 8:45 PM, Rolf Turner wrote: On 10/01/18 09:31, Doran, Harold wrote: It would be better for you to instead read the blog post that

Re: [R] random sample set for regression

2018-01-25 Thread Rui Barradas
Hello, Can you please post the output of dput(all) # if all is small dput(head(all, 30)) # if all is big in a mail? Hope this helps, Rui Barradas On 1/24/2018 4:28 PM, Francisca R. Souza Pereira wrote: Hi, I'm not a programmer, so I have a question about R functions, I run the R

Re: [R] Result show the values of fitting gamma parameter

2018-01-29 Thread Rui Barradas
Hello, I believe the following is simpler. It changes the OP's code a bit and uses lapply, not apply. res2 <- lapply(C, fitdist, "gamma") do.call(rbind, lapply(res2, `[[`, "estimate")) # shape rate #A 3.702253 1.234126 #B 31.300800 3.912649 Hope this h

Re: [R] Simulation based on runif to get mean

2018-01-30 Thread Rui Barradas
) Hope this helps, Rui Barradas On 1/30/2018 8:58 AM, Daniel Nordlund wrote: On 1/29/2018 9:03 PM, smart hendsome via R-help wrote: Hello everyone, I have a question regarding simulating based on runif.  Let say I have generated matrix A and B based on runif. Then I find mean for each matrix A

Re: [R] Problems with "predict" function ii

2018-01-31 Thread Rui Barradas
Hello, First of all, your question is about 'predict' but you include graphic instructions that have nothing to do with it. They do not hurt, but the reproducible example should also be minimal. Second, whenever you use RNG's, you should start it with set.seed(). Now, I have edited your code

Re: [R] find unique and summerize

2018-02-02 Thread Rui Barradas
ountry + IDNum, mydata) addmargins(tbl2) Hope this helps, Rui Barradas On 2/3/2018 3:00 AM, Val wrote: Hi all, I have a data set need to be summarized by unique ID (count and sum of a variable) A unique individual ID (country name Abbreviation followed by an integer numbers) may hav

Re: [R] find unique and summerize

2018-02-03 Thread Rui Barradas
l(x != 0)) tbl1b <- addmargins(tbl1[inx, ]) tbl1b Hope this helps, Rui Barradas On 2/3/2018 4:42 PM, Val wrote: Thank you so much Rui. 1. How do I export this table to excel file? I used this   tbl1 <- table(Country, IDNum)   tbl2=addmargins(tbl1)   write.xlsx(tbl2,"tt

Re: [R] Repeated use of dyn.load().

2018-03-01 Thread Rui Barradas
way around, call dyn.unload before modifying the C code.) Hope this helps, Rui Barradas On 3/1/2018 8:52 AM, Rolf Turner wrote: I am working with a function "foo" that explicitly dynamically loads a shared object library or "DLL", doing something like dyn.load("bar.so&qu

Re: [R] Repeated use of dyn.load().

2018-03-01 Thread Rui Barradas
lt;- paste(dynlib, .Platform$dynlib.ext, sep = "") dyn.unload(dynlib) } These have saved me lots and lots of typing along the years. (Note that they still call paste/sep = "") Hope this helps, Rui Barradas Eric On Thu, Mar 1, 2018 at 2:21 PM, Rui Barradas <mailt

Re: [R] couple of how-to-do it in R questions regarding corelations and mean and SD of likert items

2018-03-06 Thread Rui Barradas
se you have a matrix (or data.frame) dat <- cbind(dv, iv) apply(dat[, -1], 2, cor, dat[, 1]) Hope this helps, Rui Barradas On 3/6/2018 12:03 PM, faiz rasool wrote: Dear list, I have the following how-to-do it in R, questions. Suppose I have ten independent variables, and one dependent va

Re: [R] R help

2018-03-31 Thread Rui Barradas
Hello, Maybe you want while(x[i] < 5) not <= Hope this helps, Rui Barradas On 3/31/2018 2:45 PM, Henri Moolman wrote: Could you please provide help with something from R that I find rather puzzling? In the small program below x[1]=1, . . . , x[5]=5. R also finds that x[1]<=

Re: [R] convert numeric variables to factor

2018-04-09 Thread Rui Barradas
Hello, Though Bert's and David's answers are what you should do, note that some R functions that need factors will coerce their input variables when necessary. Have you tried to run the code you haven't posted without coercing to factor? It might run... Hope this helps, Rui

Re: [R] repeating functions for different folders?

2018-04-12 Thread Rui Barradas
t;dir1","dir2","dir3") for(directory in directories) { old_dir <- setwd(directory) # do whatever you want to do # then return to the original directory setwd(old_dir) } Hope this helps, Rui Barradas This will allow you to start and finish in the same dire

Re: [R] how to write a loop to repetitive jobs

2018-04-16 Thread Rui Barradas
t;sn7", i) DF }) seg <- do.call(rbind, seg) row.names(seg) <- NULL Hope this helps, Rui Barradas On 4/16/2018 9:54 PM, Ding, Yuan Chun wrote: Hi All.., I need to do the following repetitive jobs: seg71 <- read.csv("C:/Awork/geneAssociation/removed8samples/neuhausen71/se

Re: [R] Hacked

2018-04-17 Thread Rui Barradas
Hello, Nor do I, no gmail, also got spam. Rui Barradas On 4/17/2018 8:34 PM, Ding, Yuan Chun wrote: No, I do not use gmail, still got dirty spam email twice. -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Fowler, Mark Sent: Tuesday, April 17, 2018

Re: [R] Identifying columns with specific character

2018-04-18 Thread Rui Barradas
n try is https://regex101.com Hope this helps, Rui Barradas On 4/18/2018 11:19 PM, Jim Lemon wrote: Hi Farnoosh, Perhaps this will help: drop_dollar<-function(x) return(as.numeric(as.character(gsub("\\$","",x sapply(My.Data,drop_dollar) Jim On Thu, Apr 19, 2018 a

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

2018-04-19 Thread Rui Barradas
frames in the list. Then save the results as csv files. stats_list <- lapply(txt_list, summary_stats_function) csv_files <- sub("txt", "csv", txt_files) lapply(seq_along(csv_files), function(i) write.csv(stats_list[[i]], csv_files[i])) setwd(old_dir)# reset, if nee

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 O

Re: [R] How to define mutualy exclusive parameters of a function

2018-04-26 Thread Rui Barradas
are mutually exclusive (i.e. the user should define only one of these). How do I code this within the function? See ?missing See also the first example in help("switch") Hope this helps, Rui Barradas HTH, Chuck __ R-help@r-project.org maili

Re: [R] How to visualise what code is processed within a for loop

2018-04-28 Thread Rui Barradas
Hello, instead of ifelse, the following is exactly the same and much more efficient. d0[[nm]] <- as.integer(regexpr(d1[i,1], d0$X0) > 0) Hope this helps, Rui Barradas On 4/28/2018 8:45 PM, Luca Meyer wrote: Thanks Don, for (i in 1:10){ nm <- paste0("V"

Re: [R] How to visualise what code is processed within a for loop

2018-04-28 Thread Rui Barradas
ifelse creates both vectors, the true part and the false part, and then indexes those vectors in order to return the appropriate values. This is the double of the trouble and a great deal of memory used. Rui Barradas On 4/28/2018 10:12 PM, Rui Barradas wrote: Hello, instead of ifelse, the

Re: [R] How to visualise what code is processed within a for loop

2018-04-30 Thread Rui Barradas
Hello, Another thing to note is that regexpr is likely to take (much) more time than ifelse or as.integer. And the code will therefore not be very optimizable. Rui Barradas On 4/30/2018 4:25 PM, MacQueen, Don wrote: Luca, If speed is important, you might improve performance by making d0

Re: [R] Merging dataframes

2018-05-01 Thread Rui Barradas
Hello, Is it something like this that you want? x <- data.frame(a = c(1:3, 5, 5:10), b = c(1:7, 7, 9:10)) y <- data.frame(a = 1:10, b = 1:10) which(x != y, arr.ind = TRUE) Hope this helps, Rui Barradas On 5/1/2018 11:35 AM, Chintanu wrote: Hi, May I please ask how I do the follow

Re: [R] why the length and width of a plot region produced by the dev.new() function cannot be correctly set?

2018-05-04 Thread Rui Barradas
, though. Hope this helps, Rui Barradas On 5/4/2018 5:26 PM, David Winsemius wrote: On May 4, 2018, at 12:04 AM, sunyeping wrote: -- From:David Winsemius Send Time:2018 May 4 (Fri) 13:25 To:孙业平 Cc:R Help Mailing List

Re: [R] Fill down a new column in data frame with a number

2018-05-10 Thread Rui Barradas
20 #8 820 #9 920 #10 1020 So your code works: df$newcolumn <- number Hope this helps, Rui Barradas On 5/10/2018 2:04 PM, Marcelo Mariano Silva wrote: Hi, I am a begginer in R programming. I am traying to create a a column in my data frame filled down with

Re: [R] is there any method to defer the execution of code in r?

2018-05-13 Thread Rui Barradas
Hello, This is cross posted from StackOverflow: https://stackoverflow.com/questions/50314015/is-there-any-method-to-defer-the-execution-of-code-in-r Cross posting is discouraged in r-help. Rui Barradas On 5/13/2018 8:59 AM, akshay kulkarni wrote: dear members, I have created the following

Re: [R] is there any method to defer the execution of code in r?

2018-05-13 Thread Rui Barradas
Hello, I don't understand. It *is* the same question. Same code, same words. And same 'AKSHAY M KULKARNI' (the OP here) and 'AKshayKulkarni' (SO). Exactly the same. Rui Barradas On 5/13/2018 2:07 PM, Jeff Newmiller wrote: I am puzzled by the use of the term "

Re: [R] is there any method to defer the execution of code in r?

2018-05-13 Thread Rui Barradas
se unrelated to R-Help, I will stop it now. Rui Barradas On 5/13/2018 5:41 PM, Berry, Charles wrote: On May 13, 2018, at 9:24 AM, Jeff Newmiller wrote: Not when I click on that link. Nor me, but what I get is actually https://stackoverflow.com/questions/1174799/how-to-make-executi

Re: [R] Installing an Archived Package

2018-05-16 Thread Rui Barradas
Hello, I downloaded the file "polycor_0.7-8.tar.gz" from CRAN with Mozilla Firefox and then ran gzFile <- file.choose() install.packages(gzFile, repos=NULL, type="source") and it worked at the first try. Hope this helps, Rui Barradas On 5/16/2018 6:26 PM, William

Re: [R] Split a data.frame

2018-05-19 Thread Rui Barradas
", split_str) Hope this helps, Rui Barradas On 5/19/2018 12:07 PM, Christofer Bogaso wrote: Hi, I am struggling to split a data.frame as will below scheme : DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF split_str = c('a', 'c')

Re: [R] strange behavior of plotmath

2018-05-21 Thread Rui Barradas
Try plot(1:10, xlab = expression(NO[3]^{'-'}~(mg/L))) Hope this helps, Rui Barradas On 5/21/2018 1:09 PM, Jinsong Zhao wrote: hi there, I find the following codes produce strange output. plot(1:10, xlab = expression(NO[3]^-~(mg/L))) you will notice that the unit, mg/L is in s

Re: [R] removing part of a string

2018-05-21 Thread Rui Barradas
Hello, Try this. ss1 <- "z:f(5, a=3, b=4, c='1:4', d=2)" ss2 <- "f(5, a=3, b=4, c=\"1:4\", d=2)*z" fun <- function(s) sub("(\\().*(\\))", "\\1\\2", s) fun(ss1) #[1] "z:f()" fun(ss2) #[1] "f()*z" Hope

Re: [R] removing part of a string

2018-05-21 Thread Rui Barradas
oups, just \\( and \\) with .* between them, replaced by () Hope this helps, Rui Barradas On 5/21/2018 3:00 PM, Ulrik Stervbo wrote: I would use sub("\\(.*\\)", "()", s) It is essentially the same as Rui's suggestion, but I find the purpose to be more clear. It mi

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Rui Barradas
ypred <- predict(fit) y <- d$crp median(y - ypred)^2 } dat <- data.frame(crp, bmi, glucose) nboot <- 100 medse <- boot(dat, bootMedianSE, R = nboot) medse$t0 mean(medse$t)# This is the value you want Hope this helps, Rui Barradas On 5/22/2018 12:19 AM, vari

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Rui Barradas
I forgot, you should also set.seed() before calling boot() to make the results reproducible. Rui Barradas On 5/22/2018 10:00 AM, Rui Barradas wrote: Hello, If you want to bootstrap a statistic, I suggest you use base package boot. You would need the data in a data.frame, see how you could do

Re: [R] Bootstrap and average median squared error

2018-05-22 Thread Rui Barradas
- ypred)^2) } Sorry, rui Barradas On 5/22/2018 11:32 AM, Daniel Nordlund wrote: On 5/22/2018 2:32 AM, Rui Barradas wrote: bootMedianSE <- function(data, indices){   d <- data[indices, ]   fit <- rq(crp ~ bmi + glucose, tau = 0.5, data = d)   ypred <- predict(fit)   y &l

Re: [R] remove rows of a matrix by part of its row name

2018-05-22 Thread Rui Barradas
"73\\.", row.names(mat)) new_mat <- mat[-inx, ] new_mat Hope this helps, Rui Barradas On 5/22/2018 11:48 AM, Ahmed Serag wrote: Dear R-experts, How can I remove a certain feature or observation by a part of its name. To be clear, I have a matrix with 766 observations as a rows. T

Re: [R] remove rows of a matrix by part of its row name

2018-05-22 Thread Rui Barradas
a special character.) Hope this helps, Rui Barradas On 5/22/2018 12:50 PM, Ahmed Serag wrote: Thank you Mr. Barradas. The code works great. Unfortunately I have also some labeles with 173.1 273.1 the grep script remove them also ? Any ideas Plz, Thanks again *A

Re: [R] find the permutation function of a sorting

2018-05-22 Thread Rui Barradas
uot;dd")) y <- c("D","E", "F")[i] y #[1] "E" "D" "F" # This will give you the inverse, # just apply order() to the output of order(), # function order() is its own inverse y[ order(i) ] #[1] "D" "E" "F&q

Re: [R] Recoding variables in R

2018-05-23 Thread Rui Barradas
) summary(DF$Anxiolytics) Hope this helps, Rui Barradas On 5/23/2018 11:14 AM, Lisa van der Burgh wrote: Hi all, I have a very general question and I think for you maybe very easy, but I am not able to solve it. I have a dataset and that dataset contains the variable Anxiolytics. This va

Re: [R] CKD-Epi formula

2018-05-23 Thread Rui Barradas
) R <- ifelse(Race = "black", 1.159, 1) 141 * pmin(SCr/k, 1)^alpha * pmax(SCr/k, 1)^(- 1.209) * 0.993^Age * R * S } I really don't know what this is, my knoledge of biology is, to be nice, sketchy. [1] https://www.kidney.org/content/ckd-epi-creatinine-equation-2009 Hope t

Re: [R] Manipulation of data.frame into an array

2018-05-24 Thread Rui Barradas
Hello, I am not sure I understand the question, but see if the following is what you want. split(Imputed, cumsum(c(0, diff(Imputed$Y) != 1))) Hope this helps, Rui Barradas On 5/24/2018 3:46 PM, Ioanna Ioannou wrote: Hello everyone, I want to transform a data.frame into an array (lets

Re: [R] Manipulation of data.frame into an array

2018-05-24 Thread Rui Barradas
l be the other imputation. If this is not what you want, can you please post an example output mydata[[1]] from the database you have posted? Rui Barradas On 5/24/2018 4:14 PM, Ioanna Ioannou wrote: Hello everyone, Thank you for this. Nonetheless it is not exactly want i need. I need mydata

Re: [R] Grouping by 3 variable and renaming groups

2018-05-26 Thread Rui Barradas
Hello, See if this is it: priceStore_Grps$StoreID <- paste("Store", seq_len(nrow(priceStore_Grps)), sep = "_") Hope this helps, Rui Barradas On 5/26/2018 2:03 PM, Jeff Reichman wrote: ALCON I'm trying to figure out how to rename groups in a data fr

Re: [R] Grouping by 3 variable and renaming groups

2018-05-26 Thread Rui Barradas
}) res <- do.call(rbind, res) row.names(res) <- NULL Hope this helps, Rui Barradas On 5/26/2018 2:22 PM, Rui Barradas wrote: Hello, See if this is it: priceStore_Grps$StoreID <- paste("Store", seq_len(nrow(priceStore_Grps)), sep = "_") Hope this helps, Rui Barrada

Re: [R] if else with 4 conditions problem

2018-05-27 Thread Rui Barradas
e(dat$A == 1 & dat$B == 0, 1, 0) dat$A3 <- ifelse(dat$A == 0 & dat$B == 1, 1, 0) dat$A4 <- ifelse(dat$A == 0 & dat$B == 0, 1, 0) dat Hope this helps, Rui Barradas On 5/27/2018 3:13 PM, smart hendsome via R-help wrote: Hi everyone, I have two columns:    A               B

Re: [R] Regroup and create new dataframe

2018-06-01 Thread Rui Barradas
’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # #Residual standard error: 286.1 on 29 degrees of freedom #Multiple R-squared:  0.2426,    Adjusted R-squared:  0.1381 #F-statistic: 2.322 on 4 and 29 DF,  p-value: 0.08039 Hope this helps, Rui Barradas Às 16:54 de 01-06-2018, nguy2952 University of Minnesota esc

Re: [R] Σχετ: x-axis tick marks length in ggplot2

2018-06-29 Thread Rui Barradas
Hello, I don't believe what you want is possible because: axis.ticks.x and axis.ticks.y change the width of the tick marks axis.ticks.length changes the length but there is no x and y axis versions, just a general purpose one. Sorry I couldn't be of much help, Rui Barradas Às 1

Re: [R] command to change some vars to missing into my dataset

2018-07-05 Thread Rui Barradas
Hello, What type of data do you have? A vector? Or is it a matrix, a data.frame, a list, etc? Suppose it is a vector named x. Then you could do something like rate <- 0.2 is.na(x) <- sample(length(x), rate*length(x)) At an R prompt type ?is.na ?sample Hope this helps, Rui Barradas

Re: [R] (no subject)

2018-07-16 Thread Rui Barradas
Hello, Please repost in plain text, NO HTML formating. Also, you are missing an open parenthesis right after while: while( sum(abs(Sb-D-Sc-t(Pi))>1E-5)){ Hope this helps, Rui Barradas Às 14:25 de 15-07-2018, Atanasio Alberto Tembe Tembe escreveu: Hello! Is there anyone who can help me

Re: [R] undo compile? (or: remove bytecode from closure)

2018-07-16 Thread Rui Barradas
Hello, Maybe the following is not the recommended way but it works (and I believe makes sense). f <- function(){} formals(f) <- formals(fc) body(f) <- body(fc) f #function (x) #{ # x <- x + 1 # pi * x #} f(1) #[1] 6.283185 Hope this helps, Rui Barradas Às 03:25 de 16-07-20

Re: [R] GGPlot plot

2018-07-18 Thread Rui Barradas
(head(data, 30)) Hope this helps, Rui Barradas Às 17:47 de 18-07-2018, Francesca escreveu: Dear R help, I am new to ggplot so I apologize if my question is a bit obvious. I would like to create a plot where a compare the fraction of the values of a variable called PASP out of the number of

Re: [R] Problem with mean()

2018-07-21 Thread Rui Barradas
Hello, The first argument of mean is a vector, the dots argument is to be "passed to or from other methods." (from ?mean) Try instead mean(c(dd1, dd2)) Hope this helps, Rui Barradas Às 17:39 de 21-07-2018, John Kane via R-help escreveu: Either I am doing something very stup

Re: [R] (no subject)

2018-07-21 Thread Rui Barradas
]=1/(K*A[i,j]*c[1,1]+K*A[i,j]*c[1,2]+K*A[i,j]*c[1,3]) the denominator is zero because A[i,j] and c[] are multiplied by it. 3) What are the i,j in A[i,j] and P[i,j]? Hope this helps, Rui Barradas Às 11:51 de 21-07-2018, Atanasio Alberto Tembe Tembe escreveu: Dear Mr. Barradas, Thank you for

Re: [R] RStudio Exploratory Factor Analysis: write a function that extracts an increasing number of factors

2018-07-23 Thread Rui Barradas
pipe the output of kable() through sub(). do.call("rbind", efas) %>% kable() %>% sub("^\\|[^|]+(\\|.*)", "\\1", .) Hope this helps, Rui Barradas Às 04:21 de 24-07-2018, michael matta escreveu: I have been trying to write a function in Rstudio that

Re: [R] How can I delete column yhat AND STILL retain the order of Response?

2017-04-01 Thread Rui Barradas
anges you do to it will only have effect on the copy. The original is left as it were. So run the same code (with the obvious bug yhatResponse$yhat corrected) but eliminating the 'attach' instruction. And see if it reorders Response. Hope this helps, Rui Barradas Em 01-04-2017

Re: [R] modifying list in loop

2017-04-01 Thread Rui Barradas
print(deal[[tranche]]$CashFlow$BeginBal) } deal } result <- lapply(1:1, function(i) BeginBal(Deal, i)) result Hope this helps, Rui Barradas Em 01-04-2017 18:05, Glenn Schultz escreveu: All, I am working on structuring a FHLMC credit risk transfer deal. I have the dea

Re: [R] Seeking to Dummify Categorical Variables

2017-04-02 Thread Rui Barradas
Hello, Try the following. GENDER$Gender_male <- as.integer(GENDER$Gender == "male") GENDER$Gender_female <- as.integer(GENDER$Gender == "female") Hope this helps, Rui Barradas Em 02-04-2017 19:48, BR_email escreveu: Hi R'ers: I need a jump start to obtain my o

Re: [R] How to source a local R file to a remote session.

2017-04-03 Thread Rui Barradas
Hello, I don't use ESS but I can use google. The first hit on "ESS help mailing list" was https://stat.ethz.ch/mailman/listinfo/ess-help Hope this helps, Rui Barradas Em 03-04-2017 17:46, MacQueen, Don escreveu: Strikes me as a good question for the ESS help mailing list (a

Re: [R] differential use of R version

2017-04-05 Thread Rui Barradas
Hello, Unless you have strong reasons why not, use the most recent one, R 3.3. Hope this helps, Rui barradas Em 05-04-2017 03:47, Bogdan Tanasa escreveu: Dear all, please could you advise me on the following : on a server, in a folder "x86_64-redhat-linux-gnu-library", i have 2 v

Re: [R] Merge selected list element by name

2017-04-13 Thread Rui Barradas
Hello, There's no need to send the same question twice, we've got it at the first try. Maybe I don't understand but is this it? kk1 <- list(a_c = union(kk$a, kk$c), b = kk$b) kk1 $a_c [1] 1 2 3 4 5 6 7 8 9 10 11 $b [1] 6 7 8 9 10 Hope this helps, Rui Barra

Re: [R] seq argument along.with

2017-04-15 Thread Rui Barradas
it's the first time you've came across this function, I can guarantee you that it is really, really usefull. Hope this helps, Rui Barradas Em 15-04-2017 00:58, Carl Sutton via R-help escreveu: Hi Jeff I have seen the seq_along function but never knew the what or why of it. Your

Re: [R] Multiple Histograms in R

2017-04-19 Thread Rui Barradas
Hello, Maybe package psych, function multi.hist is what you want. https://cran.r-project.org/web/packages/psych/index.html And don't post in HTML, your data is unreadable. Hope this helps, Rui Barradas Em 19-04-2017 14:05, prateek pande escreveu: Hi, I have a data as mentioned bel

Re: [R] Error: invalid type (closure) for the variable 'time' - object specific trend

2017-05-11 Thread Rui Barradas
Hello, A closure is, like you say, a function. At an R prompt try: > typeof(time) [1] "closure" So like Duncan suggested rename 'time', for instance capitalize it 'Time'. That should do it. Hope this helps, Rui Barradas Em 11-05-2017 21:20, Tobias Christ

Re: [R] Error: invalid type (closure) for the variable 'time' - object specific trend

2017-05-12 Thread Rui Barradas
Hello, I have never used plm but the standard way of adding a quadratic term is I(time(year)^2) Hope this helps, Rui Barradas Em 12-05-2017 15:40, Tobias Christoph escreveu: Hey guys, thanks a lot for your tips. The regression is finally running. As you said, I had to integrate the column

Re: [R] P value of VAR model from Portmanteau Test

2017-05-23 Thread Rui Barradas
Hello, It seems to be right. You have Chi-squared = 23.724, df = 8, p-value = 0.002549. So try the R function ?pchisq: pchisq(23.724, df = 8, lower = FALSE) [1] 0.002549054 Hope this helps, Rui Barradas Em 23-05-2017 13:08, Dhivya Narayanasamy escreveu: Hi, I am working with bivariate

Re: [R] get the value of a biplane

2017-05-28 Thread Rui Barradas
you need. Hope this helps, Rui Barradas Em 28-05-2017 15:51, Glenn Schultz escreveu: If is specify a spline basis as follows knots <- c(6, 12, 22, 30, 35) x <- c(0.0, .25, 1.0, 2.0, 3.0) SCurve <- bs(x = x, knots = knots, intercept = FALSE, Boundary.knots = c(0,3.5)) I would like to now

Re: [R] get the value of a biplane

2017-05-28 Thread Rui Barradas
d base packages: [1] splines stats graphics grDevices utils datasets methods [8] base loaded via a namespace (and not attached): [1] compiler_3.4.0 tools_3.4.0 Rui Barradas Em 28-05-2017 17:37, Rui Barradas escreveu: Hello, Since function splines::bs returns an object of class bs

Re: [R] get the value of a biplane

2017-05-29 Thread Rui Barradas
Hello, Em 29-05-2017 10:43, Duncan Murdoch escreveu: On May 28, 2017 1:53:29 PM PDT, Rui Barradas wrote: > predict.bs(SCurve, xnew = 40:45) Error in predict.bs(SCurve, xnew = 40:45) : could not find function "predict.bs" You should call it using the generic, i.e. predict

Re: [R] Data import R: some explanatory variables not showing up correctly in summary

2017-06-01 Thread Rui Barradas
Hello, In order for us to help we need to know how you've imported your data. What was the file type? What instructions have you used to import it? Did you use base R or a package? Give us a minimal but complete code example that can reproduce your situation. Hope this helps, Rui Bar

Re: [R] months not working with local language (weekdays does)

2017-06-05 Thread Rui Barradas
] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_3.4.0 Hope this helps, Rui Barradas Em 05-06-2017 19:14, Omar André Gonzáles Díaz escreveu: Hi, I want to reporte some strange behaviour with the "months" function

Re: [R] An R question

2017-06-07 Thread Rui Barradas
Hello, See FAQ 7.31 And try ?all.equal. Hope this helps, Rui Barradas Em 07-06-2017 15:32, li li escreveu: Hi all, In checking my R codes, I encountered the following problem. Is there a way to fix this? I tried to specify options(digits=). I did not fix the problem. Thanks so much

Re: [R] plspm package error in data frame

2017-06-11 Thread Rui Barradas
al Beliefs`, Attitude, `Normative Beliefs`, `Subjective Norm`, `Control Beliefs`, `Perceived Behavioural Control`, Intention, Behaviour) Error in rbind(`Behavioural Beliefs`, Attitude, `Normative Beliefs`, `Subjective Norm`, : object 'Behavioural Beliefs' not found Please correct this

Re: [R] plspm package error in data frame

2017-06-12 Thread Rui Barradas
s, modes = TPB_modes) Error in is_tabular(x) : object 'TPBDATA' not found So we need to know what 'TPBDATA' is. Rui Barradas Em 12-06-2017 00:19, Sarah Sinasac escreveu: Hello Rui, I must have missed that line when I copied and pasted my code. Behavioural Beliefs is: "Be

Re: [R] is.null(mylist[1]) and is.null(mylist$a) returns different values

2017-06-15 Thread Rui Barradas
Hello, You have to be aware that mylist[1] and mylist[[1]] are different things. class(mylist[1]) [1] "list" class(mylist[[1]]) [1] "NULL" Apparently you want/need the latter: is.null(mylist[[1]]) [1] TRUE Hope this helps, Rui Barradas Em 15-06-2017 16:33, ce esc

Re: [R] How to Transform a Factor Variable into a Date

2017-06-19 Thread Rui Barradas
code. Note that I've made up some data, since we don't have the .csv file. x <- "Jun-11" Dataset <- data.frame(x) str(Dataset) tmp <- paste("01", as.character(Dataset$x), sep = "-") Dataset$x <- as.Date(tmp, format = "%d-%b-%y") str(

Re: [R] error while creating a simple graph

2017-06-20 Thread Rui Barradas
Hello, You don't need dev.new, but you need to tell R that the plot is finished by calling dev.off after the plot command. Hope this helps, Rui Barradas Em 20-06-2017 06:18, Yogesh Gupta escreveu: Dear All, I am learning R so it's a very simple problem but I do not understand

  1   2   3   4   5   6   7   8   9   10   >