[R] Omitted/blank variables in R function

PIKAL Petr petr.pikal at precheza.cz
Fri Aug 30 09:10:12 CEST 2013


Hi

It would be good if you provided some more specific inforamation. What function do you use for transfering data to R?.

E.g. read.table has option to specify NA values during data transfer.

If you want to set some values to NA in already read objects you can do it

object[object=="some value"] <- NA

Regards
Petr


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Greg Snow
> Sent: Friday, August 30, 2013 5:23 AM
> To: newruser12345
> Cc: r-help
> Subject: Re: [R] Omitted/blank variables in R function
> 
> Look at the "missing" function.
> 
> Or set the default value of the arguments to NA.
> 
> 
> On Thu, Aug 29, 2013 at 3:23 PM, newruser12345
> <smetcalf at gelbergroup.com>wrote:
> 
> > Hi All,
> >
> > I'm very green user and have little programming background, but
> > appreciate any and all help/direction.  I have a spreadsheet that
> > successfully sends values from Excel cells to R as variables for a
> > function, which then runs and generates a plot.  I cannot figure out
> > how to make R recognize those variables as NA if one of the cells in
> > Excel is blank - or, for that matter, I don't know how to get an R
> > function  to recognize variables as NA if no value is assigned to
> that
> > variable.
> >
> > I have unsuccessfully tried using :
> >
> > if(is.na(four)) return(NA)
> >
> > My function is very simple:
> >
> > mtmatches <- c(one,two,three,four)
> >
> > Everything runs smoothly if the four variables have values assigned
> to
> > them.
> > Any advice on how to get it to run when one of the variables has no
> value?
> > No worries about the Excel element...figure I can decipher that
> puzzle
> > later!
> >
> >
> > Thanks!
> >
> >
> >
> > --
> > View this message in context:
> > http://r.789695.n4.nabble.com/Omitted-blank-variables-in-R-function-
> tp
> > 4674931.html Sent from the R help mailing list archive at Nabble.com.
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> --
> Gregory (Greg) L. Snow Ph.D.
> 538280 at gmail.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list