Displaying 20 results from an estimated 900 matches similar to: "Adding name to nth row"
2010 May 17
4
Adding a row at top of dataframe
I have a large data frame 48:2185 with different numbers.
I would like to add only one row at the very top of my data frame with
0's or NA's.
I don't know which approach to use. Should i create 2 different data
frames and merge them? Ive also tried the rbind command with no luck.
I would appreciate some help to achieve what I'm trying to create.
Thanks!
2010 May 26
2
How to calculate mean of means
I have 3 columns of numbers, and i want to find the mean of each
separately, and then the mean of all of the means.
ive tried:
av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3))
av3daysB
but it only gives me the mean of the first column (avr1)
Any suggestions?
Thanks,
Emilija
2010 May 28
2
if negative value, make zero
I have a data frame with both positive and negative values, and I want
to make all the negative values equal zero, so i can eventually take
an average.
I've tried
temp2 <- ifelse(tempr<0, 0, tempr)
but it doesn't seem to work.
Any suggestions?
Thanks!
2012 Aug 29
4
Use or ??
Hi, My data frame looks like
A B C
a b a
x y z
I want to add a new column which says "y" if either A or B matches with C and "n" if there is no match. How can I do that?
Thanks
[[alternative HTML version deleted]]
2010 Jun 21
2
Calculating a daily average
I have a set of data with 12 readings for temperature per day, with
180 days. I want to find the average temperature of each day. I am
able to do this one by one, but with that many days to calculate the
average for, it will get very long. I'm sure there is a faster way to
do this, I just don't know how. What i have so far is:
av1 <- subset(ER9r, Day == 98, select = c
2015 May 13
2
[LLVMdev] Modifying debug information through llvm pass
Hi All,
I want to change debug information of an llvm instruction so that the
modified debug info is subsequently passed to executable binary. So if I
use "addr2line" utility on the binary, it will return my modified debug
information.
I've tried to change by using the following code snippet:
MDNode *N = Inst->getMetadata("dbg");
DebugLoc Loc =
2006 Apr 10
1
Add Column After Column in Migrations
Adding a column to a table just places the column at the end, but I
like to keep related columns together. Is there a way to specify
where the column is added in a table with migrations? For example, in
MySQL you can do:
ALTER TABLE my_table ADD COLUMN new_column INT AFTER other_column
I was hoping migrations would support something like this:
add_column :my_table, :new_column, :integer,
2010 May 17
1
suggestions/improvements for recoding strategy
I am recoding some data. Many values that should be 1.5 are recorded
as 1-2. Some example data and my solution is below. I am curious about
better approaches or any other suggestions. Thanks!
# example input data
myData <- read.table(textConnection("id, v1, v2, v3
a,1,2,3
b,1-2,,3-4
c,,3,4"),header=TRUE,sep=",")
closeAllConnections()
# the first column is IDs so remove
2006 Sep 13
7
inserting columns in the middle of a dataframe
Dear R users:
Is there a built-in and simple way to insert new columns after other columns
in a dataframe?
I.e. currently I have:
V1 V2 V3 V4
[1,]
[2,]
Etc.
But I want
V1 V5 V2 V3 V4
[1,]
[2,]
Etc.
Can this be done in one line?
Jon Minton
[[alternative HTML version deleted]]
2010 Jun 28
1
Subtraction loop
I have a data frame with 2 columns, one for day and one for average.
The day starts at 97 all the way to 279. I want to subtract day 98
average- day 97 average, then day99 average -day 98 average and so on
down my list, creating another column with the subtracted results.
I have:
Day DailyAverage
1 97 0.6076782
2 98 0.7121478
3 99 0.8059347
4 100 0.9545806
5
2009 May 26
1
Bug in "$<-.data.frame" yields corrupt data frame (PR#13724)
Full_Name: Steven McKinney
Version: 2.9.0
OS: Mac OS X 10.5.6
Submission from: (NULL) (142.103.207.10)
A corrupt data frame can be constructed as follows:
foo <- matrix(1:12, nrow = 3)
bar <- data.frame(foo)
bar$NewCol <- foo[foo[, 1] == 4, 4]
bar
lapply(bar, length)
> foo <- matrix(1:12, nrow = 3)
> bar <- data.frame(foo)
> bar$NewCol <- foo[foo[, 1] == 4, 4]
2018 Apr 15
4
Adding a new conditional column to a list of dataframes
Hi all ..,
I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes.
When I extract one dataframe and apply my code it works very well as follows :-
First suppose this is my first dataframe in the list
> OneDF <- Mylist[[1]]
> OneDF
ID Pdate
2011 Aug 01
1
Inserting column in between -- "better" way?
Folks:
I consider my reply below rather clumsy: One has to keep track of
index numbers other than that which is inserted and must separately
change column names. Is there as "essentially better" way to do this,
either via base R or via an R package. I leave it to you to define
"essentially better."
Thanks.
Cheers,
Bert
On Mon, Aug 1, 2011 at 10:17 AM, Bert Gunter
2009 Apr 29
1
Corrupt data frame construction - bug?
Hi useRs,
A recent coding infelicity along these lines
yielded a corrupt data frame.
foo <- matrix(1:12, nrow = 3)
bar <- data.frame(foo)
bar$NewCol <- foo[foo[, 1] == 4, 4]
bar
lapply(bar, length)
> foo <- matrix(1:12, nrow = 3)
> bar <- data.frame(foo)
> bar$NewCol <- foo[foo[, 1] == 4, 4]
> bar
X1 X2 X3 X4 NewCol
1 1 4 7 10 <NA>
2 2 5 8 11
2009 Feb 02
2
concatenating 2 text columns in a data.frame
Hi,
I'm trying to concatenate values from two columns in a data frame. For
example, I have the following data.frame:
C1 C2 C3 C4 C5
A B *F C* Q
G H *I J* T
K D *R S* E
P L *M N* O
I'd like to concatenate text from columns C3 and C4, to yield either a
list or vector, like so:
NewCol
FC
IJ
RS
MN
Is this feasible in R?
Thanks!
2007 Mar 12
1
How to modify a column of a matrix
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070312/5b30b712/attachment.pl
2018 Apr 15
0
Adding a new conditional column to a list of dataframes
> On Apr 15, 2018, at 4:08 AM, Allaisone 1 <Allaisone1 at hotmail.com> wrote:
>
>
> Hi all ..,
>
>
> I have a list of 7000 dataframes with similar column headers and I wanted to add a new column to each dataframe based on a certain condition which is the same for all dataframes.
>
>
> When I extract one dataframe and apply my code it works very well as
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All
I have a datafram which looks like this :
CustomerID DietType
1 a
1 c
1 b
2 f
2 a
3 j
4 c
4 c
4 f
And I would like to reshape this so I can
2008 Aug 20
3
vector operation using regexpr?
Hi,
Here's my problem... I have a data frame with three columns containing
strings. The first columns is a simple character. I want to get the
index of that character in the second column and use it to extract the
item from the third column. I can do this using a scalar method. But
I'm not finding a vector method. An example is below.
col1 col2 col3
'L'
2002 Feb 09
1
How to access objects outside an R function
Dear R-Users,
I have a dataframe (''forexdata'') of daily returns from the foreign exchange market for three currencies - British Pound (bp), Canadian Dollar(cd),
Deustche Mark (dm) vis-a-vis the US Dollar and the Date Of
Trade(yymmdd).
For some dates the returns are missing (recorded as zero) as there
were no trades in that currency for that date. My task is to
substitute the