data-manipulation

R Error: First argument, `data`, must be a data frame or shared data

社会主义新天地 提交于 2021-02-20 02:53:52
问题 I am using the R programming language. I am following this tutorial over here: https://plotly.com/r/dropdowns/ I tried to create my own data and run the same procedure: library(plotly) library(MASS) library(dplyr) # create data x <- sample( LETTERS[1:4], 731, replace=TRUE, prob=c(0.25, 0.25, 0.25, 0.25) ) y <- rnorm(731,10,10) z <- rnorm(731,5,5) date= seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") df <- data.frame(x,y, z, date) df$x = as.factor(df$x) #create plot fig <- plot_ly(df, x

R Error: First argument, `data`, must be a data frame or shared data

时光总嘲笑我的痴心妄想 提交于 2021-02-20 02:52:19
问题 I am using the R programming language. I am following this tutorial over here: https://plotly.com/r/dropdowns/ I tried to create my own data and run the same procedure: library(plotly) library(MASS) library(dplyr) # create data x <- sample( LETTERS[1:4], 731, replace=TRUE, prob=c(0.25, 0.25, 0.25, 0.25) ) y <- rnorm(731,10,10) z <- rnorm(731,5,5) date= seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") df <- data.frame(x,y, z, date) df$x = as.factor(df$x) #create plot fig <- plot_ly(df, x

R Error: First argument, `data`, must be a data frame or shared data

一曲冷凌霜 提交于 2021-02-20 02:52:15
问题 I am using the R programming language. I am following this tutorial over here: https://plotly.com/r/dropdowns/ I tried to create my own data and run the same procedure: library(plotly) library(MASS) library(dplyr) # create data x <- sample( LETTERS[1:4], 731, replace=TRUE, prob=c(0.25, 0.25, 0.25, 0.25) ) y <- rnorm(731,10,10) z <- rnorm(731,5,5) date= seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") df <- data.frame(x,y, z, date) df$x = as.factor(df$x) #create plot fig <- plot_ly(df, x

Adding zero valued entries so that all groups have entries for the same items

早过忘川 提交于 2021-02-19 06:47:07
问题 I'm trying to use Rcharts to create a stacked bar chart across a number of recorded regions (stacking separate group values on top of each other). The data is in a format similar to below. Region | Group | Value ---------------------- USA | A | 5 USA | B | 3 USA | C | 1 UK | A | 4 UK | B | 6 France | C | 3 Using the below code produces a grouped bar chart which works fine. However the stacked button does nothing to change the plot. nPlot(Value ~ Region, group = 'Group', data = example_data,

R error: “Error in check.data : Argument Should be Numeric”

微笑、不失礼 提交于 2021-02-17 05:14:45
问题 I am learning about the "kohonen" library for the R programming language. I created some artificial data to try some of the functions on. I tried using the "supersom()" function on only continuous (i.e type = as.numeric) data and everything works well. However, when I tried to run the "supersom()" function on both continuous and categorical (type = as.factor), I start to run into some errors ("Argument data should be numeric"). The "supersom()" function has an argument called "dist.fct"

Identifying points by color

ぐ巨炮叔叔 提交于 2021-02-12 11:40:21
问题 I am following the tutorial over here : https://www.rpubs.com/loveb/som . This tutorial shows how to use the Kohonen Network (also called SOM, a type of machine learning algorithm) on the iris data. I ran this code from the tutorial: library(kohonen) #fitting SOMs library(ggplot2) #plots library(GGally) #plots library(RColorBrewer) #colors, using predefined palettes iris_complete <-iris[complete.cases(iris),] iris_unique <- unique(iris_complete) # Remove duplicates #scale data iris.sc = scale

Identifying points by color

不想你离开。 提交于 2021-02-12 11:39:41
问题 I am following the tutorial over here : https://www.rpubs.com/loveb/som . This tutorial shows how to use the Kohonen Network (also called SOM, a type of machine learning algorithm) on the iris data. I ran this code from the tutorial: library(kohonen) #fitting SOMs library(ggplot2) #plots library(GGally) #plots library(RColorBrewer) #colors, using predefined palettes iris_complete <-iris[complete.cases(iris),] iris_unique <- unique(iris_complete) # Remove duplicates #scale data iris.sc = scale

R: formatting axis and titles on plotly plots (time series)

青春壹個敷衍的年華 提交于 2021-02-11 14:37:55
问题 I am using the R programming language. Using the following tutorial : https://plotly.com/r/time-series/ and this stackoverflow question : How to plot multiple series/lines in a time series using plotly in R? I was able to make an interactive time series plot: library(xts) library(ggplot2) library(dplyr) library(plotly) library(lubridate) #time series 1 date_decision_made = seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") property_damages_in_dollars <- rnorm(731,100,10) final_data <-

R: Error in FUN(X[[i]], …) : only defined on a data frame with all numeric variables

邮差的信 提交于 2021-02-11 08:22:08
问题 I am working with the R programming language. I am trying to plot some categorical and continuous data that I am working with, but I am getting an error that tells me that such plots are only possible with "only numeric variables". library(survival) library(ggplot2) data(lung) data = lung data$sex = as.factor(data$sex) data$status = as.factor(data$status) data$ph.ecog = as.factor(data$ph.ecog) str(data) #plot mycolours <- rainbow(length(unique(data$sex)), end = 0.6) # png("gally.png", 500,

R: Error in FUN(X[[i]], …) : only defined on a data frame with all numeric variables

微笑、不失礼 提交于 2021-02-11 08:19:42
问题 I am working with the R programming language. I am trying to plot some categorical and continuous data that I am working with, but I am getting an error that tells me that such plots are only possible with "only numeric variables". library(survival) library(ggplot2) data(lung) data = lung data$sex = as.factor(data$sex) data$status = as.factor(data$status) data$ph.ecog = as.factor(data$ph.ecog) str(data) #plot mycolours <- rainbow(length(unique(data$sex)), end = 0.6) # png("gally.png", 500,