Displaying 20 results from an estimated 76 matches for "inx".
Did you mean:
int
2012 Apr 06
4
Order sapply
...630649 1216399235 231414 11 11
4 9 11-11 1216637080 1216631541 5539 11 11
4 10 11-11 1216646563 1216640763 5800 11 11
4 11 11-11 1216656338 1216651635 4703 11 11
"
df1 <-read.table(textConnection(text), header=TRUE)
inx <- df1$commutation > 1000
comm1000 <- cumsum(inx)
result <- split(df1[!inx, ], list(comm1000[!inx], df1$v_source[!inx],
df1$v_destine[!inx]))
result <- sapply(result, function(x) c(x$val_user[1], x$v_source[1],
x$v_destine[1], nrow(x), mean(x$comm)))
result <- na.exclude(t(result...
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 wrote:
> Hi,
>...
2018 May 19
5
Split a data.frame
Hi,
I am struggling to split a data.frame as will below scheme :
DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF
split_str = c('a', 'c')
Now, for each element in split_str, R should find which row of DF contains
that element, and return DF with all rows starting from next row of the
corresponding element and ending with the preceding value of the
2006 Feb 15
0
readline() for passwords?
...e and password.
## Assume it will always contain pairs:
## username \t password \n username \t password \n
## Match the username to 'user' and then pickup the password as the next
## item.
i.1 <- seq(1, length(input), by=2)
usr <- input[i.1]
psd <- input[i.1 + 1]
inx <- usr==user
if(dbg) cat("\tUser=", usr[inx], "\n")
if(sum(inx) < 1)
stop(paste("User, '", user, "', not present in file: ", path, sep=''))
if(sum(inx) > 1) stop("Unable to locate unique USER in input")
if(dbg) c...
2012 Mar 27
2
R extract parts
Good Afternoon,
I believe that my to the problem, the R has a more effective solution.
in place the use the loop
I have the following set of data, and needs to extract some sections.
user pos communications source v_destine
7 1 109 22 22
7 2 100 22 22
7 3 214 22 22
7 4 322 22 22
7 5 69920 22 161
7 6
2010 Jul 07
2
What does `_data` mean in transform()?
...nderstand what the usage of `_data` in transform.data.frame.
Could you please help me understand what `_data` means and min doesn't
work row by row?
> transform.data.frame
function (`_data`, ...)
{
e <- eval(substitute(list(...)), `_data`, parent.frame())
tags <- names(e)
inx <- match(tags, names(`_data`))
matched <- !is.na(inx)
if (any(matched)) {
`_data`[inx[matched]] <- e[matched]
`_data` <- data.frame(`_data`)
}
if (!all(matched))
do.call("data.frame", c(list(`_data`), e[!matched]))
else `_data`
}
<...
2023 Mar 02
1
transform.data.frame() ignores unnamed arguments when no named argument is provided
...make it work consistently, see below:
transform.data.frame <- function (`_data`, ...) {
e <- eval(substitute(list(...)), `_data`, parent.frame())
tags <- names(e)
## NEW LINE -----------------------------------------------
if (is.null(tags)) tags <- character(length(e))
inx <- match(tags, names(`_data`))
matched <- !is.na(inx)
if (any(matched)) {
`_data`[inx[matched]] <- e[matched]
`_data` <- data.frame(`_data`)
}
if (!all(matched))
do.call("data.frame", c(list(`_data`), e[!matched]))
else `_data`
}
transform(data...
2012 Jul 24
3
Collapsing a vector/data-frame based on the previous values
Hello
I have a data frame like this:
dput(states)
structure(list(Date = c("24/07/2012", "25/07/2012", "26/07/2012",
"27/07/2012", "28/07/2012", "24/07/2012", "25/07/2012", "26/07/2012",
"27/07/2012", "28/07/2012"), State = c(1L, 1L, 1L, 1L, 1L, -1L,
-1L, -1L, 1L, -1L)), .Names = c("Date",
2009 Dec 04
0
Renaming columns of a data.frame
...unlike 'rename', whose arguments have a reverse syntax
compared to 'transform').
Here is my attempt at a rename function similar to 'transform'.
Improvements are welcome.
ren <- function(`_data`, ...){
# Influenced by transform.data.frame
e <- unlist(list(...))
inx <- match(e, names(`_data`))
if(any(is.na(inx)))
stop("Couldn't find these columns in the data: ",
paste(as.vector(e)[is.na(inx)], collapse=" ") )
names(`_data`)[inx] <- names(e)
return(`_data`)
}
d0 <- data.frame(Year = c(2009, 2009, 2009),...
2012 Aug 01
1
Error message: $ operator is invalid for atomic vectors
...??? 22
NAHAS????????? 32
GEO??????????????? 42
", header=TRUE))
MinMaxArray? <- data.frame(MIN = 25,MAX=35)
myMatrix[myMatrix$Age<=MinMaxArray$MAX & myMatrix$Age>=MinMaxArray$MIN,]
#Error in myMatrix$Age : $ operator is invalid for atomic vectors
#Then, I tried Rui's code;
?inx <- MinMaxArray[[ "MIN" ]] <= myMatrix[, "Age"] & myMatrix[, "Age"]<= MinMaxArray[[ "MAX" ]]
?myMatrix[ inx , ]
???? Name Age
[1,]??? 1? 27
[2,]??? 3? 30
[3,]??? 4? 32
#Previously, this was also working fine.
Not sure what is happening.
A.K.
2012 Aug 21
2
Sequence detection longer than a certain value
Hello,
I have 2 variable: one is an "id" sequence from 1:1000 and the other is
variable with real values "VI" from -15.0 to 20.0 and I want to detect id
values that have indicator values less than a certain threshold, for
example (x=1) BUT that are in sequence equal or longer than 5.
For instance, in the following column I want to recognize the sequence from
"id" 4
2010 Aug 10
3
grep problem decimal points looping
Hi R Users,
I have been trying to work out how to rename column names using grep,
basically I have generated these column names using tapply:
[1] "NAME" "X1.1" "X2.1" "X3.1" "X4.1" "X5.1" "X6.1" "X7.1" "X8.1"
[10] "X1.2" "X2.2" "X3.2" "X4.2"
2012 Aug 10
2
Regular Expressions + Matrices
Hi all,
My code looks like the following:
inname = read.csv("ID_error_checker.csv", as.is=TRUE)
outname = read.csv("output.csv", as.is=TRUE)
#My algorithm is the following:
#for line in inname
#if first string up to whitespace in row in inname$name = first string up
to whitespace in row + 1 in inname$name
#AND ID in inname$ID for the top row NOT EQUAL ID in inname$ID for the
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 5/22/2018 11:48 AM, Ahmed Serag wrote:
> Dear R-experts,
>
>
> How can I remove a certain feature or observation by a part of its name. To be clear, I have a matrix wi...
2010 Mar 14
1
Segfault Problem c++ R interface (detailed)
...rnals.h>
#include <Rdefines.h>
using namespace Puppy;
//Declare Functions
extern "C" {
unsigned int evaluateSymbReg(std::vector<Tree>& ioPopulation,
Context& ioContext,
const std::vector<double>& inX,
const std::vector<double>& inF);
void RSymbReg(SEXP RPopSize, SEXP RNbrGen, SEXP RNbrPartTournament, SEXP
RMaxDepth,
SEXP RMinInitDepth, SEXP RMaxInitDepth, SEXP RInitGrowProba,
SEXP RCrossoverProba, SEXP RCrossDistribProba, SEXP RMutStd...
2018 May 22
4
remove rows of a matrix by part of its row name
Dear R-experts,
How can I remove a certain feature or observation by a part of its name. To be clear, I have a matrix with 766 observations as a rows. The row names are like this
70/556
71.1/280
72.1/556
72.1/343
73.1/390
73.1/556
Now I would like to remove all the rows that contain the text 73.1
Any ideas or suggestion please ?
Regards
**********************
Ahmed Serag
Analytical
2007 Jul 04
7
List delays
Is it just me? After the mail list server upgrade, the average delivery
time for messages to the users list is between 4 and 5 days. The Dev
list seems fine!
Doug
--
Ben Franklin quote:
"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."
2023 Mar 02
1
transform.data.frame() ignores unnamed arguments when no named argument is provided
...frame <- function (`_data`, ...) {
>
> e <- eval(substitute(list(...)), `_data`, parent.frame())
>
> tags <- names(e)
>
> ## NEW LINE -----------------------------------------------
>
> if (is.null(tags)) tags <- character(length(e))
>
> inx <- match(tags, names(`_data`))
>
> matched <- !is.na(inx)
>
> if (any(matched)) {
>
> `_data`[inx[matched]] <- e[matched]
>
> `_data` <- data.frame(`_data`)
>
> }
>
> if (!all(matched))
>
> do.call("data.fr...
2018 May 22
0
remove rows of a matrix by part of its row name
...bset 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 5/22/2018 11:48 AM, Ahmed Serag wrote:
>> Dear R-experts,
>>
>>
>> How can I remove a certain feature or...
2012 Apr 27
6
Returning the coef from two coordinates
Thank you to everyone in this forum that has been helping me with the basic R
skills while I learn to apply them.
I would like to take the coefficient of two coordinates. One of them comes
from two different columns in a table:
>A
x y
a 1 3
b 2 2
c 3 1
the other is set and for this question I'll just call it (1,1)
I've been trying to find a way to return the