Perfect, thank you!
On Fri, Oct 28, 2022 at 11:53 AM Rui Barradas wrote:
>
> Às 10:43 de 28/10/2022, Luigi Marongiu escreveu:
> > Hello,
> > I have a data frame with a string column. All data that are neither
> > "POS" nor "NEG" should've replaced by an NA. How can I implement that
> > (even with
Às 10:43 de 28/10/2022, Luigi Marongiu escreveu:
Hello,
I have a data frame with a string column. All data that are neither
"POS" nor "NEG" should've replaced by an NA. How can I implement that
(even with extra libraries)? My attempts actually wipe out POS and
NEG...
Thank you
```
df = data.fram
Hello,
I have a data frame with a string column. All data that are neither
"POS" nor "NEG" should've replaced by an NA. How can I implement that
(even with extra libraries)? My attempts actually wipe out POS and
NEG...
Thank you
```
df = data.frame(a = 1:5, b = c("", "31.35", "POS", "20.61"
Try this:
dat=structure(list(Color = c("5", "<4","5", "<5", "5"), Unit =
c("Hazen","Hazen","Hazen", "Hazen", "Hazen")), .Names = c("Color", "Unit"),
row.names =c("1:2","1:3", "1:4", "1:5","1:6"), class = "data.frame")
dat=as.data.frame(dat)dat$col2 <- rep(" ", nrow(dat))dat[dat$Color == "<4", ][
Is the following what you want:
(z is your data frame)
> change <-c("2","2.5")
> names(change) <- c("<4","<5")
(note: this can be automated using regular expressions and will work for
lots more values to change. Sarah's ifelse() solution is fine for the
example, but becomes too cumbersome (as sh
Hi Shane,
On Wed, Jun 17, 2015 at 1:31 PM, Shane Carey wrote:
> Hey all,
>
> I have a dataframe that consists of:
>
> structure(list(Color = c("5", "<4","5", "<5", "5"), Unit = c("Hazen",
> "Hazen",
> "Hazen", "Hazen", "Hazen")), .Names = c("Color", "Unit"), row.names =
> c("1:2",
> "1:3", "1:4",
Hey all,
I have a dataframe that consists of:
structure(list(Color = c("5", "<4","5", "<5", "5"), Unit = c("Hazen",
"Hazen",
"Hazen", "Hazen", "Hazen")), .Names = c("Color", "Unit"), row.names =
c("1:2",
"1:3", "1:4", "1:5","1:6"), class = "data.frame")
I need to find the <4 and have a new colum
This is the wrong part of my code.
>
>> idName=users[users$id %in% ext]
> idname
> 1: U03AEKWTL agreenmamba
> 2: U032FHV3S poisonivy
> 3: U03AEKYL4 vairis
>
Best is to use:
idNames <- users[pmatch(ext, users$id, duplicates.ok = T)]. This leave
me with an ordered and dupl
I have been searching for a while now, but can't put all pieces of the
puzzle together.
Goal : I want to replace all these kinds of patterns <@U032FHV3S> by
this <@agreenmamba>. In a more generic way, it is replacing 'id' by
user 'name'.
I have two df:
The first, 'history', is some message histor
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman wrote:
> try this:
>
>> (x <- rep(letters,2))
> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p"
> "q" "r" "s" "t" "u" "v" "w"
> [24] "x" "y" "z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m"
> "n" "o" "p" "q" "r" "s" "t"
> [47
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman wrote:
> try this:
>> indx <- match(x, repl.tab[, 1], nomatch = 0)
>> x[indx != 0] <- repl.tab[indx, 2]
>> x
> [1] "A" "B" "c" "D" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p"
> "q" "r" "s" "t" "u" "v" "w"
> [24] "x" "y" "z" "A" "B" "c" "D" "e" "f"
try this:
> (x <- rep(letters,2))
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p"
"q" "r" "s" "t" "u" "v" "w"
[24] "x" "y" "z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m"
"n" "o" "p" "q" "r" "s" "t"
[47] "u" "v" "w" "x" "y" "z"
> values <- c("aa", "a", "b", NA, "d", "z
Dear all
I've got stuck when trying to replace values in a vector by selecting
replacements from a replacement table. I'm trying to use only base
functions. Here's a dummy example:
> (x <- rep(letters,2))
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p"
"q" "r" "s" "t" "u" "v"
[
On Dec 3, 2011, at 8:41 AM, syrvn wrote:
Hello,
imagine the following data.frame:
ID name
1 *_A
2 *_A
3 *_B
4 *_B
* = can be any pattern
I want to replace every row which ends with _A by 1 and every row
which ends
by _B with a 0
You can use grep(patt, x, value=TRUE) to return vlaues t
Hello,
imagine the following data.frame:
ID name
1 *_A
2 *_A
3 *_B
4 *_B
* = can be any pattern
I want to replace every row which ends with _A by 1 and every row which ends
by _B with a 0
so that the data.frame looks like the following:
ID name
1 1
2 1
3 0
4 0
Which function do I use best
On Mon, Jan 10, 2011 at 03:21:18PM +0100, joke R wrote:
> Dear all,
>
> I have a problem with arrays.
> Simplified, I have two arrays:
>
> A =
> [,,1]
> 1 2 3
> 4 5 6
> 7 8 9
>
> [,,2]
> 10 11 12
> 13 14 15
> 16 17 18
>
> B=
> 1 1 2
> 1 1 2
> 3 3 2
>
> Basically,
Dear all,
I have a problem with arrays.
Simplified, I have two arrays:
A =
[,,1]
1 2 3
4 5 6
7 8 9
[,,2]
10 11 12
13 14 15
16 17 18
B=
1 1 2
1 1 2
3 3 2
Basically, B declares to which cluster the values of A belong to. Now I
want an array C where for each cluster
Dear all,
Dear all,
I am a relatively new user.
I have an ascii file with 550 rows and 400 columns. The file contain values
ranging from 1 to 2000 and some values with -.
I want to generate a new file where the - values are replaced with 0
values, the other values with the 1.0 value.
3, 2009 8:41 AM
> To: r-help@r-project.org
> Subject: [R] Replace values in a vector
>
> Hi all,
>
> I have a vector like this:
>
> x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)
>
> I would like to replace the zero values with the first
> previous non
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Farida Mostajabi
> Sent: Thursday, December 03, 2009 8:41 AM
> To: r-help@r-project.org
> Subject: [R] Replace values in a vector
>
> Hi all,
>
WOW! It worked. Thank you!
>>> Gabor Grothendieck 12/03/09 11:46 AM >>>
na.locf in the zoo package takes the last occurrence and carries it forward
into NAs so replace your zeros with NAs and then apply na.locf like this:
library(zoo)
na.locf(replace(x, x==0, NA))
On Thu, Dec 3, 2009 at
na.locf in the zoo package takes the last occurrence and carries it forward
into NAs so replace your zeros with NAs and then apply na.locf like this:
library(zoo)
na.locf(replace(x, x==0, NA))
On Thu, Dec 3, 2009 at 11:41 AM, Farida Mostajabi
wrote:
> Hi all,
>
> I have a vector like this
Hi all,
I have a vector like this:
x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)
I would like to replace the zero values with the first previous non zero value.
my returning vector should look like this:
y<-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)
How can I do
matritz[is.na(matritz)] <- 0
On Fri, Nov 27, 2009 at 04:15:45PM -0200, Romildo Martins wrote:
> Hello,
>
> how to replace the "NA" by number zero?
>
> > matrizt
> [,1] [,2] [,3][,4]
> [1,] 1.000NA NA NA
> [2,] 0
Hi,
Try this,
matrizt[is.na(matrizt)] <- 0
HTH,
baptiste
2009/11/27 Romildo Martins :
> Hello,
>
> how to replace the "NA" by number zero?
>
>> matrizt
> [,1] [,2] [,3] [,4]
> [1,] 1.000 NA NA NA
> [2,] 0.6717685 0
Hello,
how to replace the "NA" by number zero?
> matrizt
[,1] [,2] [,3][,4]
[1,] 1.000NA NA NA
[2,] 0.6717685 0.1453253 NA NA
[3,] 0.3971276 0.1493241 0.14532526 NA
[4,] 0.1493241 0.1453
Thanks for all the reply. I solved the task using apply(as suggested by
Hans).
The tips on S-Poetry and ?Logic are very handy as well.
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinf
ano
-Messaggio originale-
Da: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] conto di Suhaila Zainudin
Inviato: mercoledì 9 aprile 2008 9.32
A: r-help@r-project.org
Oggetto: [R] Replace values according to conditions
Greetings R-users,
I have the following data called mydata in a data.frame
Col1
On 9 Apr 2008, at 09:51, [EMAIL PROTECTED] wrote:
>> I have the following data called mydata in a data.frame
>>
>> Col1 Col2 Col3 Col4 Col5
>> 1 2 46 7
>> 8 8 73 5
>> 4 4 56 7
>>
>> I want to replace the data according to the following condit
> I have the following data called mydata in a data.frame
>
> Col1 Col2 Col3 Col4 Col5
> 1 2 46 7
> 8 8 73 5
> 4 4 56 7
>
> I want to replace the data according to the following conditions
>
> Condition 1 if data <= 3, replace with -1
>
Greetings R-users,
I have the following data called mydata in a data.frame
Col1 Col2 Col3 Col4 Col5
1 2 46 7
8 8 73 5
4 4 56 7
I want to replace the data according to the following conditions
Condition 1 if data <= 3, replace with -1
Co
Try
bb[is.na(aa)] <- NA
It may be simple but it is not necessarily obvious :)
--- Carson Farmer <[EMAIL PROTECTED]> wrote:
> Dear List,
>
> I am looking for an efficient method for replacing
> values in a
> data.frame conditional on the values of a separate
> data.frame. Here is
> my scenario:
Dear List,
I am looking for an efficient method for replacing values in a
data.frame conditional on the values of a separate data.frame. Here is
my scenario:
I have a data.frame (A) with say 1000 columns, and 365 rows. Each cell
in the data.frame has either valid value, or NA. I have an additional
> I will report results then,
OK, its better this way, but no so much.
Before: 99.79 (a) vs 0.21 (b)
Now: 99.77 (a) vs 0.23 (b)
But these results continue to be surprising for me.
Ok. Thanks you guys again, I will continue bothering you sometime.
Walter
___
> Does this help clarify the differences?
For sure! Thanks Jim. I will test with the solutions you gave me,
maybe the differences are not so big, I was just surprised about that.
I will report results then,
Thanks!
Walter
__
R-help@r-project.org mail
Well you do know that R is 'interpreted' and that C is 'compiled'. In
R you are calling functions to perform the operations. There is a
function for indexing ('['):
> get ("[")
.Primitive("[")
So your 'for' statement in R is interpreting the R code and calling
some functions to perform the oper
> code (C in this case). What exactly are you asking? You can alway
> 'time' (sys.time) a set of statements to see which is better (just
> make sure you execute them enough times to get reasonable readings --
> several seconds)
I was wondering where to seach for the code of these different optio
Guilty of what? What are you trying to compare? Now all the
approaches do get down to 'loops' being performed in the base level
code (C in this case). What exactly are you asking? You can alway
'time' (sys.time) a set of statements to see which is better (just
make sure you execute them enough
> Hope this is helpful,
Certainly! Thanks Dan and Jim!
Now, I wonder where I can dig in to realize why this is better. Is C
code for this function better than others? Is C guilty on this?
Maybe I am too newbie.
Thanks again, guys!
Walter
__
R-help@r
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Walter Alini
> Sent: Tuesday, October 23, 2007 1:18 PM
> To: r-help@r-project.org
> Subject: [R] Replace values on seq
>
> Hey guys, sorry for the inconvenience (this
Is this what you want to do?
> table <- seq(255, 0, by=-1)
> data <- c(1,8,34,100)
> data <- table[data + 1]
> data
[1] 254 247 221 155
On 10/23/07, Walter Alini <[EMAIL PROTECTED]> wrote:
> Hey guys, sorry for the inconvenience (this might be a hundred times
> answered question), but I have bee
Hey guys, sorry for the inconvenience (this might be a hundred times
answered question), but I have been searching a while and gave up
about the following:
I have the following, table and data:
table <- seq(255, 0, by=-1)
data <- c(1,8,...) <--- doesn't matter what's in here
Which would be th
42 matches
Mail list logo