Displaying 20 results from an estimated 315 matches for "neater".
Did you mean:
nearer
2006 Mar 02
5
Deparsing '...'
Hi,
The following function works, but is there a neater way to write it?
f = function(x,...)
{
# return a character vector of the arguments passed in after 'x'
gsub("
","",unlist(strsplit(deparse(substitute(list(...))),"[(,)]")))[-1]
}
> f(x,a,b,c*d)
[1] "a" "b" "c*d"...
2007 Dec 10
5
Neat conditional assignment
I would like to make a new vector with values taken from two existing
vectors conditional upon a third. At present I am doing this with a for loop
but wonder if there is not a neater way, given some of the very neat things
R can do.
a<-rep(c("A","B"),50)
b<-rep(1,100)
c<-rep(2,100)
a is thus "A" "B" "A" "B" "A" "B"...
b is thus 1 1 1 1 1 1 ...
c is thus 2 2 2 2 2 2 ...
I want d[i] to be...
2020 Nov 18
3
Best practice preparing for disk restoring system
...s are there then its trivial to restore data.
What I've done in the past is before the nightly backup write a small
file to the root of each filesystem giving disk geometries. You can
then use any recovery DVD to partition and reload the OS. If rear can
do this for me it would be __much__ neater!
On 18/11/2020 08:24, John Pierce wrote:
> I'm old school, but I always liked using dump/restore on unix file
> systems. e2dump or whatever for linux, zfs send/recieve for zfs, ufsdump
> on freebsd ufs, etc etc.
>
> then I just need to know what file systems they are, and wher...
2020 Apr 16
6
suggestion: "." in [lsv]apply()
...mmary(lm(mpg ~ wt,
d))$r.squared)
#??????? 4???????? 6???????? 8
#0.5086326 0.4645102 0.4229655
could be rewritten as
sapply(split(mtcars, mtcars$cyl), summary(lm(mpg ~ wt, .))$r.squared)
"Not a big saving in typing" you can say but multiplied by the number of
[lsv]apply usage and a neater look, I think, the idea merits to be
considered.
To illustrate a possible implementation, I propose a wrapper example for
sapply():
wsapply=function(l, fun, ...) {
??? s=substitute(fun)
??? if (is.name(s) || is.call(s) && s[[1]]==as.name("function")) {
??????? sapply(l, fun,...
2020 May 31
4
Simple backup of maildir folder
On 29 May 2020, at 23:49, Admin Beckspaced <admin at beckspaced.com> wrote:
> I also have maildir as mailbox format and use the following script to do daily backups
>
> https://github.com/tachtler/dovecot-backup
A couple of notes on this quite useful script:
My mktemp does not support -p (FreeBSD 12.1) is I had to change the script to:
DIR_TEMP=$($MKTEMP_COMMAND -d $TMP_FOLDER
2006 Feb 28
4
number_to_currency UK pounds
I work in the UK and therefore most of my currency figures will be in UK
pounds. I realise that to format a number to a currency format I can
use:
number_to_currency(amt, :unit => "?")
but it would be more convenient to set ? as the default currency symbol.
What is the best way to do that?
Should I edit line 39 of this file:
2016 Mar 20
2
ssh-copy-id no newline bug
...up causing a bug report as well
> ("ssh-copy-id introduces blank lines into good files").
How about something like:
if [ "$(sed -n '${s/.*//;p}' ~/.ssh/authorized_keys | wc -l)" = 0 ]; then
echo >> ~/.ssh/authorized_keys
fi
I feel like there must be a neater but still portable way to do this,
and the above would require some careful quoting to work in the context
of ssh-copy-id.
--
Colin Watson [cjwatson at debian.org]
2003 May 19
2
To update() or not to update()?
...ejec + diavol + score + smoking +
beta + surg.done + td2,
data = data.frame(foo))
I've done a system.time() on it and update() doesn't seem to be much (if
at all) faster. Is there an advantage of using update() then (other than
that the codes look neater)?
--
Cheers,
Kevin
------------------------------------------------------------------------------
/* Time is the greatest teacher, unfortunately it kills its students */
--
Ko-Kang Kevin Wang
Master of Science (MSc) Student
SLC Tutor and Lab Demonstrator
Department of Statistics
University of...
2006 May 03
2
Conditional statement style
...ad a play/search
around and it''s just bugging me now :0)
Say I have a conditional statement, testing a variable against a number
of values. The first way i did this is like so:
if myvar != "" and myvar != 0 and myvar != nil
# .. code
end
This seems a bit messy - is there neater way of doing this? I thought of:
if myvar != ("" || 0 || nil)
but ||, as i understand it, is a conditional assigner that causes the
current value the fall through to the preceeding value, if the
preceeding value is nil. I''m sure that sentence made sense in my head
before i...
2020 Apr 16
2
suggestion: "." in [lsv]apply()
...g ~ wt, d))$r.squared) # 4 6 8
>> #0.5086326 0.4645102 0.4229655 could be rewritten as
>> sapply(split(mtcars, mtcars$cyl), summary(lm(mpg ~ wt, .))$r.squared)
>> "Not a big saving in typing" you can say but multiplied by the number
>> of [lsv]apply usage and a neater look, I think, the idea merits to be
>> considered.
> It's not in any way "neater", not only is it less readable, it's just
> plain wrong. What if the expression returned a function?
do you mean like in
l=sapply(1:3, function(i) function(x) i+x)
l[[1]](3)
# 4
l[[2]]...
2004 May 10
2
Lists and outer() like functionality?
...:
mylist <- list(1:5,3:9,8:12)
A simple example of the kind of thing I want to do is to find the sum
of the shared numbers between each vector to give a result like:
result <- array(c(15,12,0,12,42,17,0,17,50), dim=c(3,3))
Two for() loops is the easiest way but I wondered if there was a
neater/faster solution.
mylist.len <- length(mylist)
ind <- 1:mylist.len
result <- array(NA, dim=c(mylist.len,mylist.len))
for(x in ind){
for(y in ind){
result[x,y] <- sum(mylist[[x]][test[[x]] %in% test[[y]]])
}
}
Many thanks,
David Orme
2008 Jul 17
5
.build method
I have gone to the api and have searched the internet and looked
through the books that I have, but I am having trouble finding an
explanation on what the .build method actually does and how it is
used.
I guess the best example is if I want to create a todo list
application where I can create a new todo list and add to do items all
at the same time.
I would post to the todolist controller to
2007 Jun 01
2
Getting names of objects passed with "..."
...usual 'deparse(substitute())' doesn't do it:
test.func2 <- function(...) {
nms <- deparse(substitute(...))
print(nms)
}
test.func2(first=x, second)
[1] "x"
I'm using "nms <- rownames(rbind(...))" as a workaround, which works, but
there must be a neater way!
rbind/cbind are .Internal, so I can't pinch code from there.
Thanks, Mike.
--
View this message in context: http://www.nabble.com/Getting-names-of-objects-passed-with-%22...%22-tf3850318.html#a10906614
Sent from the R help mailing list archive at Nabble.com.
2013 Dec 17
3
In-string variable/symbol substitution: What formats/syntax is out there?
...ve, noweb, knitr, brew, RSP, ...). It should also be *in-string*
substitution out of the box, so sub(), sprintf() and friends does not
count.
Thanks
Henrik
PS. The following is on the borderline because it does not do
automatic variable look up, but since others may bring it up and/or
know of a neater approach, I mention it too:
** copySubstitute() in the 'Biobase' package (with some efforts), e.g.
> bbsubst <- function(fmt, ...) {
args <- lapply(list(...), FUN=as.character)
in <- textConnection(fmt)
out <- textConnection("res", open="w")
on.ex...
2015 Jul 29
4
[PATCH v2] arm: change vendor ID for virtio-mmio
ACPI spec 5.0 allows the use of PCI vendor IDs.
Since we have one for virtio, it seems neater to use that
rather than LNRO. For the device ID, use 103F which is a legacy ID that
isn't used in virtio PCI spec - seems to make sense since virtio-mmio is
a legacy device but we don't know the correct device type.
Guests should probably match everything in the range 1000-103F
(just like...
2015 Jul 29
4
[PATCH v2] arm: change vendor ID for virtio-mmio
ACPI spec 5.0 allows the use of PCI vendor IDs.
Since we have one for virtio, it seems neater to use that
rather than LNRO. For the device ID, use 103F which is a legacy ID that
isn't used in virtio PCI spec - seems to make sense since virtio-mmio is
a legacy device but we don't know the correct device type.
Guests should probably match everything in the range 1000-103F
(just like...
2002 May 28
4
Indexing Elements of a Dataframe
...called "ro" and
"co") and using a matrix for the results, which I could index with those
counters (results[ro,co] <- x) and then converting that matrix into a
dataframe and changing the row and column names. That seems a little too
convoluted.
I tried to come up with a "neater" solution, trying to create a
dataframe that looks like the one above and then indexing the fields in
the dataframe by results$i[j] but I couldn't get it to work. Is there a
way of doing this or maybe a better solution?
Thanks in advance!
Wolfgang
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-...
2015 Apr 14
2
[PATCH] virtio_balloon: drop virtio_balloon_stat_modern
...g on BE architectures: tag should use
cpu_to_le16, not cpu_to_le32.
Acked-by: Cornelia Huck <cornelia.huck at de.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
Just reposting so it's easier to apply.
Feel free to squash into previous patch if you think it's
neater.
include/uapi/linux/virtio_balloon.h | 33 +++++++++++++++++++++++++--------
drivers/virtio/virtio_balloon.c | 19 ++++---------------
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h
index f81b220..9841...
2020 Apr 17
2
suggestion: "." in [lsv]apply()
...t;>>> 8 #0.5086326 0.4645102 0.4229655 could be rewritten as
>>>> sapply(split(mtcars, mtcars$cyl), summary(lm(mpg ~ wt,
>>>> .))$r.squared) "Not a big saving in typing" you can say but
>>>> multiplied by the number of [lsv]apply usage and a neater look, I
>>>> think, the idea merits to be considered.
>>> It's not in any way "neater", not only is it less readable, it's
>>> just plain wrong. What if the expression returned a function?
>> do you mean like in l=sapply(1:3, function(i) fun...
2015 Apr 14
2
[PATCH] virtio_balloon: drop virtio_balloon_stat_modern
...g on BE architectures: tag should use
cpu_to_le16, not cpu_to_le32.
Acked-by: Cornelia Huck <cornelia.huck at de.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
Just reposting so it's easier to apply.
Feel free to squash into previous patch if you think it's
neater.
include/uapi/linux/virtio_balloon.h | 33 +++++++++++++++++++++++++--------
drivers/virtio/virtio_balloon.c | 19 ++++---------------
2 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h
index f81b220..9841...