[R] Is 'temp' a reserved/key word in R?

Sarah Goslee @@r@h@go@|ee @end|ng |rom gm@||@com
Tue Nov 30 15:49:40 CET 2021


Andrew is right - it's a typo.

More broadly, there's no restriction of that sort on the contents of
your data frame - reserved words can't be used for object names. The R
Language Definition is the best resource for identifying those words.

It would help if you provided the package for read_csv, since not
everyone uses tidyverse by default, although it isn't necessary for
this question.

Sarah


On Tue, Nov 30, 2021 at 9:45 AM Andrew Simmons <akwsimmo using gmail.com> wrote:
>
> It seems like the headers are misnamed, that should be a comma between
> sampdate and param, not a period
>
> On Tue, Nov 30, 2021, 09:35 Rich Shepard <rshepard using appl-ecosys.com> wrote:
>
> > A short data file:
> > site_nbr,sampdate.param,quant,unit
> > 31731,2005-07-12,temp,19.7,oC
> > 31731,2007-03-28,temp,9,oC
> > 31731,2007-06-27,temp,18.3,oC
> > 31731,2007-09-26,temp,15.8,oC
> > 31731,2008-01-17,temp,5.4,oC
> > 31731,2008-03-27,temp,7.4,oC
> > 31731,2010-04-05,temp,8.1,oC
> > 31731,2010-07-26,temp,20.5,oC
> > 31731,2010-10-18,temp,12.5,oC
> > 31731,2011-01-10,temp,5.4,oC
> >
> > The import function:
> > sal_temp <- read_csv("../data/geochem/sal-temp.csv", col_names = TRUE,
> >                       col_types = list (
> >                           site_nbr = col_character(),
> >                           sampdate = col_date(),
> >                           param = col_character(),
> >                           quant = col_double(),
> >                           unit = col_character()
> >                       ))
> >
> > The response from R:
> > source('../scripts/test.r')
> > Warning message:
> > The following named parsers don't match the column names: sampdate, param
> >
> > I searched the web to see if 'temp' is causing the problem and didn't find
> > an answer; my search term might have been flawed.
> >
> > If that string is a problem please suggest an alternative.
> >
> > TIA,
> >
> > Rich
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



-- 
Sarah Goslee (she/her)
http://www.numberwright.com



More information about the R-help mailing list