Displaying 20 results from an estimated 191 matches for "mydat".
Did you mean:
mydata
2013 Feb 25
1
creating variable that codes for the match/mismatch between two other variables
Dear all,
I have got two vectors coding for a stimulus presented in the current trial (mydat$Stimulus) and a prediction in the same trial (mydat$Prediciton), respectively.
By applying an if-conditional I want to create a new vector that indicates if there is a match between both vectors in the same trial. That is, if the prediction equals the stimulus.
When I pick out some trials randomly...
2013 Dec 08
2
How to evaluate sequence of strings like this
Hello Dear R community,
This is my problem. I have a data set (dataframe) called "mydat". It consist of 3 numerical variable. They are Centrecode, FSUSN and Round. I want to create unique ID by combining these 3 variables.
Follwing commands gives me what I need.
mydat1 <- paste(mydat$Centrecode, mydat$FSUSN,mydat$Round,sep="")
newds <- data.frame(mydat1)
For...
2018 Feb 25
3
include
Thank you Jim,
I read the data as you suggested but I could not find K1 in col1.
rbind(preval,mydat) Col1 Col2 col3
1 <NA> <NA> <NA>
2 X1 <NA> <NA>
3 Y1 <NA> <NA>
4 K2 <NA> <NA>
5 W1 <NA> <NA>
6 Z1 K1 K2
7 Z2 <NA> <NA>
8 Z3 X1 <NA>
9 Z4 Y1 W1
On Sat, Feb 24, 2018 at 6:18 PM, Jim Lemon...
2018 Feb 25
0
include
Hi Val,
My fault - I assumed that the NA would be first in the result produced
by "unique":
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
val23<-unique(unlist(mydat[,c("Col2","col3")]))
napos<-which(is.na(val23))
preval<-data.frame(Col1=val23[-napos],
Col2=NA,col3=NA)
myda...
2010 Oct 11
2
(no subject)
...#39;t work in plot(), so I am trying to get it to work in par().?
However, now I get the ticks where I want them but the time is output as a very
big number (serial time?).? I have also tried axis() using at= and also get
seriel time numbers.? Any suggestions on how to format time on an axis?
? mydat$Date<-as.POSIXct(as.character(mydat$Date), format=c("%m/%d/%Y"))
? mydat$Time<-as.POSIXct(as.character(mydat$Time), format=c("%H:%M:%S"))
? plot(mydat$DateTime,mydat$Time, xlab=c("Date"), ylab=c("Time"),
? xlim=c(min(mydat$DateTime),max(mydat$DateTime)...
2018 Feb 25
2
include
HI Jim and all,
I want to put one more condition. Include col2 and col3 if they are not
in col1.
Here is the data
mydat <- read.table(textConnection("Col1 Col2 col3
K2 X1 NA
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
The desired out put would be
Col1 Col2 col3
1 X1 0 0
2 K1 0 0
3 Y1 0 0
4 W1 0 0
6 K2 X1 0
7 Z1 K1 K2...
2010 Dec 30
1
Sorting data.frame datewise in a descending order
Dear 'HTH' R friends
I have a small dataframe as given below. I need to sort this database based on date in a decending order. I am not sure whether I have defined the date column in a proper format.
mydat<-data.frame(date = (c("1/31/2010", "2/28/2010", "3/31/2010", "4/30/2010", "5/31/2010", "6/30/2010", "7/31/2010", "8/31/2010", "9/30/2010", "10/31/2010", "11/30/2010", "12/28/2010&qu...
2018 Feb 25
0
include
...ome self-sufficient?
--
Sent from my phone. Please excuse my brevity.
On February 25, 2018 7:55:55 AM PST, Val <valkremk at gmail.com> wrote:
>HI Jim and all,
>
>I want to put one more condition. Include col2 and col3 if they are
>not
>in col1.
>
>Here is the data
>mydat <- read.table(textConnection("Col1 Col2 col3
>K2 X1 NA
>Z1 K1 K2
>Z2 NA NA
>Z3 X1 NA
>Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
>
>The desired out put would be
>
> Col1 Col2 col3
>1 X1 0 0
>2 K1 0 0
>3 Y1 0 0
>4...
2018 Feb 25
2
include
Sorry , I hit the send key accidentally here is my complete message.
Thank you Jim and all, I got it.
I have one more question on the original question
What does this "[-1] " do?
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE)
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],...
2013 Oct 16
1
How to write an error to output
Dear R forum,
The example below is just an indicative one and I have constructed it. My real life data and conditions are different.
I have a data.frame as given below
mydat = data.frame(A = c(19, 20, 19, 19, 19, 18, 16, 18, 19, 20), B = c(19, 20, 20, 19, 20, 18, 19, 18, 17, 16))
if (length(mydat$A) > 10)
{
stop("A has length more than 10")
}else
if (max(mydat$B) > 18)
{
stop("max B exceeds limit")
}else
{result = mydat$A + mydat$B
if...
2009 Aug 26
6
Managing output
Hi,
Is there a way to build up a vector, item by item. In perl, we can
"push" an item onto an array. How can we can do this in R?
I have a loop that generates values as it goes. I want to end up with a
vector of all the loop results.
In perl it woud be:
for(item in list){
result <- 2*item^2 (Or whatever formula, this is just a pseudo example)
Push(@result_list,
2018 Feb 25
0
include
hi Val,
Your problem seems to be that the data are read in as a factor. The
simplest way I can think of to get around this is:
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
rbind(preval,mydat)
mydat[is.na(mydat)]<-"0&qu...
2011 Jul 23
2
sum part of a vector
Dear colleagues, I have a data set that looks roughly like this;
mydat<-data.frame(state=c(rep("Alabama", 5), rep("Delaware", 5), rep("California", 5)), news=runif(15, min=0, max=8), cum.news=rep(0, 15))
For each state, I'd like to cumulatively sum the value of "news" and make that put that value in cum.news.
I'm tr...
2011 Jul 14
2
cbind in aggregate formula - based on an existing object (vector)
Hello!
I am aggregating using a formula in aggregate - of the type:
aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata)
However, I actually have an object (vector of my variables to be aggregated):
myvars<-c("var1","var2","var3")
I'd like my aggregate formula (its "cbind" part) to be able to use my
"myvars" object. Is it possible?
Thanks for your help!
Di...
2006 Jun 20
2
expanded dataset and random number
Dear all R-users,
(My apologies if this subject is wrong)
I have dataset:
mydat <- as.data.frame(
matrix(c(14,0,1,0,1,1,
25,1,1,0,1,1,
5,0,0,1,1,0,
31,1,1,1,1,1,
10,0,0,0,0,1),
nrow=5,ncol=6,byrow=TRUE))
dimnames(mydat)[[2]] <-c("size","A","B","C&q...
2011 Jun 28
1
lattice multiple y-scale possible?
...e quite different ranges of values, so it would be best to
have a separate y-axis range for each panel. Below is a basic example of
what I am trying to do. As is seen, the y-axes need to be scaled
individually to make this useful. Any information on how to do this
would be much appreciated:
rm(mydat)
rm(tempdf)
for (i in 1:5){
for (ii in 1:5){
dat <- sample(1:20)*10^ii
tempdf <- data.frame(dat)
tempdf$parameter <- paste("parameter ",ii,sep="")
tempdf$site <- paste("site",i,sep="")
if(!exists("mydat")) {mydat <- tempdf
}else {...
2011 Mar 12
2
Identifying unique pairs
Dear R helpers
Suppose I have a data frame as given below
mydat = data.frame(x = c(1,1,1, 2, 2, 2, 2, 2, 5, 5, 6), y = c(10, 10, 10, 8, 8, 8, 7, 7, 2, 2, 4))
mydat
x y
1 1 10
2 1 10
3 1 10
4 2 8
5 2 8
6 2 8
7 2 7
8 2 7
9 5 2
10 5 2
11 6 4...
2009 Oct 06
2
Extracting year from a date object
...left me a bit puzzled, as I don't seem to find a function to
perform this easily. I must have overlooked the obvious, so sorry in
advance.
I have a list of dates in numerical format (i.e. 34576), defined as
the number of days that passed since january 1st 1900. So I apply the
function :
> MyDate <-as.Date(34576,origin="1900-01-01")
> MyDate
[1] "1994-09-01"
But then I want to do something like :
MyYear <- a.year.function(MyDate)
MyYear should have the numerical value 1994. Alas, I don't find any
function like that. I know I can take a substring of MyDate...
2007 Nov 12
4
time plotting problem
...zoo might do it but
I seem to be missing something there too.
Any suggestions gratefully recieved.
Example 1 consecutive dates same year.
=================================================
x <- "days
9/26/09
9/27/06
9/28/06
9/29/06
9/29/06
9/29/06
10/1/06
10/1/06
10/2/06
10/3/06"
mydata <- read.table(textConnection(x), header=TRUE,
as.is=TRUE); mydata
mydates <- as.Date(mydata[,1], "%m/%d/%y"); mydates
mynums <- rnorm(10)
plot(mydates, mynums)
================================================
Example 2 (things go blooy!)
non-consecutive dates different years....
2006 Aug 06
1
Take random sample from class variable
Dear all,
Suppose I have a dataset like below, then I take for example, 100
random sample "class" variable where contains "yes" and "no"
respectively, 70% and 30%.
I need a new 100 random sample from mydat dataset, but I can't get the result.
Thanks you very much for any helps.
Best, Muhammad Subianto
mydat <- data.frame(size=c(30,12,15,10,12,12,25,30,20,14),
A=c(0,1,0,1,0,1,1,1,0,0),
B=c(1,1,0,1,0,1,1,0,0,1),
C=c(0,0,1,1,0,...