Re: [R] [External] Parser For Line Number Tracing

2025-01-20 Thread IVO I WELCH
There is a little catch-22 here. I would be happy to fund a student to spend a summer cleaning up the error messages and making it more userfriendly, but the catch-22 problem is that I don’t have much confidence that this effort would be adopted into the basic R distribution — and the only

[R] R Shiny Help - Trouble passing user input columns to emmeans after ANOVA analysis

2024-06-06 Thread I B
Hello everybody, I have experience coding with R, but am brand new to R Shiny. I am trying to produce an application that will allow users to upload their own dataset, select columns they want an ANOVA analysis run on, and generate graphs that will allow users to view their results. However, I am

Re: [R] Including a large number of variables in a formula.

2019-06-06 Thread Rolando I. Valdez via R-help
[lvadd %in% names(wageszm14)] > > > On 5 Jun 2019, at 06:46 , Rolando I. Valdez via R-help < > r-help@r-project.org> wrote: > > > > Hello, > > > > I have almost 40 variables that I am trying to include in a formula. > > > > I tried to includ

[R] Including a large number of variables in a formula.

2019-06-05 Thread Rolando I. Valdez via R-help
Hello, I have almost 40 variables that I am trying to include in a formula. I tried to include them using as.formula(), however the variables do not follow a patter in the name. e.g. These variables are named like: lvacb23 lvacb30 lvacb300 lvacb40 . lvacb81. > lvadd <- paste0("

Re: [R] scatter3D and colours

2016-07-14 Thread Jorge I Velez
Thank you very much, Sarah, for your help. The colvar argument was certainly what I needed. I will follow your suggestion. Cheers, Jorge.- On Thu, Jul 14, 2016 at 1:29 PM, Sarah Goslee wrote: > I assume you want some variant of: > with(d0, scatter3D(X, Z, Y, bty = "b2", co

[R] scatter3D and colours

2016-07-14 Thread Jorge I Velez
Dear R-help, I am using the plot3D package to produce 3D spheres along with 95% CIs distinguishing each sphere with a predefined colour (see the reproducible example at the end). I have been successful in producing a similar plot using a different data set (kindly see https://www.dropbox.com/s

Re: [R] Extract every 2 element for a list which are not equal in length

2016-03-07 Thread Jorge I Velez
Dear Mohammad, What's wrong with the result? Best, Jorge.- On Monday, March 7, 2016, Mohammad Tanvir Ahamed via R-help < r-help@r-project.org> wrote: > Hi, > > a <- c(1:5)b <- c(1:3) > c <- 1 > d <- 5 > e <- list(a,b,c,d) > > # To extract every 1st element > lapply(e,"[[",1) > > ## Out-put > [[1]

[R] Options for running Hausman-Taylor with robust standard errors

2015-11-13 Thread Alex I
This has been eating at me for a very long time. From everything I understand, the plm package does not yet allow robust standard errors to be calculated for the Hausman-Taylor using the coeftest command you would for other estimators (i.e. pooled, within, random). This is of course the error

Re: [R] Extract entries from matrix

2015-11-04 Thread Jorge I Velez
Dear Dr. Steipe, Thank you for the code. It does exactly what I needed. Best regards, Jorge.- On Wed, Oct 28, 2015 at 1:18 PM, Boris Steipe wrote: > Your code does not produce the matrix in your image. > The first three rows contain all-zeros and the last row is missing. > The

Re: [R] Extract entries from matrix

2015-10-28 Thread Jorge I Velez
Dear all, I thought I would better send an image illustrating that the problem is (hope the file gets through). In the picture, the matrix "m" is given by ## input m <- structure(c(0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 3, 3, 3, 3, 3, 3,

Re: [R] Extract entries from matrix

2015-10-27 Thread Jorge I Velez
Thank you all for your solutions and comments. As Dr. Carlson mentioned, we leave rows 1 to 3 out as they are all zeroes. Then, the entries I need to select from m are entry value 4,1 ---> 1 5,2 ---> 2 6,3 ---> 3 7,1 ---> 1 8,2 ---> 2 9

Re: [R] Extract entries from matrix

2015-10-27 Thread Jorge I Velez
Dear Jim, Thank you very much for your quick reply. I am sorry for the confusion it may have caused, but I messed up the indexes in my example. I would like, from the following matrix "m" ## input m <- structure(c(0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 2L, 2

[R] Extract entries from matrix

2015-10-27 Thread Jorge I Velez
Dear R-help, I am working with a matrix "m" from which I would like to extract some elements. An toy example is as follows: ## input matrix m <- structure(c(0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 2L, 2L, 2L, 2L, 2L, 2L, 2

Re: [R] Number of digits to display?

2015-10-26 Thread Jorge I Velez
-0.58 -0.50 0.30 0.60 ​Best regards, Jorge.- On Mon, Oct 26, 2015 at 11:43 AM, Judson wrote: > How do I control the number of digits to display, > say, in a matrix, without rounding or losing accuracy > in subsequent calculations? > round() of course reduces accuracy. > >

[R] Update dataframe based on some conditions

2015-10-21 Thread Jorge I Velez
Dear R-help, I am working on what it seems to be a simple problem, but after several hours trying to come up with a solution, unfortunately I have not been able to. I would like to go from "datain" to "dataout", that is, create the NEWREF variable according with some restrict

Re: [R] Count number in r

2015-05-19 Thread Jorge I Velez
hafizuddinarsha...@gmail.com> wrote: > Dear R users, > > Could someone help me on this? I have this kind of data set: > > structure(list(Year = c(1971L, 1971L, 1971L, 1971L, 1971L, 1971L, > 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, 1971L, > 1971L, 1971L, 1971L,

[R] Help with pedigree() function in kinship2

2015-05-12 Thread Jorge I Velez
Dear R-help, I am interested in plotting some pedigrees and came across the kinship2 package. What follows is an example of the pedigrees I am working with. Now, when running ## check package availability if(!require(kinship2)) install.packages('kinship2') require(kinship2) ## data

Re: [R] How to access https page

2015-03-09 Thread Jorge I Velez
Hi Hui, I have used the source_url function in the devtools package with good results. Give it a shot! Best, Jorge.- On Tue, Mar 10, 2015 at 9:39 AM, Hui Du wrote: > Hi All, > > I am trying to parse some information from website, say, a linkedin page. > The linkedin url was >

Re: [R] Save a plot with a name given as an argument in a function

2015-02-09 Thread Jorge I Velez
on(data, TitleGraph){ > > > pdf("TitleGraph.pdf",width=7,height=5) > plot(data) > dev.off() > } > > test(cars <- c(1, 3, 6, 4, 9),TitleGraph="etc") > > My problem is that I want graph pdf being saved as etc and not as > Titlegraph.pdf > > >

[R] Proportion of equal entries in dist()?

2015-01-19 Thread Jorge I Velez
Dear all, Given vectors "x" and "y", I would like to compute the proportion of entries that are equal, that is, mean(x == y). Now, suppose I have the following matrix: n <- 1e2 m <- 1e4 X <- matrix(sample(0:2, m*n, replace = TRUE), ncol = m) I am interested in cal

Re: [R] non negativity constraints if else function

2014-12-20 Thread Jorge I Velez
What about ifelse(w < 0, 0, w) See ?ifelse for more information. Best, Jorge.- On Sat, Dec 20, 2014 at 3:26 PM, Esra Ulasan wrote: > Hello, > > I have tried the solve the non-negativity constraint "if else function" in > R. But I have done something wrong becaus

Re: [R] keep only the first value of a numeric sequence

2014-12-15 Thread Jorge I Velez
Dear jeff6868, Here is one way: ifelse(with(data, c(0, diff(mydata))) != 1, 0, 1) You could also take a look at ?rle HTH, Jorge.- On Mon, Dec 15, 2014 at 9:33 PM, jeff6868 wrote: > > Hello dear R-helpers, > > I have a small problem in my algorithm. I have sequences of "0&

Re: [R] Creating a new column from a series of columns

2014-10-31 Thread Jorge I Velez
Dear Dennis, Assuming that your data.frame() is called dd, the following should get you started: colnames(dd[,-1])[apply(dd[,-1], 1, function(x) which(x == 'Yes'))] HTH, Jorge.- On Sat, Nov 1, 2014 at 12:32 PM, Fisher Dennis wrote: > R 3.1.1 > OS X > > Colleagu

Re: [R] print vectors with consecutive numbers

2014-08-22 Thread Jorge I Velez
Hi James, Try mat[, apply(mat, 2, function(x) any(diff(x) == 1))] HTH, Jorge.- On Fri, Aug 22, 2014 at 10:18 PM, James Wei wrote: > > > Hi all, > > I have a matrix with consecutive and non-consecutive numbers > in columns. For example, the first 2 columns have consecutive

Re: [R] data.table/ifelse conditional new variable question

2014-08-17 Thread Jorge I Velez
Perhaps I am missing something but I do not get the same result: x <- read.table(textConnection("Family.ID Sample.ID Relationship 2702 349 mother 2702 3456 sibling 2702 9980 sibling 3064 3 father 3064 4 mother 3064 5sibling 3064 86 sibling 3064 87 sibling&q

Re: [R] data.table/ifelse conditional new variable question

2014-08-17 Thread Jorge I Velez
$PID[l$Relationship == 'sibling'] <- l$Sample.ID[father] if(sum(mother) == 0) l$MID[l$Relationship == 'sibling'] <- 0 else l$MID[l$Relationship == 'sibling'] <- l$Sample.ID[mother] l })) It is assumed that when either parent is not available the M/PID is 0.

Re: [R] data.table/ifelse conditional new variable question

2014-08-16 Thread Jorge I Velez
[l$Relationship == 'sibling'] <- l$Sample.ID[father] l$MID[l$Relationship == 'sibling'] <- l$Sample.ID[mother] l })) res HTH, Jorge.- Best regards, Jorge.- On Sun, Aug 17, 2014 at 5:42 AM, Kate Ignatius wrote: > Hi, > > I have a data.table question (

Re: [R] reshape a dataset

2014-08-15 Thread Jorge I Velez
nal output is a list. > How do I covert it back a dataframe? > -Sohail > > > On Fri, Aug 15, 2014 at 5:37 AM, Jorge I Velez > wrote: > >> Dear Sohail, >> >> Using Jim's data set skdat, two more options would be >> >> # first option >

Re: [R] reshape a dataset

2014-08-15 Thread Jorge I Velez
Dear Sohail, Using Jim's data set skdat, two more options would be # first option d <- with(skdat, table(ID, lettertag)) names <- colnames(d) d <- c(list(rownames(d)), lapply(1:ncol(d), function(i) as.numeric(d[,i]))) names(d) <- c('ID', names) d # second optio

Re: [R] Possible pair of 2 binary vectors

2014-08-09 Thread Jorge I Velez
Dear Ron, What about this? set.seed(123) d <- 4 x1 <- sample(0:1, d, TRUE) x2 <- sample(0:1, d, TRUE) x1 x2 expand.grid(x1 = x1, x2 = x2) See ?expand.grid for more information. Best, Jorge.- On Sat, Aug 9, 2014 at 7:46 PM, Ron Michael wrote: > Hi, > > Let say I have 2

Re: [R] Grouped Boxplot

2014-07-11 Thread Jorge I Velez
Dear Anupam, Try boxplot(DISO ~ POS * NODE_CAT, data = yourdata) Another option would be the last example in ?boxplot HTH, Jorge.- On Fri, Jul 11, 2014 at 4:38 PM, anupam sinha wrote: > Dear all, > I need some help with plotting boxplots in groups. I have a > fi

Re: [R] From long to wide format

2014-06-30 Thread Jorge I Velez
Hi Arun, Thank you very much for your suggestion. While running some tests, I came across the following: # sample data n <- 2000 p <- 1000 x2 <- data.frame(variable = rep(paste0('x', 1:p), each = n), id = rep(paste0('p', 1:p), n), outcome = sample(0:2, n*p, TRUE), r

[R] From long to wide format

2014-06-29 Thread Jorge I Velez
Dear R-help, I am working with some data stored as "filename.txt.gz" in my working directory. After reading the data in using read.table(), I can see that each of them has four columns (variable, id, outcome, and rate) and the following structure: # sample data x2 <- data.frame(v

Re: [R] counting the number of rows that satisfy a certain criteria

2014-06-21 Thread Jorge I Velez
Hi Kate, You could try sum(X[, 1] == 1 & X[, 2] == 1) where X is your data set. HTH, Jorge.- On Sun, Jun 22, 2014 at 12:57 AM, Kate Ignatius wrote: > I have 4 columns, and about 300K plus rows with 0s and 1s. > > I'm trying to count how many rows satisfy a certa

Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values

2014-06-13 Thread Jorge I Velez
Hi Pascal, Perhaps I am missing something, but what about changing passing ylim = c(0, 10) to barp()? Best, Jorge.- On Fri, Jun 13, 2014 at 7:50 PM, Pascal Oettli wrote: > Dear list, > > Please consider the following example: > > library(plotrix) > barp(c(2,3,4,5,6,7

Re: [R] How to print something in the same location in console?

2014-06-12 Thread Jorge I Velez
Dear Juan, Perhaps the last example in http://stat.ethz.ch/R-manual/R-devel/library/utils/html/txtProgressBar.html is what you are looking for. Best, Jorge.- On Thu, Jun 12, 2014 at 8:49 PM, Juan Andres Hernandez < jhernandezcabr...@gmail.com> wrote: > Hi I need to print the iterati

Re: [R] Problem with rbind.fill

2014-06-01 Thread Jorge I Velez
der q1 q2 q3 q4 > > 11 f 1 1 5 1 > > 22 f 2 1 4 1 > > 31 f 2 2 4 3 > > 51 m 4 5 2 4 > > 62 m 5 4 5 5 > > 82 m 4 5 5 5 > > > > Next I changed the o

Re: [R] Problem with products in R ?

2014-05-04 Thread Jorge I Velez
Try options(digits = 22) 168988580159 * 36662978 # [1] 6195624596620653568 HTH, Jorge.- On Sun, May 4, 2014 at 10:44 PM, ARTENTOR Diego Tentor < diegotento...@gmail.com> wrote: > Trying algorithm for products with large numbers i encountered a difference > between result of

Re: [R] Return "TRUE" only for first match of values between matrix and vector.

2014-05-02 Thread Jorge I Velez
Hi Nevil, Try apply(A, 2, function(x) x == B) HTH, Jorge.- On Fri, May 2, 2014 at 6:46 PM, nevil amos wrote: > I wish to return " True" in a matrix for only the first match of a value > per row where the value equals that in a vector with the same number of > values as

Re: [R] how to extract a part of objects from list ?

2014-05-01 Thread Jorge I Velez
Hi Kristi, Try out1970$smoot HTH, Jorge.- On Fri, May 2, 2014 at 10:00 AM, Kristi Glover wrote: > Hi R User, > I am wonedring how I can extract a part of objects from list. > > For example > > > str(out1970) > List of 8 > $ comm : num [1:16, 1:57] 1 1 1 1 1

Re: [R] Faster way to transform vector [3 8 4 6 1 5] to [2 6 3 5 1 4]

2014-04-26 Thread Jorge I Velez
d a fast way to fix the following question? > > Given a verctor of length N, for example bo = [3 8 4 6 1 5], > I want to drive a vector whose elements are 1, 2, ..., N and the order of > elements is the same as that in verctor bo. > In this example, the result is supposed to be

Re: [R] for loop to list files

2014-04-21 Thread Jorge I Velez
Hi Beatriz, Try paste("val_mapped_petpe_", 1976:1981, "01.txt", sep="") Best, Jorge.- On Mon, Apr 21, 2014 at 6:43 PM, Beatriz R. Gonzalez Dominguez < aguitatie...@hotmail.com> wrote: > Dear all, > > I'm trying to create a loop to select

Re: [R] Selecting numbers not divisible by 3

2014-03-27 Thread Jorge I Velez
Hi there, Try X[X %% 3 == 0] HTH, Jorge.- On Thu, Mar 27, 2014 at 6:46 PM, Prabhakar Ghorpade < dr.prabhaka...@gmail.com> wrote: > Hi, > here's my code > > X <- 1:100 > > I want to select number divisible by 3 out of them how can I select it? > > ( I t

Re: [R] Calculations with aggregate data: confidence intervals

2014-03-25 Thread Jorge I Velez
25, 2014 at 7:51 PM, Luigi Marongiu wrote: > Dear all, > I would like to calculate the confidence intervals on aggregate data. I > know how to do this using the t test, but it did not work together with the > aggregate function. > Is there a function that can be applied to the agg

Re: [R] plotting vectors of different lengths

2014-03-22 Thread Jorge I Velez
You are welcome, Eliza. If I understand correctly, the following will do: x <- 1:8 y <- 1:5 matrix(apply(expand.grid(x = y, y = x), 1, function(r) paste0("(", r[1], ",", r[2], ")")), ncol = length(x)) Best, Jorge.- On Sat, Mar 22, 2014 at 10:37 PM, eliz

Re: [R] plotting vectors of different lengths

2014-03-22 Thread Jorge I Velez
Hi Eliza, Perhaps the following? matpoints(t(dat), type = 'l') HTH, Jorge.- On Sat, Mar 22, 2014 at 10:18 PM, eliza botto wrote: > > Dear useRs, > I have two column vectors of different lengths say x=1,2,3,4,5,6,7,8 and > y=1,2,3,4,5. I wanted to plot them by using &quo

Re: [R] replace duplicates with 0

2014-03-13 Thread Jorge I Velez
Hi Catalin, The following should give you some ideas: set.seed(123) x <- rpois(50, 2) x idx <- duplicated(x) x[idx] <- 0 x Best, Jorge.- On Thu, Mar 13, 2014 at 11:35 PM, catalin roibu wrote: > Dear all! > > Is there a possibility to replace all duplicates values in data frame with > 0? > >

Re: [R] dim vector or data.frame

2014-02-14 Thread Jorge I Velez
Hi Berry, What about using NROW(input) ? Best, Jorge.- On Sat, Feb 15, 2014 at 2:26 AM, Berry Boessenkool < berryboessenk...@hotmail.com> wrote: > Hi, > > In my function, I want to allow input to be a vector or a data.frame. > Certain operations need to be done if t

Re: [R] impossible to install package

2014-02-12 Thread Jorge I Velez
Dear Eve, See http://cran.r-project.org/web/packages/languageR/index.html The name of the package is "languageR", not "LanguageR". Best, Jorge.- On Thu, Feb 13, 2014 at 3:39 PM, Eve Dupierrix wrote: > Hi, > I want to install "languageR" but is doesn'

Re: [R] Label point with (x,hat(y))

2013-11-23 Thread Jorge I Velez
Try R> plot(1:10) R> text(1,3, expression("(x, "*hat(y)*")"), pos=3) Best, Jorge.- On Sun, Nov 24, 2013 at 10:51 AM, David Arnold wrote: > Hi, > > I'd like to do this: > > text(1,3,"(x,yhat)",pos=3) > > But using (x,hat(y)). Any suggestions? > > D. > > > > -- > View this message in context: >

Re: [R] left transpose

2013-10-21 Thread Jorge I Velez
2 leftTranspose <- function(x) t(x[, ncol(x):1]) leftTranspose(x) HTH. Jorge.- On Tue, Oct 22, 2013 at 12:52 PM, Vokey, John <> wrote: > useRs, > I frequently require the following transform of a matrix that I call a > leftTranspose: > > -- transposes x such that the la

Re: [R] replace Na values with the mean of the column which contains them

2013-07-29 Thread Jorge I Velez
Consider the following: f <- function(x){ m <- mean(x, na.rm = TRUE) x[is.na(x)] <- m x } apply(de, 2, f) HTH, Jorge.- On Tue, Jul 30, 2013 at 2:39 AM, iza.ch1 wrote: > Hi everyone > > I have a problem with replacing the NA values with the mean of the column > whic

Re: [R] find closest value in a vector based on another vector values

2013-06-18 Thread Jorge I Velez
T hank you very much, Bert. Point well taken. Regards, Jorge.- On Wed, Jun 19, 2013 at 12:07 AM, Bert Gunter wrote: > Jorge: No. > > > a <-c(1,5,8,15,32,33.5,69) > > b <-c(8.5,33) > > a[findInterval(b, a)] > [1] 8 32 ##should be 8 33.5 > > I believe

Re: [R] find closest value in a vector based on another vector values

2013-06-18 Thread Jorge I Velez
Dear Andras, Try > a[findInterval(b, a)] [1] 8 32 HTH, Jorge.- On Tue, Jun 18, 2013 at 10:34 PM, Andras Farkas wrote: > Dear All, > > would you please provide your thoughts on the following: > let us say I have: > > a <-c(1,5,8,15,32,69) > b <-c(8.5,33) > &

Re: [R] How can we access an element in a structure

2013-06-10 Thread Jorge I Velez
Hi Miao, Try attributes(test1)[[1]] HTH, Jorge.- On Tue, Jun 11, 2013 at 3:49 PM, jpm miao wrote: > Hi, > > I have a structure, which is the result of a function > How can I access the elements in the gradient? > > > dput(test1) > structure(-1.17782911684913

Re: [R] boot, what am I doing wrong?

2013-06-07 Thread Jorge I Velez
t1* 0.4069613 0.005465687 0.07355997 See http://www.mayin.org/ajayshah/KB/R/documents/boot.html for more information and examples. HTH, Jorge.- On Fri, Jun 7, 2013 at 6:03 PM, Rguy wrote: > I am getting started with the boot package and boot command. As a first > step I tried the

Re: [R] Subsetting out missing values for a certain variable

2013-06-05 Thread Jorge I Velez
"Y" | sample==1 | !is.na(glb_ind)) > subset2<-subset(dframe, cwar_ind="Y" |sample==2 | !is.na(cwar_ind)) > subset3<-subset(dframe, reg_ind="Y" | sample==3 | !is.na(reg_ind)) > > > On Wed, Jun 5, 2013 at 9:33 AM, Daniel Tucker > wrote: > >> I am

Re: [R] Refer to Data Frame Name Inside a List

2013-06-04 Thread Jorge I Velez
Try names(ResList) HTH, Jorge.- Sent from my phone. Please excuse my brevity and misspelling. On Jun 5, 2013, at 12:34 AM, "Sparks, John James" wrote: > Dear R Helpers, > > I have a fairly complicated list of data frames. To give you an idea of > the structure, the to

Re: [R] Repeating sequence elements

2013-05-17 Thread Jorge I Velez
Try rep(1:length(v), v) HTH, Jorge.- On Fri, May 17, 2013 at 8:53 PM, Stefan Petersson wrote: > I want to create a sequence, repeating each element according to a vector. > > I have this: > > v <- c(4, 4, 4, 3, 3, 2) > > And want to create this: > > 1 1 1 1 2

Re: [R] How can I find negative items from a vector with a short command?

2013-05-08 Thread Jorge I Velez
[f<0] > [1] -2 -8 -32 -128 > > f[f>0] > [1] 4 16 64 > > f[f=4] > [1] 16 > > > 2013/5/8 Jorge I Velez > >> f [ f < 0 ] >> >> >> On Wed, May 8, 2013 at 11:54 AM, jpm miao wrote: >> >>> Hi, >>> >&g

Re: [R] How can I find negative items from a vector with a short command?

2013-05-07 Thread Jorge I Velez
f [ f < 0 ] On Wed, May 8, 2013 at 11:54 AM, jpm miao wrote: > Hi, > >I have a vector f with some negative columns. I remember that there is > an easy expression that can find out negative items. Can someone tell me > how I can do it? > > It seems to be &

Re: [R] How can I access the rowname of a data?

2013-05-06 Thread Jorge I Velez
company, which is the primary output > result. How can I access the first column, rowname, 4, 5, 6, 7, 8, 9, 11? > How can I build a dataframe consisting of two columns, the company name > (code) and the efficiency? >as.data.frame(a) produce only a column with company names, wh

Re: [R] R does not subset

2013-05-03 Thread Jorge I Velez
Hi Kasia, You need subset(REC2, INFECTION=="Infected ") (note the space after "Infected"). HTH, Jorge.- On Fri, May 3, 2013 at 7:48 PM, Katarzyna Kulma wrote: > Hi everyone, > > I know there have been several requests regarding subsetting before, but > n

Re: [R] Need help on matrix calculation

2013-04-29 Thread Jorge I Velez
Sorry, the first line should have been Mat[match( Subscript_Vec, rownames(Mat)),] and the rest remains the same. Best, Jorge.- On Mon, Apr 29, 2013 at 11:45 PM, Jorge I Velez wrote: > Christofer, > > The following should get you started: > > r <- Mat[match(rownames(M

Re: [R] Need help on matrix calculation

2013-04-29 Thread Jorge I Velez
Christofer, The following should get you started: r <- Mat[match(rownames(Mat), Subscript_Vec),] rownames(r) <- Subscript_Vec r HTH, Jorge.- On Mon, Apr 29, 2013 at 11:38 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > Hello again, > > Let say I h

Re: [R] Decomposing a List

2013-04-25 Thread Jorge I Velez
Dear Dr. Harding, Try sapply(L, "[", 1) sapply(L, "[", 2) HTH, Jorge.- On Thu, Apr 25, 2013 at 8:16 PM, Ted Harding wrote: > Greetings! > For some reason I am not managing to work out how to do this > (in principle) simple task! > > As a result of

Re: [R] Looking for a better code for my problem.

2013-04-24 Thread Jorge I Velez
Try subset(Dat, AA == "A" | (AA == "B" & BB == "b")) HTH, Jorge.- On Wed, Apr 24, 2013 at 8:21 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > Hello again, > > Let say I have following data: > > Dat <- structure(list(AA

Re: [R] subset dataframe

2013-04-22 Thread Jorge I Velez
Mike, You need subset(agoa, agoa$X.1 == "AGOA ") instead of subset(agoa, agoa$X.1 == "AGOA") (note the space after the last A in "AGOA". HTH, Jorge.- On Tue, Apr 23, 2013 at 7:14 AM, Mihai Nica wrote: > I can't understand what is happening. Th

Re: [R] Subsetting a large number into smaller numbers and find the largest product

2013-04-18 Thread Jorge I Velez
nchar(x) # digits in x b <- 5 # period tapply(strsplit(x, "")[[1]], rep(1:(nchar(x)/b), each = b), function(x) prod(as.numeric(x))) HTH, Jorge.- On Thu, Apr 18, 2013 at 6:47 PM, Janesh Devkota wrote: > Hello, > > I have a big number lets say of around hundred digits. I w

Re: [R] Error: could not find function "invlogit" and "bayesglm"

2013-04-17 Thread Jorge I Velez
.- On Wed, Apr 17, 2013 at 6:08 PM, S'dumo Masango wrote: > I have installed the arm package and its dependents (e.g MATRIX, etc), but > cannot use the functions "invlogit" and "bayesglm" because it gives me the > error message "Error: could not find function

Re: [R] non linear equation

2013-04-10 Thread Jorge I Velez
Please do not forget to CC the list to increase your chances of getting help. --JIV On Wed, Apr 10, 2013 at 9:31 PM, catalin roibu wrote: > Hello! > I try to compute the double exponential function this code: > f<-function(cls,a,b,c,d)a*exp(cls*b)+c*exp(cls*d) > > n2<-n

Re: [R] non linear equation

2013-04-10 Thread Jorge I Velez
Dear Catalin, You can look at ?nls. Alternatively, you could also consider a linear model as follows, where "d" is your data: # plot your data with(d, plot(cls, proc, las = 1)) # linear model fit <- lm(proc ~ I(1/cls) + I((1/cls)^2), data = d) summary(fit) # plotting with(d, p

Re: [R] Generating a bivariate joint t distribution in R

2013-04-02 Thread Jorge I Velez
Dear Miao, Check require(MASS) ?mvrnorm for some ideas. HTH, Jorge.- On Wed, Apr 3, 2013 at 4:57 PM, jpm miao <> wrote: > Hi, > >I conduct a panel data estimation and obtain estimators for two of the > coefficients beta1 and beta2. R tells me the mean and

Re: [R] 95% Confidence Interval for a p-p plot

2013-04-01 Thread Jorge I Velez
Pablo, Check the qqPlot function in "car": require(car) qqPlot(x, dist = "gamma", shape = 1.7918012, rate = 0.9458022) Best, Jorge.- On Tue, Apr 2, 2013 at 4:41 AM, pablo.castano <> wrote: > Hi, > > I want to create upper and lower 95% confidence interva

Re: [R] Faster way of summing values up based on expand.grid

2013-03-25 Thread Jorge I Velez
Hi Dimitri, If I understood correctly, the following will do: system.time(sum1 <- apply(mycombos, 1, function(x) sum(values1[x]))) system.time(sum2 <- apply(mycombos, 1, function(x) sum(values2[x]))) system.time(sum3 <- apply(mycombos, 1, function(x) sum(values3[x]))) cbind(sum1, s

Re: [R] trouble with data frame

2013-03-22 Thread Jorge I Velez
Sahana, The notation df[a,b)] is plain wrong. I think you meant (but I may be mistaken) df[a, b] and I am not still sure if that would work in your example. Have you instead considered subset()? E.g., subset(df, a <= 10 & b <= 10) See ?subset for more details. Also, "df

Re: [R] Help on indicator variables

2013-03-21 Thread Jorge I Velez
Try ifelse(ABS ==1 | DEFF == 1, 1, 0) HTH, Jorge.- On Fri, Mar 22, 2013 at 12:02 AM, Tasnuva Tabassum wrote: > I have two indicator variables ABS and DEFF. I want to create another > indicator variable which will take value 1 if either ABS=1 or DEFF=1. > Otherwise, it will take val

Re: [R] problem subsetting data.frame in R version 2.15.2 for Windows

2013-03-21 Thread Jorge I Velez
ad idea -- dangerous -- confusing statefulness, etc. (See > explanations in the archives as to why) > > > > > which results in adding your column names to the search path of R for > name > > resolving. > > > > Pierrick Bruneau > > CRP Gabriel Lippmann > &g

Re: [R] Counting confidence intervals

2013-03-18 Thread Jorge I Velez
hanks arun!! > > > On Mon, Mar 18, 2013 at 10:06 AM, arun wrote: > > Hi, > >Try this: > >set.seed(25) > >mat1<- > matrix(cbind(sample(1:15,20,replace=TRUE),sample(16:30,20,replace=TRUE)),ncol=2) > > nrow(mat1[sapply(seq_len(nrow(mat1)),function(i) >

Re: [R] Counting confidence intervals

2013-03-18 Thread Jorge I Velez
run <> wrote: > Hi, > Try this: > set.seed(25) > mat1<- > matrix(cbind(sample(1:15,20,replace=TRUE),sample(16:30,20,replace=TRUE)),ncol=2) > nrow(mat1[sapply(seq_len(nrow(mat1)),function(i) > any(seq(mat1[i,1],mat1[i,2])==12)),]) > #[1] 17 > > > set.seed

Re: [R] Counting confidence intervals

2013-03-18 Thread Jorge I Velez
Hi Jim, Try either of the following (untested): sum( x[1, ] < 12 & x[2, ] > 12) sum(apply(x, 2, function(x) x[1] < 12 & x[2] > 12)) where "x" is your 2x1000 matrix. HTH, Jorge.- On Tue, Mar 19, 2013 at 12:03 AM, Jim Silverton <> wrote: > Hi, &g

Re: [R] Extract letters from a column

2013-03-13 Thread Jorge I Velez
Try x <- c("Tom Cruiser", "Bread Pett", "Arnold Schwiezer") sapply(strsplit(x, " "), function(r) paste0(substr(r[1], 1, 3), substr(r[2], 1, 3))) [1] "TomCru" "BrePet" "ArnSch" HTH, Jorge.- On Thu, Mar 14, 2013 at 1:21

Re: [R] Extract letters from a column

2013-03-13 Thread Jorge I Velez
Try substr(tempdf$abb 4, 6) --JIV On Thu, Mar 14, 2013 at 1:15 AM, SH wrote: > Dear Jorge, > > I gave me this result (below) since it defines starting from the forth > letter and ending 6th letter from the first element. > > > substr(tempdf$name, 4, 6) > [1] "

Re: [R] Extract letters from a column

2013-03-13 Thread Jorge I Velez
Dear SH, Hmmm... what about substr(tempdf$name, 4, 6)) ? HTH, Jorge.- On Thu, Mar 14, 2013 at 1:06 AM, SH wrote: > Dear list: > > I would like to extract three letters from first and second elements > in one column and make a new column. > > For example below, > &g

Re: [R] merge datas

2013-03-13 Thread Jorge I Velez
Dear Catalun, If I understood your description, please see ?"%in%" and try subset(x, names(x) %in% c(1834,1876,1901,1928,2006) ) where "x" is your data. HTH, Jorge.- On Wed, Mar 13, 2013 at 9:25 PM, catalin roibu <> wrote: > Hello all! > I have a problem

Re: [R] string split at xth position

2013-03-13 Thread Jorge I Velez
4) [1] "b1" "b2" "b2" HTH, Jorge.- On Wed, Mar 13, 2013 at 7:37 PM, Johannes Radinger <> wrote: > Hi, > > I have a vector of strings like: > c("a1b1","a2b2","a1b2") which I want to spilt into two parts like: > c(

Re: [R] take two columns from a set of lists

2013-03-11 Thread Jorge I Velez
Is the following that you are looking for? unlist(lapply(x.list, "[", 2)) HTH, Jorge.- On Mon, Mar 11, 2013 at 9:52 PM, ishi soichi <> wrote: > say I have a matrix and lists like > > x <- matrix(c(12.1, 3.44, 0.1, 3, 12, 33.1, 1.1, 23), nrow=2) > > x.list &l

Re: [R] transpose lists

2013-03-08 Thread Jorge I Velez
3.44 > > [[2]] > [1] 0.1 3.0 > > [[3]] > [1] 12.0 33.1 > > [[4]] > [1] 1.1 23.0 > > lapply(x, t) doesn't do the job, I think. > > ishida > > > 2013/3/8 PIKAL Petr > > > Hi > > > > > -Original Message- > > &g

Re: [R] reduce the size of list

2013-03-07 Thread Jorge I Velez
If I understood correctly, lapply(x, "[", 1:3) will do what you want. HTH, Jorge.- On Fri, Mar 8, 2013 at 5:05 PM, ishi soichi <> wrote: > hi. I have a list like > > x <- list(1:10,11:20,21:30) > > It's a sort of a 3 x 10 matrix in list form. > I

Re: [R] How to export data with defined decimal places

2013-03-07 Thread Jorge I Velez
Dear Marin, May be not the cleanest way to do it, but the following seems to work: write.table(as.character(round(pi, 10)), "pi.txt", row.names = FALSE, col.names = FALSE, quote = FALSE) Best, Jorge.- On Fri, Mar 8, 2013 at 11:24 AM, Marino David wrote: > Hi Bert, > > I re

Re: [R] How to reference to the `stats` package in academical paper

2013-03-05 Thread Jorge I Velez
Dear Julien, Check citation('stats') HTH, Jorge.- On Wed, Mar 6, 2013 at 12:05 AM, Julien Mvdb wrote: > The question is in the title. > Then, I would like to know how I should refer to the documentation > regarding the use of each functions. > > Thanks,

Re: [R] recode data according to quantile breaks

2013-02-19 Thread Jorge I Velez
Hi Alain, The following should get you started: apply(df[,-1], 2, function(x) cut(x, breaks = quantile(x), include.lowest = TRUE, labels = 1:4)) Check ?cut and ?apply for more information. HTH, Jorge.- On Tue, Feb 19, 2013 at 9:01 PM, D. Alain <> wrote: > Dear R-List, > >

Re: [R] Correlation with p value

2013-02-13 Thread Jorge I Velez
Nico, Check https://stat.ethz.ch/pipermail/r-help/2008-May/161725.html for some alternatives. You might have to change the structure of your data, though. HTH, Jorge.- On Wed, Feb 13, 2013 at 10:13 PM, Nico Met <> wrote: > Dear all, > > I have a data (bellow) and I want to mak

Re: [R] Is there a neat R trick for this?

2013-02-12 Thread Jorge I Velez
e 2nd element of x is at the 3rd position > in y > 3rd element of z is NA, because the 3rd element of x is not in y > > Of course I can write the function findIndexIn() using a for loop, but > in 80% of cases when I felt the urge to use "for" in R it turned out > that there

Re: [R] Transform every integer to 1 or 0

2013-02-05 Thread Jorge I Velez
Dear Wim, You could try 1*(df > 0) HTH, Jorge.- On Tue, Feb 5, 2013 at 5:33 AM, Wim Kreinen <> wrote: > Hello, > > I have a dataframe with positive integers and > for every value > 0 > I would like to have 1 and the rest should be zero. > > For instance

Re: [R] Transforming 4x3 data frame into 2 column df in R

2013-02-01 Thread Jorge I Velez
Dear Gundala, Try as.data.frame.table(foo) HTH, Jorge.- On Fri, Feb 1, 2013 at 5:00 PM, Gundala Viswanath <> wrote: > I have the following data frame: > > > foo >w x y z > n 1.51550092 1.4337572 1.2791624 1.1771230 > q 0.0

Re: [R] recoding variables again :(

2013-01-30 Thread Jorge I Velez
Hi David, Check ?"%in%" for a simpler approach. Regards, Jorge.- On Wed, Jan 30, 2013 at 8:42 PM, David Studer <> wrote: > Hello everybody! > > I have again a rather simple question concerning recoding of variables: > > I have a variable/data-frame column BIRT

Re: [R] substring from behind

2013-01-30 Thread Jorge I Velez
; HTH, Jorge.- On Wed, Jan 30, 2013 at 8:05 PM, Mat <> wrote: > Hello together, > > i have a question for "substring". > I know i can filter a number like this one: > bill$No<-substring(bill$Customer,2,4) > > in this case i get the 2nd, 3rd and 4th number

Re: [R] an apply question

2013-01-18 Thread Jorge I Velez
Hi m p, You can use either apply(fhours, 2, function(x) ifelse(x < 0, x + 24, x) or shours <- fhours shours[shours < 0 ] <- shours[shours < 0 ] + 24 shours HTH, Jorge.- On Sat, Jan 19, 2013 at 4:17 PM, m p <> wrote: > Hello, > It should be easu but I cannot

Re: [R] Determining sample size from power function

2013-01-09 Thread Jorge I Velez
Dear Kaveh, Take a look at http://www.statmethods.net/stats/power.html HTH, Jorge.- On Thu, Jan 10, 2013 at 3:21 PM, Kaveh Zakeri <> wrote: > Hello, > > I am trying to get the power function to report the sample size rather > than the power. My goal is to input a variety o

  1   2   3   4   5   6   >