How to create a function where if the R version is older than 3.5, it gives a warning?R and version control for the solo data analystdata.table vs dplyr: can one do something well the other can't or does poorly?warning messages when trying to run glmer in rHow should I deal with “package 'xxx' is not available (for R version x.y.z)” warning?no visible global function definition for ‘median’At least some columns satisfy a conditionpredict.gls fails when the package “MuMin” is installed in RProblems to configure Java for using in R version 3.5.0 and use rJava and coreNLP librariesError: package or namespace load failed, object … not foundSudden errors with as.data.frame with previously used code and objects
Why do textbooks often include the solutions to odd or even numbered problems but not both?
Why is prior to creation called holy?
Can humans ever directly see a few photons at a time? Can a human see a single photon?
How to make clear to people I don't want to answer their "Where are you from?" question?
Heavily limited premature compiler translates text into excecutable python code
What is the legal status of travelling with methadone in your carry-on?
How can I politely work my way around not liking coffee or beer when it comes to professional networking?
How is hair tissue mineral analysis performed?
What happened to Steve's Shield in Iron Man 2?
Count All Possible Unique Combinations of Letters in a Word
Is "Busen" just the area between the breasts?
What does the hyphen "-" mean in "tar xzf -"?
Why do even high-end cameras often still include normal (non-cross-type) AF sensors?
Why are < or > required to use /dev/tcp
Can White Castle?
How many children?
What could exist inside and between the walls of a Dyson Sphere?
When two first person POV characters meet
How large would a mega structure have to be to host 1 billion people indefinitely?
What size of powerbank will I need to power a phone and DSLR for 2 weeks?
Minor traveling without parents from USA to Sweden
Greeting with "Ho"
What is "industrial ethernet"?
How many people are necessary to maintain modern civilisation?
How to create a function where if the R version is older than 3.5, it gives a warning?
R and version control for the solo data analystdata.table vs dplyr: can one do something well the other can't or does poorly?warning messages when trying to run glmer in rHow should I deal with “package 'xxx' is not available (for R version x.y.z)” warning?no visible global function definition for ‘median’At least some columns satisfy a conditionpredict.gls fails when the package “MuMin” is installed in RProblems to configure Java for using in R version 3.5.0 and use rJava and coreNLP librariesError: package or namespace load failed, object … not foundSudden errors with as.data.frame with previously used code and objects
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I currently have the following code to see if the current R version is not equal to 3.5.0. However, I would like to change it so that if someone has a R version older than 3.5.0, it gives a warning to update R. Because 3.5.0 is not "less than" 3.4.0, etc, I am having issues creating a boolean command, since the computer doesnt recognize 3.4.0 as being "less than" 3.5.0. Is there a way to facilitate this?
if(strsplit(version[['version.string']], ' ')[[1]][3] != '3.5.0')
print("Warning: Update R")
r
add a comment |
I currently have the following code to see if the current R version is not equal to 3.5.0. However, I would like to change it so that if someone has a R version older than 3.5.0, it gives a warning to update R. Because 3.5.0 is not "less than" 3.4.0, etc, I am having issues creating a boolean command, since the computer doesnt recognize 3.4.0 as being "less than" 3.5.0. Is there a way to facilitate this?
if(strsplit(version[['version.string']], ' ')[[1]][3] != '3.5.0')
print("Warning: Update R")
r
1
You can either change your version string to a number or do something like:if(strsplit(version[['version.string']], ' ')[[1]][3] < '3.5.0') print("Warning: Update R")
– patL
Mar 25 at 8:26
3
Actually'3.4.0' < '3.5.0','3.4.9' < '3.5.0'does returnTRUEbut I think you still need some stricter checks.
– Ronak Shah
Mar 25 at 8:27
1
What about remove the dotsas.numeric(gsub(".", "", substring(version[['version.string']], 11, 15), fixed = TRUE)) < 350
– Clemsang
Mar 25 at 8:30
@Clemsang What doesfixed=TRUEdo?
– user321627
Mar 25 at 8:32
1
Take the dots as dots in regular expressions, otherwise it is evaluated as any character. Fixed allows to have dot as a dot.
– Clemsang
Mar 25 at 8:53
add a comment |
I currently have the following code to see if the current R version is not equal to 3.5.0. However, I would like to change it so that if someone has a R version older than 3.5.0, it gives a warning to update R. Because 3.5.0 is not "less than" 3.4.0, etc, I am having issues creating a boolean command, since the computer doesnt recognize 3.4.0 as being "less than" 3.5.0. Is there a way to facilitate this?
if(strsplit(version[['version.string']], ' ')[[1]][3] != '3.5.0')
print("Warning: Update R")
r
I currently have the following code to see if the current R version is not equal to 3.5.0. However, I would like to change it so that if someone has a R version older than 3.5.0, it gives a warning to update R. Because 3.5.0 is not "less than" 3.4.0, etc, I am having issues creating a boolean command, since the computer doesnt recognize 3.4.0 as being "less than" 3.5.0. Is there a way to facilitate this?
if(strsplit(version[['version.string']], ' ')[[1]][3] != '3.5.0')
print("Warning: Update R")
r
r
asked Mar 25 at 8:21
user321627user321627
487411
487411
1
You can either change your version string to a number or do something like:if(strsplit(version[['version.string']], ' ')[[1]][3] < '3.5.0') print("Warning: Update R")
– patL
Mar 25 at 8:26
3
Actually'3.4.0' < '3.5.0','3.4.9' < '3.5.0'does returnTRUEbut I think you still need some stricter checks.
– Ronak Shah
Mar 25 at 8:27
1
What about remove the dotsas.numeric(gsub(".", "", substring(version[['version.string']], 11, 15), fixed = TRUE)) < 350
– Clemsang
Mar 25 at 8:30
@Clemsang What doesfixed=TRUEdo?
– user321627
Mar 25 at 8:32
1
Take the dots as dots in regular expressions, otherwise it is evaluated as any character. Fixed allows to have dot as a dot.
– Clemsang
Mar 25 at 8:53
add a comment |
1
You can either change your version string to a number or do something like:if(strsplit(version[['version.string']], ' ')[[1]][3] < '3.5.0') print("Warning: Update R")
– patL
Mar 25 at 8:26
3
Actually'3.4.0' < '3.5.0','3.4.9' < '3.5.0'does returnTRUEbut I think you still need some stricter checks.
– Ronak Shah
Mar 25 at 8:27
1
What about remove the dotsas.numeric(gsub(".", "", substring(version[['version.string']], 11, 15), fixed = TRUE)) < 350
– Clemsang
Mar 25 at 8:30
@Clemsang What doesfixed=TRUEdo?
– user321627
Mar 25 at 8:32
1
Take the dots as dots in regular expressions, otherwise it is evaluated as any character. Fixed allows to have dot as a dot.
– Clemsang
Mar 25 at 8:53
1
1
You can either change your version string to a number or do something like:
if(strsplit(version[['version.string']], ' ')[[1]][3] < '3.5.0') print("Warning: Update R") – patL
Mar 25 at 8:26
You can either change your version string to a number or do something like:
if(strsplit(version[['version.string']], ' ')[[1]][3] < '3.5.0') print("Warning: Update R") – patL
Mar 25 at 8:26
3
3
Actually
'3.4.0' < '3.5.0', '3.4.9' < '3.5.0' does return TRUE but I think you still need some stricter checks.– Ronak Shah
Mar 25 at 8:27
Actually
'3.4.0' < '3.5.0', '3.4.9' < '3.5.0' does return TRUE but I think you still need some stricter checks.– Ronak Shah
Mar 25 at 8:27
1
1
What about remove the dots
as.numeric(gsub(".", "", substring(version[['version.string']], 11, 15), fixed = TRUE)) < 350– Clemsang
Mar 25 at 8:30
What about remove the dots
as.numeric(gsub(".", "", substring(version[['version.string']], 11, 15), fixed = TRUE)) < 350– Clemsang
Mar 25 at 8:30
@Clemsang What does
fixed=TRUE do?– user321627
Mar 25 at 8:32
@Clemsang What does
fixed=TRUE do?– user321627
Mar 25 at 8:32
1
1
Take the dots as dots in regular expressions, otherwise it is evaluated as any character. Fixed allows to have dot as a dot.
– Clemsang
Mar 25 at 8:53
Take the dots as dots in regular expressions, otherwise it is evaluated as any character. Fixed allows to have dot as a dot.
– Clemsang
Mar 25 at 8:53
add a comment |
2 Answers
2
active
oldest
votes
You can transform version number like 3.5.0 to 350 by removing dots. This way you can easily compare current and target version :
if(gsub(".", "", strsplit(version[['version.string']], ' ')[[1]][3], fixed = TRUE) < '350')
print("Warning: Update R")
add a comment |
The C interface has a nice convienence function to do this. You can see how it's defined:
#define R_VERSION 197890
#define R_NICK "Eggshell Igloo"
#define R_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s))
So you can do something like this:
#include <Rversion.h>
// [[Rcpp::export]]
bool isVersionOutdated()
#if R_VERSION < R_Version(3, 5, 1)
return true;
#else
return false;
#endif
R side:
library(Rcpp)
sourceCpp("test.cpp")
isVersionOutdated()
[1] FALSE
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333691%2fhow-to-create-a-function-where-if-the-r-version-is-older-than-3-5-it-gives-a-wa%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can transform version number like 3.5.0 to 350 by removing dots. This way you can easily compare current and target version :
if(gsub(".", "", strsplit(version[['version.string']], ' ')[[1]][3], fixed = TRUE) < '350')
print("Warning: Update R")
add a comment |
You can transform version number like 3.5.0 to 350 by removing dots. This way you can easily compare current and target version :
if(gsub(".", "", strsplit(version[['version.string']], ' ')[[1]][3], fixed = TRUE) < '350')
print("Warning: Update R")
add a comment |
You can transform version number like 3.5.0 to 350 by removing dots. This way you can easily compare current and target version :
if(gsub(".", "", strsplit(version[['version.string']], ' ')[[1]][3], fixed = TRUE) < '350')
print("Warning: Update R")
You can transform version number like 3.5.0 to 350 by removing dots. This way you can easily compare current and target version :
if(gsub(".", "", strsplit(version[['version.string']], ' ')[[1]][3], fixed = TRUE) < '350')
print("Warning: Update R")
answered Mar 25 at 8:56
ClemsangClemsang
1,166816
1,166816
add a comment |
add a comment |
The C interface has a nice convienence function to do this. You can see how it's defined:
#define R_VERSION 197890
#define R_NICK "Eggshell Igloo"
#define R_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s))
So you can do something like this:
#include <Rversion.h>
// [[Rcpp::export]]
bool isVersionOutdated()
#if R_VERSION < R_Version(3, 5, 1)
return true;
#else
return false;
#endif
R side:
library(Rcpp)
sourceCpp("test.cpp")
isVersionOutdated()
[1] FALSE
add a comment |
The C interface has a nice convienence function to do this. You can see how it's defined:
#define R_VERSION 197890
#define R_NICK "Eggshell Igloo"
#define R_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s))
So you can do something like this:
#include <Rversion.h>
// [[Rcpp::export]]
bool isVersionOutdated()
#if R_VERSION < R_Version(3, 5, 1)
return true;
#else
return false;
#endif
R side:
library(Rcpp)
sourceCpp("test.cpp")
isVersionOutdated()
[1] FALSE
add a comment |
The C interface has a nice convienence function to do this. You can see how it's defined:
#define R_VERSION 197890
#define R_NICK "Eggshell Igloo"
#define R_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s))
So you can do something like this:
#include <Rversion.h>
// [[Rcpp::export]]
bool isVersionOutdated()
#if R_VERSION < R_Version(3, 5, 1)
return true;
#else
return false;
#endif
R side:
library(Rcpp)
sourceCpp("test.cpp")
isVersionOutdated()
[1] FALSE
The C interface has a nice convienence function to do this. You can see how it's defined:
#define R_VERSION 197890
#define R_NICK "Eggshell Igloo"
#define R_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s))
So you can do something like this:
#include <Rversion.h>
// [[Rcpp::export]]
bool isVersionOutdated()
#if R_VERSION < R_Version(3, 5, 1)
return true;
#else
return false;
#endif
R side:
library(Rcpp)
sourceCpp("test.cpp")
isVersionOutdated()
[1] FALSE
answered Mar 25 at 9:02
thcthc
6,17711225
6,17711225
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333691%2fhow-to-create-a-function-where-if-the-r-version-is-older-than-3-5-it-gives-a-wa%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You can either change your version string to a number or do something like:
if(strsplit(version[['version.string']], ' ')[[1]][3] < '3.5.0') print("Warning: Update R")– patL
Mar 25 at 8:26
3
Actually
'3.4.0' < '3.5.0','3.4.9' < '3.5.0'does returnTRUEbut I think you still need some stricter checks.– Ronak Shah
Mar 25 at 8:27
1
What about remove the dots
as.numeric(gsub(".", "", substring(version[['version.string']], 11, 15), fixed = TRUE)) < 350– Clemsang
Mar 25 at 8:30
@Clemsang What does
fixed=TRUEdo?– user321627
Mar 25 at 8:32
1
Take the dots as dots in regular expressions, otherwise it is evaluated as any character. Fixed allows to have dot as a dot.
– Clemsang
Mar 25 at 8:53