Displaying 20 results from an estimated 9000 matches similar to: "filling in a dataframe with another dataframe"
2008 Mar 16
2
How to loop through all the columns in dataframe
Hi:
Can anyone advice me on how to loop and perform a
calculation through all the columns.
here's my data
xd<-
c(2.2024,2.4216,1.4672,1.4817,1.4957,1.4431,1.5676)
pd<-
c(0.017046,0.018504,0.012157,0.012253,0.012348,0.011997,0.012825)
td<- c(160524,163565,143973,111956,89677,95269,81558)
mydf<-data.frame(xd,pd,td)
trans<-t(mydf)
trans
I have these values that I need to
2010 Oct 21
2
Adding rows to column
I'm new to R.
I'm extracting important columns from single table using following code:
File2<-"file.txt"
table2<- read.delim(File2, skip=19, sep=";", header=F, na.strings=NA,
fill=T)
#extracting column 7 where rows match "ID"
col1<- table2[grep("ID", table2[,1]),7]
#similarly extracting column 9,11,13,15
col2<-
2013 Jan 11
3
split & rbind (cast) dataframe
Hi,
I would like to split dataframe based on one colum and want
to connect the two dataframes by rows (like rbind). Here a small example:
# The orgininal dataframe
df1 <- data.frame(col1 = c("A","A","B","B"),col2 = c(1:4), col3 = c(1:4))
# The datafame how it could look like
df2 <- data.frame(A.col2 = c(1,2), A.col3 = c(1,2), B.col2 = c(3,4),
B.col3
2006 Dec 14
5
Better way to change the name of a column in a dataframe?
Hello R users --
If I have a dataframe such as the following, named "frame" with the
columns intended to be named col1 through col6,
> frame
col1 col2 cmlo3 col4 col5 col6
[1,] 3 10 2 6 5 7
[2,] 6 8 4 10 7 1
[3,] 7 5 1 3 1 8
[4,] 10 6 5 4 9 2
and I want to correct or otherwise change the
2013 Jan 11
2
Merging list of dataframes with reshape merge_all
Hi,
I'd like to merge mutliple dataframes from a list of dataframes by some common
columns. The approach for simply merging 2 dataframes is working with:
merge(df1,df2,by=c("col1","col2","col3"),all=TRUE)
For mutliple dataframes in a list I try to use the merge_all command
from the package reshape.
The documentation states that the command takes a list of
2010 Mar 22
1
help needed with boxplot
I am new to R, can anyone help with boxplot for a dataset like:
file1 col1 col2 col3 col4 col5
050350005 101 56.625 48.318 RED
051010002 106 50.625 46.990 GREEN
051190007 25 65.875 74.545 BLUE
051191002 246 52.875 57.070 RED
220050004 55 70 80.274 BLUE
220150008 75 67.750 62.749 RED
220170001 77 65.750 54.307 GREEN
file2
col1 col2 col3 col4 col5
050350005 101 56.625 57 RED
051010002 106 50.625 77
2020 Sep 10
2
aplicar codigo
Yo copio y pego este código y me sale correctamente. Se me ocurre que
pueda deberse a la versión de R ¿cuál usas?
El 10/09/2020 a las 17:51, Samura . escribió:
> Gracias por las respuestas.
>
> Probé lo de hacer la función y no me salía. Pensaba que hacía algo mal.
> Ahora con el código de Marcelino tampoco me sale.
>
> col1 <- c('x1', 'x2', 'x11',
2020 Sep 10
3
aplicar codigo
Hola,
me gustar?a hacer algo como en el siguiente ejemplo
A un df a?adirle una columna que es la transformaci?n de otra,
en plan a todo lo que sea x1, x2, x3 lo llamo prueba 1
todo lo que sea x4,x5,x6 lo llamo prueba 2
el resto de x las dejo como est?n.
Ser?a algo as?
col1 <- c('x1', 'x2', 'x11', 'x1','x33', 'x1','x4', 'x5',
2008 Apr 09
1
Replace values according to conditions
Greetings R-users,
I have the following data called mydata in a data.frame
Col1 Col2 Col3 Col4 Col5
1 2 4 6 7
8 8 7 3 5
4 4 5 6 7
I want to replace the data according to the following conditions
Condition 1 if data <= 3, replace with -1
Condition 2 if data >=6, replace with 1
Condition 3 if data = 4 or data =5, replace with 0
2011 Aug 25
2
replicate lines of data frame
Greetings!
I am just now learning to use R for my dissertation project. I need
to manipulate a lot of text and numeric data. I created a data frame
that has 7 columns and 127 unique rows. Now I need to replicate each
line 6 times and then later change values in the first 2 columns.
I am trying to figure out how to accomplish this. I think that I need
to use rep(my.df, each=6) but it does
2013 Jun 11
1
mapply on multiple data frames
Hi all-
I am wondering about using the mapply function to multiple data frames. Specifically, I would like to do a t-test on a subset of multiple data frames. All data frames have the same structure.
Here is my code so far:
f<-function(x,y) {
test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=="num",],paired=T,alternative="greater")
out<-test$p.value
2020 Sep 10
5
aplicar codigo
Hola:
Como dice Carlos, algo así, por ejemplo:
transforma <- function(df) sapply(df, function(x)
ifelse(x%in%c("x1","x2","x3"),
"prueba1",ifelse(x%in%c("x4","x5","x6"),"prueba2",x)))
> transforma(df1)
col1
[1,] "prueba1"
[2,] "prueba1"
[3,] "x11"
[4,]
2016 Dec 27
0
colnames for data.frame could be greatly improved
Hi there,
Any update on this?
Should I create bugzilla ticket and submit patch?
Regards
Jan Gorecki
On 20 December 2016 at 01:27, Jan Gorecki <J.Gorecki at wit.edu.pl> wrote:
> Hello,
>
> colnames seems to be not optimized well for data.frame. It escapes
> processing for data.frame in
>
> if (is.data.frame(x) && do.NULL)
> return(names(x))
>
> but
2009 Nov 05
1
Set colors in a PCA plot based on a gradient vector
Hi all,
I'm making a PCA plot with eight variables (columns taken from a larger data frame "fieldTrial0809[idx,c(39:46)]"). I then want the symbols in the plot to be colored as a gradient from red to blue, depending on the value of another column in "fieldTrial0809[idx, c(48)]" containg temperatures from -12.1 to -5.4.
I don't want to use the heat.colors(n)
2017 Jun 21
0
selecting dataframe columns based on substring of col name(s)
> On Jun 21, 2017, at 9:11 AM, Evan Cooch <evan.cooch at gmail.com> wrote:
>
> Suppose I have the following sort of dataframe, where each column name has a common structure: prefix, followed by a number (for this example, col1, col2, col3 and col4):
>
> d = data.frame( col1=runif(10), col2=runif(10), col3=runif(10),col4=runif(10))
>
> What I haven't been able to
2011 Jan 24
2
how to slice a zoo object
Hi
Would anyone have any pointers on how to slice up a large zoo table. I
have the following structure: -
> str(ZOO_OBJ)
?zoo [1:632, 1:83] 30.4 30.4 30.4 30.4 30.3 ...
?- attr(*, "dimnames")=List of 2
??..$ : NULL
??..$ : chr [1:83] "COL1" "COL2" "COL3" "COL4" ...
?- attr(*, "index")= POSIXct[1:632], format: "2009-05-01
2006 Mar 16
3
Did I use "step" function correctly? (Is R's step() function reliable?)
Hi all,
I put up an exhaustive model to use R's "step" function:
------------------------
mygam=gam(col1 ~ 1
+ col2 + col3 + col4
+ col2 ^ 2 + col3 ^ 2 + col4 ^ 2
+ col2 ^ 3 + col3 ^ 3 + col4 ^ 3
+ s(col2, 1) + s(col3, 1) + s(col4, 1)
+ s(col2, 2) + s(col3, 2) + s(col4, 2)
+ s(col2, 3) + s(col3, 3) + s(col4, 3)
+ s(col2, 4) + s(col3, 4) + s(col4, 4)
+ s(col2, 5) + s(col3,
2017 Jun 21
4
selecting dataframe columns based on substring of col name(s)
Suppose I have the following sort of dataframe, where each column name
has a common structure: prefix, followed by a number (for this example,
col1, col2, col3 and col4):
d = data.frame( col1=runif(10), col2=runif(10),
col3=runif(10),col4=runif(10))
What I haven't been able to suss out is how to efficiently
'extract/manipulate/play with' columns from the data frame, making use
2016 Dec 20
2
colnames for data.frame could be greatly improved
Hello,
colnames seems to be not optimized well for data.frame. It escapes
processing for data.frame in
if (is.data.frame(x) && do.NULL)
return(names(x))
but only when do.NULL true. This makes huge difference when do.NULL
false. Minimal edit to `colnames`:
if (is.data.frame(x)) {
nm <- names(x)
if (do.NULL || !is.null(nm))
return(nm)
else
2012 Oct 18
4
speeding read.table
R 2.15.1
OS X
Colleagues,
I am reading a 1 GB file into R using read.table. The file consists of 100 tables, each of which is headed by two lines of characters.
The first of these lines is:
TABLE NO. 1
The second is a list of column headers.
For example:
TABLE NO. 1
COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10