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
ishes - B
-Original Message-
From: MacQueen, Don [mailto:macque...@llnl.gov]
Sent: Wednesday, September 21, 2016 11:26 AM
To: Crombie, Burnette N ; r-help@r-project.org
Subject: Re: [R] if/else help
Hopefully this is not a homework question.
The other responses are fine, but I would sugges
> On Sep 21, 2016, at 8:26 AM, MacQueen, Don wrote:
>
> Hopefully this is not a homework question.
>
> The other responses are fine, but I would suggest the simplest way to do
> exactly what you ask is
>
>
> if (!exists('r4')) r4 <- data.frame(a=0, b=0, c=0, d='x')
>
>
> The exists() functi
Hopefully this is not a homework question.
The other responses are fine, but I would suggest the simplest way to do
exactly what you ask is
if (!exists('r4')) r4 <- data.frame(a=0, b=0, c=0, d='x')
The exists() function requires a character string for its first argument,
i.e., the name of the
If you write your code as functions you can avoid the nasty
'if(exists("x"))x<-...' business this by writing default values for
arguments to your function. They will be computed only when
they are used. E.g.,
analyzeData <- function(a=0, b=0, c=0, d="x", r4 = data.frame(a, b, c, d)) {
summa
> On Sep 20, 2016, at 12:31 PM, Crombie, Burnette N wrote:
>
> If a data.frame (r4) does not exist in my R environment, I would like to
> create it before I move on to the next step in my script. How do I make that
> happen? Here is what I want to do from a code perspective:
>
> if (exists(r
Get rid of the commas? Get rid of the get() function call? Get rid of the
cbind() function call? Post using plain text format so the HTML doesn't screw
up code? Read the Posting Guide? All of these ideas have merit IMHO...
--
Sent from my phone. Please excuse my brevity.
On September 20, 2016
If a data.frame (r4) does not exist in my R environment, I would like to create
it before I move on to the next step in my script. How do I make that happen?
Here is what I want to do from a code perspective:
if (exists(r4))
{
is.data.frame(get(r4))
}
else
{
a <- 0, b <- 0, c <- 0, d <- "x", r4
8 matches
Mail list logo