which(df == 1, arr.ind=TRUE) is useful here:
> df <- matrix(c(0,NA,0,0,0,1,1,1,0,0,1,0,0,0,NA), nrow=3)
> df
[,1] [,2] [,3] [,4] [,5]
[1,]00100
[2,] NA0110
[3,]0100 NA
> ## Identify (row,col) indices for 1:s
> idxs <- which(df == 1, arr
Hi Saba,
Try this:
df<-matrix(c(0,NA,0,0,0,1,1,1,0,0,1,0,0,0,NA),nrow=3)
dimdf<-dim(df)
df1<-df==1
df[cbind(rep(FALSE,dimdf[1]),df1[,-dimdf[2]])]<-1
Jim
On Fri, Sep 23, 2016 at 12:27 PM, Saba Sehrish via R-help
wrote:
> Hi
>
> I have a matrix that contains 1565 rows and 132 columns. All the o
tmpf <- function(x) {
n <- length(x)
indices <- which(match(x,1) == 1)
x[indices+1] <- 1
x[1:n] ## needed for the case when the last item in a row has value 1
}
tmp <- matrix(c(0,0,1,0,0,
NA,0,1,1,0,
0,1,0,0,NA,
1,0,1,0,1), ## last item in r
Hi
I have a matrix that contains 1565 rows and 132 columns. All the observations
are either "0" or "1". Now I want to keep all the observations same but just
one change, i.e. whenever there is "1", the very next value in the same row
should become "1". Please see below as a sample:
>df
0
> On 22 Sep 2016, at 21:24 , luke-tier...@uiowa.edu wrote:
>
> On Thu, 22 Sep 2016, luke-tier...@uiowa.edu wrote:
>
>> My preference is to use a top level function in the package or global
>> env that takes as arguments just the variables I want in the parent
>> frame. That avoids the explicit e
> In other words, try to mislead CRAN.
Well, no. The thought was that if CRAN has agreed an exception, as Uwe had
indicated, you might want a simpler way of maintaining it than discussing it on
every update.
I can see that that would sidestep an enforced regular review, though.
Keep up the g
Looking at your data there are several issues.
1. Tank is an integer, but it sounds like you intend to use it as a categorical
measure. If so that it should be a factor, but factors cannot be used in pca.
Is Tank 10 10 times more of something than Tank 1?
2. Date is a factor. That means you are
Dear Professor Wood,
Thank you for taking the time to fix the problem.
Best,
Fotis
On Thu, Sep 22, 2016 at 4:25 PM, Simon Wood wrote:
> Hi Fotis,
>
> Thanks for the report, and sending me the data and code (off list). The
> problem is triggered by 'ctrial' being a (one column) matrix. An imm
On Thu, 22 Sep 2016, luke-tier...@uiowa.edu wrote:
My preference is to use a top level function in the package or global
env that takes as arguments just the variables I want in the parent
frame. That avoids the explicit environment manipulations. Here that
would be
makeFunc0 <- function(xmin,
My preference is to use a top level function in the package or global
env that takes as arguments just the variables I want in the parent
frame. That avoids the explicit environment manipulations. Here that
would be
makeFunc0 <- function(xmin, xmax)
function(y) (y - xmin) / (xmax - xmin)
I like to have my function-returning functions use new.env(parent=XXX)
to make an environment for the returned function and put into it only
the objects needed by the function. The 'XXX' should be a an environment
which will hang around anyway. It could be globalenv(), but if your
function
is in
> On Sep 22, 2016, at 8:01 AM, Roy Mendelssohn - NOAA Federal
> wrote:
>
> Hi All:
>
> I am trying to write code to create a string to be executed as a command.
> The string will be of the form:
>
> "param <- param[,rev(seq_len(dataYLen)),,drop = FALSE]"
>
> Now just creating that string i
> On Sep 22, 2016, at 9:45 AM, Ismail SEZEN wrote:
>
>
>> On 22 Sep 2016, at 18:41, Olivier Merle wrote:
>>
>> Dear,
>>
>> When I use big data for a temporary use it seems that the memory is not
>> released when a function/environement is created nearby.
>> Here the reproducible exemple:
>>
> On Sep 22, 2016, at 8:41 AM, Olivier Merle wrote:
>
> Dear,
>
> When I use big data for a temporary use it seems that the memory is not
> released when a function/environement is created nearby.
> Here the reproducible exemple:
>
> test<-function(){
> x=matrix(0,5,1)
> y=function(nb)
> On 22 Sep 2016, at 18:41, Olivier Merle wrote:
>
> Dear,
>
> When I use big data for a temporary use it seems that the memory is not
> released when a function/environement is created nearby.
> Here the reproducible exemple:
>
> test<-function(){
> x=matrix(0,5,1)
> y=function(nb) nb
Dear,
When I use big data for a temporary use it seems that the memory is not
released when a function/environement is created nearby.
Here the reproducible exemple:
test<-function(){
x=matrix(0,5,1)
y=function(nb) nb^2
return(y)
}
xx=test() # 3 Go of Ram is used
gc() # Memory is not rele
Hi All:
I am trying to write code to create a string to be executed as a command. The
string will be of the form:
"param <- param[,rev(seq_len(dataYLen)),,drop = FALSE]"
Now just creating that string is simple enough. Where the problem arises is
the array param could be 2, 3, or 4 dimensions
Hello,
data["601",] doesn't generate an error because you can also refer to a
row by its name, as an alternative to refering to it by row number.
It's the same with vectors, just consider the following case.
(x <- c("601"=1, b=2))
x[1]
x["601"] # the same
But when you want to remove it yo
Hi,
Yes, you can use "latticeExtra" package and use a text layer on top of your
current chart.
Thanks,
Carlos Ortega
2016-09-22 16:04 GMT+02:00 Jun Shen :
> Dear list,
>
> Just wonder if there is a way to add annotation text outside an xyplot,
> (e.g. the bottom of the plot). the panel.text see
On 22/09/2016 4:45 AM, Colin Phillips wrote:
I'm sure I'm doing something wrong, but I'm seeing strange behaviour using the
`head` and `tail` functions on an empty data.frame.
To reproduce:
# create an empty data frame. I actually read an empty table from Excel using
`readWorkbook` from packa
Dear list,
Just wonder if there is a way to add annotation text outside an xyplot,
(e.g. the bottom of the plot). the panel.text seems only add text within
the plot. Thanks.
Jun
[[alternative HTML version deleted]]
__
R-help@r-project.org mail
Tanks for all your answers and for taking the time to help me better
understand my mistake.
I will take your advice and do some reading!
Best,
P.
Le mercredi 21 septembre 2016, William Dunlap a écrit :
> The OP cannot be entirely blamed for thinking that x[,-"ColName"]
> would omit x's "ColName"
Works like a charm, thanks!
Still don't know what that error message means though. Any idea?
2016-09-20 20:13 GMT+02:00 :
> Sorry, I've made a stupid mistake.
> It's obviously the other way around.
>
> ix <- which(rownames(data) %in% c("601", "604"))
> clean <- data[-ix, ]
>
>
> Rui Barradas
>
>
I'm sure I'm doing something wrong, but I'm seeing strange behaviour using the
`head` and `tail` functions on an empty data.frame.
To reproduce:
# create an empty data frame. I actually read an empty table from Excel using
`readWorkbook` from package `openxlsx`
test <- structure(list(Code = NUL
Hi, thanks for the answer.
In this case, the row named "601" is not the 601st row of the table, but
the 117th. data[601,] actually refers to a non existing row.
I was wondering why data[-"601,] generates an error message whereas
data["601",] does not?
2016-09-20 19:08 GMT+02:00 Bert Gunter :
> Hi
Thanks very much for your detailed reply to my post. Very helpful/useful
tool(s) you’ve provide me. Best wishes, B.
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Wednesday, September 21, 2016 10:48 AM
To: Crombie, Burnette N
Cc: r-help@r-project.org
Subject: Re: [R] if/else help
If yo
Thank you for your time, Don. Exactly what I was looking for - a one-liner.
Feedback from others on this post has been good to expand my knowledge, though.
I'm too old for homework but have just started using R if/else, loops, and
functions and trying to get the hang of them. Best wishes - B
Hi Fotis,
Thanks for the report, and sending me the data and code (off list). The
problem is triggered by 'ctrial' being a (one column) matrix. An
immediate fix is
data_a$ctrial <- as.numeric(data_a$ctrial)
- mgcv 1.8-16 will catch the problem automatically internally.
best,
Simon
On 20/09
28 matches
Mail list logo