Displaying 20 results from an estimated 20000 matches similar to: "Renaming columns of a data.frame"
2010 Jul 07
2
What does `_data` mean in transform()?
Hi All,
I meant to take the min row by row. But the result is apparently not
what I want. Changing min to pmin solve the problem.
> df=data.frame(X=1:10, Y=1:10)
> transform(df, Z=min(X,10-Y))
X Y Z
1 1 1 0
2 2 2 0
3 3 3 0
4 4 4 0
5 5 5 0
6 6 6 0
7 7 7 0
8 8 8 0
9 9 9 0
10 10 10 0
I try to look at the source code to understand what transform() does.
I know
2023 Mar 02
1
transform.data.frame() ignores unnamed arguments when no named argument is provided
Dear r-devel,
See below:
transform(data.frame(a = 1), 2, 3)
#> a
#> 1 1
transform(data.frame(a = 1), b=2, 3)
#> a b X3
#> 1 1 2 3
We need a small modification to make it work consistently, see below:
transform.data.frame <- function (`_data`, ...) {
e <- eval(substitute(list(...)), `_data`, parent.frame())
tags <- names(e)
## NEW LINE
2023 Mar 02
1
transform.data.frame() ignores unnamed arguments when no named argument is provided
Note that ?transform.data.frame says arguments need to be named, so you
are testing unspecified behaviour. I guess this falls in a similar
category as the note
If some of the values are not vectors of the appropriate length,
you deserve whatever you get!
Experiments for a related Problem Report
(<https://bugs.r-project.org/show_bug.cgi?id=17890>) showed that
packages
2006 Feb 15
0
readline() for passwords?
I don't like to have my password exposed by typing at all. I also don't like
to enter it each time that I wish to open a database (or when I run scripts
automatically across a Linux cluster). My solution has been to keep a file
in my HOME directory containing the username and password for the databases.
This file has read and write permission set so only I (and root) can read
it; this is
2012 Apr 06
4
Order sapply
Good Afternoon,
I have the following code, but it seems that something must be doing
wrong, because it is giving the results I want.
The idea is to create segments while the value of Commutation is less than
1000.
for example, from the small set of data below
text="
val_user pos v v_star v_end commutation v_source
v_destine
1 1 96-96 1173438391 1173438391 0
2018 May 19
0
Split a data.frame
Hello,
Maybe something like the following.
splitDF <- function(data, col, s){
n <- nrow(data)
inx <- which(data[[col]] %in% s)
lapply(seq_along(inx), function(i){
k <- if(inx[i] < n) (inx[i] + 1):(inx[i + 1])
data[k, ]
})
}
splitDF(DF, "name", split_str)
Hope this helps,
Rui Barradas
On 5/19/2018 12:07 PM, Christofer Bogaso
2011 Nov 25
1
Multiple selection, renaming and saving the results
Dear all,
I have a
big data frame:
str(data1)
'data.frame': 18272 obs. of 11 variables:
$ tag :
int 100001 100002 100003 100005 100007
100008 100009 100011 100012 100014 ...
$ sp :
Factor w/ 18 levels "acassp","acocar",..: 13 5 7 14 14 18 3
11 13 10 ...
$ gx :
num 20 10 35 68 88 63 123 115 137 136
...
$ gy :
num 30 25 24 1 10 40 45 25 23 45 ...
2010 Mar 14
1
Segfault Problem c++ R interface (detailed)
Hello R Community,
I've been working on a project that uses pre-made C++ libraries (using STL)
in R and build a package. However, I've been getting an unusual segfault
that I'm unable to trace its origin. After many attempts of debugging using
gdb, commenting out parts (or all of my code) and valgrind, I'm unable to
make heads or tails about what I'm doing wrong. In fact, when
2009 Jul 19
1
transform(_data,...) using strptime gives an error
I have timstamped data like this:
> sd[1:10,]
Tstamp Density Mesh50 Mesh70 Mesh100 Mesh150 Mesh200
2 2009/02/27 07:00 30.5 0.7 10.7 21.4 32.8 41.6
3 2009/02/27 08:00 32.2 1.6 12.4 23.3 34.5 43.0
4 2009/02/27 09:00 32.7 4.8 13.0 24.0 35.1 43.5
5 2009/02/27 10:00 26.7 0.3 6.5 17.6 28.1 36.9
6 2009/02/27 11:00
2012 Aug 01
1
Error message: $ operator is invalid for atomic vectors
HI,
The code was working perfectly fine yesterday and today, until half an hour ago.? Couldn't find any problems in the code. Still, I am getting error message.
myMatrix <- data.matrix(read.table(text="
Name??????????? Age
ANTONY??????? 27
IMRAN????????? 30
RAJ????????????????? 22
NAHAS????????? 32
GEO??????????????? 42
", header=TRUE))
MinMaxArray? <- data.frame(MIN =
2018 May 22
0
remove rows of a matrix by part of its row name
Hello,
Use grep to get the row indices and then subset with a *negative* index
to remove those rows.
rn <- scan(what = character(), text = "
70/556
71.1/280
72.1/556
72.1/343
73.1/390
73.1/556
")
mat <- matrix(rnorm(6*6), nrow = 6)
row.names(mat) <- rn
inx <- grep("73\\.", row.names(mat))
new_mat <- mat[-inx, ]
new_mat
Hope this helps,
Rui Barradas
On
2018 May 22
0
remove rows of a matrix by part of its row name
Hello,
Please always cc the list.
As for the question, yes, it does. If you want to remove just the ones
with exactly 73.1 use the pattern
grep("^73\\.1$", etc)
Explanation:
Beginning of string: ^
End of string: $
Escape special characters: \\ (needed because the period is a special
character.)
Hope this helps,
Rui Barradas
On 5/22/2018 12:50 PM, Ahmed Serag wrote:
> Thank
2023 Nov 28
1
computer algebra in R
Dear all,
I'm currently working on converting mathematica code
(https://github.com/ASDSE/thermosimfit/blob/master/Packages/thermoHD-Comp/thermoCacheHD-1Comp.m)
to R. The code is related to solve algebraic systems.
> eqthermo = {h0 == h + hd + hga, d0 == d + hd, ga0 == ga + hga, kga ==
> ???? hga / (h * ga), kd == hd / (h * d)};
>
> (* IDA HD*)
> sthdIDAcacheHD[fkd_, fkga_,
2003 Dec 05
1
Can anyone help me reproduce this SAS Mixed output??
I asked this before and I am going to try again in more applied terms. I
am trying to use R to extract variance components for a two-factor random
effects model with both factors crossed. It would also be nice to
generate some confidence intervals as well. For example, a data set
using SAS Proc Mixed is below followed by the four variance component
estimates and the respective confidence
2018 Feb 05
0
find unique and summerize
Thank you so much Rui!
On Sun, Feb 4, 2018 at 12:20 AM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
> Hello,
>
> Please always cc the list.
>
> As for the question, I believe the following does it.
>
> a <- strsplit(mydata$ID, "[[:alpha:]]+")
> b <- strsplit(mydata$ID, "[[:digit:]]+")
>
> a <- sapply(a, `[`, 1)
> c <-
2005 Aug 26
1
compare c-index of two logistic models using rcorrp.senc() of the Hmisc library
Dear R-help,
Would it be appropriate to do the following to
calculate a p-value for the difference between c-ind
of x1 and c-inx of x2 using the output from
rcorrp.senc()
> r<-rcorrp.senc(x1,x1,y)
> pValue<-1-pnorm((r[11]-r[12])/(r[2]/r[5])*1.96)
Osman O. Al-Radi, MD, MSc, FRCSC
Chief Resident, Cardiac Surgery
University of Toronto, Canada
2017 Dec 09
1
Remove
Hello,
Try the following.
keep <- list(A = c(15, 30), B = c(40, 50), C = c(60, 75))
sp <- split(DM$x, DM$GR)
inx <- unlist(lapply(seq_along(sp), function(i) keep[[i]][1] <= sp[[i]]
& sp[[i]] <= keep[[i]][2]))
DM[inx, ]
# GR x y
#1 A 25 125
#2 A 23 135
#5 B 45 321
#6 B 47 512
#9 C 61 521
#10 C 68 235
Hope this helps,
Rui Barradas
On 12/9/2017 12:48 AM, Ashta
2005 May 18
1
Audio flutter on OH323 output?
Hi, I'm using OH323, mostly with success, to interface Asterisk to
a provider's switch (World Telecom INX). I have noticed a particular
effect, and I wonder whether anyone else has seen the same?
The effect is audio flutter (almost like the flutter one gets on
MF or HF radio sometimes) which only happens intermittently.
Audio coming into Asterisk is unaffected, as proved by using the
2020 Jun 21
8
Inclusive language in LLVM: can we rename `job` in source code?
<div> </div><div>Yes, broad. But what guys say: "You LLVM developers are all racists, because you use 'master' word"</div><div>Or broader: "You all developers are all racists, because you use 'master' word". We are not racists, but other guys think so.</div><div>So let's begin consistent and take into account all
2015 Sep 03
0
sieve filtering utf 8 strings
Op 9/2/2015 om 5:03 PM schreef Sergey Schwartz:
> Guys,
>
> I'm completely stuck, so asking for advice.
> My user has a sieve script which checks message header if it contains
> words in russian like '???? ???????????? ?????????'.
>
> Pritty simple script
>
> # rule:[??????????]
> if allof (header :contains "subject" "LDS (robot): ????