Displaying 20 results from an estimated 10000 matches similar to: "Insert rows into a pre-existing data frame"
2008 Jul 23
2
Can't Load Text Files
Hi,
I've completely forgotten how to do R, and it seems I can't even load
simple files correctly.
I have two tab deliminated text files (attached, these were test files
of the larger data files I'm trying to work with) that I am trying to
load into R so that I can merge them. They were originally excel files
but I used "saved as" to reformat to text. I don't know if
2008 Sep 29
3
replicating dataframe rows
Dear all,
I have a data.frame like the sample below, and I would
like to expand my data.frame using "population" variable.
So, for each line of my data.frame I would like that
the new data.frame have many rows as the population collumn.
place<-c("place1", "place2", "place3", "place4", "place5")
population<-c(100,200,300,50,30)
2012 Aug 14
4
Subsetting rows by multiple levels of selected values
Dear list,
Let's say we have a data frame as follows,
>expand.grid(a=1:5,b=c(1,5,10,20),DV=c(0.1,0.2,0.3))->df1
>df1$DV<-rgamma(60,shape=10)
columns a and b are two levels. DV is the column with values we are
interested in.
Then another data frame df2 with values as follows
data.frame(a=c(2,2,3,4,5),b=c(5,10,1,5,20))->df2
Now I want to a subset of df1 that match df2 at the
2016 Apr 24
3
Dividing rows in groups
Hi
I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1.
df1:
ID A B
1 1 2
1 0 3
2 5 NA
2 1 3
3 1 4
4 NA NA
4
2010 Nov 03
2
biding rows while merging at the same time
Hello!
I have 2 data frames like this (well, actually, I have 200 of them):
df1<-data.frame(location=c("loc 1","loc 2","loc
3"),date=c("1/1/2010","1/1/2010","1/1/2010"), a=1:3,b=11:13,c=111:113)
df2<-data.frame(location=c("loc 1","loc 2","loc
2008 Jul 01
3
Change name of a specific column of a data frame
Hi,
Sorry for the simple question. Is there a way to change the name of only one
column of an existing data frame?
I know colnames allows you to set the name of all the columns, but only one
column in the middle of my data frame needs a new name.
Thanks,
-Nina
2008 Jul 01
3
Ignore blank columns when reading a row from a table
Hi,
I am extracting data from a table where the rows have different column lengths,
and empty columns have NA in them. Whenever I extract a row with some empty
columns, the resulting vector carries all the NAs. Is there a way to ignore the
empty columns?
Thanks,
-Nina
2011 Dec 07
2
Dividing rows when time is overlapping
Hi all,
I have dataframe that was created from the fusion of two dataframes. Both
spanned over the same time intervall but contained different information.
When I put them together, the info overlapped since there is no holes in the
time interval of one of the dataframe. Here is an example where the rows
"sp=A and B" are part of a first df and the rows "sp=C" come from a
2012 Apr 16
3
Select rows based on condition
Hi,
I am relatively new to R and I am trying to figure out how to select rows of
my data based on a condition.
For example in the dataset below multiple observers recorded data at the
same point on the same date and the data was recorded on separate rows, but
I only need one of the rows of data. Is it possible to use grep to search
for rows that have matching PtName and Date and then select the
2018 Feb 25
0
reshaping column items into rows per unique ID
I believe you need to spend time with an R tutorial or two: a data frame
(presumably the "table" data structure you describe) can *not* contain
"blanks" -- all columns must be the same length, which means NA's are
filled in as needed.
Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fit into any
local version of R (maybe it would in some server version --
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
2008 Jun 30
4
Problem reading a CSV
Hi,
I have a CSV file where each row has at least 20 columns and some rows have up
to 30 columns of data. When I use the command,
Pathways<-read.table('MetaCycSample3.csv',sep=',',header=FALSE,quote='"')
anything past the 21st column gets kicked down to a new row. How can I fix this?
Thanks,
-Nina
2012 Jul 25
3
Select rows based on matching conditions and logical operators
Hi,
I have a dataset in which I would like to select rows based on matching
conditions and return the maximum value of a variable else return one row if
duplicate counts exist. My dataset looks like this:
PGID PTID Year Visit Count
6755 53121 2009 1 0
6755 53121 2009 2 0
6755 53121 2009 3 0
6755 53122 2008 1 0
6755 53122 2008 2 0
6755 53122 2008 3 1
6755 53122 2009 1 0
6755 53122 2009 2 1
6755
2013 Jan 24
3
how to combine unequal rows and columns in R
HI,
I have the following list:
crosspries
$crosspries[[1]]
Product Year_Month prod1
A 201208 1
B 201208 2
C 201208 1
$crosspries[[2]]
Product Year_Month prod1 prod2
A 201209 1 1
B 201209 2
2012 Jan 18
2
Extracting rows with latest date from a data frame
Hi,
I have a list of unique patient IDs which I want to run against a dataframe
of unique patient IDs with dates. There are multiple date instances against
unique IDs. The end result I wish is that I have a list of IDs (which are
unique) with the latest date. I have begun with using test data (but I
haven't got very far!)
#Create test data
#Data frame creation
2009 Oct 13
2
splitting dataframe, assign to new dataframe, add new rows to new dataframe
Hi, all,
My objective is to split a dataframe named "cmbine" according to the value of "classes". After the split, I will take the first instance from each class and bin them into a new dataframe, "df1". In the 2nd iteration, I will take the 2nd available instance and bin them into another new dataframe, "df2".
>cmbine$names
apple tiger pencil chicken
2010 Sep 14
3
how to compute when row length is different
hi guys..please help me with this
i am working on two data frames
one goes like this:
DF1
Sample_id RepairHours Denatured Dose ZeroMean FourtyFiveMean NinetyMean
1 SDM071 0 1 B 60.5 19.0 45.0
2 SDM071 1 1 B 46.0 23.0 42.5
3 SDM071 2 1 B 52.5 24.0 40.0
4 SDM071
2008 Jul 17
3
Display variables when running a script
Hi,
I know this must be a stupid question, and sorry in advance for being such a
noob. But, is there way to get R to display only certain variables when running
a script. I know if you want to see the value of a variable when using the
interface, you just type it in and hit enter, but is there a command that I can
use in a script file that will show the value at a certain point?
Thanks,
-Nina
2012 Jul 18
2
duplicate data between two data frames according to row names
Hi everybody.
I'll first explain my problem and what I'm trying to do.
Admit this example:
I'm working on 5 different weather stations.
I have first in one file 3 of these 5 weather stations, containing their
data. Here's an example of this file:
DF1 <- data.frame(station=c("ST001","ST004","ST005"),data=c(5,2,8))
And my two other stations in
2008 Jul 06
4
Numbers as Points in Graphs
I am trying to produce a simple plot where the points in the plot are
actually integers from my data. That is, I am making a length/width plot and
I would like the points, rather dots or triangles, appear as different
numbers corresponding to a column in my data. I have tried using this:
...,pch="column title"
but this merely returns the first letter of the column title, B. Is there