search for: dat1

Displaying 20 results from an estimated 511 matches for "dat1".

Did you mean: dat
2012 Aug 07
0
predicting test dataset response from training dataset with randomForest
.... I ran the following: > library(randomForest) > > path <- "C:\\..." > path2 <- "..." > name <- "..." > > actualFileName <- paste(path, path2, name, ".txt", sep="") > > # reading in the training dataset > dat1 <- read.table(actualFileName, header=TRUE, sep="\t", > colClasses="character") > > head(dat1) X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 ... SR 1 M K V K L L V L L C T F T A T Y A ... suscep 2 M K V K L L V L L...
2018 May 11
0
add one variable to a data frame
Sarah's solutions are good, and here's another, even more basic: tmp1 <- unique(dat1$B) tmp2 <- seq_along(tmp1) dat1$C <- tmp2[ match( dat1$B, tmp1) ] > dat1 N B C 1 1 29_log 1 2 2 29_log 1 3 3 29_log 1 4 4 27_cat 2 5 5 27_cat 2 6 6 1_log 3 7 7 1_log 3 8 8 1_log 3 9 9 1_log 3 10 10 1_log 3 11 11 3_cat 4 12 12 3_cat 4 As a single line com...
2018 May 11
3
add one variable to a data frame
...not open attachments or click on links from unknown senders or unexpected emails.] Hi, Here's one way to approach it, using the coercion of factor to numeric. Note that I changed your data.frame() statement to avoid coercing strings to factors, just to make it simpler to set the levels. dat1 <-data.frame(N=seq(1, 12,1), B=c("29_log","29_log", "29_log", "27_cat", "27_cat", "1_log", "1_log", "1_log", "1_log", "1_log", "3_cat", "3_cat"), stringsAsFactors=FALSE) dat1...
2010 Mar 30
2
Need help to split a given matrix is a "sequential" way
...100 180 80 [3,] 200 150 180 [4,] 200 50 140 [5,] 100 150 60 [6,] 100 50 60 [7,] 100 100 100 [8,] 200 150 100 [9,] 100 50 120 [10,] 200 50 180 Now I need to split above matrix according to unique numbers in the 2nd column. Therefore I have following : > dat1 <- dat[which(dat[,1] == unique(dat[,1])[1]),] > dat2 <- dat[-which(dat[,1] == unique(dat[,1])[1]),]; dat1; dat2 [,1] [,2] [,3] [1,] 200 100 80 [2,] 200 150 180 [3,] 200 50 140 [4,] 200 150 100 [5,] 200 50 180 [,1] [,2] [,3] [1,] 100 180 80 [2,] 100 150 6...
2018 May 11
3
add one variable to a data frame
Hi All, I have a data frame dat1: dat1 <-data.frame(N=seq(1, 12,1), B=c("29_log","29_log", "29_log", "27_cat", "27_cat", "1_log", "1_log", "1_log", "1_log", "1_log...
2004 Nov 24
1
what does order() stand for in an lme formula?
...rep data y1 <- c(rnorm(25, 35, sd=5), rnorm(17, 55, sd=4)) # this is a line paralle to x-axis (slope=0) with noise x1 <- c(sample(1:25, 25, replace=F), sample(1:17, 17, replace=F)) # scramble the x, so that they do not appear in-oorder f1 <- c(rep("A",25), rep("B", 17)) dat1 <- data.frame(y1, x1, f1) x1 <- NULL y1 <- NULL f1 <- NULL # load libraries require(nlme) require(gmodels) # for the ci() # fit model with and w/o order() dat1.lm.1 <- lm(y1 ~ x1 + f1 -1, data=dat1) dat1.lm.2 <- lm(y1 ~ order(x1) + f1 -1, data=dat1) # # using lme, and ass...
2018 May 11
0
add one variable to a data frame
Hi, Here's one way to approach it, using the coercion of factor to numeric. Note that I changed your data.frame() statement to avoid coercing strings to factors, just to make it simpler to set the levels. dat1 <-data.frame(N=seq(1, 12,1), B=c("29_log","29_log", "29_log", "27_cat", "27_cat", "1_log", "1_log", "1_log", "1_log", "1_log", "3_cat", "3_cat"), stringsAsFactors=FALSE) dat1...
2009 Oct 10
1
Resultados distintos
...Totdat)=>5483 rows; 20 variables ### QUITO LAS FILAS DUPLICADAS ### Totdat<-Totdat[!duplicated(Totdat),] dim(Totdat)#4982 rows; 20 variables #CREO UNA VARIABLE IDENTIFICADORA Totdat$MI_id<-paste(1:dim(Totdat)[1],"mi_id",sep="_") ### ACTUALIZO Totdat CON NUEVOS DATOS: dat1<-read.xls("C:\\Documents and Settings\\Obtenido del script\\dat1.xls",sheet=1) dat1<-dat1[(!is.na(dat1$ti) & !is.na(dat1$fi) & !is.na(dat1$x) & !is.na(dat1$y)),] dim(dat1)#401rows - 33cols dat1<-dat1[,-c(16:33)]#ELIMINO LAS COLUMNAS QUE NO ME INTERESAN dim(dat1)#401r...
2013 May 07
4
create unique ID for each group
Hey All, I have a dataset(dat1) like this: ObsNumber ID Weight 1 0001 12 2 0001 13 3 0001 14 4 0002 16 5 0002 17 And another dataset(dat2) like this: ID...
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and "a3" from dat 1 so both dat1 and dat2 are the same. My R abilities ar...
2013 Sep 21
1
Translating recoding syntax from SPSS to R
Colleagues, I am in the process of learning R. I've been able to import my dataset (from Stata) and do some simple coding. I have now come to coding situation that requires some assistance. This is some code in SPSS that I would like to be able to execute in R: if (race eq 1 and usborn=0) confused=1 . if (race eq 2 and usborn=0) confused=1 . if (race eq 1 and usborn=1) confused=0 . if (race
2012 Jul 01
2
list to dataframe conversion-testing for identical
HI R help, I was trying to get identical data frame from a list using two methods. #Suppose my list is: listdat1<-list(rnorm(10,20),rep(LETTERS[1:2],5),rep(1:5,2)) #Creating dataframe using cbind dat1<-data.frame(do.call("cbind",listdat1)) colnames(dat1)<-c("Var1","Var2","Var3") #Second dataframe conversion dat2<-data.frame(Var1=listdat1[[1]],Var2=listdat1...
2013 Jan 08
2
plot residuals per factor
Dear R-users, I want to plot residuals vs fitted for multiple groups with ggplot2. I try this code, but unsuccessful. library("plyr") models<-dlply(dat1,"d",function(df) mod<-lm(y~x,data=df) ggplot(models,aes(.fitted,.resid), color=factor(d))+ geom_hline(yintercept=0,col="white",size=2)+ geom_point()+ geom_smooth(se=F) -- --- Catalin-Constantin ROIBU Forestry engineer, PhD Forestry Faculty of Suceava Str. Universit...
2010 Aug 20
2
Determining the length of unique items in a vector
Dear all, let suppose I have following vector:   > dat1 <- c(rep("asd", 5), rep("xyz", 12), rep("erd", 17)) > dat1 <- dat1[sample(1:length(dat1), length(dat1), replace=F)] > dat1  [1] "erd" "xyz" "erd" "asd" "asd" "erd" "xyz" "asd" &...
2013 Apr 29
4
expanding a presence only dataset into presence/absence
Hello, I'm working with a very large dataset (250,000+ lines in its' current form) that includes presence only data on various species (which is nested within different sites and sampling dates). I need to convert this into a dataset with presence/absence for each species. For example, I would like to expand "My current data" to "Desired data": My current data
2013 Jan 09
4
select partial name and full name columns
Hi, I have the following function: getDataFromDVFileCustom <- function (file, hasHeader = TRUE, separator = "\t") { DVdatatmp <- as.matrix(read.table(file, sep = "\t", fill = TRUE, comment.char = "#", as.is = TRUE, stringsAsFactors = FALSE, na.strings = "NA")) DVdatatmper <- as.matrix(DVdatatmp[ , c("datetime",
2013 Jan 04
2
Can you help me please
HI Fares, You could try this: dat1<- read.table(text=" date????? donation 3jan2003?? 20235 4jan2003?? 25655 5jan2003?? 225860 6jan2003?? 289658 7jan2003?? 243889 8jan2003?? 244338 9jan2003?? 243889 ",sep="",header=TRUE,stringsAsFactors=FALSE) The post is not very specific as to what you need.? I hope this w...
2010 Jul 13
3
Need help on index for time series object
Dear all, Please forgive me if there is a duplicate post; my previous mail perhaps didnt reach the list....... Let say I have following time series library(zoo) > dat1 <- zooreg(rnorm(10), start=as.Date("2010-01-01"), frequency=1) > dat1[c(3, 7,8)] = NA > dat1 2010-01-01 2010-01-02 2010-01-03 2010-01-04 2010-01-05 2010-01-06 2010-01-07 2010-01-08 2010-01-09 2010-01-10 0.31244288 -2.49383257 NA 0.38975582 -1.23040380 -0.096979...
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping. #some data L3 <- LETTERS[1:3] dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE))) #When x==1 and y==1 I want to replace the 1 values with NA #I can select the rows I want: dat2<-subset(dat1,x==1 & y==1) #replace the 1 with NA dat2$x<-rep(NA,nrow(dat2) dat2$y<-rep(NA,nrow(dat2) #select th...
2010 Mar 22
1
Replacing elements of list
Dear all, I have following two list object, both are basically collection of matrices : dat1 <- matrix(rnorm(25*6), ncol=6) dat1 <- split(dat1, seq(5,25,by=5)) dat1 <- lapply(dat1, matrix, ncol=6) dat2 <- matrix(rnorm(25*4), ncol=4) dat2 <- split(dat2, seq(5,25,by=5)) dat2 <- lapply(dat2, matrix, ncol=4) Now I want to replace last 4 columns of each matrix at "dat1...