search for: finaldata

Displaying 13 results from an estimated 13 matches for "finaldata".

2008 May 14
4
Accessing items in a list of lists
...for the lowest level list are common. How can I most efficiently access all of the sublist items "a" indexed by the outer list names? For example, I can loop through comb[[i]], unlisting as I go, and then look up the field "a", as below, but there has got to be a cleaner way. finaldata <- double(0) for(i in 1:length(names(comb))) { test <- unlist(comb[[i]]) finaldata <- c(finaldata, test[which(names(test) == "a")]) } data.frame(names(comb), finaldata) Gives what I want: names.comb. finaldata 1 data1 1 2 data2 4 3 data3...
2008 Aug 21
1
problem merging two data sets ( one with a header and one without)
...nd Data2 does not. I would like to merge the two data sets after removing some columns from data2 . I am having a problem merging so I had to write and read final data and specify the ?header=F? so the merge can be done by?V1?. Is there a way to avoid this step. The problem is when I do cbind the FinalData has different column names Data1<-read.table("data1.txt", sep='\t', header=F, stringsAsFactors=F) Data2<-read.table("data2.txt", sep='\t', header=T, stringsAsFactors=F) P1<-cbind(Data2[,2]) P2<-cbind(Data2[,5:30]) FinalData<-cbind(P1,P2) writ...
2011 Sep 03
1
Lmer plot help
...). I'm using the table to investigate what questions act differently to the others, so I can better fit my model. Going through tables of numbers doesn't seem the most efficient way of instantly seeing what questions work differently, and I'd like to plot that. Here is my code: table(finaldata$Voice, finaldata$supportive, finaldata$question) #generates my table# , , = attractive no yes male1 28 35 male2 20 22 female1 21 21 female2 30 19 Any help most appreciated. Drew -- View this message in context: http://r.789695....
2011 May 19
2
balanced panel data
...Aveiro) #My reproducible example: firm<-sort(rep(1:3,5),decreasing=F) year<-rep(2000:2004,3) X<-rnorm(15) data1<-data.frame(firm,year,X) data1 firm<-sort(rep(4:6,3),decreasing=F) year<-rep(2001:2003,3) X<-rnorm(9) data2<-data.frame(firm,year,X) data2 finaldata<-rbind(data1,data2) finaldata [[alternative HTML version deleted]]
2009 Jun 08
5
if else
...;-c(rep(2001:2003,4)) X1<-rep(c(10,NA),6) X2<-rep(c(5,NA,2),4) data<-data.frame(firm, year,X1,X2) data So I want to obtain the same dataframe with a variable X3 that is: X1, if X2=NA X2, if X1=NA X1+X2 if X1 and X2 are not NA So my final data is X3<-c(15,NA,12,5,10,2,15,NA,12,5,10,2) finaldata<-data.frame(firm, year,X1,X2,X3) I've tried this finaldata<-ifelse(data$X1==NA,ifelse(data$X2==NA,NA,X2),ifelse(data$varvendas==NA,X1,X1+X2)) But I got just NA in X3. Anyone could help me with this? Thanks in advance, Cec?lia (Universidade de Aveiro - Portugal)
2018 May 01
2
how can I convert a long to wide matrix?
Hi R user, I was trying to convert a long matrix to wide? I have an example and would like to get a table (FinalData1): FinalData1 B1 B2 id_X "A" "B" id_Y "A" "B" but I got the following table using the following code. FinalData1 B1 B2 id_X "A" "A" id_Y "A" "B" the code and the example data I used ar...
2018 May 01
0
how can I convert a long to wide matrix?
...ch_df(dat,idvar="ID",to.stretch=c("EventDate","SITE")) Jim On Wed, May 2, 2018 at 8:24 AM, Marna Wagley <marna.wagley at gmail.com> wrote: > Hi R user, > I was trying to convert a long matrix to wide? I have an example and would > like to get a table (FinalData1): > > > FinalData1 > B1 B2 > id_X "A" "B" > id_Y "A" "B" > > but I got the following table using the following code. > > FinalData1 > > B1 B2 > > id_X "A" "A" > > i...
2018 May 01
2
how can I convert a long to wide matrix?
...ot;EventDate","SITE")) > > Jim > > > On Wed, May 2, 2018 at 8:24 AM, Marna Wagley <marna.wagley at gmail.com> > wrote: > > Hi R user, > > I was trying to convert a long matrix to wide? I have an example and > would > > like to get a table (FinalData1): > > > > > > FinalData1 > > B1 B2 > > id_X "A" "B" > > id_Y "A" "B" > > > > but I got the following table using the following code. > > > > FinalData1 > > > > B...
2018 May 01
0
how can I convert a long to wide matrix?
...; >> Jim >> >> >> On Wed, May 2, 2018 at 8:24 AM, Marna Wagley <marna.wagley at gmail.com> >> wrote: >> > Hi R user, >> > I was trying to convert a long matrix to wide? I have an example and >> > would >> > like to get a table (FinalData1): >> > >> > >> > FinalData1 >> > B1 B2 >> > id_X "A" "B" >> > id_Y "A" "B" >> > >> > but I got the following table using the following code. >> > >> &g...
2018 May 01
2
how can I convert a long to wide matrix?
Hi Jim, The data set is correct. I took two readings from the "SITE A" within a short time interval, therefore I want to take the first value if there are repeated within a same group of "timeGroup". Therefore I wanted following FinalData1 B1 B2 id_X "A" "B" id_Y "A" "B" thanks, On Tue, May 1, 2018 at 4:05 PM, Jim Lemon <drjimlemon at gmail.com> wrote: > Hi Marna, > I think this is due to having three rows for id_X and only two for > id_Y. The function c...
2018 May 01
0
how can I convert a long to wide matrix?
....com> wrote: > Hi Jim, > The data set is correct. I took two readings from the "SITE A" within a > short time interval, therefore I want to take the first value if there are > repeated within a same group of "timeGroup". > Therefore I wanted following > > FinalData1 > > B1 B2 > id_X "A" "B" > id_Y "A" "B" > > thanks, > > > > On Tue, May 1, 2018 at 4:05 PM, Jim Lemon <drjimlemon at gmail.com> wrote: >> >> Hi Marna, >> I think this is due to having...
2007 Mar 30
1
Using split() several times in a row?
Hi, fellow R users. I have a question about sapply and split combination. I have a big dataframe (40000 observations, 21 variables). First variable (factor) is "date" and it is in format "8.29.97", that is, I have monthly data. Second variable (also factor) has levels 1 to 6 (fractiles 1 to 5 and missing value with code 6). The other 19 variables are numeric. For each month I
2008 Jul 26
1
Marking Interval Length
...> fmt<-"%m/%d/%y" > dd<-read.csv("Desktop/R/CDSdate.txt") > dd$Date<-as.Date(dd$Date, fmt) >library(zoo) > data<-read.zoo("Desktop/R/Countrydata.txt", head=T, format=fmt, sep="\t") >newdata<-merge(data, zoo(,dd$Date) >Finaldata<-na.locf(newdata, fromLast=TRUE) Now, I have to break up this Finaldata. I've been told to do something like this: # first make up some data jym.df<-data.frame(country=rep(c("au","br""cn","in","us"),each=100), date=rep(as.Date("02...