similar to: Troubleshooting code

Displaying 20 results from an estimated 3000 matches similar to: "Troubleshooting code"

2013 Mar 07
2
Copying a dataframe
Hi, I am trying to create a data frame using the dimensions of another data frame that I have input. This is the code I am using: tab is the data frame that is input. c.leng<-length(tab[,1]); r.leng<-length(tab[1,]); opdf<-data.frame(ncol=c.leng, nrow=r.leng); a<-1; while(a<=c.leng) { opdf[[1]][a]<-tab[[1]][a]; a<-a+1; } This is the error message I am getting: Error in
2013 Mar 19
4
Copying rows in data frames
Hi, I'm trying to copy the first row of one data frame to another. This is the statement I am using : df2[1,]<-df1[1,]; I have printed them out separately: df1[1,] = A C D E F But after copying: df2[1,] = 96 29 88 122 68 Why isn't it copying? They are both data frames, and "as.character" isn't working either. Thanks for your input :) [[alternative HTML version
2013 Mar 25
3
nested 'while' loops
Hi everyone, I'm using the following code to go over every element of a data frame (row wise). The problem I am facing is that the outer 'x' variable is not incrementing itself, thus, only one row of values is obtained, and the program does not proceed to the next row. This is the code: while(x<=coln) { while(y<=rown) { n<-as.numeric(df[[y]][x]);
2013 Mar 06
2
Generating unique filenames.
Hi, I am trying to create unique filenames for my output text file. The idea is that I would like to append a string to ".zsc.txt" so that all my files are uniquely named but with a similar format. I have tried adding the string variable to ".zsc.txt" while creating the output file name, i.e. write.table function, is what I have tried using : write.table(x,
2003 Sep 14
1
reading in a file with multiple data types
Hi, I have a data file which contains multiple data types (char and numeric) alongside with line spaces, tabs and spaces. I hope to extract out the numeric blocks of the data, probably as matrices or dataframes where each line in the data block is a corresponding row in the dataframe/ matrix. I have tried using many R read functions but they do not seem to yield the appropriate structure that
2003 Aug 04
1
Error in calling stepAIC() from within a function
Hi, I am experiencing a baffling behaviour of stepAIC(), and I hope to get any advice/help on what went wrong or I'd missed. I greatly appreciate any advice given. I am using stepAIC() to, say, select a model via stepwise selection method. R Version : 1.7.1 Windows ME Many thanks and best regards, Siew-Leng ***Issue : When stepAIC() is placed within a function, it seems
2010 May 20
10
Libtheora
Hi all, I am Sahana. I am currently working on Libtheora for windows platform and very new to it. I am getting a lot of compiling errors. Since Libtheora depends on libogg and libvorbis i have added these as well to my workspace in VC++ 6. I have a doubt regarding the x86 and x86_vc folders described in the libtheora software.Since both these folders have the same set of files which one do we
2011 Aug 18
2
Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
Dear expeRts, What is the best approach to create a third data frame from two given ones, when the new/third data frame has last column computed from the last columns of the two given data frames? ## Okay, sounds complicated, so here is an example. Assume we have the two data frames: df1 <- data.frame(Year=rep(2001:2010, each=2), Group=c("Group 1","Group 2"), Value=1:20)
2009 Sep 16
1
re-code missing value
Dear all, I have partial data set with four colums. First column is "site" with three factors (i.e., A, B, and C). From second to fourth columns (v1 ~ v3) are my observations. In the observations of the data set, "." indicates missing value. I replaced "." with NA. To replace "." with NA, I used two steps. First, I replaced "." with NA, and
2013 Feb 26
2
merging or joining 2 dataframes: merge, rbind.fill, etc.?
#I want to "merge" or "join" 2 dataframes (df1 & df2) into a 3rd (mydf). I want the 3rd dataframe to contain 1 row for each row in df1 & df2, and all the columns in both df1 & df2. The solution should "work" even if the 2 dataframes are identical, and even if the 2 dataframes do not have the same column names. The rbind.fill function seems to work. For
2009 Feb 10
1
aggregate taking way too long to count.
Folks, I'm checking the structure of a dataframe for duplicate parameters at a site station (i.e depth should be measured once, not twice), using aggregate to count each parameter within a site station. The fake data below has only 26000 rows, and takes roughly 14 seconds. My real data has 750000 rows and I had to stop execution after about an hour. The by() function is faster, but I
2017 Jul 13
2
about plotting a special case
Thanks, Jim. The code works, but I don't understand why you use q1090 <- quantile(DF1$B, probs=c()), rather than DF1$A? Also, how to add a legend for both points DF1 and DF2? On Wed, Jul 12, 2017 at 8:25 PM, Jim Lemon <drjimlemon at gmail.com> wrote: > Hi lily, > Here is the first plot: > > plot(DF1$A,DF1$B,pch=19,col="red") > meanA<-mean(DF1$A) >
2012 Jul 11
4
Help with loop
Hi, I have two dataframes: The first, df1, contains some missing data: cola colb colc cold cole 1 NA 5 9 NA 17 2 NA 6 NA 14 NA 3 3 NA 11 15 19 4 4 8 12 NA 20 The second, df2, contains the following: cola colb colc cold cole 1 1.4 0.8 0.02 1.6 0.6 I'm wanting all missing data in df1$cola to be replaced by the value of df2$cola.
2011 Nov 30
1
Replace columns in a data.frame randomly splitted
Dear community, I'm working with the data.frame attached ( http://r.789695.n4.nabble.com/file/n4122926/df1.xls df1.xls ), let's call it df1. I typed: df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, rowNames= TRUE) Then I splited randomly df1 using splitdf function (http://gettinggeneticsdone.blogspot.com/2011/03/splitting- dataset-revisited-keeping.html)
2013 Jun 10
1
modify and append new rows to a data.frame using ddply
Hi, I have a data.frame that contains a variable act which records the duration (in seconds) of two states (wet-dry) for several individuals (identified by Ring) over a period of time. Since I want to work with daytime (i.e. from sunrise till sunset) and night time (i.e. from sunset till next sunrise), I have to split act from time[i] till sunset and from sunset until time[i+1], and from time[k]
2009 Dec 13
1
xtabs - missing combination
Dear list, I am trying to make a contingency table with xtabs but I am getting a 0 where I expect a 'NA'. Here is a simple example: options(stringsAsFactors = FALSE) rn <- LETTERS[1:4] df1 <- data.frame(r07 = rep(rn, each=4), r08 = rep(rn, 4), value = 1:16) xtabs(value ~ r07 + r08, df1) # Delete the combination [A, C] df1 <- df1[-3,] # Set 'value'
2005 Jun 29
3
return NA
A<-c(1,2,NA,7,5) B<-c(3,4,1,4,1) C<-c(6,5,6,NA,9) D<-c(8,7,4,6,2) df1<-cbind(A,B,C,D) for(i in seq(1,ncol(df1)-1, by=2)) { ifelse(df1[,i]=="NA",df1[,i+1]=="NA",df1[,] ) } Tried several variations but none worked. I wish to find any NA's in column's 1 or 3 and change the numerical value to the right of the " NA"'s . In this case I
2010 Nov 19
3
Still confused with lapply
Hello, I would like to replace a for loop with lapply in order to speed up the treatment of my data (I've read lapply can help to do it). At the end of the message, you will find a simple example (function is more complex and data frames is more than 1 million of rows) of what I would like to do, that is applying the same calculation to all the rows of the data frame (knowing that I cannot
2007 May 05
1
loop in function
Dear Mailing-List, I think this is a newbie question. However, i would like to integrate a loop in the function below. So that the script calculates for each variable within the dataframe df1 the connecting data in df2. Actually it takes only the first row. I hope that's clear. My goal is to apply the function for each data in df1. Many thanks in advance. An example is as follows: df1
2016 Jun 23
2
Asignar a un dataframe un id de otro dataframe en función de intervalos con fechas
Hola a todxs, No encuentro la manera de hacer algo que aparentemente parece muy sencillo: Tengo dos dataframe, en el primero tengo una serie de códigos con hora de inicio y hora de fin y en el segundo otros códigos asociados a una hora; Lo que necesito es crear una nueva variable en el segundo data frame que indique a qué intervalo del primer data frame (df1$id) pertenece cada nivel del segundo