2022 1:37 PM
> To: PIKAL Petr
> Cc: R-help Mailing List
> Subject: Re: [R] data frame returned from sapply but vector expected
>
> On Fri, 4 Nov 2022 15:30:27 +0300
> Ivan Krylov wrote:
>
> > sapply(mylist2, `[[`, 'b')
>
> Wait, that would simplify t
On Fri, 4 Nov 2022 15:30:27 +0300
Ivan Krylov wrote:
> sapply(mylist2, `[[`, 'b')
Wait, that would simplify the return value into a matrix when there are
no NULLs. But lapply(mylist2, `[[`, 'b') should work in both cases,
which in my opinion goes to show the dangers of using simplifying
function
On Fri, 4 Nov 2022 12:19:09 +
PIKAL Petr wrote:
> > str(sapply(mylist2, "[", "b"))
>
> List of 3
>
> $ : NULL
>
> $ :'data.frame': 5 obs. of 1 variable:
>
> ..$ b: num [1:5] 0.01733 0.46055 0.19421 0.11609 0.00789
>
> $ :'data.frame': 5 obs. of 1 variable:
>
> ..$ b:
Aaaah finally !!! Thanks a lot !!!
Arnaud
Le lun. 26 août 2019 18 h 28, Jim Lemon a écrit :
> Hi Arnaud,
> The reason I wrote the following function is that it always takes me
> half a dozen tries with "reshape" before I get the syntax right:
>
> amdf<-read.table(text="A 10
> B 5
> C
Hi Arnaud,
The reason I wrote the following function is that it always takes me
half a dozen tries with "reshape" before I get the syntax right:
amdf<-read.table(text="A 10
B 5
C 9
A 5
B 15
C 20")
library(prettyR)
stretch_df(amdf,"V1","V2")
V1 V2_1 V2_2
1 A 105
2 B5 15
3
Dear Arnaud,
I just played around with your data a bit and found this to be useful. But
kindly note that I am NO expert like the other people in the group. My answer
to you is purely for help purposes. My knowledge in R too is limited. I used
the reshape function and arrived at something. I am
Statements like c(rbind(x, xx+yy), max(t)) and rep(0,length(df$b[1])) don't
make any sense. You're example will be easier to understand if you show us the
nrow(df) ==3
case. Thanks
Grant Izmirlian, Ph.D.
Mathematical Statistician
izmir...@mail.nih.gov
Delivery Address:
9609 Medical Center Dr,
Thanks Bert this will do...
Andras
Sent from Yahoo Mail on Android
On Sun, Jan 6, 2019 at 1:09 PM, Bert Gunter wrote:
... and my reordering of column indices was unnecessary: merge(dat, d, all.y
= TRUE)will do.
Bert Gunter
"The trouble with having an open mind is that people keep comi
... and my reordering of column indices was unnecessary:
merge(dat, d, all.y = TRUE)
will do.
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 strip )
On Sun, Jan 6, 20
Like this (using base R only)?
dat<-data.frame(id=id,letter=letter,weight=weight) # using your data
ud <- unique(dat$id)
ul = unique(dat$letter)
d <- with(dat,
data.frame(
letter = rep(ul, e = length(ud)),
id = rep(ud, length(ul))
) )
merge(dat[,c(2,1,3)]
Hi!
Maybe this would do the trick:
--- snip ---
library(reshape2) # Use 'reshape2'
library(dplyr)# Use 'dplyr'
datatransfer<-data %>% mutate(letter2=letter) %>%
dcast(id+letter~letter2, value.var="weight")
--- snip ---
Or did I misunderstood something?
Best,
Kimmo
2019-01-06, 13:16
859932257 Remove
Good to go now, for the moment, big smile!
Thank you for your help Sir.
WHP
From: Bill Poling
Sent: Thursday, June 14, 2018 6:49 AM
To: 'Jim Lemon'
Cc: r-help (r-help@r-project.org)
Subject: RE: [R] Data frame with Factor column missing data change to NA
#Good
HX recommended savings
Claim paid without PHX recommended savings
MRC Amount
MRC Amount
Appreciate your help Sir.
WHP
From: Jim Lemon [mailto:drjimle...@gmail.com]
Sent: Wednesday, June 13, 2018 8:30 PM
To: Bill Poling
Cc: r-help (r-help@r-project.org)
Subject: Re: [R] Data frame with Fa
Hi Bill,
It may be that the NonAcceptanceOther, being a character value, has ""
(0 length string) rather than NA. You can convert that to NA like
this:
df2$NonAcceptanceOther[nchar(df2$NonAcceptanceOther) == 0]<-NA
Jim
On Thu, Jun 14, 2018 at 12:47 AM, Bill Poling wrote:
> Good morning.
>
> #I
thank you both... assumption is in fact that a and b are always the same
length... these work for me well...
much appreciate it...
Andras
On Sunday, August 6, 2017 12:14 PM, Ulrik Stervbo
wrote:
Hi Andreas,
assuming that the increment is always indicated by the same value (in your
exam
Hi Andreas,
assuming that the increment is always indicated by the same value (in your
example 0), this could work:
df$a <- cumsum(seq_along(df$b) %in% which(df$b == 0))
df
HTH,
Ulrik
On Sun, 6 Aug 2017 at 18:06 Bert Gunter wrote:
> Your specification is a bit unclear to me, so I'm not sure t
Your specification is a bit unclear to me, so I'm not sure the below
is really what you want. For example, your example seems to imply that
a and b must be of the same length, but I do not see that your
description requires this. So the following may not be what you want
exactly, but one way to do
You could use transform() instead of [[<- to add columns to your data.frame
so the new columns get transformed they way they do when given to the
data.frame function itself. E.g.,
> dd <- data.frame(X=1:5, Y=11:15)
> str(transform(dd, Z=matrix(X+Y,ncol=1,dimnames=list(NULL, "NewZ"
'data.frame
> On Apr 23, 2016, at 8:59 AM, thomas mann wrote:
>
> I am attempting to add a calculated column to a data frame. Basically,
> adding a column called "newcol2" which are the stock closing prices from 1
> day to the next.
>
> The one little hang up is the name of the column. There seems to be
Sorry, looked like there were a different number of rows in the results because
the rownames were different. I also see that the OP was interested in any
Groups, not just the two in the example, so your solution probably meets the
requirements better than mine
-
Hi Peter and Jeff!
Thanks very much for your code! Both worked perfectly in my data set!!
All best,
Raoni
2015-10-10 21:40 GMT-03:00 peter dalgaard :
>
>> On 11 Oct 2015, at 02:12 , Jeff Newmiller wrote:
>>
>> Sorry I missed the boat the first time, and while it looks like Peter is
>> getting
> On 11 Oct 2015, at 02:12 , Jeff Newmiller wrote:
>
> Sorry I missed the boat the first time, and while it looks like Peter is
> getting closer I suspect that is not quite there either due to the T2 being
> considered separate from T3 requirement.
Er, what do you mean by that?
As far as I
Sorry I missed the boat the first time, and while it looks like Peter is
getting closer I suspect that is not quite there either due to the T2
being considered separate from T3 requirement.
Here is another stab at it:
library(dplyr)
# first approach is broken apart to show the progression of t
These situations where the desired results depend on the order of observations
in a dataset do tend to get a little tricky (this is one kind of problem that
is easier to handle in a SAS DATA step with its sequential processing
paradigm). I think this will do it:
keep <- function(d)
with(d, {
Hello Jeff!
Thanks very much for your prompt reply, but this is not exactly what I
need. I need the first sequence of records. In example that I send, I
need the first seven lines of group "T2" in ID "1" (lines 3 to 9) and
others six lines of group "T3" in ID "1" (lines 10 to 15). I have to
discar
?aggregate
in base R. Make a short function that returns the first element of a vector and
give that to aggregate.
Or...
library(dplyr)
( test %>% group_by( ID, Group ) %>% summarise( Var=first( Var ) ) %>%
as.data.frame )
---
Here's one way in base R:
df <- data.frame(id=c("A","A","B","B"),
first=c("BX",NA,NA,"LF"),
second=c(NA,"TD","BZ",NA),
third=c(NA,NA,"RB","BT"),
fourth=c("LG","QR",NA,NA))
new_df <- data.frame(do.call(rbind, by(df, df$id, functi
Hi
Your question is without reproducible example and I find it a bit cryptic. You
do not uncover what is i. If it is a number I wonder why your atempts fail.
Find answer in line below.
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ragia
> Ibrahim
On 08/12/14 21:18, Ragia Ibrahim wrote:
Hi,
Kindly I had a data frame looks like this
x y
1 3
2 2
3 1
4 3
and I want to add column z that sum cumulativly like this
x y z
1 3 3
2 2 5
3 1 6
4 3 9
how to do this?
(1) Learn to use R. This is very basic; read some introductory
material. Start wi
my.data$z <- cumsum(my.data$y)
Yes, the function you need is even in your message subject.
> On Dec 8, 2014, at 12:18 AM, Ragia Ibrahim wrote:
>
> Hi,
> Kindly I had a data frame looks like this
> x y
> 1 3
> 2 2
> 3 1
> 4 3
> and I want to add column z that sum cumulativly like this
Hello,
If your dataset is named 'dat', try
dat$z <- cumsum(dat$y)
Hope this helps,
Rui Barradas
Em 08-12-2014 08:18, Ragia Ibrahim escreveu:
Hi,
Kindly I had a data frame looks like this
x y
1 3
2 2
3 1
4 3
and I want to add column z that sum cumulativly like this
x y z
1 3 3
2 2 5
3 1 6
4
Thanks Richard!
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-gu
Frank,
Dates are extremely difficult. I recommend you do not attempt to do
your own data computations with paste().
Use the lubridate package.
> install.packages(lubridate)
> library(lubridate)
Read the end section of
> vignette("lubridate")
>From that you will most likely be wanting one of thes
Hi
You shall consult
?aggregate
to get summaries for groups.
And you shall also consult R-intro manual to learn some basic facts about
objects structure and manipulation with them.
And finally you shal also have a look into Posting guide how to construct
questions
Regards
Petr
> -Origin
On Jun 27, 2014, at 5:53 AM, Robert Sherry wrote:
Suppose that a data frame has been created by the user. Perhaps it
has been
created using the library quantmod. Is there any command to find out
what
the members of the data frame is?
Most of the objects created by quantmod functions are n
I'm not sure what you mean by members.
Some options:
colnames(yourdf)
str(yourdf)
summary(yourdf)
You would probably benefit from reading the Intro to R that came with
your R installation.
Sarah
On Fri, Jun 27, 2014 at 8:53 AM, Robert Sherry wrote:
> Suppose that a data frame has been created
Hi,
May be this helps:
dat1 <- as.data.frame(matrix(1:(640*5), ncol=5,byrow=TRUE))
set.seed(41)
indx <-sample(nrow(dat1),nrow(dat1),replace=FALSE)
lst1 <- lapply(split(indx,as.numeric(gl(640,64,640))),function(x) dat1[x,])
A.K.
Dear all,
I have a data frame (d) composed of 640 observations fo
m all to a common type (often character), so it may give
you the wrong result in addition to being unnecessarily slow.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf
Of Duncan Murdoch
Sent: Sunda
On 2014-03-17 01:31, Jeff Newmiller wrote:
Did you really intend to make all of the x values the same?
Not at all; the code in the loop was in fact just nonsense. The point
was to illustrate the huge difference in execution time. And that the
relative difference seems to increase fast with th
On 2014-03-16 23:56, Duncan Murdoch wrote:
On 14-03-16 2:57 PM, Göran Broström wrote:
I have always known that "matrices are faster than data frames", for
instance this function:
dumkoll <- function(n = 1000, df = TRUE){
dfr <- data.frame(x = rnorm(n), y = rnorm(n))
if (df){
Did you really intend to make all of the x values the same? If so, try one line
instead of the for loop:
dfr$x[ 2:n ] <- dfr$x[ 1 ]
If that was merely an error in your example, then you could use a different
one-liner:
dfr$x[ 2:n ] <- dfr$x[ seq.int( n-1 ) ]
In either case, the speedup is con
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Duncan Murdoch
> Sent: Sunday, March 16, 2014 3:56 PM
> To: Göran Broström; r-help@r-project.org
> Subject: Re: [R] data frame v
On 14-03-16 2:57 PM, Göran Broström wrote:
I have always known that "matrices are faster than data frames", for
instance this function:
dumkoll <- function(n = 1000, df = TRUE){
dfr <- data.frame(x = rnorm(n), y = rnorm(n))
if (df){
for (i in 2:NROW(dfr)){
if
Hello,
This is to be expected. Matrices can hold only one type of data so the
problem is solved once and for all, data frames can have many types of
data so the code to handle them must determine which type to handle on
every access.
Hope this helps,
Rui Barradas
Em 16-03-2014 18:57, Göran
On 3/7/2014 7:41 PM, Keith S Weintraub wrote:
Folks,
I have a data frame as follows:
foo<-structure(list(name = c("A", "B", "C"), num = c(3L, 2L, 1L)), .Names =
c("name",
"num"), row.names = c(NA, -3L), class = "data.frame")
str(foo)
'data.frame': 3 obs. of 2 variables:
$ name: chr
Arun et al.
Thanks,
This is exactly what I need.
All the best,
KW
--
On Mar 7, 2014, at 10:59 PM, arun wrote:
> Try:
> oof1 <- list()
> oof1[foo$name] <- foo$num
> A.K.
>
>
>
>
> On Friday, March 7, 2014 10:43 PM, Keith S Weintraub wrote:
> Folks,
>
> I have a data frame as follows:
>
Try:
oof1 <- list()
oof1[foo$name] <- foo$num
A.K.
On Friday, March 7, 2014 10:43 PM, Keith S Weintraub wrote:
Folks,
I have a data frame as follows:
> foo<-structure(list(name = c("A", "B", "C"), num = c(3L, 2L, 1L)), .Names =
> c("name",
"num"), row.names = c(NA, -3L), class = "data.fra
> oof <- as.list(foo$num)
> names(oof) <- foo$name
> oof
On Fri, Mar 7, 2014 at 10:41 PM, Keith S Weintraub wrote:
> Folks,
>
> I have a data frame as follows:
>
>> foo<-structure(list(name = c("A", "B", "C"), num = c(3L, 2L, 1L)), .Names =
>> c("name",
> "num"), row.names = c(NA, -3L), class =
Depending what you really want to achieve, the following may be useful or
educational:
dat$ID2x <- with( dat, ave( rep( 1, nrow( dat ) ), ID, USE, FUN=cumsum ) )
dat$ID2y <- dat$ID2x
dat$ID2y[ dat$USE != "001" ] <- NA
On Thu, 20 Feb 2014, arun wrote:
Hi,
Try:
dat$ID2 <- with(dat,ave(seq_along
Hi,
Try:
dat$ID2 <- with(dat,ave(seq_along(USE),ID,FUN=function(x){x1 <- USE[x] =='001';
ifelse(!x1,'',cumsum(x1))}))
A.K.
On Thursday, February 20, 2014 3:31 PM, Pedro Mardones
wrote:
Dear R community;
I'm kind of stuck with the following situation and would appreciate any
hint. Let's assu
Hi Andras,
here is an other solution which also works if b contains missing values:
a <-seq(0,10,by=1)
b <-c(NA, 11:20)
f <-16
#
a[which.max(b[b If it's not homework, then I'm happy to provide more help:
>
>
> a <-seq(0,10,by=1)
> b <-c(10:20)
> d <-data.frame(a=a,b=b)
> f <-16
>
> subset(d, b <
If it's not homework, then I'm happy to provide more help:
a <-seq(0,10,by=1)
b <-c(10:20)
d <-data.frame(a=a,b=b)
f <-16
subset(d, b < f & b == max(b[b < f]))$a
# I'd turn it into a function
getVal <- function(d, f) {
subset(d, b < f & b == max(b[b < f]))$a
}
Sarah
On Mon, Dec 9, 2013
Thank you for providing a reproducible example. I tweaked it a little
bit to make it actually a data frame problem.
There are lots of ways to do this; here's one approach.
On second thought, this looks a lot like homework, so perhaps instead
I'll just suggest using subset() with more than one con
Hi Jonathan,If you look at the str()
str(res)
'data.frame': 2 obs. of 4 variables:
$ gene : chr "gene1" "gene2"
$ case_1:List of 2
..$ : chr "nsyn" "amp"
..$ : chr
$ case_2:List of 2
..$ : chr "del"
..$ : chr
$ case_3:List of 2
..$ : chr
..$ : chr "UTR"
In this case,
c
Hi Arun,
That seemed to do the trick - thanks!!
Jonathan
On Wed, Oct 23, 2013 at 11:12 PM, arun wrote:
> HI,
>
> Better would be:
> res1 <- dcast(df,gene~case,value.var="issue",paste,collapse=",",fill="0")
>
> str(res1)
> #'data.frame':2 obs. of 4 variables:
> # $ gene : chr "gene1"
HI,
Better would be:
res1 <- dcast(df,gene~case,value.var="issue",paste,collapse=",",fill="0")
str(res1)
#'data.frame': 2 obs. of 4 variables:
# $ gene : chr "gene1" "gene2"
# $ case_1: chr "nsyn,amp" "0"
# $ case_2: chr "del" "0"
# $ case_3: chr "0" "UTR"
write.table(res1,"test.txt",
Hi Arun,
Your suggestion using dcast is simple and worked splendidly!
Unfortunately, the resulting data frame does not play nicely with
write.table.
Any idea how to could print this out to a tab-delimited text file, perhaps
substituting zeros in for the empty cells?
See the error below:
> wri
HI,
You may try:
library(reshape2)
df <-
data.frame(case=c("case_1","case_1","case_2","case_3"),
gene=c("gene1","gene1","gene1","gene2"), issue=c("nsyn","amp","del","UTR"),
stringsAsFactors=FALSE)
res <- dcast(df,gene~case,value.var="issue",list)
res
# gene case_1 case_2 case_3
#1 gene1 ns
On Oct 23, 2013, at 5:24 PM, David Winsemius wrote:
>
> On Oct 23, 2013, at 4:36 PM, Jon BR wrote:
>
>> Hello,
>> I've been running several programs in the unix shell, and it's time to
>> combine results from several different pipelines. I've been writing shell
>> scripts with heavy use of a
On Oct 23, 2013, at 4:36 PM, Jon BR wrote:
> Hello,
>I've been running several programs in the unix shell, and it's time to
> combine results from several different pipelines. I've been writing shell
> scripts with heavy use of awk and grep to make big text files, but I'm
> thinking it would
Hi,
Try:
datNew <- read.table(text=as.character(mydata$NATIONALITY),sep="_")
mydata2 <- within(mydata,{NATIONALITY <- as.character(datNew[,1]);YEAR <-
datNew[,2]})
head(mydata2)
# PROVINCE AGE5 ZONA91OK NATIONALITY FREQUENCY YEAR
#1 1 10-14 101 SPAIN 600 1998
#
Hi,
Try:
datNew <- read.table(text=as.character(mydata$NATIONALITY),sep="_")
mydata2 <- within(mydata,{NATIONALITY <- as.character(datNew[,1]);YEAR <-
datNew[,2]})
head(mydata2)
# PROVINCE AGE5 ZONA91OK NATIONALITY FREQUENCY YEAR
#1 1 10-14 101 SPAIN 600 1998
#501
Thank you mate!
--
View this message in context:
http://r.789695.n4.nabble.com/Data-frame-to-Matrix-by-category-tp4669669p4669768.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/
Hello,
Maybe something like the following.
dat <- read.table(text = "
isin dt
1 FR0109970386 2010-01-12
2 FR0109970386 2011-01-12
3 FR0109970386 2012-01-12
4 FR0116114978 2010-01-12
5 FR0116114978 2011-01-12
6 FR0116114978 2012-01-12
", header = TRUE, stringsAsFactors = FALSE)
Hi,
ab<- cbind(a,b)
indx<-duplicated(names(ab))|duplicated(names(ab),fromLast=TRUE)
res1<-cbind(ab[!indx],v2=rowSums(ab[indx]))
res1[,order(as.numeric(gsub("[A-Za-z]","",names(res1,]
#v1 v2 v3
#1 3 4 5
#Another example:
a2<- data.frame(v1=c(3,6,7),v2=c(2,4,8))
b2<- data.frame(v2=c(2,6,7
Hi,
Not sure if this is what you wanted:
activity<-
data.frame(Name=paste0("activity",LETTERS[1:5]),stringsAsFactors=FALSE)
dates1<-
data.frame(dat=as.Date(c("2013-02-01","2013-02-04","2013-02-05"),format="%Y-%m-%d"))
merge(dates1,activity)
# dat Name
#1 2013-02-01 activityA
#2 2
That sounds like a job for merge().
If you provide an actual reproducible example using dput(), then you
will likely get some actual runnable code.
Sarah
On Mon, Apr 1, 2013 at 11:54 AM, ramoss wrote:
> Hello,
>
> I have 2 data frames: activity and dates. Activity contains a l variable
> list
Yes, it works.
Thank very much you Rui.
Franck Berthuit
France
De :Rui Barradas
A : franck.berth...@maif.fr,
Cc :r-help@r-project.org
Date : 25/02/2013 15:10
Objet : Re: [R] Data frame as table
Hello,
If your data.frame is named 'dat', the following might be wha
Hello,
If your data.frame is named 'dat', the following might be what you want.
as.table(data.matrix(dat))
Hope this helps,
Rui Barradas
Em 25-02-2013 11:35, franck.berth...@maif.fr escreveu:
Hello R user's,
I've read a txt file with the read.table syntax. This file is already in a
form of
Here is how to get the information from the file name that you want:
> # let's assume you have the filename
> fileName <- "G7_pig328_unit328_Site141_30MAR2012_RNo4_SitNo1.csv"
> # parse it for the group and bird names
> group <- sub("^G([0-9]+).*", "\\1", fileName)
> bird <- sub(".*pig([0-9]+).*",
Hi,
TRy this:
dat1 <- read.table(text="
Date_ Time_ Speed Course Type_ Distance
30/03/2012 11:15:05 108 121 -2 0
30/03/2012 11:15:06 0 79 0 0
30/03/2012 11:15:07 0 76 0 1
30/03/2012 11:15:08 0 86 0 2
30/03/2012 11:15:09 0 77 0 3
", header = TRUE, stringsAsFactors = FA
Hello,
First of all, the best way of posting data examples is ?dput. Anyway,
try the following.
dat <- read.table(text="
Date_ Time_ Speed Course Type_ Distance
30/03/2012 11:15:05 108 121 -2 0
30/03/2012 11:15:060 79 0 0
30/03/2012 11:15:070 76 0 1
30/03/2012 11:15
Hi,
May be this helps:
library(reshape)
dat1 # data that needs to be converted
res<-melt(dat1,id=c("Local","Mês","Dia","Colonia"))
names(res)[5:6]<-c("Hora","N")
res1<-res[order(res$Dia),]
row.names(res1)<-1:nrow(res1)
res1$Hora<-gsub("[X]","",res1$Hora)
head(res1)
# Local Mês Dia Colo
The 'reshape2' package is your friend:
> require(reshape2)
> x <- melt(wrong, id = c("Local", "Mês", "Dia", "Colonia"), variable.name =
> "Hora")
> # remove "X" from Hora
> x$Hora <- as.character(substring(x$Hora, 2))
> head(x) # not in the right order
Local Mês Dia Colonia Hora value
Hello,
Try the following.
rownames(df) <- seq_len(nrow(df))
Hope this helps,
Rui Barradas
Em 10-10-2012 08:41, CrimMagic escreveu:
Hi Everyone! :D
Just need a little help on data frames. I was wondering if anyone would know
a way to rename the row numbers on a data frame.
e.g.
head(df)
Thanks Arun and Rui for help. Will try with your suggestion and get back if
the problem persist.
On Sep 19, 2012 5:41 PM, "Rui Barradas" wrote:
> Hello,
>
> Your code is reproducible and completely explains the issue, thanks.
> First I had the impression of a well organized question.
> Then I've
Hi,
Try this:
a <- data.frame(table( cut( Sys.time() + seq(0,82800,3600), "60 mins")
b <- data.frame(a$Var1)
str(b)
#'data.frame': 24 obs. of 1 variable:
# $ a.Var1: Factor w/ 24 levels "2012-09-19 18:03:00",..: 1 2 3 4 5 6 7 8 9 1
b1<-within(b,{a.Var1<-as.POSIXct(a.Var1,format="%Y-%m-%d %H:%
Hello,
Your code is reproducible and completely explains the issue, thanks.
First I had the impression of a well organized question.
Then I've read point 4.
4. The sequence 1:1 starts and ends at 1. You don't need b[1:1, 1:1],
b[1, 1] will do.
Then you assign a different value to 'b'. This ti
Hello,
Try the following.
agg <- aggregate(buddleiat ~ samplet + datet, data = traffic, FUN = mean)
mrg <- merge(encounters, agg,
by.x = c("samplec", "datec"),
by.y = c("samplet", "datet"))
mrg$Div <- with(mrg, Bladen/buddleiat)
Hope this helps,
Rui Barradas
Em 18-09-2012 12:1
On Tue, Sep 18, 2012 at 12:17 PM, Marta Miguel wrote:
> Dear all,
>
>
> I have two different data frames, that have two common variables: date and
> sample. Here is a small extract of both of them
>
>> head(traffic)
> datetsessiont samplet buddleiat
> 1 07-08-20121 1
On May 30, 2012, at 4:51 PM, R. Michael Weylandt wrote:
I think you're looking for xtabs [see the examples; they're quite
good] but I can't be sure: your printed object can't really exist in R
so I'm not sure what you have currently.
Michael
On Wed, May 30, 2012 at 3:25 PM, cassiorx
wrote:
I think you're looking for xtabs [see the examples; they're quite
good] but I can't be sure: your printed object can't really exist in R
so I'm not sure what you have currently.
Michael
On Wed, May 30, 2012 at 3:25 PM, cassiorx wrote:
> I have a data frame that has columns Semester, Student ID (
On May 1, 2012, at 1:33 PM, Bert Gunter wrote:
AdvisoRs:
Is the following a bug, feature, hinky error message, or dumb Bert?
mtest <- matrix(1:12,nr=4)
dftest <- data.frame(mtest)
ix <- cbind(1:2,2:3)
mtest[ix] <- NA
mtest
[,1] [,2] [,3]
[1,]1 NA9
[2,]26 NA
[3,]3
Hello,
Bert Gunter wrote
>
> Duncan:
>
> Maybe there **is** a bug, then.
>
> > zmat <- matrix(1:12,nr=4)
>> zdf <- data.frame(zmat)
>> ix <- cbind(c(FALSE,TRUE),c(TRUE,TRUE))
>> zmat[ix]
> [1] 2 3 4 6 7 8 10 11 12
>> zdf[ix]
> [1] 2 3 4 6 7 8 10 11 12
>> zmat[ix] <- NA
>> zmat
>
P.S.
The way the logical matrix is constructed is NOT general purpose.
Quoting myself quoting Bert,
>
> Actually, it works, as long as the logical index matrix has the same
> dimensions as the data frame.
>
> zmat <- matrix(1:12,nr=4)
> zdf <- data.frame(zmat)
>
> # Numeric index matrix.
> ix <-
nd Data Analysis Division
Olympia, WA 98504-5204
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Bert Gunter
Sent: Tuesday, May 01, 2012 11:46 AM
To: Duncan Murdoch
Cc: r-help@r-project.org
Subject: Re: [R] Data frame vs matrix q
lympia, WA 98504-5204
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> project.org] On Behalf Of Bert Gunter
>> Sent: Tuesday, May 01, 2012 11:46 AM
>> To: Duncan Murdoch
>> Cc: r-help@r-project.org
&
Research and Data Analysis Division
Olympia, WA 98504-5204
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Bert Gunter
> Sent: Tuesday, May 01, 2012 11:46 AM
> To: Duncan Murdoch
> Cc: r-help@r-project.org
&g
On 01/05/2012 2:45 PM, Bert Gunter wrote:
Duncan:
Maybe there **is** a bug, then.
> zmat<- matrix(1:12,nr=4)
> zdf<- data.frame(zmat)
> ix<- cbind(c(FALSE,TRUE),c(TRUE,TRUE))
> zmat[ix]
[1] 2 3 4 6 7 8 10 11 12
> zdf[ix]
[1] 2 3 4 6 7 8 10 11 12
> zmat[ix]<- NA
> zmat
nal Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Bert Gunter
> Sent: Tuesday, May 01, 2012 1:46 PM
> To: Duncan Murdoch
> Cc: r-help@r-project.org
> Subject: Re: [R] Data frame vs matrix quirk: Hinky error message?
Duncan:
Maybe there **is** a bug, then.
> zmat <- matrix(1:12,nr=4)
> zdf <- data.frame(zmat)
> ix <- cbind(c(FALSE,TRUE),c(TRUE,TRUE))
> zmat[ix]
[1] 2 3 4 6 7 8 10 11 12
> zdf[ix]
[1] 2 3 4 6 7 8 10 11 12
> zmat[ix] <- NA
> zmat
[,1] [,2] [,3]
[1,]159
[2,] NA N
On 01/05/2012 2:12 PM, Bert Gunter wrote:
Many thanks, Ista:
I only looked in "].default" so the answer is: Alternative 4: dumb
Bert. Rap knuckles with ruler.
Actually, indexing by a logical matrix doesn't make much sense to me
in either case, as it does not have the effect of selecting indivi
Many thanks, Ista:
I only looked in "].default" so the answer is: Alternative 4: dumb
Bert. Rap knuckles with ruler.
Actually, indexing by a logical matrix doesn't make much sense to me
in either case, as it does not have the effect of selecting individual
elements, which is what numeric matrix
On 01-May-2012 17:33:23 Bert Gunter wrote:
> AdvisoRs:
>
> Is the following a bug, feature, hinky error message, or dumb Bert?
>
> mtest <- matrix(1:12,nr=4)
> dftest <- data.frame(mtest)
> ix <- cbind(1:2,2:3)
> mtest[ix] <- NA
> mtest
> [,1] [,2] [,3]
> [1,]1 NA9
> [2,]
Hi Bert,
The failure itself is the documented behavior: ?'[.data.frame' says
"Matrix indexing ('x[i]' with a logical or a 2-column integer
matrix 'i') using '[' is not recommended, and barely supported.
For extraction, 'x' is first coerced to a matrix. For
replacement, a logical m
Thanks a ton! That is great.
ben
On Thu, Mar 1, 2012 at 9:29 PM, Peter Langfelder wrote:
> On Thu, Mar 1, 2012 at 8:05 PM, Ben quant wrote:
> > Hello,
> >
> > I have another question
> >
> > I have a data frame that looks like this:
> > a b
> > 2007-03-31 "
On Thu, Mar 1, 2012 at 8:05 PM, Ben quant wrote:
> Hello,
>
> I have another question
>
> I have a data frame that looks like this:
> a b
> 2007-03-31 "20070514" "20070410"
> 2007-06-30 "20070814" "20070709"
> 2007-09-30 "20071115" "20071009"
> 2007-12-31 "2008
nlap.
>
> Arnaud Gaboury
>
> A2CT2 Ltd.
>
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of ilai
> Sent: vendredi 24 février 2012 20:14
> To: A2CT2 Trading
> Cc: r-help@r-project.org
> Subject:
To: A2CT2 Trading
Cc: r-help@r-project.org
Subject: Re: [R] data frame manipulation with conditions
On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading wrote:
> Dear list,
>
> n00b question, but still can't find any easy answer.
>
> Here is a df:
>
>> df<-data.frame(cbin
On Fri, Feb 24, 2012 at 8:11 AM, A2CT2 Trading wrote:
> Dear list,
>
> n00b question, but still can't find any easy answer.
>
> Here is a df:
>
>> df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4))
# No, your y is a factor
str(df)
'data.frame': 4 obs. of 2 variables:
$ x: Factor w/ 3 leve
1 - 100 of 307 matches
Mail list logo