Displaying 11 results from an estimated 11 matches for "stringasfactor".
Did you mean:
stringsasfactor
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()?
...)
as.character(x)
x=as.factor(8:18)
levels(x)
labels(x)
as.numeric(x)
as.character(x)
as.numeric(as.character(x))
Usé labels en el código aunque no se si son exatamente las labels de los
factores, pero usandola ejemplifica justamente lo que digo.
Para evitarme algunos problemas en general uso stringAsFactor=F cuando
levanto datos porque algunas identificaciones alfanumericas las levanta
como factores y si te comes eso luego gráficos por id o cosas así te salen
con las labels de los factores y no con los valores en sí.
Espero que fuera de ayuda, saludos
Fernando Macedo
El 04/08/16 a las 09:40, Maur...
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()?
...> as.character(x)
> > as.numeric(as.character(x))
> >
> >
> > Usé labels en el código aunque no se si son exatamente las labels de los
> > factores, pero usandola ejemplifica justamente lo que digo.
> >
> > Para evitarme algunos problemas en general uso stringAsFactor=F cuando
> > levanto datos porque algunas identificaciones alfanumericas las levanta
> > como factores y si te comes eso luego gráficos por id o cosas así te
> salen
> > con las labels de los factores y no con los valores en sí.
> >
> > Espero que fuera de ayuda, sa...
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(..... ,