Displaying 20 results from an estimated 60000 matches similar to: "How use lapply over one column in a dataframe?"
2008 May 02
2
Transform values from one column into column names of new dataframe
Hi, I have a question about reformatting data. It looks like it should
be simple, but I've been working at it for awhile now and it's about
time I ask for help.
My data look like this:
ITEM VALUE STEP
item1 A first
item2 C first
item2 D second
item1 A second
item3 A first
item3 B second
item3 A third
I just want to transform
2007 Oct 22
3
median value dataframe coming from multiple dataframes
Hi all,
I am not a skillful R programmer and has I am handling with large dataframes (about 30000 x 300) I am in need of an efficient function.
I have 4 dataframes with the same dimension. I need to generate other dataframe with the some dimension than the others where in each position it has the median value of the 4 values in the same position coming from the 4 dataframes.
Grateful by your
2010 Oct 26
3
stripping #s in a text file prior to reading into table or dataframe
I'm importing a lot of text tables of data (from Latent Gold) that includes
hashes in some of the column names ("Cluster#1", "Cluster#2", etc.). Is
there an easy way to strip the offending hashes out before pushing the text
into a table or data frame? I thought I'd use gsub, e.g., but can't figure
out how to read in a text file without reading it into a table or
2010 Apr 30
3
Why do data frame column types vary across apply, lapply?
Hi,
I still have little ability to predict how these functions will treat the
columns of data frames:
> # Here's a data frame with a column "a" of integers,
> # and a column "b" of characters:
> df <- data.frame(
+ a = 1:2,
+ b = c("a","b")
+ )
> df
a b
1 1 a
2 2 b
>
> # Except -- both columns are characters:
>
2009 Aug 06
2
Convert dataframe to table with counts where column names become row names
Can anyone explain how best to go from a dataframe to a table (or better yet
a new dataframe) of counts, where the row names in the new table (or
dataframe) are the column names of the original df.
start w/
DF1 =
Pos1 Pos2 Pos3 ....
oligo1 G C A
oligo2 U U A
oligo3 G C C
oligo4 C G U
oligo5 A A G
.....
End with
DF2 =
2009 Jun 24
2
lapply across using multiple columns
Hi,
To set a simple an clear picture of what I'd like to do, here is an example.
I would like to calculate mean of column A and B bucketed by factor in
column X in a data.frame. lapply or aggregate operates on a single column. I
found dapply function in some package which doesn't seem to exist any more.
Is there anyway that I can accomplish something like this? Thank you so much
in
2010 Jun 03
2
lapply or data.table to find a unit's previous transaction
I have a dataset of property transactions that includes the
transaction ID (TranID), property ID (UnitID), and transaction date
(TranDt). I need to create a data frame (or data table) that includes
the previous transaction date, if one exists.
This is an easy problem in SQL, where I just run a sub-query, but I'm
trying to make R my one-stop-shopping program. ?The following code
works on a
2008 Oct 28
1
outputting (writing) output into a dataframe
I have solved this problem once before but don't recall exactly how.
Is there a url that shows how?
What I want to do now is quite specific but my query is actually very general
There are many functions in which one specifies several parameters and
an output is generated. Well what happens if one wants to specify a
range of parameters and have the output written to a data frame.
To
2010 Aug 10
1
partial match of one column in data frame to another character vector
Here is some data (dput output below)
> myData
id group
1 D599 A
2 002-0004 B
3 F01932 A
18 F16 B
19
2011 Feb 04
3
lapply, strsplit, and list elements
Hi there,
I have a problem about lapply, strsplit, and accessing list elements,
which I don't understand or cannot solve:
I have e.g. a character vector with three elements:
x = c("349/077,349/074,349/100,349/117",
"340/384.2,340/513,367/139,455/128,D13/168",
"600/437,128/903,128/904")
The task I want to perform, is to generate a list,
2010 Jun 01
3
lapply with functions with changing parameters
Dear all,
I am trying to avoid a for loop here and wonder if the following is possible:
I have a data.frame with 6 columns and i want to get a cross-correlogram (by using ccf) . Obivously ccf only accepts two columns at once and then returms a list.
In fact, with a for loop i?d do the following
for (i in 1:6) {
x[[i]]=ccf(mydf[,i],mydf[,6])
}
Is there any chance to the same with
2010 Sep 21
2
lapply version with [ subseting - a suggestion
Dear R developers,
Reviewing my code, I have realized that about 80% of the time in the lapply I
need to access the names of the objects inside the loop.
In such cases I iterate over indexes or names:
lapply(names(x), ... [i]),
lapply(seq_along(x), ... x[[i]] ... names(x)[i] ), or
for(i in seq_along(x)) ...
which is rather inconvenient.
How about an argument to lapply which would specify the
2008 Mar 09
2
transforming column of a dataframe by var- and median-functions
Hello,
I try to transform a data frame like
A B C
1 1 2,5
2 2 NA
3 1 1,0
4 1 56
5 2 23
6 1 NA
7 2 46
to the following dataframe, calculating the variance and median of the
C-column, group by B, so the result will be:
B C(median) D (var)
1 19,83
2008 Feb 25
2
Exporting a dataframe from R to Excel
I am trying to export a dateframe created in R:
> Duration_summary
V1 2.5 % 97.5 % V4 2.5 % 97.5 %
[1,] 1 0.46076018 1.128776 1.000000 0.5280828 0.9576338
[2,] 0 0.00000000 0.000000 1.000000 0.1741793 1.2352705
[3,] 1 0.46566719 1.313711 1.000000 0.7233312 1.4097987
[4,] 1 0.38866371 2.453226 0.976024 0.6377314 1.3493957
[5,] 1 0.08894066 1.036830
2011 Jan 31
5
Finding a Diff within a Dataframe columns
Hi,
I have a Dataframe.
A B C D
0.1 0.7 0.9 0.8
0.20 0.60 0.80 0.70
0.40 0.80 0.70 0.76
I need a resultant dataframe
(A-B) (C-D)
-0.6 0.1
-0.40 0.1
-0.40 -0.06
Any suggestion would be of a great help
Thanks
Ramya
--
View this message in context: http://r.789695.n4.nabble.com/Finding-a-Diff-within-a-Dataframe-columns-tp3247943p3247943.html
Sent from
2003 Apr 15
5
making a dataframe out of lapply() result
Dear R-helpers,
i have a question on how to vectorize this problem:
i have a dataframe:
tester <- data.frame(groups=c("A","A","B","B","C","C"), one=c(1,1,2,2,3,3), two=c(6,6,7,7,8,8))
# i split it into a list
tester.L <- split(tester, tester$groups)
# And want to keep only the first item in each:
lapply(tester.L, function(x) x
2008 Oct 31
2
how to retrieve some records from a dataframe
Hi ,
Dataframe Df contains more than 30 no of records.but I want only
first 30 rows of data.
How can I retrieve it.
Thanks
K.Ravichandra
[[alternative HTML version deleted]]
2009 Aug 06
1
problem with recording numeric output into another dataframe
dear all,
I have two dataframes
dataframe1
ID
a
b
c
dataframe2
ID value
a;W 100
X;c 200
Y;Z 300
I wanted to match the IDs from the two dataframes and record the values into
a new column of dataframe1 at the corresponding rows. This is what I expect:
dataframe1
ID value
a 100
b
c 200
I tried doing it like this:
for (i in seq(1:nrow(dataframe1))) {
2007 Nov 28
1
Order observations in a dataframe
Dear All,
Suppose I have the following dataframe:
country;weight;group
bul;10;1
cze;12;1
grc;12;1
hun;12;1
prt;12;1
rom14;1
fra;29;2
ita;29;2
gbr;29;2
aut;10;3
bel;12;3
The "group" variable denotes the id-number of a group of countries. How can
I re-label the groups in the descending order of their cumulative "weight",
which wound be:
country;weight;group
fra;29;1
ita;29;1
2010 Aug 10
3
sapply/lapply instead of loop
Using the input below, can I do something more elegant (and more efficient)
than the loop also listed below to pad strings to a width of 5? The true
matrix is about 300K rows and 31 columns.
#######################
#INPUT
#######################
> temp
DX1 DX2 DX3
1 13761 8125 49178
2 63371 v75 22237
3 51745 77703 93500
4 64081 32826 v72
5 78477 43828 87645
>