Jose Claudio Faria
2013-Sep-23 18:55 UTC
[R] Vector of char generated by Sys.getenv function is not available when the package is loaded
I have been developing a new package (TinnRcom) to avoid the necessity
of any script
(as below) in the Rprofile.site file related to the use of Tinn-R Editor and R:
#==============================================================# Tinn-R:
necessary packages and functions
# Tinn-R: >= 2.4.1.1 with TinnR package >= 1.0.3
#==============================================================# Set the URL of
the preferred repository, below some examples:
options(repos='http://cran.at.r-project.org/') # Austria/Wien
#options(repos='http://cran-r.c3sl.ufpr.br/') # Brazil/PR
#options(repos='http://cran.fiocruz.br/') # Brazil/RJ
#options(repos='http://www.vps.fmvz.usp.br/CRAN/') # Brazil/SP
#options(repos='http://brieger.esalq.usp.br/CRAN/') # Brazil/SP
library(utils)
# Check necessary packages
necessary <- c('TinnR',
'svSocket',
'formatR')
installed <- necessary %in% installed.packages()[, 'Package']
if (length(necessary[!installed]) >=1)
install.packages(necessary[!installed])
# Load packages
library(TinnR)
library(svSocket)
# Uncoment the two lines below if you want Tinn-R to always start R at start-up
# (Observation: check the path of Tinn-R.exe)
options(IDE='C:/Tinn-R/bin/Tinn-R.exe')
trStartIDE()
# Short paths
.trPaths <- paste(paste(Sys.getenv('APPDATA'),
'\\Tinn-R\\tmp\\',
sep=''),
c('',
'search.txt',
'objects.txt',
'file.r',
'selection.r',
'block.r',
'lines.r',
'reformat-input.r',
'reformat-output.r'),
sep='')
library(Matrix)
library(cluster)
library(Hmisc)
#==============================================================
For this it is necessary to put the object trPaths in the new TinnRcom package.
I make this as follows in the folder TinnRcom/R/trPaths.R:
trPaths <- paste(paste(Sys.getenv('APPDATA'),
'\\Tinn-R\\tmp\\',
sep=''),
c('',
'search.txt',
'objects.txt',
'file.r',
'selection.r',
'block.r',
'lines.r',
'reformat-input.r',
'reformat-output.r'),
sep='')
The NAMESPACE file is as below:
import(utils, tcltk, Hmisc, R2HTML)
importFrom(formatR, tidy.source)
importFrom(svSocket, evalServer)
export(
trArgs,
trComplete,
trCopy,
trExport,
trObjList,
trObjSearch,
trPaths,
trStartIDE)
S3method(trExport, default)
S3method(trExport, data.frame)
S3method(trExport, matrix)
After to load the package
> library(TinnRcom)
the result is always:> trPaths
[1] "\\Tinn-R\\tmp\\"
"\\Tinn-R\\tmp\\search.txt"
[3] "\\Tinn-R\\tmp\\objects.txt"
"\\Tinn-R\\tmp\\file.r"
[5] "\\Tinn-R\\tmp\\selection.r"
"\\Tinn-R\\tmp\\block.r"
[7] "\\Tinn-R\\tmp\\lines.r"
"\\Tinn-R\\tmp\\reformat-input.r"
[9] "\\Tinn-R\\tmp\\reformat-output.r"
When should be:> trPaths
[1] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\"
[2] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\search.txt"
[3] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\objects.txt"
[4] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\file.r"
[5] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\selection.r"
[6] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\block.r"
[7] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\lines.r"
[8]
"C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-input.r"
[9]
"C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-output.r"
What is wrong?
Why the Sys.getenv function is not making the job when in the package?
Anyone can help please?
P.S: The beta version of the TinnRcom package is available to download at:
http://nbcgib.uesc.br/lec/download/R/TinnRcom_1.0-09.zip
--
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Jose Claudio Faria
Estatistica
UESC/DCET/Brasil
joseclaudio.faria at gmail.com
Telefones:
55(73)3680.5545 - UESC
55(73)9100.7351 - TIM
55(73)8817.6159 - OI
///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
Gabor Grothendieck
2013-Sep-23 19:14 UTC
[R] Vector of char generated by Sys.getenv function is not available when the package is loaded
On Mon, Sep 23, 2013 at 2:55 PM, Jose Claudio Faria <joseclaudio.faria at gmail.com> wrote:> trPaths <- paste(paste(Sys.getenv('APPDATA'), > '\\Tinn-R\\tmp\\', > sep=''), > c('', > 'search.txt', > 'objects.txt', > 'file.r', > 'selection.r', > 'block.r', > 'lines.r', > 'reformat-input.r', > 'reformat-output.r'), > sep='') >Try this: trPaths <- file.path( Sys.getenv('APPDATA'), 'Tinn-R', 'tmp', c('', 'search.txt', 'objects.txt', 'file.r', 'selection.r', 'block.r', 'lines.r', 'reformat-input.r', 'reformat-output.r'), fsep = '\\') -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Philippe Grosjean
2013-Sep-24 06:16 UTC
[R] Vector of char generated by Sys.getenv function is not available when the package is loaded
Hi JCFaria, You package is supposed to be used only under Windows, right? Then, use: OS_type=windows in the DESCRIPTION file? and, of course, use R CMD check/R CMD build/ R CMD INSTALL under Windows only. Best, Philippe On 23 Sep 2013, at 20:55, Jose Claudio Faria <joseclaudio.faria at gmail.com> wrote:> I have been developing a new package (TinnRcom) to avoid the necessity > of any script > (as below) in the Rprofile.site file related to the use of Tinn-R Editor and R: > > #==============================================================> # Tinn-R: necessary packages and functions > # Tinn-R: >= 2.4.1.1 with TinnR package >= 1.0.3 > #==============================================================> # Set the URL of the preferred repository, below some examples: > options(repos='http://cran.at.r-project.org/') # Austria/Wien > #options(repos='http://cran-r.c3sl.ufpr.br/') # Brazil/PR > #options(repos='http://cran.fiocruz.br/') # Brazil/RJ > #options(repos='http://www.vps.fmvz.usp.br/CRAN/') # Brazil/SP > #options(repos='http://brieger.esalq.usp.br/CRAN/') # Brazil/SP > > library(utils) > > # Check necessary packages > necessary <- c('TinnR', > 'svSocket', > 'formatR') > > installed <- necessary %in% installed.packages()[, 'Package'] > if (length(necessary[!installed]) >=1) > install.packages(necessary[!installed]) > > # Load packages > library(TinnR) > library(svSocket) > > # Uncoment the two lines below if you want Tinn-R to always start R at start-up > # (Observation: check the path of Tinn-R.exe) > options(IDE='C:/Tinn-R/bin/Tinn-R.exe') > trStartIDE() > > # Short paths > .trPaths <- paste(paste(Sys.getenv('APPDATA'), > '\\Tinn-R\\tmp\\', > sep=''), > c('', > 'search.txt', > 'objects.txt', > 'file.r', > 'selection.r', > 'block.r', > 'lines.r', > 'reformat-input.r', > 'reformat-output.r'), > sep='') > > library(Matrix) > library(cluster) > library(Hmisc) > #==============================================================> > For this it is necessary to put the object trPaths in the new TinnRcom package. > > I make this as follows in the folder TinnRcom/R/trPaths.R: > > trPaths <- paste(paste(Sys.getenv('APPDATA'), > '\\Tinn-R\\tmp\\', > sep=''), > c('', > 'search.txt', > 'objects.txt', > 'file.r', > 'selection.r', > 'block.r', > 'lines.r', > 'reformat-input.r', > 'reformat-output.r'), > sep='') > > > The NAMESPACE file is as below: > > import(utils, tcltk, Hmisc, R2HTML) > importFrom(formatR, tidy.source) > importFrom(svSocket, evalServer) > > export( > trArgs, > trComplete, > trCopy, > trExport, > trObjList, > trObjSearch, > trPaths, > trStartIDE) > > S3method(trExport, default) > S3method(trExport, data.frame) > S3method(trExport, matrix) > > > After to load the package > >> library(TinnRcom) > > the result is always: >> trPaths > [1] "\\Tinn-R\\tmp\\" "\\Tinn-R\\tmp\\search.txt" > [3] "\\Tinn-R\\tmp\\objects.txt" "\\Tinn-R\\tmp\\file.r" > [5] "\\Tinn-R\\tmp\\selection.r" "\\Tinn-R\\tmp\\block.r" > [7] "\\Tinn-R\\tmp\\lines.r" "\\Tinn-R\\tmp\\reformat-input.r" > [9] "\\Tinn-R\\tmp\\reformat-output.r" > > When should be: >> trPaths > [1] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\" > [2] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\search.txt" > [3] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\objects.txt" > [4] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\file.r" > [5] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\selection.r" > [6] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\block.r" > [7] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\lines.r" > [8] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-input.r" > [9] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-output.r" > > What is wrong? > Why the Sys.getenv function is not making the job when in the package? > > Anyone can help please? > > P.S: The beta version of the TinnRcom package is available to download at: > http://nbcgib.uesc.br/lec/download/R/TinnRcom_1.0-09.zip > -- > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ > Jose Claudio Faria > Estatistica > UESC/DCET/Brasil > joseclaudio.faria at gmail.com > Telefones: > 55(73)3680.5545 - UESC > 55(73)9100.7351 - TIM > 55(73)8817.6159 - OI > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ > > ______________________________________________ > 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. >