result you expect.
>
> Thanks for the complete reproducible example. I wouldn't have even
> looked at your problem without something to test.
>
> Sarah
>
> On Thu, Jul 14, 2016 at 1:55 PM, Jorge I Velez
> wrote:
> > Dear R-help,
> >
> > I am using the
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/sn
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]
t;- numeric(nrow(m))
> j <- 1
> for (i in 1:nrow(m)) {
> if (j > ncol(m) || m[i,j] == 0) {
> j <- 1
> }
> v[i] <- m[i,j]
> j <- j+1
> }
>
> v
>
> Note that this puts 0 in the output if
> there is a zero in your first column and
>
.
The output vector would then be of the same length as the number of rows in
"m", and would contain the elements previously selected.
Any ideas on how to proceed?
Thank you very much in advance.
Best regards,
Jorge Velez.-
On Tue, Oct 27, 2015 at 4:38 PM, Jorge I Velez
wrote:
&
leave them out, but then we have 4th: 1, 2, 3; 5th: 1,
> 2, 3; 6th: 1, 2, 3, 4, etc so you must have some additional rule in mind to
> get your answer.
>
> -
> David L Carlson
> Department of Anthropology
> Texas A&M University
> Coll
345
> [22,]12345
> > indx
> [,1] [,2]
> [1,]41
> [2,]52
> [3,]63
> [4,]71
> [5,]82
> [6,]93
> [7,] 101
> [8,] 11 2
> [9,] 123
> > m[indx]
>
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, 2L, 2L, 2L, 2L,
Dear Judson,
Perhaps the following example would give you some ideas:
R> options(digits = 4)
R> rnorm(5)
#[1] -0.57089 -0.14759 0.05717 -0.04935 2.22123
R> options(digits = 3)
R> rnorm(5)
#[1] 0.789 0.616 0.156 -1.315 -1.090
R> options(digits = 2)
R> rnorm(5)
#[1] -1.04 -0.58 -0.50 0.30 0.
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 restrictions, and update the
Dear Arshad,
Here is a possibility using tapply():
with(d, tapply(Rain, list(Month, Year), function(x) sum(x > .1)))
##1971
#1 12
#20
where "d" is your data.frame(). See also ?aggregate and ?ave.
Best,
Jorge.-
On Tue, May 19, 2015 at 8:10 PM, Hafizuddin Arshad <
hafizuddinarsha...@gm
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 to plot
d <
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
>
> url = "http:/
Hi Evgenia,
Try
test2 <- function(data, TitleGraph){
pdf(paste0(TitleGraph, ".pdf"), width = 7, height = 5)
plot(data)
dev.off()
}
instead. Take a look at ?paste0 for more information.
HTH,
Jorge.-
On Tue, Feb 10, 2015 at 12:14 AM, Evgenia wrote:
> test<-function(data, TitleGraph){
>
>
> p
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 calculating the above proportion f
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 because it still gives the same
> so
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" and "1"
> values i
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
>
> Colleagues,
> I have a dataset containi
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 numbers. I
> want
gt; number of items to replace is not a multiple of replacement length
>
> looking at the output I get numbers where the father/mother ID should
> be in the M/PID field. For example:
>
> 2702 349 mother 0 0
> 2702 3456 sibling 0 842
> 2702 9980 sibling
ing error:
> >
> > Error in l$PID[l$\Relationship == "sibling"] <- l$Sample.ID[father] :
> > replacement has length zero
> >
> >
> >
> > On Sat, Aug 16, 2014 at 6:48 PM, Jorge I Velez
> wrote:
> >> Dear Kate,
> >>
> &
Dear Kate,
Assuming you have nuclear families, one option would be:
x <- read.table(textConnection("Family.ID Sample.ID Relationship
14 62 sibling
14 94 father
14 63 sibling
14 59 mother
17 6004 father
17 6003 mother
17 6005 s
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
>
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 option
d <- with(skdat, table(ID, letter
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 binary vectors of len
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
> file of the followin
}, mc.cores = 4)
> X[, -1] <- do.call(rbind, r)
> X
> })
>
> # user system elapsed
> # 0.125 0.011 0.074
>
>
> wide2 <- wide1
> wide2$id <- as.character(wide2$id)
> wide$id <- as.character(wide$id)
> all.equal(wide, wide2,
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(variable = rep(pas
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 certain criteria... for
> instan
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,8), ylim=c(-10,10))
>
> H
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 iteration number o
Hi Bill,
You need
require(plyr)
?rbind.fill
and then the rest of the code you already tried.
Best,
Jorge.-
On Mon, Jun 2, 2014 at 3:49 AM, Bill Bentley wrote:
> The following works as it should...
>
> > both<-rbind(females,males)
>
> > both
>
> workshop gender q1 q2 q3 q4
>
> 11
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 168988580159 * 366
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 rosw in the matrix
>
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 1 1 1 1 1 ...
> ..- attr(*,
Hi Xueming,
Try
(1:length(bo))[rank(bo)]
In a function the above would be
f <- function(x){
N <- length(x)
(1:N)[rank(x)]
}
f(bo)
# [1] 2 6 3 5 1 4
HTH,
Jorge.-
On Sat, Apr 26, 2014 at 7:54 PM, xmliu1...@gmail.com wrote:
> Hi,
>
> could anybody help me to find a fast way to fi
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 a series of files into my computer
> but I haven't been
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 tried following
> X <- 1:100
> DIV <- Y -
Hi Luigi,
Thanks for sending the data in reproducible format. Perhaps something
like this?
aggregate(my.data[,3], list(my.data[,2]), FUN = function(x) t.test(x)$
conf.int[1:2])
#Group.1 x.1 x.2
#1 Unstimulated 5.296492e+02 2.410510e+03
#2ESAT6 9.105338e+00 4.078
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, eliza botto wrote:
> Thankyou very much jorg
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 "points()" command over an
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?
>
>
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 the length or nrows exceeds
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't work.
>
> I tried it by two ways:
> (1) b
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:
>
Dear Dr. Vokey,
Here is one approach, although may not be the more efficient:
x <- matrix(1:8, ncol = 4)
x
# [,1] [,2] [,3] [,4]
#[1,]1357
#[2,]2468
t(x[, ncol(x):1])
# [,1] [,2]
#[1,]78
#[2,]56
#[3,]34
#[4,]12
leftTranspos
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
> which contains them. If I repla
ues you choose to be different or not, in which case they may not
> be minimum?
>
> a <- c(1, 8, 9)
> b <- c(2,3)
>
> Then what are the 2 closest values of a to b?
>
> -- Bert
>
> On Tue, Jun 18, 2013 at 5:43 AM, Jorge I Velez
> wrote:
> > Dear Andras
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)
>
> and I would like to extract from
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, gradient = structure(c(-0.0
Hi there,
You need a function for your statistic:
> boot(x, function(x, index) mean(x[index]), R = 1000)
ORDINARY NONPARAMETRIC BOOTSTRAP
Call:
boot(data = x, statistic = function(x, index) mean(x[index]),
R = 1000)
Bootstrap Statistics :
original biasstd. error
t1* 0.40696
Daniel,
You need "==" instead of "=".
HTH,
Jorge.-
Sent from my phone. Please excuse my brevity and misspelling.
On Jun 6, 2013, at 10:36 AM, Daniel Tucker wrote:
> Also tried this but results werent any different
>
> subset1<- subset(dframe, glb_ind="Y" | sample==1 | !is.na(glb_ind))
> subset2
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 top of the str output is s
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 2 2 2 3 3 3 3 4 4 4 5 5 5 6 6
>
[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
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
>f[i such that f[i]<0 ...]
>
>
rownames(a)
perhaps?
HTH,
Jorge.-
On Mon, May 6, 2013 at 6:03 PM, jpm miao wrote:
> Hi,
>
>Below is the output from an R package. The first column (4, 5, 6, 7,
> which is unnamed) is the company name (code), while the second column
> efficiency is the performance of each company, which is
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
> none of them really helps with my prob
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
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 have 1 matrix:
>
> Mat <- matrix
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 applying strsplit() to a vector of character
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 = structure(c(3L, 1L, 2L, 1L, 2L, 3L, 3L, 2L,
> 3L, 1L, 1L,
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. This is the code and results:
>
> > agoa <- read
Dear Janesh,
Here is one way:
# note "x" is a character
x <-
"73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557"
k <- nchar(x) # digits in x
b <
Hi Carrington,
You also need the boot package (see
http://stat.ethz.ch/R-manual/R-patched/library/boot/html/inv.logit.html )
As for the other function, please load the arm package, e.g.,
require(arm)
require(boot)
and then you will be able to use the functions mentioned below.
HTH,
Jorge.-
O
equation, but the problem
>> in nls is to anticipate the regression coefficients.
>>
>>
>> On 10 April 2013 12:19, Jorge I Velez wrote:
>>
>>> Dear Catalin,
>>>
>>> You can look at ?nls.
>>>
>>> Alternatively, you could also
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, plot(cls, proc, la
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 covariance of the
> distribution
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 intervals for a p-p plot of
> an empirical di
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, sum2, sum3)
HTH
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" is a very bad n
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 value 0. How c
Or simply
subset(dat, a > 0)
HTH,
Jorge.-
On Thu, Mar 21, 2013 at 6:58 PM, Michael Weylandt <> wrote:
>
>
> On Mar 21, 2013, at 7:39, Pierrick Bruneau wrote:
>
> > Hi Borja,
> >
> > You may issue:
> >
> > attach(data)
>
> No -- bad idea -- dangerous -- confusing statefulness, etc. (See
> expl
If you don't use apply() it would be even faster:
> system.time(sum(mat2[,1] < 12 & mat2[,2] > 12))
user system elapsed
0.004 0.000 0.003
Regards,
Jorge.-
On Tue, Mar 19, 2013 at 1:21 AM, arun <> wrote:
> Hi,
> Jorge's method will be faster.
> #system.time(res1<-sum(apply(mat2,1,func
Thats cumbersome, Arun.
> sum(mat1[,1] < 12 & mat1[,2] > 12)
[1] 17
will do the job and even faster:
> system.time(replicate(1, sum(mat1[,1] < 12 & mat1[,2] > 12)))
# user system elapsed
# 0.067 0.001 0.078
HTH,
Jorge.-
On Tue, Mar 19, 2013 at 1:06 AM, arun <> wrote:
> Hi,
> Try
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,
> I have a 2 x 1 matrix of confidence interva
AM, SH wrote:
> What I want to do is to extrac three letters from first and last name
> and to combine them to make another column 'abb'. The column 'abb' is
> to be a my final product. I can make column 'abb' using 'paste'
> function once I ha
; Cr" "ad " "old"
>
> I would like to have letters from first and second elements if possible.
>
> Thanks for replying,
>
> Steve
>
>
> On Wed, Mar 13, 2013 at 10:10 AM, Jorge I Velez
> wrote:
> > Dear SH,
> >
> > Hmmm... what
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,
>
> > tempdf = read.table("cli
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 with R. I try to merge data like this
Dear Johannes,
May not be the best way, but this looks like what you described:
> x <- c("a1b1","a2b2","a1b2")
> x
[1] "a1b1" "a2b2" "a1b2"
> substr(x, 1, 2)
[1] "a1" "a2" "a1"
> substr(x, 3, 4)
[1] "b1" "b2" "b2"
HTH,
Jorge.-
On Wed, Mar 13, 2013 at 7:37 PM, Johannes Radinger <> wrote:
> Hi,
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 <- lapply(seq_len(nrow(x)), function(i
One option would be
x <- list(c(12.1, 0.1, 12, 1.1), c(3.44, 3, 33.1, 23))
do.call(c, apply(do.call(rbind, x), 2, list))
HTH,
Jorge.-
On Fri, Mar 8, 2013 at 9:06 PM, ishi soichi wrote:
> Thanks. The result should be a list of lists like...
>
> > x
> [[1]]
> [1] 12.10 3.44
>
> [[2]]
> [1] 0.
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 would like to reduce the dimension of this lis
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 read both options and
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,
>
> Julien Mehl Vettori
>
> [
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,
>
> I would like to re
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 make a correlation
Robert,
Try
match(x, y)
HTH,
Jorge.-
On Tue, Feb 12, 2013 at 9:09 PM, Robert Latest wrote:
> Hello all,
>
> given two vectors X and Y I'd like to receive a vector Z which
> contains, for each element of X, the index of the corresponding
> element in Y (or NA if that element isn't in Y).
>
>
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
>
> 1 0 1
> 0 1 1
>
> with df as refere
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.09977303 0.8173761 1.6123402 0.15107
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 BIRTHPLACE containing abbreviations
Hi Mat,
The following should get you started:
> s <- "Mercedes_02352"
> substr(s, nchar(s) - 3, nchar(s) - 1)
[1] "235"
>
> # defining a function
> foo <- function(x, a = 3, b = 1) substr(s, nchar(x) - a, nchar(x) - b)
> foo(s)
[1] "235"
HTH,
Jorge.-
On Wed, Jan 30, 2013 at 8:05 PM, Mat <> wr
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 figure out how to use apply func
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 of values for theta an
Here is one option (not the best, but does the job):
foo <- function(x) table(factor(unlist(strsplit(as.character(x), "")),
levels = c('A','C','G','T')))
t(apply(d[, -c(1:4)], 1, foo))
What's wrong with Jim Holtman's solution?
HTH,
Jorge.-
On Thu, Jan 10, 2013 at 3:46 PM, Yao He <> wrote:
> H
Hi Ista,
I was doing about something similar when I saw your post, so I took your
code and did some timings:
> system.time(replicate(100, count.0 <- length(which(x == 0
user system elapsed
5.590 0.173 5.834
> system.time(replicate(100, count.1 <- sum(x == 0)))
user syste
> }
> FUN(x, y)
> }
>
> fun(Mat1, Mat2)
> fun(Mat1, Mat2, `*`) # Note the back quotes
>
>
> Hope this helps,
>
> Rui Barradas
> Em 04-01-2013 12:06, Jorge I Velez escreveu:
>
>> Dear Christofer,
>>
>> You can try the following:
>>
>&g
Dear Christofer,
You can try the following:
# proccess the matrices
foo <- function(m1, m2){
if(ncol(m1) != ncol(m2)) stop('number of columns should be equal')
if(nrow(m1) < nrow(m2)){
nas <- matrix(NA, ncol = ncol(m1), nrow = nrow(m2) - nrow(m1))
m1 <- rbind(m1, nas)
}
else{
nas <- matrix(NA
Dear meng,
Check I understood correctly, the Ryacas package might do what you want.
Check its vignette at
http://cran.r-project.org/web/packages/Ryacas/vignettes/Ryacas.pdf
Best,
Jorge.-
On Fri, Jan 4, 2013 at 5:59 PM, meng <> wrote:
> Hi all:
> I have a question about the computation of expr
1 - 100 of 275 matches
Mail list logo