Well, it can be done without a temporary variable, but I'm not sure you
would want to.
Anyway...
## simplified example
> a <- 1
> vname <- "a"
> eval(substitute(attr(x,"b") <- "hi", list( x = as.name(vname
> a
[1] 1
attr(,"b")
[1] "hi"
Cheers,
Bert
Bert Gunter
"The trouble with having an
oops, I think the right code would be
x = get(varname)
attr(x, "foo") = "bar"
assign(varname, x)
On Wed, Oct 10, 2018 at 9:30 PM Peter Langfelder
wrote:
> I would try something like
>
> x = get(myvarname)
> attr(x, "foo") = "bar"
> assign(varname, x)
>
> HTH,
>
> Peter
>
> On Wed, Oct 10, 2018
Hello,
> month.names
Erro: objeto 'month.names' não encontrado
> month.name
[1] "January" "February" "March" "April" "May" "June"
[7] "July" "August""September" "October" "November" "December"
Hope this helps,
Rui Barradas
Às 01:05 de 11/10/2018, William
I would try something like
x = get(myvarname)
attr(x, "foo") = "bar"
assign(varname, x)
HTH,
Peter
On Wed, Oct 10, 2018 at 9:15 PM Marc Girondot via R-help <
r-help@r-project.org> wrote:
> Hello everybody,
>
> Has someone the solution to set attribute when variable is known by name ?
>
>
Hello everybody,
Has someone the solution to set attribute when variable is known by name ?
Thanks a lot
Marc
Let see this exemple:
# The variable name is stored as characters.
varname <- "myvarname"
assign(x = varname, data.frame(A=1:5, B=2:6))
attributes(myvarname)
$names
[1] "A" "B"
Hey Matthew,
In addition to what's been mentioned, you may want to look at the
'caret' package, as it provides a nice system for whatever flavor of
cross-validation you're after *and* has a built-in method for `kknn`:
http://topepo.github.io/caret/available-models.html
Hope this helps,
Zach
You can paste the directory names, dir.names(files), back on, with
file.path(), after you do the sorting. A better idiom is to use order()
instead of sort() and usng order's output to subscript file.names. E.g.,
the following sorts by year and month number.
> file.names <-
On 10/10/2018 7:23 PM, Ek Esawi wrote:
Thank you Bill and RUI. I use month.name with sort and basename, as
suggested by Bill. i got the sorted numerical values, then i use
month.name to get proper ordered month names. The problem is that i
have to paste to the names the extension PDF giving me
On 10/10/2018 7:11 PM, Olivier GIVAUDAN wrote:
It is not wrong to claim that R currently doesn't have a function
returning the path of the R file where this same function was invoked.
But it does. I didn't realize that's what you were asking for. This
has nothing to do with your subject
If I’m following all this correctly, it seems your criticism is that R doesn’t
provide a run-time function that is equivalent to a compile-time macro. You do
realize that __FILE__ is not part of the C programming language - it’s a
predefined variable recognized by the cpp - the C preprocessor
Thank you Bill and RUI. I use month.name with sort and basename, as
suggested by Bill. i got the sorted numerical values, then i use
month.name to get proper ordered month names. The problem is that i
have to paste to the names the extension PDF giving me the correct
ordered file names, but then i
On 10/10/2018 6:52 PM, Olivier GIVAUDAN wrote:
Again, you seem to think making a package is a big deal.
Perhaps not a big deal (I believe you, I didn't write an R package yet),
but not as straightforward as having a function within an R file
returning its own path.
But you're free to
On 10/10/2018 6:17 PM, Olivier GIVAUDAN wrote:
Nothing says a package has to go on CRAN. You can distribute
themprivately to a small audience.
Yes, I agree in theory. But this solution still violates my own
proportionality principle.
Again, you seem to think making a package is a big deal.
Hi again,
Two things, I named the data frame SR as shown in the model.
The other is for those who may wish to answer the OP. The mediafire
website is loaded with intrusive ads and perhaps malware.
Jim
On Thu, Oct 11, 2018 at 9:02 AM Jim Lemon wrote:
>
> Hi Tranh,
> I'm not sure why you are
On 10/10/2018 5:45 PM, Olivier GIVAUDAN wrote:
I'm not sure I'm "inventing my own way" of distributing R code... And I
distribute it to a very limited audience.
Nothing says a package has to go on CRAN. You can distribute them
privately to a small audience.
Anyway, why not "inventing a new
Hi Tranh,
I'm not sure why you are converting your variables to factors, and I
think the model you want is:
lm(KIC~temperature+AC+AV+Thickness+temperature:AC+
temperature:AV+temperature:thickness+AC:AV+
AC:thickness+AV:thickness,SR)
Note the colons (:) rather than asterisks (*) for the
On 10/10/2018 5:31 PM, Olivier GIVAUDAN wrote:
I do not want to use the terminal, just double clicks (i.e. the
simplest, automatic, non-manual way, without having to write a line /
command).
Therefore everything should happen outside any terminal. The user won't
use a terminal.
I don't have
I do not want to use the terminal, just double clicks (i.e. the simplest,
automatic, non-manual way, without having to write a line / command).
Therefore everything should happen outside any terminal. The user won't use a
terminal.
I don't have a Mac and I'm not familiar with this OS, sorry.
Hi Leslie,
Keeping track of any sort of text (or music or pictures) can be
challenging when the number of files becomes large. One way to
organize a large collection is to categorize it in some way that makes
sense to you. Say you create a directory structure:
"tags" are a way to label things digitally so that they are easier to find
later - Twitter uses these, as one example.
I found a nice solution: GitHubGist with an interface via Lepton, if anyone
else would like to avoid rummaging through old code to find something (a
function, an example,
Actually there is a difference between:
1. Directly executing the file by the user by double clicking on the
"physical" file (you can only do that from the directory where the file is
located), without going through any terminal, and
2. Executing this file "remotely" by calling it through
On 10/10/2018 4:42 PM, Olivier GIVAUDAN wrote:
Why are you not simply double-clicking on 'TestPWD' and choosing to
execute the file (don't add anything)?
Are you executing the file from a terminal?
Yes, I was executing the file from my terminal. Otherwise I really have
no idea what the
Why are you not simply double-clicking on 'TestPWD' and choosing to execute the
file (don't add anything)?
Are you executing the file from a terminal?
De : Duncan Murdoch
Envoyé : mercredi 10 octobre 2018 20:17
À : Olivier GIVAUDAN; Jeff Newmiller
Cc :
I haven't followed this discussion closely, so this may be offbase, but in
response to your point 2., note that you can set the working directory via
setwd() in your .Rprofile file. Of course, users can always determine the
working directory via invoking the getwd() function, so I'm not sure what
On 10/10/2018 3:51 PM, Olivier GIVAUDAN wrote:
Well, no idea...
I just created a file 'TestPWD', made it executable, inserted in it
these lines and moved the file in various places:
#!/bin/bash
echo $PWD
read -p ""
When I execute that, it prints my working directory. Doesn't matter
"get organized around R programming" is rather vague. Nor do I know what
you mean by "tagging" code snippets.
A standard answer would be to write your "code" as documented functions in
a package (e.g. "LeslieMisc"). RStudio -- a wholly separate software
product -- has various tools to that may
Thank you, Luke.
Unfortunately I don't use Rscript (it is not allowed to run shell scripts on my
professional computer).
Best regards,
Olivier
De : Tierney, Luke
Envoy� : mercredi 10 octobre 2018 15:48
� : Olivier GIVAUDAN
Cc : Eik Vettorazzi;
To be able to change easily, cleanly and automatically the working directory
and thus to work with relative paths in the close neighbourhood of your R files.
De : William Dunlap
Envoyé : mercredi 10 octobre 2018 15:25
À : Olivier GIVAUDAN
Cc : Duncan Murdoch;
Well, no idea...
I just created a file 'TestPWD', made it executable, inserted in it these lines
and moved the file in various places:
#!/bin/bash
echo $PWD
read -p ""
De : Duncan Murdoch
Envoyé : mercredi 10 octobre 2018 15:20
À : Olivier GIVAUDAN; Jeff
Hi all,
I'm trying to get organized about my R programming and I'm looking for a
way to "tag" snippets of handy code that I go back to time and again. At
the moment, I just plop .R files into a folder and rely on the file name to
guide me. In desperation, I've taken to saving the same chunk as
Hi Tina,
What's wrong with what you did?
The output object of som() contains the classification of each sample.
You probably do need to read more about self-organizing maps, since
you specified you wanted the samples classified into nine groups, and
that's unlikely to be your actual intent.
I
If you are always running your main script as 'Rscript myscript.R'
then your file argument will appear as '--file=myscript.R' in
commandArgs(). So you can use something like
scriptFile <- function()
{
pat <- "^--file="
args <- commandArgs()
file <- args[grepl(pat, args, args)]
I am curious about why it is desirable for a script to know where in the
file system it is. Is it because you have a set of scripts invoking each
other? If so, the best route it to convert the scripts into functions and
put them into a package. Functions do know which package they live in and
On 10/10/2018 11:20 AM, Duncan Murdoch wrote:
On 10/10/2018 11:18 AM, Olivier GIVAUDAN wrote:
Hi Duncan,
Yes, if you need to display the content of $PWD you obviously need to
type 'echo' before this variable.
It prints the user's working directory if run from a terminal but if run
from a bash
On 10/10/2018 11:18 AM, Olivier GIVAUDAN wrote:
Hi Duncan,
Yes, if you need to display the content of $PWD you obviously need to
type 'echo' before this variable.
It prints the user's working directory if run from a terminal but if run
from a bash file it prints the working directory of the
Hi Duncan,
Yes, if you need to display the content of $PWD you obviously need to type
'echo' before this variable.
It prints the user's working directory if run from a terminal but if run from a
bash file it prints the working directory of the script.
At least for me (I am running on the last
Hi Don,
Thanks for your message.
> First fact:
> R understands relative paths (as do the other languages you mentioned) (you
> have misunderstood R if you think it doesn't)
I never said R doesn't understand relative paths (which software doesn't...). I
simply said it is not
On 10/10/2018 10:37 AM, Olivier GIVAUDAN wrote:
Hi Jeff,
That is, there is not always a file in a particular directory even involved in
the executing code.
True. I'm only asking in the case where some R code is run from an R file. This
function 'MyOwnPath()' (say) should only work
Es lo mismo que te había dicho yo... jeje
De todas formas tú eres muy listo, e igual puedes reprogramar el código del
pequete...
El mié., 10 oct. 2018 a las 16:36, Fernando Sanchez via R-help-es (<
r-help-es@r-project.org>) escribió:
> Hola a todos,
> Cierro este tema con la propia respuesta
Search!
the rseek.org site gives many hits for "self organizing maps", including
the som package among others.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic
Hi Jeff,
> That is, there is not always a file in a particular directory even involved
> in the executing code.
True. I'm only asking in the case where some R code is run from an R file. This
function 'MyOwnPath()' (say) should only work (i.e. return a useful result) in
this case.
>
Hola a todos,
Cierro este tema con la propia respuesta del autor del paquete, Dimitri
Rizopoulos.
Dear Fernando,
Thanks for your e-mail and interestin my package. Regarding your question,
unfortunately, it is not possible to dothat with the plot method. You will need
to create the figure
Hi
see in line
> -Original Message-
> From: R-help On Behalf Of Subhamitra Patra
> Sent: Wednesday, October 10, 2018 1:07 PM
> To: r-help@r-project.org
> Subject: [R] [R studio] Plotting line chart for the obtained entropy values
>
> Hello friends,
>
> I have obtained the approximate
Hi Gabor,
1. By definition the relative path (I'm excluding the absolute path solution
for obvious reasons) depends on the current working directory: What if my R
script is not located along this current working directory? It won't work.
2. What should I write as an option in this
Hello friends,
I have obtained the approximate entropy values for the multiple series.
But, after that, I am unable to draw a line chart for the obtained
approximate entropy values. Please help me to draw a line chart for the
obtained entropy values. For your reference, I am writing my code here
We cannot read your message. Should post pure text, not html. Hm, my phone
now may post html, must try to stop. Your R code not legible. It seems to
be output? Lines all run together. I tried find articles you mention, but
"not found" resulted.
You should use aov() for fitting, then get post hoc
Muchas gracias, Isidro, Javier y Jose.
Efectivamente, el problema lo tenía en querer poner en algún lado la orden
<- . Había andado investigando, desde mi tozudez, la orden assign() y la
había descartado. Erroneamente descartado.
La librería, Javier, es más una escusa que otra cosa. Me doy
Dear ESS users,
The ESS core team is planning a new release of ESS, 18.10,
before the end of October, possibly in 10 days already.
Whereas some of you may be using the always latest somewhat
unstable development of ESS from MELPA or directly via regular
pull from github, many will use released
Dear ESS users,
The ESS core team is planning a new release of ESS, 18.10,
before the end of October, possibly in 10 days already.
Whereas some of you may be using the always latest somewhat
unstable development of ESS from MELPA or directly via regular
pull from github, many will use released
Dear All,
Who can I use Self Organizing Map (SOM) results to cluster samples? I have
tried following but this gives me only the clustering of grids, while I
want to cluster (150) samples:
library(kohonen)
iris.sc <- scale(iris[, 1:4])
iris.som <- som(iris.sc, grid=somgrid(xdim = 3, ydim=3,
Hi eveyone,
I'm studying about variance (ANOVA) in R and have some questions to share.
I read an article investigating the effect of factors (temperature, Asphalt
content, Air voids, and sample thickness) on the hardness of asphalt
concrete in the tensile test (abbreviated as Kic). Each condition
51 matches
Mail list logo