• Register
0 votes
1.1k views

Problem :

I have about 25 dataframes which are essentially the frequency counts of my elements stored in the column called Elements. They all have some of the different and some of the the same elements in my Elements columns so they just look like below :

dataframe called DataFrame1

Elements    freq
boby         4324234
janey        433
hamy        4324
timy         22
dataframe called DataFrame1
Elements     freq
boby          987
janey         223
jonny        12
jimy          98092

I am just trying to set up the table so that my Elements becomes my column and each row is my frequencies. This is so that I should be able to combine all my dataframes.

I have tried rbind on them but facing below error:

“Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match”.

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

An alternative method to the rbind + dcast technique is that the use of the tidyverse.

Please use the pipes (%>%) to first use the bind_rows() to bind all the dataframes together while simultaneously creating the dataframe id column here I just called the variable as "df". Then use the spread() to move the unique " Elements" values to become the column names and spreading your values of the "freq" across your new columns. " Elements" is the key and "freq" is your value in this case.

9 7 4
38,600 points

Related questions

0 votes
1 answer 738 views
738 views
Problem : I am trying to merge data in R but facing following error error in fix.by(by.x, x) : 'by' must specify one or more columns as numbers, names or logical
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
2 answers 1.3K views
1.3K views
Problem : I am facing below error and I am unable to understand the meaning of the error. All my variable names are correct and there are no typing errors. Does anybody faced this issue before any solution on it? My erroneous code : datNewagg <- aggregate (dataNew, by = ... mean) It gives following error : Error in aggregate.data.frame(datNew, by = list("x", "y", : arguments must have same length
asked Dec 6, 2019 alecxe 7.5k points
0 votes
1 answer 1.1K views
1.1K views
Problem : I am learning to work with neural networks in R. As a learning tutorial I am using the following problem over at Kaggle: https://www.kaggle.com/c/titanic This problem is specifically designed for people who want to learn and please note there is no reward ... Error in neurons[[i]] %*% weights[[i]] : requires numeric/complex matrix/vector arguments Can anyone help in resolving my issue?
asked Nov 27, 2019 alecxe 7.5k points
1 vote
1 answer 1K views
1K views
Problem : Currently I am learning the r programming. I am unable to find the answer to below error but I am unable to do so. Currently I have one dataframe it has a column of strings. My task is to count the exact number of characters present in each entry of ... , with no default Error in match.fun(FUN): argument "FUN" is missing, with no default Can someone guide me in fixing above error?
asked Mar 30, 2020 morrisBson 3.2k points
0 votes
1 answer 77 views
0 votes
1 answer 6 views
6 views
Please tell me how to resolve this error
asked Jan 4 TeamScript 9.5k points
0 votes
1 answer 102 views
102 views
Problem : When I compile the Python code I get below error IndentationError: unindent does not match any outer indentation level
asked Oct 21, 2019 peterlaw 6.9k points
1 vote
2 answers 213 views
213 views
Problem: Dear all, Right now I&rsquo;ve imported a maven project into my eclipse IDE and I changed my java path library to work on java 1.7 Suddenly, eclipse started showing an error but I&rsquo;ve got no errors in my files there. The error is &ldquo;java compiler level ... Project Problem (Java Version Mismatch) Please tell me how to resolve this error (I want to have my JRE version as 1.7 only).
asked Mar 22, 2020 Gavin 15.3k points
0 votes
1 answer 2K views
2K views
Problem : Please have a look at the below date related error : $ R --vanilla > as.Date("09 Jan 2019") Error in charToDate(x) : character string is not in a standard unambiguous format But that date is clearly in the correct standard unambiguous format. So why am I facing ... and without any warning or error and then read very incorrectly! As shown below: > as.Date("01/01/2000") [1] "0001-01-20"
asked Dec 21, 2019 alecxe 7.5k points
0 votes
2 answers 2.3K views
2.3K views
Problem : Below is my code which is giving me the error. plot(x,y) yx.lm <- lm(y ~ x) lines(x, predict(yx.lm), col="red") Why am I facing following error? Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet
asked Dec 4, 2019 alecxe 7.5k points