search for: stringasfactors

Displaying 11 results from an estimated 11 matches for "stringasfactors".

Did you mean: stringsasfactors
2008 Sep 04
1
text file imported incorrectly
Dear R-users, When I tried to import a text file (tab delimited) which has 2000+ rows with the following command (With the importData in S, it works though), x <- read.table(textfile, sep= "\t", skip=5, stringAsFactors=F) I received the following warning message: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,: number of items read is not a multiple of the number of columns. I checked the resulting data frame and found only about 1500 observations rather than 2000+ observations. Then,...
2010 Jul 20
5
Help with time in R
Hi, I have a problem with the time formatting in R. I have entered time in the format "MM:SS.xyz" and R has automatically classified this as a factor, but I need it numerically. However when I use as.numeric() it gives me totally different numbers. Is there any way I can tell R to read thes input as a number? Thank you very much [[alternative HTML version deleted]]
2007 Mar 27
3
Unexpected result of as.character() and unlist() applied to a data frame
Hi, > dd <- data.frame(A=c("b","c","a"), B=3:1) > dd A B 1 b 3 2 c 2 3 a 1 > unlist(dd) A1 A2 A3 B1 B2 B3 2 3 1 3 2 1 Someone else might get something different. It all depends on the values of its 'stringsAsFactors' option: > dd2 <- data.frame(A=c("b","c","a"), B=3:1, stringsAsFactors=FALSE) > dd2
2006 Jan 15
8
/ Operator not meaningful for factors
Folks, I have a very basic question. The solution eludes me perhaps because of my own lack of creativity. I am not attaching a fully reproducible session because the issue may well be becuase of the way the data file is, and the data file is large (and I don't know whether I can legally distribute it). If people can suggest things that might be wrong in my data or the way that I am reading it,
2007 Aug 12
2
Convert factor to numeric vector of labels
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: https://stat.ethz.ch/pipermail/r-help/attachments/20070812/6da70dc8/attachment.pl
2016 Aug 04
2
¿Qué hace as.numeric()?
En general lo que yo uso en esos casos es as.numeric(as.character(X)) No se los términos correctos pero los factores aunque se muestren con los nombres de las diferentes clases, internamente son clases separadas que se nombran como enteros por ejemplo del 1 al n de clases. Cuando usas directamente as.nuemric sobre un factor, este toma los numeros de las clases y no el valor de clase. Fijate en
2010 May 05
3
concatenate values of two columns
Dear list, I'm trying to concatenate the values of two columns but im not able to do it: i have a dataframe with the following two columns: X VAR1 VAR2 1 2 2 1 3 2 4 3 5 4 6 4 what i would like to
2011 May 15
2
Unexpected behaviour as.data.frame
I use the following code to create two data.frames d1 and d2 from a list: types <- c("integer", "character", "double") nlines <- 10 d1 <- as.data.frame(lapply(types, do.call, list(nlines)), stringsAsFactor=FALSE) l2 <- lapply(types, do.call, list(nlines)) d2 <- as.data.frame(l2, stringsAsFactors=FALSE) I would expect d1 and d2 to be the
2010 Oct 12
2
Factors in an regression using lm()
Hi, I am trying to do a multiple regression on the dataset "Hdma", available in the Ecdat package. The data looks like this: > str(Hdma) 'data.frame': 2381 obs. of 13 variables: $ dir : num 0.221 0.265 0.372 0.32 0.36 ... $ hir : num 0.221 0.265 0.248 0.25 0.35 ... $ lvr : num 0.8 0.922 0.92 0.86 0.6 ... $ ccs : num 5 2 1 1 1 1 1 2 2 2
2016 Aug 05
2
¿Qué hace as.numeric()?
Muchas gracias, Fernando y Javier. > pami$PP <- as.numeric(as.character(pami$PP)) Warning message: NAs introduced by coercion Y entonces los datos que antes convertía en labels(pami$PP) (v.g. 753,2256 a 61343 o 62,7688 ? a 17390, que me pa eran enteros del 1 al n de clases como decía Fernando), los convertía en NA.- Luego de probar también con read.table, pasé a: > pami <-
2016 Aug 03
3
¿Qué hace as.numeric()?
Tranquilo que no te han hackeado tu "R"... Simplemente que al importar tu CSV, no has indicado que los decimales son las ",". Y ese campo lo importa como un character (un string). Y cuando lo conviertes a numeric, el resultado es un tanto impredecible. Si utilizas read.table para importar, simplemente incluye el parámetro "dec" de esta forma "read.table(..... ,