我想绘制一个散点图,其中x轴是离散的(一周中的某天),而y轴是连续的(值),并且一个类指示器为每个数据点赋予颜色。
与此类似:Plotting column names as x-axis in R
但是我不想使用数据中的所有列,并且颜色是基于我不想要的观测值。
示例数据:
DAT = data.frame(
person = c(1:5),
Mon = c(100, 98, 95, 99, 93),
Tues = c(95, 88, 90, 91, 87),
Wed = c(85, 80, 86, 81, 80),
Thurs = c(84, 80, 77, 75, 74),
Fri = c(66, 50, 20, 0, 72),
Score = c("Y","Y","N","N","N")
)
ggplot(DAT, aes(x = c(Mon, Tues, Wed, Thurs, Fri), y = values, color = Score)) + geom_point()
我的try / pesuedo ggplot代码不起作用,但希望能给出我要完成的目标的想法。
我试图将Mon-Fri设为数字(1,2,3,4,5),以便将其作为我的x坐标,并将其值作为y坐标,但这意味着行数是5倍。
有什么想法吗?
答案 0 :(得分:1)
首先:您的数据是“宽”的(天为列)。最好将其设置为“长”(一列为几天,另一列为值)。
然后:您需要对日期进行排序-将变量设为一个因子并设置水平。
INFO:sagemaker:Creating training-job with name: sagemaker-tensorflow-scriptmode-2019-01-31-18-51-07-292
Creating tmp_axa2vmo_algo-1-s8vfu_1 ...
Attaching to tmp_axa2vmo_algo-1-s8vfu_1
algo-1-s8vfu_1 | 2019-01-31 18:51:11,828 sagemaker-containers INFO Imported framework sagemaker_tensorflow_container.training
algo-1-s8vfu_1 | 2019-01-31 18:51:11,940 sagemaker-containers ERROR Reporting training FAILURE
algo-1-s8vfu_1 | 2019-01-31 18:51:11,940 sagemaker-containers ERROR framework error:
algo-1-s8vfu_1 | Traceback (most recent call last):
algo-1-s8vfu_1 | File "/usr/local/lib/python3.6/dist-packages/sagemaker_containers/_trainer.py", line 67, in train
algo-1-s8vfu_1 | entrypoint()
algo-1-s8vfu_1 | File "/usr/local/lib/python3.6/dist-packages/sagemaker_tensorflow_container/training.py", line 167, in main
algo-1-s8vfu_1 | s3_utils.configure(env.hyperparameters.get('model_dir'), os.environ.get('SAGEMAKER_REGION'))
algo-1-s8vfu_1 | File "/usr/local/lib/python3.6/dist-packages/sagemaker_tensorflow_container/s3_utils.py", line 23, in configure
algo-1-s8vfu_1 | os.environ['S3_REGION'] = _s3_region(job_region, model_dir)
algo-1-s8vfu_1 | File "/usr/local/lib/python3.6/dist-packages/sagemaker_tensorflow_container/s3_utils.py", line 39, in _s3_region
algo-1-s8vfu_1 | bucket_location = s3.get_bucket_location(Bucket=bucket_name)['LocationConstraint']
algo-1-s8vfu_1 | File "/usr/local/lib/python3.6/dist-packages/botocore/client.py", line 357, in _api_call
algo-1-s8vfu_1 | return self._make_api_call(operation_name, kwargs)
algo-1-s8vfu_1 | File "/usr/local/lib/python3.6/dist-packages/botocore/client.py", line 661, in _make_api_call
algo-1-s8vfu_1 | raise error_class(parsed_response, operation_name)
algo-1-s8vfu_1 | botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the GetBucketLocation operation: Access Denied
algo-1-s8vfu_1 |
algo-1-s8vfu_1 | An error occurred (AccessDenied) when calling the GetBucketLocation operation: Access Denied
tmp_axa2vmo_algo-1-s8vfu_1 exited with code 1
Aborting on container exit...
可以使数据变长,tidyr::gather()
可以对日期进行排序。
dplyr::mutate
答案 1 :(得分:1)
您可以融化数据,然后绘制:
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\SystemInformation"))
{
if (key != null)
{
object value = key.GetValue("ComputerHardwareIds");
if (value != null)
{
var computerHardwareIds = (value as string[]); // cast value object to string array, because its type is REG_MULTI_SZ
var lines_num = computerHardwareIds.Length; // then you can get lines number this way
}
}
}