similar to: convert factor dataframe into numeric matrix

Displaying 20 results from an estimated 10000 matches similar to: "convert factor dataframe into numeric matrix"

2013 Oct 27
2
numeric data being interpreted as a factor -trouble with reading data into a dataframe in R
Hello. trying to do one of the simplest actions -read in data into R. I don't know why the FBfollowers column is being read as a factor and also if I use as.numeric on it, it looks really strange and actually complety alters the data. I am attaching the data set here called ddd.csv I used data=read.csv("ddd.csv",header=TRUE) fb=data$FBfollowers fb fb=as.numeric(fb) fb Thnxs in
2007 Nov 13
7
combine two dataframe
I have two data frame A and B adn want to cross them. A has format as: a1 a2 a3 1 2 3 2 3 1 1 3 2 ... B: b1 b2 1 2 2 1 ... the combine result shall be something like a1 a2 a3 b1 b2 1 2 3 1 2 1 2 3 2 1 2 3 1 1 2 2 3 1 2 1 1 3 2 1 2 1 3 2 2 1 .... is there a function able of doing this instead of loops? Thanks, Sun
2005 Dec 06
2
how to extract row& col names from a matrix
Dear all, I like to extract row names & column names from the named matrix...... like...... a<-matrix(1:6,2) ro<-c("aa","bb") co<-c("dd","ee","ff") dimnames(a)<-list(ro,co) a > dd ee ff aa 1 3 5 bb 2 4 6 from the above matrix "a" I like to extract rownames separately like
2008 Mar 27
2
colMeans in a data.frame with numeric and character data
Hi all, I would like to know if it is posible by, someway, to get colMeans from a data.frame with numeric as well as character data, dispersed all over the object. Note that I would like to get colMeans neglecting character data. I am really in need of some function proceeding in that way… All the best Diogo André Alagador [[alternative HTML version deleted]]
2006 Jul 02
1
workaround for numeric problems
Dear R-people, I have to compute C - -(pnorm(B)*dnorm(B)*B + dnorm(B)^2)/pnorm(B)^2 This expression seems to be converging to -1 if B approaches to -Inf (although I am unable to prove it). R has no problems until B equals around -28 or less, where both numerator and denominator go to 0 and you get NaN. A simple workaround I did was C <- ifelse(B > -25, -(pnorm(B)*dnorm(B)*B
2005 May 06
3
conversion factor into numeric
Thank you all for your (fast) comments. Unfortunately I could not make the advise work: > mass [1] 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 800 910 910 910 910 910 910 910 [26] 910 910 910 910 910 910 910 910 910 910 910 910 910 910 1,020 1,020 1,020 1,020 1,020 1,020 1,020 1,020 1,020
2006 Dec 07
2
Splitting a dataframe at the results of tapply
I have got a dataframe containing measurement of aircraft noise like this: > Id <- c(1,4,5,2,3,6,4,1,2,5,6,3) > Noise <- c(88,94,97,98,92,56,103,102,87,95,92,97) > Height <- c(190, 150, 120, 115, 188, 104, 101, 189, 146, 111, 124, 126) > > df <- data.frame(Id, Noise, Height) Now I would like to split this in two new dataframes. The first one containing the rows
2005 Oct 18
1
change factor labels
it must be terribly simple, can someone quickly help me? test <- data.frame(y=c(1:10), x=as.factor(c(rep("a",5),rep("b",5)))) how can i change the factor labels from "a" and "b" to for example "u" and "v"? i don't succeed with factor() thanks a lot ------------------------------------------------ Sebastian Leuzinger
2006 Apr 19
1
apply(table) miss factor structure
Hi, all. I didn't find something similar to this problem in past list. I have a data frame (named restr) where some columns are factors, like you can see: > table(restr[,"p1"]) 0 1 2 3 4 5 0 26 1 0 1 0 > table(restr[,"p2"]) 0 1 2 3 4 5 6 0 13 11 1 2 1 0 When I use apply, the factor structure is missed: >
2006 Jun 23
3
Interpreting as.factor
When I run a linear regression and include a variable in the regression with as.factor i.e. lm(y ~x +as.factor(x1) and i read the output as as.factor(x1)1.... as.factor(x1)2... etc. how do i interpret the estimate for each level? Is this simply to be regarded as a shift in the equation predicted by the intercept and independent variable x? jdr -- Justin Rapp 409 S. 22nd St. Apt. 1
2008 Jan 12
2
Factor Analysis
Good Morning, Is it possible to use the R program for a CFA with dichotomous data? Thank you, Kathleen Kathleen Kemp, M.A. Doctoral Clinical Psychology Student, Concentration: Forensic Psychology Drexel University Philadelphia, PA 19104 kk354@drexel.edu [[alternative HTML version deleted]]
2010 Apr 19
5
dataframe
Hi all, I'm trying to load a csv file in which all the variables must be of type number.The object is a dataframe.When i load the file what i get is a dataframe in wich the variables are of type factor.How can I get variables of type number??? Thanks all
2008 Feb 07
1
How to split a factor (unique identifier) into several others?
Hello, I have a data frame with a factor column, which uniquely identifies the observations in the data frame and it looks like this: sample1_condition1_place1 sample2_condition1_place1 sample3_condition1_place1 . . . sample3_condition3_place3 I want to turn it into three separate factor columns "sample", "condition" and "place". This is what I did so far: #
2007 Mar 19
3
character to numeric conversion
Hi. Is there a straightforward way to convert a character string containing comma-delimited numbers to a numeric vector? In my application, I use system(executable.string, intern=TRUE) which returns a string like "[0.E-38, 2.096751179214927596171268230, 3.678944959657480671183123052, 4.976528845643001020345216157, 6.072390165503099343887569007, 7.007958550337542210168866070,
2008 Feb 14
4
plot each column of a matrix or dataframe versus x in a single plot
How do a plot several columns of a matrix at once in a single plot versus a single x-variable? The default plot.matrix or plot.dataframe commands plot each column versus each other column in several sub-plots. I want to plot each column versus a single other vector (x) as several lines or points in one plot. I can do it by hand: get the range of all variables (i.e. columns of the matrix or
2004 Dec 07
1
how to test the existence of a name in a dataframe
I wanted to test if there exists already a name (which is incidentally a substring of another name) in a dataframe. I did e.g.: > data(swiss) > names(swiss) [1] "Fertility" "Agriculture" "Examination" "Education" [5] "Catholic" "Infant.Mortality" > ! is.null(swiss$EduX) [1] FALSE > !
2007 Dec 20
2
factor manipulation: edgelist to a matrix?
Hello All, I have had considerable bad luck with attempting the following with for loops. Here is the problem: # Suppose we have a data.frame with the following data, which can be considered a type of edgelist (for those with networks backgrounds): # # V1 V2 # 1 A # 1 A # 1 B # 2 A # 3 C # 3 A # 3 C # 3 B # # I want the output of the function to produce a matrix, such that #each factor of
2008 Jul 20
3
Order of columns(variables) in dataframe
Dear R experts,   I have a dataframe with 4 columns (variables). I want to redorder (or reposition) these columns on the basis of a value in its last row. e.g.   df1<-data.frame( v1= c(2,3,1,9,5), v2=c(8,5,12,4,11), v3=c(7,8,2,6,9), v4=c(1,4,6,3,6))    > df1    v1 v2 v3 v4 1  2  8  7  1 2  3  5  8  4 3  1 12  2  6 4  9  4  6  3 5  5 11  9  6 I wanto to get the order of df1 on the basis of
2007 May 16
3
more woes trying to convert a data.frame to a numerical matrix
I have the following csv file: name,x,y,z category,delta,gamma,epsilon a,1,2,3 b,4,5,6 c,7,8,9 I'd like to create a numeric matrix of just the numbers in this csv dataset. I've tried the following program: sample.data <- read.csv("sample.csv") numerical.data <- as.matrix(sample.data[-1,-1]) However, print(numerical.data) returns what appears to be a matrix of
2005 Sep 25
2
getting variable length numerical gradient
Hi all. I have a numerical function f(x), with x being a vector of generic size (say k=4), and I wanna take the numerically computed gradient, using deriv or numericDeriv (or something else). My difficulties here are that in deriv and numericDeric the function is passed as an expression, and one have to pass the list of variables involved as a char vector... So, it's a pure R programming