Use ifelse function, not if. If is only good for one logical value at a time,
but you are working with long vectors of values simultaneously. I have no
interest in doing all of your workfor you, but the concept is
cpl_or_sngl <- dat1$b %in% c( "couple", "single" )
a_pvt <- "private" == dat1$a
da
You appear to be confusing && with & and || with | ; (the first of each
pair take a logical expression, the second of each a logical vector) ...
as well as if ... else with ifelse (the first is a flow control statement
taking a logical expression; the second is a function taking a logical
vector
Hi all,
I am trying to use the if else statement and create two new columns
based on the existing two columns. Below please find my sample data,
dat1 <-read.table(text="ID a b c d
A private couple 25 35
B private single 24 38
C none single28 32
E none none 20 36 ",header=TRUE,stringsAs
Hi Subhamitra,
Your data didn't make it through, so I guess the first thing is to
guess what it looks like. Here's a try at just January and February of
1994 so that we can see the result on the screen. The logic will work
just as well for the whole seven years.
# create fake data for the first tw
Hello,
Inline.
Às 17:33 de 12/09/19, Bert Gunter escreveu:
But she wants *monthly* averages, Rui.
Thanks, my mistake.
Ergo ave() or tidyData
equivalent, right?
Maybe. But ave() returns as many values as the input length, this seems
more suited for tapply or aggregate.
I will first cre
Awesome, thanks!
On Fri, Sep 13, 2019 at 12:19 AM Bert Gunter wrote:
>
>
> You can't use the same regex for str_extract_all as I used for sub (or gsub,
> which is what is required here)! If you do this sort of thing a lot, you
> *must* learn more about regex's.
>
> Anyway, this will do what you
You can't use the same regex for str_extract_all as I used for sub (or
gsub, which is what is required here)! If you do this sort of thing a lot,
you *must* learn more about regex's.
Anyway, this will do what you want I think:
z <- paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " ") ## just for
r
Thanks Bert,
This works, but if in my text there are more than one patterns then
fails to generate desired result.
library(stringr)
str_extract_all(paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " "),
".*(\\{.*\\}).*")
This generates below -
[[1]]
[1] "ab{cd$ }ed ab{cad$ }ed"
I was expecting I
> sub(".*(\\{.*\\}).*", "\\1","ab{cd$ }ed")
[1] "{cd$ }"
Use ".+" instead of ".*" within the {} if you don't want to return empty
{}'s.
You might wish to use the stringr package for string matching and
manipulation, as it provides a more user friendly and consistent interface
to these tasks.
Be
Hi,
I am wondering on what is the correct way to select a pattern which goes as -
{"(any character with any length)"}
The expressions " {" " and " "} " both are included in the pattern.
For example, the lookup of the above pattern in the text "
{"asaf455%"}57573blabla " will result in {"asaf455
Dear R-users,
I have daily data from 03-01-1994 to 03-08-2017. In my datafile, The first
column is date and the second and third columns are the returns and volume
data. I want to estimate the average returns, and volumes for each month,
then, I want to export the results into excel.
So please he
Thanks.You are right. I have realized that the atv function returns
empty for negative arguments. I was not aware that this would affect how
sapply processes its result.
>
> Quoting bic...@math.usask.ca:
>
>> Here is are a few lines of my R session:
>>
>>> class(income)
>> [1] "integer"
>>>
Hello,
Please include data, say
dput(head(data, 20)) # post the output of this
But, is the problem as simple as
rowMeans(data[2:3], na.rm = TRUE)
?
Hope this helps,
Rui Barradas
Às 15:53 de 12/09/19, Subhamitra Patra escreveu:
Dear R-users,
I have daily data from 03-01-1994 to 29-12-2
No reproducible example, so hard to say. What class is your "date" column?
-- factor, character, Date? See ?Date
Once you have an object of appropriate class -- see ?format.Date -- ?months
can extract the month and ?ave can do your averaging. No explicit looping
is needed.
The tidydata alternativ
Dear R-users,
I have daily data from 03-01-1994 to 29-12-2000. In my datafile, he first
column is date and the second and third columns are the returns of the
country A, and B. Here, the date column is same for both countries. I want
to calculate the monthly average of both country's returns by us
Please keep the mailing list included with reply-all.
I misread your error. I suspect you need to use a newer version of R on your
"pc".
On September 12, 2019 12:29:39 AM PDT, Faheem Jan wrote:
>Jeff Newmiller i dies not understand your answer,i run the simulation
>it give result in pc and i sa
On 12/09/2019 7:10 a.m., PIKAL Petr wrote:
Dear all
Is there any simple way checking whether after calling pdf device something was
plotted into it?
In interactive session I used
if (dev.cur()==1) plot(ecdf(rnorm(100))) else plot(ecdf(rnorm(100)), add=T,
col=i)
which enabled me to test if pl
Dear all
Is there any simple way checking whether after calling pdf device something was
plotted into it?
In interactive session I used
if (dev.cur()==1) plot(ecdf(rnorm(100))) else plot(ecdf(rnorm(100)), add=T,
col=i)
which enabled me to test if plot is open
But when I want to call eg. pdf("
Quoting bic...@math.usask.ca:
Here is are a few lines of my R session:
class(income)
[1] "integer"
class(sapply(1000*income-999,atv,sktaxb,sktax))
[1] "numeric"
class(sapply(1000*income-1001,atv,sktaxb,sktax))
[1] "list"
Although "income" is a numeric array, and sapply works as expecte
Hi Lubo,
Have a look at the "irr" package. I transferred any unique functions
from concord to it to reduce duplication of functions in different
packages.
Jim
On Thu, Sep 12, 2019 at 7:03 PM Lubo Larsson wrote:
>
> Hello,
>
> I would like to know if there is an R utility for computing some
> mea
Can you create a reproducible example?
You don't show: income, atv, sktaxb, sktax
On Thu, Sep 12, 2019 at 12:04 PM wrote:
> Here is are a few lines of my R session:
>
> > class(income)
> [1] "integer"
> > class(sapply(1000*income-999,atv,sktaxb,sktax))
> [1] "numeric"
> > class(sapply(1000*inc
Hi bickis,
Putting on my dark glasses and flailing about with a big white stick*,
I would suggest that you look at what "atv" actually produces from
those three objects. I wouldn't be surprised to find quite different
things.
Jim
* blind guess
On Thu, Sep 12, 2019 at 7:04 PM wrote:
>
> Here is a
Here is are a few lines of my R session:
> class(income)
[1] "integer"
> class(sapply(1000*income-999,atv,sktaxb,sktax))
[1] "numeric"
> class(sapply(1000*income-1001,atv,sktaxb,sktax))
[1] "list"
Although "income" is a numeric array, and sapply works as expected
returning an array (the function
Hi,
I would like help from knowledgeble mai-listers in pspline matter.I just a
beginner.
I have the following pspline program and I get strange (for me) results like
:17.172881859251717.17297751018117.17307316917.173168812047817.173264462992617.1733601139499for
all file.
The file have 20234
Hello,
I would like to know if there is an R utility for computing some
measure of inter-rater reliability/agreement for 3 raters (columns),
where each rating is a binary assessment. Further, the three raters
are unique (the same rater's assessment in any single column) so that
ideally the statist
Use the correct function.. readRDS.
On September 11, 2019 11:28:41 PM PDT, Faheem Jan via R-help
wrote:
>
>
>Subject: How to read a result saved in Rstudio
>HI, i run the simulation result in other computer with high speed
>computer ,i save the result in the rda file. know i want to open this
>
26 matches
Mail list logo