search for: col1

Displaying 20 results from an estimated 435 matches for "col1".

Did you mean: col
2020 Sep 13
2
Cambiar datos de un DF
Hola: Si codificas "col1" como un factor, lo puedes cambiar todo de una vez renombrando los niveles correspondientes: > df$col1<-as.factor(df$col1) > df$col1  [1] uno   dos   3     4     cinco 6     siete 8     9     diez Levels: 3 4 6 8 9 cinco diez dos siete uno > levels(df$col1)[1:5] <- c(&qu...
2011 Mar 16
3
making dataframes
Dear all, I have a dataframe which looks like this (dummy): date<-c("jan", "feb", "mar", "apr", "may", "june", "july", "aug","sep","oct","nov","dec") col1<-c(8.2,5.4,4.3,4.1,3.1,2.5,1.1,4.5,3.2,1.9,7.8,6.5) col2<-c(3.1,2.3,4.7,6.9,7.5,1.1,3.6,8.5,7.5,2.5,4.1,2.3) dum<-data.frame(cbind(date,col1,col2)) dum date col1 col2 1 jan 8.2 3.1 2 feb 5.4 2.3 3 mar 4.3 4.7 4 apr 4.1 6.9 5 may 3.1 7.5 6 june 2.5 1.1 7 july 1.1...
2020 Aug 24
3
(sin asunto)
Creo que el problema se podría simplificar y aún obtener un resultado aceptable si simplemente haces un ajuste lineal en un entorno del punto. Como ya tienes los valores de los puntos de cada curva como dices Carlos, creo que con esa información podrías identificar un entorno adecuado en el cual ajustar linealmente. Cuéntanos como te va, Saludos !! Eric. On 24-08-20 12:52, Carlos Ortega
2006 Mar 06
1
Sort problem in merge()
Hello! I am merging two datasets and I have encountered a problem with sort. Can someone please point me to my error. Here is the example. ## I have dataframes, first one with factor and second one with factor ## and integer > tmp1 <- data.frame(col1 = factor(c("A", "A", "C", "C", "0", "0"))) > tmp2 <- data.frame(col1 = factor(c("C", "D", "E", "F")), col2 = 1:4) > tmp1 col1 1 A 2 A 3 C 4 C 5 0 6 0 > tmp2 col1 col...
2008 Feb 10
11
data frame question
Hello I have 2 data frames df1 and df2. I would like to create a new data frame new_df which will contain only the common rows based on the first 2 columns (chrN and start). The column score in the new data frame should be replaced with a column containing the average score (average_score) from df1 and df2. df1= data.frame(chrN= c(“chr1”, “chr1”, “chr1”, “chr1”, “chr2”, “chr2”, “chr2”),
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', 'x35', 'x1','x2', 'x4') df1<-data.frame(col1) attach(df1) df1$transformacion<-ifelse(col1 == "x1"|col1 == "x2"| col1 ==...
2017 Aug 23
0
Comparing 2 dale columns
Patrick, ## Run the following script an notice the different values of the dataframe "data" in each instance. # I understand you have done something like the following: data <- data.frame(COL1 = c("6/1/14", "7/1/14"), COL2 = c("5/1/15", "5/1/15"), stringsAsFactors = FALSE) data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) data data$COL2 <- as.Date(as.character(data$COL2, format = "%y/%m/%d")) data$COL1 <-...
2005 Oct 07
2
finding missing lines...
Take this as an example: > a=data.frame(col1=c(1,2,3,4,5), col2=c ("my","beloved","daughter","son","wife")) > b=data.frame(col1=c(1,2,4), col2=c("my","beloved","son")) > a col1 col2 1 1 my 2 2 beloved 3 3 daughter 4 4 son 5...
2017 Aug 23
2
Comparing 2 dale columns
Dear R fellows, I created a new column Date_flag to compare the dates of COL1 and COL2 using the code below. But it showed that 5/1/15 is greater than 6/1/2014 and 5/1/2015 greater than 7/1/2014 despite the year is greater. How do I fix that? I did try to format as %y/%m/%d but it does not fix that. data$Date_Flag <- ifelse(data$COL2 > data$COL1, 0,1) COL1...
2012 Aug 13
4
if else elseif for data frames
Hi all, It seems like I cannot use normal 'if' for data frames. What would be the best way to do the following. if data$col1='high' data$col2='H' else if data$col1='Neutral' data$col2='N' else if data$col='low' data$col2='L' else #chuch a warning? Note that col2 was not an existing column and was newly assigned for this task. Thanks, Sachin [[alternative...
2018 Feb 25
3
include
Thank you Jim, I read the data as you suggested but I could not find K1 in col1. rbind(preval,mydat) Col1 Col2 col3 1 <NA> <NA> <NA> 2 X1 <NA> <NA> 3 Y1 <NA> <NA> 4 K2 <NA> <NA> 5 W1 <NA> <NA> 6 Z1 K1 K2 7 Z2 <NA> <NA> 8 Z3 X1 <NA> 9 Z4 Y1 W1 On Sat, Feb 24, 2018...
2018 Feb 25
2
include
HI Jim and all, I want to put one more condition. Include col2 and col3 if they are not in col1. Here is the data mydat <- read.table(textConnection("Col1 Col2 col3 K2 X1 NA Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) The desired out put would be Col1 Col2 col3 1 X1 0 0 2 K1 0 0 3 Y1 0 0 4 W1 0 0 6 K2 X...
2018 Feb 25
0
include
Hi Val, My fault - I assumed that the NA would be first in the result produced by "unique": mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) val23<-unique(unlist(mydat[,c("Col2","col3")])) napos<-which(is.na(val23)) preval<-data.frame(Col1=val23[-napos], Col2=NA,col3=NA) mydat<-rbind(preval,mydat) mydat[is.na(mydat...
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, 5) + s(col4, 5) + s(c...
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,] "prueba1"  [5,] "x33"  [6,] "prueba1"  [7,] "prueba2"  [8,] "prueba2"  [9,] "x35" [10,] "prueba1" [11,] "prueba1" [12,] "prue...
2008 Jul 17
4
help with data layout
Hello list I have been given some Excel sheets with data laid like this: Col1 Col2 A 3 2 3 B 4 5 4 C 1 4 3 I was hoping to import this into R as a csv and then get the mean and SD for each letter in column 1. Could someone give me some guidance on best to approach this? Thanks...
2017 Aug 23
2
Comparing 2 dale columns
...precheza.cz> Sent: Wednesday, August 23, 2017 11:20:00 AM To: Patrick Casimir; r-help at r-project.org Subject: RE: Comparing 2 dale columns Hi your code is wrong. I get > test<-read.table("clipboard", header=T) > str(test) 'data.frame': 2 obs. of 2 variables: $ COL1: Factor w/ 2 levels "6/1/14","7/1/14": 1 2 $ COL2: Factor w/ 1 level "5/1/15": 1 1 > test$COL2<- as.Date(as.character(test$COL2, format="%y/%m/%d")) > test$COL1<- as.Date(as.character(test$COL1, format="%y/%m/%d"))...
2018 Feb 25
0
include
...on your specific weaknesses and become self-sufficient? -- Sent from my phone. Please excuse my brevity. On February 25, 2018 7:55:55 AM PST, Val <valkremk at gmail.com> wrote: >HI Jim and all, > >I want to put one more condition. Include col2 and col3 if they are >not >in col1. > >Here is the data >mydat <- read.table(textConnection("Col1 Col2 col3 >K2 X1 NA >Z1 K1 K2 >Z2 NA NA >Z3 X1 NA >Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE) > >The desired out put would be > > Col1 Col2 col3 >1 X1 0 0 >2 K1...
2018 Feb 25
2
include
Sorry , I hit the send key accidentally here is my complete message. Thank you Jim and all, I got it. I have one more question on the original question What does this "[-1] " do? preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1], Col2=NA,col3=NA) mydat <- read.table(textConnection("Col1 Col2 col3 Z1 K1 K2 Z2 NA NA Z3 X1 NA Z4 Y1 W1"),header = TRUE) preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3...
2020 Sep 10
2
aplicar codigo
...ctamente. 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', 'x1','x33', 'x1','x4', 'x5', 'x35', > 'x1','x2', 'x4') > col2 <- c('x12', 'x4', 'x6', 'x771','x4', 'x2') > col3 &lt...